[Xfce4-commits] <ristretto:ristretto-0.0> Update Todo Store navbar position in xfconf

Stephan Arts noreply at xfce.org
Sun Oct 23 19:17:22 CEST 2011


Updating branch refs/heads/ristretto-0.0
         to 99225225b34039abe5d69041ba1483d25ef5686e (commit)
       from ebd4e629d93f715f8d0888aee4ae22583986c552 (commit)

commit 99225225b34039abe5d69041ba1483d25ef5686e
Author: Stephan Arts <stephan at xfce.org>
Date:   Tue Sep 1 22:42:25 2009 +0200

    Update Todo
    Store navbar position in xfconf

 TODO              |    4 +++
 src/main.c        |    2 +-
 src/main_window.c |   41 +++++++++++++++++++-----------
 src/settings.c    |   72 +++++++++++++++++++++++++++++++++++++++++++++++++++++
 src/settings.h    |    3 ++
 5 files changed, 106 insertions(+), 16 deletions(-)

diff --git a/TODO b/TODO
index fb53141..a3f116c 100644
--- a/TODO
+++ b/TODO
@@ -6,6 +6,10 @@
     - nautilus
     - rox
 
+- Implement Sorting
+
+- Implement open-with
+
 - Implement box-zoom
 
 - Add preloading
diff --git a/src/main.c b/src/main.c
index fa411ff..1a98148 100644
--- a/src/main.c
+++ b/src/main.c
@@ -113,7 +113,7 @@ main(int argc, char **argv)
         rof.image_list = image_list;
         rof.argc = argc;
         rof.argv = argv;
-	rof.iter = 1;
+    	rof.iter = 1;
 
         g_idle_add ((GSourceFunc )cb_rstto_open_files, &rof);
 
diff --git a/src/main_window.c b/src/main_window.c
index 2f52e41..0a6f1d8 100644
--- a/src/main_window.c
+++ b/src/main_window.c
@@ -327,8 +327,8 @@ static const GtkRadioActionEntry radio_action_sort_entries[] =
 static const GtkRadioActionEntry radio_action_pos_entries[] = 
 {
     { "pos-left", NULL, N_("Left"), NULL, NULL, 0},
-    { "pos-right", NULL, N_("Right"), NULL, NULL, 2},
-    { "pos-top", NULL, N_("Top"), NULL, NULL, 1},
+    { "pos-right", NULL, N_("Right"), NULL, NULL, 1},
+    { "pos-top", NULL, N_("Top"), NULL, NULL, 2},
     { "pos-bottom", NULL, N_("Bottom"), NULL, NULL, 3},
 };
 
@@ -384,6 +384,8 @@ rstto_main_window_init (RsttoMainWindow *window)
     window->priv->recent_manager = gtk_recent_manager_get_default();
     window->priv->settings_manager = rstto_settings_new();
 
+    navigationbar_position = rstto_settings_get_navbar_position (window->priv->settings_manager);
+
     accel_group = gtk_ui_manager_get_accel_group (window->priv->ui_manager);
     gtk_window_add_accel_group (GTK_WINDOW (window), accel_group);
 
@@ -1228,6 +1230,12 @@ cb_rstto_main_window_open_image (GtkWidget *widget, RsttoMainWindow *window)
             }
             else
             {
+
+                uri = g_file_get_uri (files->data);
+                gtk_recent_manager_add_item (window->priv->recent_manager, uri);
+                g_free (uri);
+                uri = NULL;
+
                 gtk_widget_show (window->priv->message_bar);
                 gtk_widget_show (window->priv->message_bar_label);
                 gtk_widget_show (window->priv->message_bar_button_cancel);
@@ -1286,7 +1294,7 @@ cb_rstto_main_window_open_folder (GtkWidget *widget, RsttoMainWindow *window)
                                                     GTK_WINDOW(window),
                                                     GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER,
                                                     GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
-                                                    GTK_STOCK_OPEN, GTK_RESPONSE_OK,
+                                                    GTK_STOCK_OPEN, GTK_RESPONSE_ACCEPT,
                                                     NULL);
 
     if (g_value_get_string (&current_uri_val))
