[Xfce4-commits] <ristretto:ristretto-0.0> Fix errors when the 'ristretto' icon is not available. Add toggle-button for hiding navigation-toolbar

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


Updating branch refs/heads/ristretto-0.0
         to 1b71f80354aecfebee9fe7bb2fdd064b81074a2f (commit)
       from 527692577906730757dea30dbb640f1f12ff5cd8 (commit)

commit 1b71f80354aecfebee9fe7bb2fdd064b81074a2f
Author: Stephan Arts <stephan at xfce.org>
Date:   Sun Aug 30 10:38:23 2009 +0200

    Fix errors when the 'ristretto' icon is not available.
    Add toggle-button for hiding navigation-toolbar

 src/main_window.c      |   82 ++++++++++++++++++++++++++++++++++++++---------
 src/main_window_ui.xml |    3 +-
 src/picture_viewer.c   |   41 +++++++++++++-----------
 src/settings.c         |   36 ++++++++++++++++-----
 4 files changed, 117 insertions(+), 45 deletions(-)

diff --git a/src/main_window.c b/src/main_window.c
index 84153ef..82b7ac9 100644
--- a/src/main_window.c
+++ b/src/main_window.c
@@ -205,7 +205,9 @@ cb_rstto_main_window_message_bar_cancel (GtkWidget *widget, RsttoMainWindow *win
 
 
 static void
-cb_rstto_main_window_toggle_show_toolbar (GtkWidget *widget, RsttoMainWindow *window);
+cb_rstto_main_window_toggle_show_file_toolbar (GtkWidget *widget, RsttoMainWindow *window);
+static void
+cb_rstto_main_window_toggle_show_nav_toolbar (GtkWidget *widget, RsttoMainWindow *window);
 static void
 cb_rstto_main_window_fullscreen (GtkWidget *widget, RsttoMainWindow *window);
 static void
@@ -289,7 +291,8 @@ static GtkActionEntry action_entries[] =
 
 static const GtkToggleActionEntry toggle_action_entries[] =
 {
-    { "show-toolbar", NULL, N_ ("Show _Toolbar"), NULL, NULL, G_CALLBACK (cb_rstto_main_window_toggle_show_toolbar), TRUE, },
+    { "show-file-toolbar", NULL, N_ ("Show File _Toolbar"), NULL, NULL, G_CALLBACK (cb_rstto_main_window_toggle_show_file_toolbar), TRUE, },
+    { "show-nav-toolbar", NULL, N_ ("Show Nav _Toolbar"), NULL, NULL, G_CALLBACK (cb_rstto_main_window_toggle_show_nav_toolbar), TRUE, },
     { "show-thumbnailbar", NULL, N_ ("Show Thumb_nailbar"), NULL, NULL, NULL, FALSE},
 };
 
@@ -330,7 +333,7 @@ static void
 rstto_main_window_init (RsttoMainWindow *window)
 {
     GtkAccelGroup   *accel_group;
-    GValue          show_toolbar_val = {0,}, window_width = {0, }, window_height = {0, };
+    GValue          show_file_toolbar_val = {0,}, show_nav_toolbar_val = {0, }, window_width = {0, }, window_height = {0, };
     GtkWidget       *separator, *back, *forward;
     GtkWidget       *main_vbox = gtk_vbox_new (FALSE, 0);
     GtkRecentFilter *recent_filter;
@@ -464,6 +467,7 @@ rstto_main_window_init (RsttoMainWindow *window)
     gtk_box_pack_start(GTK_BOX(main_vbox), window->priv->statusbar, FALSE, FALSE, 0);
 
     gtk_widget_set_no_show_all (window->priv->toolbar, TRUE);
+    gtk_widget_set_no_show_all (window->priv->image_list_toolbar, TRUE);
     gtk_widget_set_no_show_all (window->priv->message_bar, TRUE);
 
     /**
@@ -511,13 +515,13 @@ rstto_main_window_init (RsttoMainWindow *window)
     /**
      * Retrieve the toolbar state from the settings-manager
      */
-    g_value_init (&show_toolbar_val, G_TYPE_BOOLEAN);
-    g_object_get_property (G_OBJECT(window->priv->settings_manager), "show-toolbar", &show_toolbar_val);
-    if (g_value_get_boolean (&show_toolbar_val))
+    g_value_init (&show_file_toolbar_val, G_TYPE_BOOLEAN);
+    g_object_get_property (G_OBJECT(window->priv->settings_manager), "show-file-toolbar", &show_file_toolbar_val);
+    if (g_value_get_boolean (&show_file_toolbar_val))
     {
         gtk_check_menu_item_set_active (
                 GTK_CHECK_MENU_ITEM (
-                        gtk_ui_manager_get_widget (window->priv->ui_manager, "/main-menu/view-menu/show-toolbar")),
+                        gtk_ui_manager_get_widget (window->priv->ui_manager, "/main-menu/view-menu/show-file-toolbar")),
                 TRUE);
         gtk_widget_show (window->priv->toolbar);
     }
@@ -525,10 +529,30 @@ rstto_main_window_init (RsttoMainWindow *window)
     {
         gtk_check_menu_item_set_active (
                 GTK_CHECK_MENU_ITEM (
-                        gtk_ui_manager_get_widget (window->priv->ui_manager, "/main-menu/view-menu/show-toolbar")),
+                        gtk_ui_manager_get_widget (window->priv->ui_manager, "/main-menu/view-menu/show-file-toolbar")),
                 FALSE);
         gtk_widget_hide (window->priv->toolbar);
     }
