[gthumb/ext] allow to hide the browser sidebar



commit b2b8e5625452d02810d794edca859498881c0938
Author: Paolo Bacchilega <paobac src gnome org>
Date:   Sun Oct 18 19:21:34 2009 +0200

    allow to hide the browser sidebar

 data/gthumb.schemas.in                 |   13 +++++++++++++
 gthumb/gth-browser-actions-callbacks.c |    8 ++++++++
 gthumb/gth-browser-actions-callbacks.h |    1 +
 gthumb/gth-browser-actions-entries.h   |    5 +++++
 gthumb/gth-browser-ui.h                |    1 +
 gthumb/gth-browser.c                   |   32 +++++++++++++++++++++++++++++++-
 gthumb/gth-preferences.h               |    1 +
 7 files changed, 60 insertions(+), 1 deletions(-)
---
diff --git a/data/gthumb.schemas.in b/data/gthumb.schemas.in
index 855ab05..b691c05 100644
--- a/data/gthumb.schemas.in
+++ b/data/gthumb.schemas.in
@@ -454,6 +454,19 @@
       </schema>
 
       <schema>
+	<key>/schemas/apps/gthumb/ui/sidebar_visible</key>
+	<applyto>/apps/gthumb/ui/sidebar_visible</applyto>
+	<owner>gthumb</owner>
+	<type>bool</type>
+	<default>true</default>
+	<locale name="C">
+	  <short></short>
+	  <long>
+	  </long>
+	</locale>
+      </schema>
+
+      <schema>
 	<key>/schemas/apps/gthumb/ui/sidebar_width</key>
 	<applyto>/apps/gthumb/ui/sidebar_width</applyto>
 	<owner>gthumb</owner>