@@ -2157,6 +2165,7 @@ cb_rstto_main_window_message_bar_open (GtkWidget *widget, RsttoMainWindow *windo
 static void
 cb_rstto_main_window_set_as_wallpaper (GtkWidget *widget, RsttoMainWindow *window)
 {
+    
 }
 
 static void
@@ -2168,9 +2177,11 @@ cb_rstto_main_window_navigationtoolbar_position_changed (GtkRadioAction *action,
 static void
 rstto_main_window_set_navigationbar_position (RsttoMainWindow *window, guint orientation)
 {
+    rstto_settings_set_navbar_position (window->priv->settings_manager, orientation);
+
     switch (orientation)
     {
-        case 0:
+        case 0: /* Left */
             g_object_ref (window->priv->image_list_toolbar);
             g_object_ref (window->priv->thumbnailbar);
 
@@ -2182,31 +2193,31 @@ rstto_main_window_set_navigationbar_position (RsttoMainWindow *window, guint ori
             gtk_toolbar_set_orientation (GTK_TOOLBAR (window->priv->image_list_toolbar), GTK_ORIENTATION_VERTICAL);
             rstto_thumbnail_bar_set_orientation (RSTTO_THUMBNAIL_BAR(window->priv->thumbnailbar), GTK_ORIENTATION_VERTICAL);
             break;
-        case 1:
+        case 1: /* Right */
             g_object_ref (window->priv->image_list_toolbar);
             g_object_ref (window->priv->thumbnailbar);
 
             gtk_container_remove (GTK_CONTAINER (gtk_widget_get_parent (window->priv->thumbnailbar)), window->priv->thumbnailbar);
-            gtk_paned_pack1 (GTK_PANED (window->priv->vpaned_top), window->priv->thumbnailbar, FALSE, FALSE);
+            gtk_paned_pack2 (GTK_PANED (window->priv->hpaned_right), window->priv->thumbnailbar, FALSE, FALSE);
 
             gtk_container_remove (GTK_CONTAINER (window->priv->table), window->priv->image_list_toolbar);
-            gtk_table_attach (GTK_TABLE (window->priv->table), window->priv->image_list_toolbar, 0, 3, 0, 1, GTK_EXPAND|GTK_FILL,GTK_FILL, 0, 0);
-            gtk_toolbar_set_orientation (GTK_TOOLBAR (window->priv->image_list_toolbar), GTK_ORIENTATION_HORIZONTAL);
-            rstto_thumbnail_bar_set_orientation (RSTTO_THUMBNAIL_BAR(window->priv->thumbnailbar), GTK_ORIENTATION_HORIZONTAL);
+            gtk_table_attach (GTK_TABLE (window->priv->table), window->priv->image_list_toolbar, 2, 3, 0, 3, GTK_FILL,GTK_EXPAND|GTK_FILL, 0, 0);
+            gtk_toolbar_set_orientation (GTK_TOOLBAR (window->priv->image_list_toolbar), GTK_ORIENTATION_VERTICAL);
+            rstto_thumbnail_bar_set_orientation (RSTTO_THUMBNAIL_BAR(window->priv->thumbnailbar), GTK_ORIENTATION_VERTICAL);
             break;
-        case 2:
+        case 2: /* Top */
             g_object_ref (window->priv->image_list_toolbar);
             g_object_ref (window->priv->thumbnailbar);
 
             gtk_container_remove (GTK_CONTAINER (gtk_widget_get_parent (window->priv->thumbnailbar)), window->priv->thumbnailbar);
-            gtk_paned_pack2 (GTK_PANED (window->priv->hpaned_right), window->priv->thumbnailbar, FALSE, FALSE);
+            gtk_paned_pack1 (GTK_PANED (window->priv->vpaned_top), window->priv->thumbnailbar, FALSE, FALSE);
 
             gtk_container_remove (GTK_CONTAINER (window->priv->table), window->priv->image_list_toolbar);
-            gtk_table_attach (GTK_TABLE (window->priv->table), window->priv->image_list_toolbar, 2, 3, 0, 3, GTK_FILL,GTK_EXPAND|GTK_FILL, 0, 0);
-            gtk_toolbar_set_orientation (GTK_TOOLBAR (window->priv->image_list_toolbar), GTK_ORIENTATION_VERTICAL);
-            rstto_thumbnail_bar_set_orientation (RSTTO_THUMBNAIL_BAR(window->priv->thumbnailbar), GTK_ORIENTATION_VERTICAL);
+            gtk_table_attach (GTK_TABLE (window->priv->table), window->priv->image_list_toolbar, 0, 3, 0, 1, GTK_EXPAND|GTK_FILL,GTK_FILL, 0, 0);
+            gtk_toolbar_set_orientation (GTK_TOOLBAR (window->priv->image_list_toolbar), GTK_ORIENTATION_HORIZONTAL);
+            rstto_thumbnail_bar_set_orientation (RSTTO_THUMBNAIL_BAR(window->priv->thumbnailbar), GTK_ORIENTATION_HORIZONTAL);
             break;
-        case 3:
+        case 3: /* Bottom */
             g_object_ref (window->priv->image_list_toolbar);
             g_object_ref (window->priv->thumbnailbar);
 
diff --git a/src/settings.c b/src/settings.c
index 42b5b1b..821ef14 100644
--- a/src/settings.c
+++ b/src/settings.c
@@ -55,6 +55,7 @@ enum
     PROP_0,
     PROP_SHOW_FILE_TOOLBAR,
     PROP_SHOW_NAV_TOOLBAR,
+    PROP_NAVBAR_POSITION,
     PROP_SHOW_THUMBNAILBAR,
     PROP_TOOLBAR_OPEN,
     PROP_ENABLE_CACHE,
@@ -104,6 +105,7 @@ struct _RsttoSettingsPriv
     gboolean  show_file_toolbar;
     gboolean  show_nav_toolbar;
     gboolean  show_thumbnailbar;
+    gchar    *navigationbar_position;
     guint     preload_images;
     gboolean  enable_cache;
     guint     cache_size;
@@ -150,6 +152,7 @@ rstto_settings_init (GObject *object)
     xfconf_g_property_bind (settings->priv->channel, "/window/show-file-toolbar", G_TYPE_BOOLEAN, settings, "show-file-toolbar");
     xfconf_g_property_bind (settings->priv->channel, "/window/show-navigation-toolbar", G_TYPE_BOOLEAN, settings, "show-nav-toolbar");
     xfconf_g_property_bind (settings->priv->channel, "/window/show-thumbnailbar", G_TYPE_BOOLEAN, settings, "show-thumbnailbar");
+    xfconf_g_property_bind (settings->priv->channel, "/window/navigationbar-position", G_TYPE_STRING, settings, "navigationbar-position");
     xfconf_g_property_bind (settings->priv->channel, "/window/scrollwheel-action", G_TYPE_STRING, settings, "scrollwheel-action");
 
     xfconf_g_property_bind (settings->priv->channel, "/slideshow/timeout", G_TYPE_UINT, settings, "slideshow-timeout");
@@ -229,6 +232,15 @@ rstto_settings_class_init (GObjectClass *object_class)
                                      PROP_SHOW_THUMBNAILBAR,
                                      pspec);
 
+    pspec = g_param_spec_string  ("navigationbar-position",
+                                  "",
+                                  "",
+                                  "right",
+                                  G_PARAM_READWRITE);
+    g_object_class_install_property (object_class,
+                                     PROP_NAVBAR_POSITION,
+                                     pspec);
+
     pspec = g_param_spec_uint ("preload-images",
                                "",
                                "",
@@ -397,6 +409,7 @@ rstto_settings_set_property    (GObject      *object,
                                 GParamSpec   *pspec)
 {
     GdkColor *color;
+    const gchar *str_val = NULL;
     RsttoSettings *settings = RSTTO_SETTINGS (object);
 
     switch (property_id)
@@ -410,6 +423,19 @@ rstto_settings_set_property    (GObject      *object,
         case PROP_SHOW_THUMBNAILBAR:
             settings->priv->show_thumbnailbar= g_value_get_boolean (value);
             break;
+        case PROP_NAVBAR_POSITION:
+            str_val = g_value_get_string (value);
+
+            if ((!g_strcasecmp (str_val, "left")) ||
+                (!g_strcasecmp (str_val, "right")) ||
+                (!g_strcasecmp (str_val, "bottom")) ||
+                (!g_strcasecmp (str_val, "top")))
+            {
+                if (settings->priv->navigationbar_position)
+                    g_free (settings->priv->navigationbar_position);
+                settings->priv->navigationbar_position = g_strdup (str_val);
+            }
+            break;
         case PROP_PRELOAD_IMAGES:
             settings->priv->preload_images = g_value_get_uint (value);
             break;
@@ -481,6 +507,9 @@ rstto_settings_get_property    (GObject    *object,
         case PROP_SHOW_THUMBNAILBAR:
             g_value_set_boolean (value, settings->priv->show_thumbnailbar);
             break;
+        case PROP_NAVBAR_POSITION:
+            g_value_set_string (value, settings->priv->navigationbar_position);
+            break;
         case PROP_PRELOAD_IMAGES:
             g_value_set_uint (value, settings->priv->preload_images);
             break;
@@ -522,3 +551,46 @@ rstto_settings_get_property    (GObject    *object,
 
     }
 }
+
+void
+rstto_settings_set_navbar_position (RsttoSettings *settings, guint pos)
+{
+    GValue val = {0, };
+    g_value_init (&val, G_TYPE_STRING);
+ 
+    switch (pos)
+    {
+        default:
+            g_value_set_string (&val, "left");
+            break;
+        case 1:
+            g_value_set_string (&val, "right");
+            break;
+        case 2:
+            g_value_set_string (&val, "top");
+            break;
+        case 3:
+            g_value_set_string (&val, "bottom");
+            break;
+    }
+
+    g_object_set_property (G_OBJECT(settings), "navigationbar-position", &val);
+
+    g_value_reset (&val);
+}
+
+guint
+rstto_settings_get_navbar_position (RsttoSettings *settings)
+{
+    if (settings->priv->navigationbar_position == NULL)
+        return 0;
+
+    if (!strcmp (settings->priv->navigationbar_position, "left"))
+        return 0;
+    if (!strcmp (settings->priv->navigationbar_position, "right"))
+        return 1;
+    if (!strcmp (settings->priv->navigationbar_position, "top"))
+        return 2;
+    if (!strcmp (settings->priv->navigationbar_position, "bottom"))
+        return 3;
+}
diff --git a/src/settings.h b/src/settings.h
index 4b526c2..ea2ec3f 100644
--- a/src/settings.h
+++ b/src/settings.h
@@ -60,6 +60,9 @@ struct _RsttoSettingsClass
 RsttoSettings *rstto_settings_new (void);
 GType          rstto_settings_get_type (void);
 
+void           rstto_settings_set_navbar_position (RsttoSettings *, guint);
+guint          rstto_settings_get_navbar_position (RsttoSettings *);
+
 G_END_DECLS
 
 #endif /* __RISTRETTO_SETTINGS_H__ */


More information about the Xfce4-commits mailing list