+    g_value_init (&show_nav_toolbar_val, G_TYPE_BOOLEAN);
+    g_object_get_property (G_OBJECT(window->priv->settings_manager), "show-nav-toolbar", &show_nav_toolbar_val);
+    if (g_value_get_boolean (&show_nav_toolbar_val))
+    {
+        gtk_check_menu_item_set_active (
+                GTK_CHECK_MENU_ITEM (
+                        gtk_ui_manager_get_widget (window->priv->ui_manager, "/main-menu/view-menu/show-nav-toolbar")),
+                TRUE);
+        gtk_widget_show (window->priv->image_list_toolbar);
+    }
+    else
+    {
+        gtk_check_menu_item_set_active (
+                GTK_CHECK_MENU_ITEM (
+                        gtk_ui_manager_get_widget (window->priv->ui_manager, "/main-menu/view-menu/show-nav-toolbar")),
+                FALSE);
+        gtk_widget_hide (window->priv->image_list_toolbar);
+    }
+    g_value_reset (&show_file_toolbar_val);
+    g_value_reset (&show_nav_toolbar_val);
 
     g_signal_connect(G_OBJECT(window->priv->picture_viewer), "motion-notify-event", G_CALLBACK(cb_rstto_main_window_picture_viewer_motion_notify_event), window);
     g_signal_connect(G_OBJECT(window), "configure-event", G_CALLBACK(cb_rstto_main_window_configure_event), NULL);
@@ -1700,14 +1724,14 @@ cb_rstto_main_window_delete (GtkWidget *widget, RsttoMainWindow *window)
 }
 
 /**
- * cb_rstto_main_window_toggle_show_toolbar:
+ * cb_rstto_main_window_toggle_show_file_toolbar:
  * @widget:
  * @window:
  *
  *
  */
 static void
