[Xfce4-commits] <ristretto:master> Add --settings option to launch the settings-dialog

Stephan Arts noreply at xfce.org
Fri Oct 28 17:12:01 CEST 2011


Updating branch refs/heads/master
         to df78db5c1f1f3b924a2cbc6c7b99432e1d40ba9d (commit)
       from 2fb12e9c9825cd39ed33c3b73609ff5ca91700e4 (commit)

commit df78db5c1f1f3b924a2cbc6c7b99432e1d40ba9d
Author: Stephan Arts <stephan at xfce.org>
Date:   Fri Oct 28 16:34:54 2011 +0200

    Add --settings option to launch the settings-dialog

 src/Makefile.am        |    2 +-
 src/main.c             |   66 ++++++++++++++++++++++++++++++++----------------
 src/main_window.c      |   10 +------
 src/{util.h => util.c} |   22 +++++-----------
 src/util.h             |    3 ++
 5 files changed, 56 insertions(+), 47 deletions(-)

diff --git a/src/Makefile.am b/src/Makefile.am
index 6270f06..6e39af4 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -18,7 +18,7 @@ ristretto_SOURCES = \
 	marshal.c marshal.h \
 	file.c file.h \
 	privacy_dialog.h privacy_dialog.c \
-	util.h \
+	util.c util.h \
 	main.c
 
 ristretto_CFLAGS = \
diff --git a/src/main.c b/src/main.c
index ca29b35..5a32c77 100644
--- a/src/main.c
+++ b/src/main.c
@@ -27,6 +27,7 @@
 #include <gdk/gdkkeysyms.h>
 #include <string.h>
 
+#include <libxfce4ui/libxfce4ui.h>
 #include <libxfce4util/libxfce4util.h>
 #include <libexif/exif-data.h>
 
@@ -35,11 +36,13 @@
 #include "image_list.h"
 #include "settings.h"
 #include "main_window.h"
+#include "preferences_dialog.h"
 
 
 gboolean version = FALSE;
 gboolean start_fullscreen = FALSE;
 gboolean start_slideshow = FALSE;
+gboolean show_settings = FALSE;
 
 typedef struct {
     RsttoImageList *image_list;
@@ -66,6 +69,14 @@ static GOptionEntry entries[] =
         N_("Start a slideshow"),
         NULL
     },
+    { "settings",
+            'S',
+            G_OPTION_FLAG_IN_MAIN,
+            G_OPTION_ARG_NONE,
+            &show_settings,
+            N_("Show settings dialog"),
+        NULL
+    },
     { NULL, ' ', 0, 0, NULL, NULL, NULL }
 };
 
@@ -107,36 +118,47 @@ main(int argc, char **argv)
     gtk_window_set_default_icon_name("ristretto");
     settings = rstto_settings_new();
 
-    image_list = rstto_image_list_new ();
-    window = rstto_main_window_new (image_list, FALSE);
-
-    if (argc > 1)
+    if (FALSE == show_settings)
     {
-        RsttoOpenFiles rof;
+        image_list = rstto_image_list_new ();
+        window = rstto_main_window_new (image_list, FALSE);
 
-        rof.image_list = image_list;
-        rof.argc = argc;
-        rof.argv = argv;
-    	rof.iter = 1;
-        rof.window = window;
+        if (argc > 1)
+        {
+            RsttoOpenFiles rof;
 
-        g_idle_add ((GSourceFunc )cb_rstto_open_files, &rof);
+            rof.image_list = image_list;
+            rof.argc = argc;
+            rof.argv = argv;
+            rof.iter = 1;
+            rof.window = window;
+
+            g_idle_add ((GSourceFunc )cb_rstto_open_files, &rof);
+
+            if (TRUE == rstto_settings_get_boolean_property (
+                        settings,
+                        "maximize-on-startup"))
+            {
+                gtk_window_maximize (GTK_WINDOW(window));
+            }
+        }
 
-        if (TRUE == rstto_settings_get_boolean_property (
-                    settings,
-                    "maximize-on-startup"))
+        g_signal_connect(G_OBJECT(window), "destroy", G_CALLBACK(gtk_main_quit), NULL);
+        gtk_widget_show_all (window);
+     
+        GDK_THREADS_ENTER();
+        gtk_main();
+        GDK_THREADS_LEAVE();
+    }
+    else
+    {
+        window = rstto_preferences_dialog_new (NULL);
+        while (gtk_dialog_run (GTK_DIALOG(window)) != GTK_RESPONSE_HELP)
         {
-            gtk_window_maximize (GTK_WINDOW(window));
+            rstto_launch_help ();
         }
     }
 
-    g_signal_connect(G_OBJECT(window), "destroy", G_CALLBACK(gtk_main_quit), NULL);
-    gtk_widget_show_all (window);
-
-    GDK_THREADS_ENTER();
-    gtk_main();
-    GDK_THREADS_LEAVE();
-
     g_object_unref (settings);
 
     xfconf_shutdown();
diff --git a/src/main_window.c b/src/main_window.c
index a4725da..5df6e3a 100644
--- a/src/main_window.c
+++ b/src/main_window.c
@@ -2236,15 +2236,7 @@ cb_rstto_main_window_about (GtkWidget *widget, RsttoMainWindow *window)
 static void
 cb_rstto_main_window_contents (GtkWidget *widget, RsttoMainWindow *window)
 {
-    if (FALSE == exo_execute_preferred_application (
-            "WebBrowser",
-            RISTRETTO_HELP_LOCATION,
-            "/tmp",
-            NULL,
-            NULL))
-    {
-
-    }
+    rstto_launch_help ();
 }
 
 
diff --git a/src/util.h b/src/util.c
similarity index 64%
copy from src/util.h
copy to src/util.c
index 334cddb..c9a0250 100644
--- a/src/util.h
+++ b/src/util.c
@@ -16,22 +16,14 @@
  *  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
  */
 
-#ifndef __RISTRETTO_UTIL_H__
-#define __RISTRETTO_UTIL_H__
+#include <config.h>
+#include <glib.h>
 
-G_BEGIN_DECLS
+#include <exo/exo.h>
 
-typedef enum
+
+gboolean
+rstto_launch_help (void)
 {
-  RSTTO_IMAGE_ORIENT_NONE = 1,
-  RSTTO_IMAGE_ORIENT_FLIP_HORIZONTAL,
-  RSTTO_IMAGE_ORIENT_180,
-  RSTTO_IMAGE_ORIENT_FLIP_VERTICAL,
-  RSTTO_IMAGE_ORIENT_FLIP_TRANSPOSE,
-  RSTTO_IMAGE_ORIENT_90,
-  RSTTO_IMAGE_ORIENT_FLIP_TRANSVERSE,
-  RSTTO_IMAGE_ORIENT_270,
-  RSTTO_IMAGE_ORIENT_NOT_DETERMINED,
-} RsttoImageOrientation;
 
-#endif /* __RSTTO_UTIL_H__ */
+}
diff --git a/src/util.h b/src/util.h
index 334cddb..34020ac 100644
--- a/src/util.h
+++ b/src/util.h
@@ -34,4 +34,7 @@ typedef enum
   RSTTO_IMAGE_ORIENT_NOT_DETERMINED,
 } RsttoImageOrientation;
 
+gboolean
+rstto_launch_help (void);
+
 #endif /* __RSTTO_UTIL_H__ */


More information about the Xfce4-commits mailing list