diff --git a/gthumb/gth-browser-actions-callbacks.c b/gthumb/gth-browser-actions-callbacks.c
index ec9c101..77a3e1e 100644
--- a/gthumb/gth-browser-actions-callbacks.c
+++ b/gthumb/gth-browser-actions-callbacks.c
@@ -262,6 +262,14 @@ gth_browser_activate_action_view_statusbar (GtkAction  *action,
 
 
 void
+gth_browser_activate_action_view_sidebar (GtkAction  *action,
+					  GthBrowser *browser)
+{
+	eel_gconf_set_boolean (PREF_UI_SIDEBAR_VISIBLE, gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (action)));
+}
+
+
+void
 gth_browser_activate_action_view_stop (GtkAction  *action,
 				       GthBrowser *browser)
 {
diff --git a/gthumb/gth-browser-actions-callbacks.h b/gthumb/gth-browser-actions-callbacks.h
index f1caabb..f341dbe 100644
--- a/gthumb/gth-browser-actions-callbacks.h
+++ b/gthumb/gth-browser-actions-callbacks.h
@@ -58,6 +58,7 @@ DEFINE_ACTION(gth_browser_activate_action_view_thumbnails)
 DEFINE_ACTION(gth_browser_activate_action_view_toolbar)
 DEFINE_ACTION(gth_browser_activate_action_view_show_hidden_files)
 DEFINE_ACTION(gth_browser_activate_action_view_statusbar)
+DEFINE_ACTION(gth_browser_activate_action_view_sidebar)
 DEFINE_ACTION(gth_browser_activate_action_view_stop)
 DEFINE_ACTION(gth_browser_activate_action_view_reload)
 DEFINE_ACTION(gth_browser_activate_action_view_next)
diff --git a/gthumb/gth-browser-actions-entries.h b/gthumb/gth-browser-actions-entries.h
index 4f6e8da..823dca0 100644
--- a/gthumb/gth-browser-actions-entries.h
+++ b/gthumb/gth-browser-actions-entries.h
@@ -205,6 +205,11 @@ static GtkToggleActionEntry gth_browser_action_toggle_entries[] = {
 	  N_("View or hide the filterbar of this window"),
 	  G_CALLBACK (gth_browser_activate_action_view_filterbar),
 	  TRUE },
+	{ "View_Sidebar", NULL,
+	  N_("_Sidebar"), "F9",
+	  N_("View or hide the sidebar of this window"),
+	  G_CALLBACK (gth_browser_activate_action_view_sidebar),
+	  TRUE },
 	{ "View_Thumbnails", NULL,
 	  N_("_Thumbnails"), "<control>T",
 	  N_("View thumbnails"),
diff --git a/gthumb/gth-browser-ui.h b/gthumb/gth-browser-ui.h
index 625cd55..39535b1 100644
--- a/gthumb/gth-browser-ui.h
+++ b/gthumb/gth-browser-ui.h
@@ -62,6 +62,7 @@ static const char *fixed_ui_info =
 "      <menuitem action='View_Reload'/>"
 "      <separator/>"
 "      <menuitem action='View_Toolbar'/>"
+"      <menuitem action='View_Sidebar'/>"
 "      <menuitem action='View_Statusbar'/>"
 "      <placeholder name='View_Bars'/>"
 "      <separator/>"
diff --git a/gthumb/gth-browser.c b/gthumb/gth-browser.c
index 82312c1..24e6ca9 100644
--- a/gthumb/gth-browser.c
+++ b/gthumb/gth-browser.c
@@ -62,7 +62,7 @@
 #define GO_FORWARD_HISTORY_POPUP "/GoForwardHistoryPopup"
 #define GO_PARENT_POPUP "/GoParentPopup"
 #define MAX_HISTORY_LENGTH 15
-#define GCONF_NOTIFICATIONS 10
+#define GCONF_NOTIFICATIONS 11
 #define DEF_SIDEBAR_WIDTH 255
 #define DEF_VIEWER_SIDEBAR_WIDTH 295
 #define DEF_PROPERTIES_HEIGHT 128
@@ -3036,6 +3036,31 @@ pref_ui_statusbar_visible_changed (GConfClient *client,
 
 
 static void
+_gth_browser_set_sidebar_visibility  (GthBrowser *browser,
+				      gboolean    visible)
+{
+	g_return_if_fail (browser != NULL);
+
+	_gth_browser_set_action_active (browser, "View_Sidebar", visible);
+	if (visible)
+		gtk_widget_show (browser->priv->browser_sidebar);
+	else
+		gtk_widget_hide (browser->priv->browser_sidebar);
+}
+
+
+static void
+pref_ui_sidebar_visible_changed (GConfClient *client,
+				 guint        cnxn_id,
+				 GConfEntry  *entry,
+				 gpointer     user_data)
+{
+	GthBrowser *browser = user_data;
+	_gth_browser_set_sidebar_visibility (browser, gconf_value_get_bool (gconf_entry_get_value (entry)));
+}
+
+
+static void
 pref_show_hidden_files_changed (GConfClient *client,
 				guint        cnxn_id,
 				GConfEntry  *entry,
@@ -3283,6 +3308,7 @@ _gth_browser_construct (GthBrowser *browser)
 	browser->priv->browser_sidebar = gtk_vpaned_new ();
 	gtk_widget_show (browser->priv->browser_sidebar);
 	gtk_paned_pack1 (GTK_PANED (browser->priv->browser_container), browser->priv->browser_sidebar, FALSE, TRUE);
+	_gth_browser_set_sidebar_visibility (browser, eel_gconf_get_boolean (PREF_UI_SIDEBAR_VISIBLE, TRUE));
 
 	/* the box that contains the location and the folder list.  */
 
@@ -3496,6 +3522,10 @@ _gth_browser_construct (GthBrowser *browser)
 					   pref_ui_statusbar_visible_changed,
 					   browser);
 	browser->priv->cnxn_id[i++] = eel_gconf_notification_add (
+					   PREF_UI_SIDEBAR_VISIBLE,
+					   pref_ui_sidebar_visible_changed,
+					   browser);
+	browser->priv->cnxn_id[i++] = eel_gconf_notification_add (
 					   PREF_SHOW_HIDDEN_FILES,
 					   pref_show_hidden_files_changed,
 					   browser);
diff --git a/gthumb/gth-preferences.h b/gthumb/gth-preferences.h
index da2dcd4..1beb287 100644
--- a/gthumb/gth-preferences.h
+++ b/gthumb/gth-preferences.h
@@ -67,6 +67,7 @@ G_BEGIN_DECLS
 #define PREF_UI_TOOLBAR_VISIBLE       "/apps/gthumb/ui/toolbar_visible"
 #define PREF_UI_STATUSBAR_VISIBLE     "/apps/gthumb/ui/statusbar_visible"
 #define PREF_UI_FILTERBAR_VISIBLE     "/apps/gthumb/ui/filterbar_visible"
+#define PREF_UI_SIDEBAR_VISIBLE       "/apps/gthumb/ui/sidebar_visible"
 #define PREF_UI_BROWSER_SIDEBAR_WIDTH "/apps/gthumb/ui/browser_sidebar_width"
 #define PREF_UI_VIEWER_SIDEBAR_WIDTH  "/apps/gthumb/ui/viewer_sidebar_width"
 #define PREF_UI_PROPERTIES_HEIGHT     "/apps/gthumb/ui/properties_height"



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]