-cb_rstto_main_window_toggle_show_toolbar (GtkWidget *widget, RsttoMainWindow *window)
+cb_rstto_main_window_toggle_show_file_toolbar (GtkWidget *widget, RsttoMainWindow *window)
 {
     GValue val = {0,};
     g_value_init (&val, G_TYPE_BOOLEAN);
@@ -1722,7 +1746,33 @@ cb_rstto_main_window_toggle_show_toolbar (GtkWidget *widget, RsttoMainWindow *wi
         gtk_widget_hide (window->priv->toolbar);
         g_value_set_boolean (&val, FALSE);
     }
-    g_object_set_property (G_OBJECT (window->priv->settings_manager), "show-toolbar", &val);
+    g_object_set_property (G_OBJECT (window->priv->settings_manager), "show-file-toolbar", &val);
+}
+
+/**
+ * cb_rstto_main_window_toggle_show_nav_toolbar:
+ * @widget:
+ * @window:
+ *
+ *
+ */
+static void
+cb_rstto_main_window_toggle_show_nav_toolbar (GtkWidget *widget, RsttoMainWindow *window)
+{
+    GValue val = {0,};
+    g_value_init (&val, G_TYPE_BOOLEAN);
+
+    if (gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (widget)))
+    {
+        gtk_widget_show (window->priv->image_list_toolbar);
+        g_value_set_boolean (&val, TRUE);
+    }
+    else
+    {
+        gtk_widget_hide (window->priv->image_list_toolbar);
+        g_value_set_boolean (&val, FALSE);
+    }
+    g_object_set_property (G_OBJECT (window->priv->settings_manager), "show-nav-toolbar", &val);
 }
 
 /**
@@ -1801,7 +1851,7 @@ static void
 cb_rstto_main_window_state_event(GtkWidget *widget, GdkEventWindowState *event, gpointer user_data)
 {
     RsttoMainWindow *window = RSTTO_MAIN_WINDOW(widget);
-    GValue           show_toolbar_val = {0,};
+    GValue           show_file_toolbar_val = {0,};
 
     if(event->changed_mask & GDK_WINDOW_STATE_FULLSCREEN)
     {
@@ -1854,16 +1904,16 @@ cb_rstto_main_window_state_event(GtkWidget *widget, GdkEventWindowState *event,
             }
             gtk_widget_show (window->priv->image_list_toolbar);
 
-            g_value_init (&show_toolbar_val, G_TYPE_BOOLEAN);
-            g_object_get_property (G_OBJECT(window->priv->settings_manager), "show-toolbar", &show_toolbar_val);
+            g_value_init (&show_file_toolbar_val, G_TYPE_BOOLEAN);
+            g_object_get_property (G_OBJECT(window->priv->settings_manager), "show-file-toolbar", &show_file_toolbar_val);
 
             gtk_widget_show (window->priv->menubar);
             gtk_widget_show (window->priv->statusbar);
 
-            if (g_value_get_boolean (&show_toolbar_val))
+            if (g_value_get_boolean (&show_file_toolbar_val))
                 gtk_widget_show (window->priv->toolbar);
             
-            g_value_reset (&show_toolbar_val);
+            g_value_reset (&show_file_toolbar_val);
         }
     }
     if (event->changed_mask & GDK_WINDOW_STATE_MAXIMIZED)
diff --git a/src/main_window_ui.xml b/src/main_window_ui.xml
index 6b5760b..0ab4824 100644
--- a/src/main_window_ui.xml
+++ b/src/main_window_ui.xml
@@ -31,7 +31,8 @@
             <menuitem action="preferences"/>
         </menu>
         <menu action="view-menu">
-            <menuitem action="show-toolbar"/>
+            <menuitem action="show-file-toolbar"/>
+            <menuitem action="show-nav-toolbar"/>
             <menuitem action="show-thumbnailbar"/>
             <separator/>
             <menu action="zoom-menu">
diff --git a/src/picture_viewer.c b/src/picture_viewer.c
index 9fc6201..a5ea1fa 100644
--- a/src/picture_viewer.c
+++ b/src/picture_viewer.c
@@ -611,25 +611,28 @@ rstto_picture_viewer_paint (GtkWidget *widget)
                                                "ristretto", 
                                                (size*0.8),
                                                GTK_ICON_LOOKUP_FORCE_SIZE, NULL);
-            gdk_pixbuf_saturate_and_pixelate (pixbuf, pixbuf, 0, TRUE);
-            pixbuf = gdk_pixbuf_composite_color_simple (pixbuf, (size*0.8), (size*0.8), GDK_INTERP_BILINEAR, 40, 40, bg_color->pixel, bg_color->pixel);
-
-            x1 = (widget->allocation.width-gdk_pixbuf_get_width(pixbuf))<0?0:(widget->allocation.width-gdk_pixbuf_get_width(pixbuf))/2;
-            y1 = (widget->allocation.height-gdk_pixbuf_get_height(pixbuf))<0?0:(widget->allocation.height-gdk_pixbuf_get_height(pixbuf))/2;
-            x2 = gdk_pixbuf_get_width(pixbuf);
-            y2 = gdk_pixbuf_get_height(pixbuf);
-
-            gdk_draw_pixbuf(GDK_DRAWABLE(buffer), 
-                            NULL, 
-                            pixbuf,
-                            0,
-                            0,
-                            x1,
-                            y1,
-                            x2, 
-                            y2,
-                            GDK_RGB_DITHER_NONE,
-                            0,0);
+            if (pixbuf)
+            {
+                gdk_pixbuf_saturate_and_pixelate (pixbuf, pixbuf, 0, TRUE);
+                pixbuf = gdk_pixbuf_composite_color_simple (pixbuf, (size*0.8), (size*0.8), GDK_INTERP_BILINEAR, 40, 40, bg_color->pixel, bg_color->pixel);
+
+                x1 = (widget->allocation.width-gdk_pixbuf_get_width(pixbuf))<0?0:(widget->allocation.width-gdk_pixbuf_get_width(pixbuf))/2;
+                y1 = (widget->allocation.height-gdk_pixbuf_get_height(pixbuf))<0?0:(widget->allocation.height-gdk_pixbuf_get_height(pixbuf))/2;
+                x2 = gdk_pixbuf_get_width(pixbuf);
+                y2 = gdk_pixbuf_get_height(pixbuf);
+
+                gdk_draw_pixbuf(GDK_DRAWABLE(buffer), 
+                                NULL, 
+                                pixbuf,
+                                0,
+                                0,
+                                x1,
+                                y1,
+                                x2, 
+                                y2,
+                                GDK_RGB_DITHER_NONE,
+                                0,0);
+            }
         }
         gdk_draw_drawable(GDK_DRAWABLE(widget->window), 
                         gdk_gc_new(widget->window), 
diff --git a/src/settings.c b/src/settings.c
index 1bf543d..7fa0b53 100644
--- a/src/settings.c
+++ b/src/settings.c
@@ -53,7 +53,8 @@ static RsttoSettings *settings_object;
 enum
 {
     PROP_0,
-    PROP_SHOW_TOOLBAR,
+    PROP_SHOW_FILE_TOOLBAR,
+    PROP_SHOW_NAV_TOOLBAR,
     PROP_TOOLBAR_OPEN,
     PROP_ENABLE_CACHE,
     PROP_PRELOAD_IMAGES,
@@ -99,7 +100,8 @@ struct _RsttoSettingsPriv
 {
     XfconfChannel *channel;
 
-    gboolean  show_toolbar;
+    gboolean  show_file_toolbar;
+    gboolean  show_nav_toolbar;
     guint     preload_images;
     gboolean  enable_cache;
     guint     cache_size;
@@ -143,7 +145,8 @@ rstto_settings_init (GObject *object)
 
     xfconf_g_property_bind (settings->priv->channel, "/file/current-uri", G_TYPE_STRING, settings, "current-uri");
 
-    xfconf_g_property_bind (settings->priv->channel, "/window/show-toolbar", G_TYPE_BOOLEAN, settings, "show-toolbar");
+    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/scrollwheel-action", G_TYPE_STRING, settings, "scrollwheel-action");
 
     xfconf_g_property_bind (settings->priv->channel, "/slideshow/timeout", G_TYPE_UINT, settings, "slideshow-timeout");
@@ -196,13 +199,22 @@ rstto_settings_class_init (GObjectClass *object_class)
                                      PROP_WINDOW_HEIGHT,
                                      pspec);
 
-    pspec = g_param_spec_boolean ("show-toolbar",
+    pspec = g_param_spec_boolean ("show-file-toolbar",
                                   "",
                                   "",
                                   TRUE,
                                   G_PARAM_READWRITE);
     g_object_class_install_property (object_class,
-                                     PROP_SHOW_TOOLBAR,
+                                     PROP_SHOW_FILE_TOOLBAR,
+                                     pspec);
+
+    pspec = g_param_spec_boolean ("show-nav-toolbar",
+                                  "",
+                                  "",
+                                  TRUE,
+                                  G_PARAM_READWRITE);
+    g_object_class_install_property (object_class,
+                                     PROP_SHOW_NAV_TOOLBAR,
                                      pspec);
 
     pspec = g_param_spec_uint ("preload-images",
@@ -377,8 +389,11 @@ rstto_settings_set_property    (GObject      *object,
 
     switch (property_id)
     {
-        case PROP_SHOW_TOOLBAR:
-            settings->priv->show_toolbar = g_value_get_boolean (value);
+        case PROP_SHOW_FILE_TOOLBAR:
+            settings->priv->show_file_toolbar = g_value_get_boolean (value);
+            break;
+        case PROP_SHOW_NAV_TOOLBAR:
+            settings->priv->show_nav_toolbar = g_value_get_boolean (value);
             break;
         case PROP_PRELOAD_IMAGES:
             settings->priv->preload_images = g_value_get_uint (value);
@@ -442,8 +457,11 @@ rstto_settings_get_property    (GObject    *object,
 
     switch (property_id)
     {
-        case PROP_SHOW_TOOLBAR:
-            g_value_set_boolean (value, settings->priv->show_toolbar);
+        case PROP_SHOW_FILE_TOOLBAR:
+            g_value_set_boolean (value, settings->priv->show_file_toolbar);
+            break;
+        case PROP_SHOW_NAV_TOOLBAR:
+            g_value_set_boolean (value, settings->priv->show_nav_toolbar);
             break;
         case PROP_PRELOAD_IMAGES:
             g_value_set_uint (value, settings->priv->preload_images);


More information about the Xfce4-commits mailing list