[gthumb] Allow to change the position of the file properties in browser mode



commit 29d6b16da02d7a44a7245cf617f04dfc82b70fb6
Author: Paolo Bacchilega <paobac src gnome org>
Date:   Wed Nov 16 15:28:59 2011 +0100

    Allow to change the position of the file properties in browser mode
    
    Allow to set the file properties on the right side or below the folder list when
    in browser mode.
    
    [new feature]

 data/org.gnome.gthumb.gschema.xml.in |    5 ++-
 data/ui/preferences.ui               |   56 ++++++++++++++++++++-----
 gthumb/dlg-preferences.c             |   14 ++++++
 gthumb/gth-browser.c                 |   76 +++++++++++++++++++++++++++++-----
 gthumb/gth-preferences.h             |    1 +
 5 files changed, 129 insertions(+), 23 deletions(-)
---
diff --git a/data/org.gnome.gthumb.gschema.xml.in b/data/org.gnome.gthumb.gschema.xml.in
index cb3a2ba..0946dbb 100644
--- a/data/org.gnome.gthumb.gschema.xml.in
+++ b/data/org.gnome.gthumb.gschema.xml.in
@@ -88,7 +88,7 @@
     </key>
     <key name="sort-inverse" type="b">
       <default>false</default>
-    </key>   
+    </key>
     <key name="toolbar-style" enum="org.gnome.gthumb.GthToolbarStyle">
       <default>'system'</default>
     </key>
@@ -116,6 +116,9 @@
     <key name="properties-visible" type="b">
       <default>true</default>
     </key>
+    <key name="properties-on-the-right" type="b">
+      <default>false</default>
+    </key>
     <key name="thumbnail-list-visible" type="b">
       <default>true</default>
     </key>
diff --git a/data/ui/preferences.ui b/data/ui/preferences.ui
index 6b2fec3..78f0517 100644
--- a/data/ui/preferences.ui
+++ b/data/ui/preferences.ui
@@ -1,6 +1,20 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <interface>
   <!-- interface-requires gtk+ 3.0 -->
+  <object class="GtkListStore" id="file_properties_position_liststore">
+    <columns>
+      <!-- column-name name -->
+      <column type="gchararray"/>
+    </columns>
+    <data>
+      <row>
+        <col id="0" translatable="yes">below the folder list</col>
+      </row>
+      <row>
+        <col id="0" translatable="yes">on the right</col>
+      </row>
+    </data>
+  </object>
   <object class="GtkDialog" id="preferences_dialog">
     <property name="can_focus">False</property>
     <property name="border_width">5</property>
@@ -18,7 +32,6 @@
             <child>
               <object class="GtkButton" id="help_button">
                 <property name="label">gtk-help</property>
-                <property name="use_action_appearance">False</property>
                 <property name="visible">True</property>
                 <property name="can_focus">True</property>
                 <property name="receives_default">True</property>
@@ -35,7 +48,6 @@
             <child>
               <object class="GtkButton" id="close_button">
                 <property name="label">gtk-ok</property>
-                <property name="use_action_appearance">False</property>
                 <property name="visible">True</property>
                 <property name="can_focus">True</property>
                 <property name="receives_default">True</property>
@@ -167,10 +179,39 @@
                                   <placeholder/>
                                 </child>
                                 <child>
-                                  <placeholder/>
+                                  <object class="GtkLabel" id="label10">
+                                    <property name="visible">True</property>
+                                    <property name="can_focus">False</property>
+                                    <property name="xalign">0</property>
+                                    <property name="label" translatable="yes">File _properties in browser:</property>
+                                    <property name="use_underline">True</property>
+                                    <property name="mnemonic_widget">file_properties_position_combobox</property>
+                                  </object>
+                                  <packing>
+                                    <property name="left_attach">0</property>
+                                    <property name="top_attach">2</property>
+                                    <property name="width">1</property>
+                                    <property name="height">1</property>
+                                  </packing>
                                 </child>
                                 <child>
-                                  <placeholder/>
+                                  <object class="GtkComboBox" id="file_properties_position_combobox">
+                                    <property name="visible">True</property>
+                                    <property name="can_focus">False</property>
+                                    <property name="model">file_properties_position_liststore</property>
+                                    <child>
+                                      <object class="GtkCellRendererText" id="cellrenderertext1"/>
+                                      <attributes>
+                                        <attribute name="text">0</attribute>
+                                      </attributes>
+                                    </child>
+                                  </object>
+                                  <packing>
+                                    <property name="left_attach">1</property>
+                                    <property name="top_attach">2</property>
+                                    <property name="width">1</property>
+                                    <property name="height">1</property>
+                                  </packing>
                                 </child>
                               </object>
                               <packing>
@@ -222,7 +263,6 @@
                             <child>
                               <object class="GtkRadioButton" id="go_to_last_location_radiobutton">
                                 <property name="label" translatable="yes">Go to last _visited location</property>
-                                <property name="use_action_appearance">False</property>
                                 <property name="visible">True</property>
                                 <property name="can_focus">True</property>
                                 <property name="receives_default">False</property>
@@ -246,7 +286,6 @@
                                 <child>
                                   <object class="GtkRadioButton" id="use_startup_location_radiobutton">
                                     <property name="label" translatable="yes">Go to this _folder:</property>
-                                    <property name="use_action_appearance">False</property>
                                     <property name="visible">True</property>
                                     <property name="can_focus">True</property>
                                     <property name="receives_default">False</property>
@@ -290,7 +329,6 @@
                                 <child>
                                   <object class="GtkButton" id="set_to_current_button">
                                     <property name="label" translatable="yes">Set to C_urrent</property>
-                                    <property name="use_action_appearance">False</property>
                                     <property name="visible">True</property>
                                     <property name="can_focus">True</property>
                                     <property name="receives_default">True</property>
@@ -354,7 +392,6 @@
                             <child>
                               <object class="GtkCheckButton" id="confirm_deletion_checkbutton">
                                 <property name="label" translatable="yes">As_k confirmation before deleting files or catalogs</property>
-                                <property name="use_action_appearance">False</property>
                                 <property name="visible">True</property>
                                 <property name="can_focus">True</property>
                                 <property name="receives_default">False</property>
@@ -372,7 +409,6 @@
                             <child>
                               <object class="GtkCheckButton" id="ask_to_save_checkbutton">
                                 <property name="label" translatable="yes">Ask whether to save _modified files</property>
-                                <property name="use_action_appearance">False</property>
                                 <property name="visible">True</property>
                                 <property name="can_focus">True</property>
                                 <property name="receives_default">False</property>
@@ -390,7 +426,6 @@
                             <child>
                               <object class="GtkCheckButton" id="embed_metadata_checkbutton">
                                 <property name="label" translatable="yes">_Store metadata inside files if possible</property>
-                                <property name="use_action_appearance">False</property>
                                 <property name="visible">True</property>
                                 <property name="can_focus">True</property>
                                 <property name="receives_default">False</property>
@@ -568,7 +603,6 @@
                             <child>
                               <object class="GtkCheckButton" id="slow_mime_type_checkbutton">
                                 <property name="label" translatable="yes">D_etermine image type from content (slower)</property>
-                                <property name="use_action_appearance">False</property>
                                 <property name="visible">True</property>
                                 <property name="can_focus">True</property>
                                 <property name="receives_default">False</property>
diff --git a/gthumb/dlg-preferences.c b/gthumb/dlg-preferences.c
index 73e6212..73626fb 100644
--- a/gthumb/dlg-preferences.c
+++ b/gthumb/dlg-preferences.c
@@ -163,6 +163,14 @@ thumbnails_pane_orientation_changed_cb (GtkWidget  *widget,
 
 
 static void
+file_properties_position_combobox_changed_cb (GtkWidget  *widget,
+					      DialogData *data)
+{
+	g_settings_set_boolean (data->browser_settings, PREF_BROWSER_PROPERTIES_ON_THE_RIGHT, gtk_combo_box_get_active (GTK_COMBO_BOX (GET_WIDGET ("file_properties_position_combobox"))) == 1);
+}
+
+
+static void
 confirm_deletion_toggled_cb (GtkToggleButton *button,
 			     DialogData      *data)
 {
@@ -291,6 +299,8 @@ dlg_preferences (GthBrowser *browser)
 				  get_idx_from_size (g_settings_get_int (data->browser_settings, PREF_BROWSER_THUMBNAIL_SIZE)));
 	gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (GET_WIDGET ("slow_mime_type_checkbutton")),
 				      ! g_settings_get_boolean (data->browser_settings, PREF_BROWSER_FAST_FILE_TYPE));
+	gtk_combo_box_set_active (GTK_COMBO_BOX (GET_WIDGET ("file_properties_position_combobox")),
+				  g_settings_get_boolean (data->browser_settings, PREF_BROWSER_PROPERTIES_ON_THE_RIGHT) ? 1 : 0);
 
 	gth_hook_invoke ("dlg-preferences-construct", data->dialog, data->browser, data->builder);
 
@@ -319,6 +329,10 @@ dlg_preferences (GthBrowser *browser)
 			  "changed",
 			  G_CALLBACK (thumbnails_pane_orientation_changed_cb),
 			  data);
+	g_signal_connect (GET_WIDGET ("file_properties_position_combobox"),
+			  "changed",
+			  G_CALLBACK (file_properties_position_combobox_changed_cb),
+			  data);
 	g_signal_connect (G_OBJECT (GET_WIDGET ("use_startup_location_radiobutton")),
 			  "toggled",
 			  G_CALLBACK (use_startup_toggled_cb),
diff --git a/gthumb/gth-browser.c b/gthumb/gth-browser.c
index 6b495a7..b63b75e 100644
--- a/gthumb/gth-browser.c
+++ b/gthumb/gth-browser.c
@@ -91,7 +91,8 @@ struct _GthBrowserPrivate {
 	GtkWidget         *infobar;
 	GtkWidget         *statusbar;
 	GtkWidget         *browser_toolbar;
-	GtkWidget         *browser_container;
+	GtkWidget         *browser_right_container;
+	GtkWidget         *browser_left_container;
 	GtkWidget         *browser_sidebar;
 	GtkWidget         *location_chooser_container;
 	GtkWidget         *location_chooser;
@@ -164,6 +165,7 @@ struct _GthBrowserPrivate {
 	char              *location_free_space;
 	gboolean           recalc_location_free_space;
 	gboolean           shrink_wrap_viewer;
+	gboolean           file_properties_on_the_right;
 
 	/* settings */
 
@@ -2350,6 +2352,16 @@ _gth_browser_update_browser_ui (GthBrowser *browser,
 /* --- _gth_browser_set_current_page --- */
 
 
+static GtkWidget *
+_gth_browser_get_browser_file_properties_container (GthBrowser *browser)
+{
+	if (browser->priv->file_properties_on_the_right)
+		return browser->priv->browser_right_container;
+	else
+		return browser->priv->browser_sidebar;
+}
+
+
 static void
 _gth_browser_real_set_current_page (GthWindow *window,
 				    int        page)
@@ -2375,11 +2387,14 @@ _gth_browser_real_set_current_page (GthWindow *window,
 
 	gtk_widget_unrealize (browser->priv->file_properties);
 	if (page == GTH_BROWSER_PAGE_BROWSER) {
-		gtk_widget_reparent (browser->priv->file_properties, browser->priv->browser_sidebar);
+		GtkWidget *file_properties_parent;
+
+		file_properties_parent = _gth_browser_get_browser_file_properties_container (browser);
+		gtk_widget_reparent (browser->priv->file_properties, file_properties_parent);
 		/* restore the child properties that gtk_widget_reparent doesn't preserve. */
-		gtk_container_child_set (GTK_CONTAINER (browser->priv->browser_sidebar),
+		gtk_container_child_set (GTK_CONTAINER (file_properties_parent),
 					 browser->priv->file_properties,
-					 "resize", TRUE,
+					 "resize", ! browser->priv->file_properties_on_the_right,
 					 "shrink", FALSE,
 					 NULL);
 	}
@@ -3730,6 +3745,33 @@ pref_ui_toolbar_style_changed (GSettings  *settings,
 
 
 static void
+pref_browser_properties_on_the_right_changed (GSettings  *settings,
+					      const char *key,
+					      gpointer    user_data)
+{
+	GthBrowser *browser = user_data;
+	GtkWidget  *old_parent;
+	GtkWidget  *new_parent;
+
+	old_parent = _gth_browser_get_browser_file_properties_container (browser);
+	browser->priv->file_properties_on_the_right = g_settings_get_boolean (browser->priv->browser_settings, PREF_BROWSER_PROPERTIES_ON_THE_RIGHT);
+	new_parent = _gth_browser_get_browser_file_properties_container (browser);
+
+	if (old_parent == new_parent)
+		return;
+
+	gtk_widget_unrealize (browser->priv->file_properties);
+	gtk_widget_reparent (browser->priv->file_properties, new_parent);
+	/* restore the child properties that gtk_widget_reparent doesn't preserve. */
+	gtk_container_child_set (GTK_CONTAINER (new_parent),
+				 browser->priv->file_properties,
+				 "resize", ! browser->priv->file_properties_on_the_right,
+				 "shrink", FALSE,
+				 NULL);
+}
+
+
+static void
 pref_ui_viewer_thumbnails_orient_changed (GSettings  *settings,
 					  const char *key,
 					  gpointer    user_data)
@@ -3854,7 +3896,7 @@ _gth_browser_set_sidebar_visibility  (GthBrowser *browser,
 	_gth_browser_set_action_active (browser, "View_Sidebar", visible);
 	if (visible) {
 		gtk_widget_show (browser->priv->browser_sidebar);
-		gtk_paned_set_position (GTK_PANED (browser->priv->browser_container),
+		gtk_paned_set_position (GTK_PANED (browser->priv->browser_left_container),
 				        g_settings_get_int (browser->priv->browser_settings, PREF_BROWSER_BROWSER_SIDEBAR_WIDTH));
 	}
 	else
@@ -4130,6 +4172,7 @@ gth_browser_init (GthBrowser *browser)
 	browser->priv->browser_settings = g_settings_new (GTHUMB_BROWSER_SCHEMA);
 	browser->priv->messages_settings = g_settings_new (GTHUMB_MESSAGES_SCHEMA);
 	browser->priv->desktop_interface_settings = g_settings_new (GNOME_DESKTOP_INTERFACE_SCHEMA);
+	browser->priv->file_properties_on_the_right = g_settings_get_boolean (browser->priv->browser_settings, PREF_BROWSER_PROPERTIES_ON_THE_RIGHT);
 
 	/* find a suitable size for the window */
 
@@ -4317,15 +4360,19 @@ gth_browser_init (GthBrowser *browser)
 
 	/* main content */
 
-	browser->priv->browser_container = gtk_paned_new (GTK_ORIENTATION_HORIZONTAL);
-	gtk_widget_show (browser->priv->browser_container);
-	gth_window_attach_content (GTH_WINDOW (browser), GTH_BROWSER_PAGE_BROWSER, browser->priv->browser_container);
+	browser->priv->browser_right_container = gtk_paned_new (GTK_ORIENTATION_HORIZONTAL);
+	gtk_widget_show (browser->priv->browser_right_container);
+	gth_window_attach_content (GTH_WINDOW (browser), GTH_BROWSER_PAGE_BROWSER, browser->priv->browser_right_container);
+
+	browser->priv->browser_left_container = gtk_paned_new (GTK_ORIENTATION_HORIZONTAL);
+	gtk_widget_show (browser->priv->browser_left_container);
+	gtk_paned_pack1 (GTK_PANED (browser->priv->browser_right_container), browser->priv->browser_left_container, TRUE, TRUE);
 
 	/* the browser sidebar */
 
 	browser->priv->browser_sidebar = gth_auto_paned_new (GTK_ORIENTATION_VERTICAL);
 	gtk_widget_set_size_request (browser->priv->browser_sidebar, g_settings_get_int (browser->priv->browser_settings, PREF_BROWSER_BROWSER_SIDEBAR_WIDTH), -1);
-	gtk_paned_pack1 (GTK_PANED (browser->priv->browser_container), browser->priv->browser_sidebar, FALSE, TRUE);
+	gtk_paned_pack1 (GTK_PANED (browser->priv->browser_left_container), browser->priv->browser_sidebar, FALSE, TRUE);
 
 	/* the box that contains the location and the folder list.  */
 
@@ -4428,13 +4475,16 @@ gth_browser_init (GthBrowser *browser)
 	browser->priv->file_properties = gth_sidebar_new ("file-tools");
 	gtk_widget_set_size_request (browser->priv->file_properties, -1, FILE_PROPERTIES_MINIMUM_HEIGHT);
 	gtk_widget_hide (browser->priv->file_properties);
-	gtk_paned_pack2 (GTK_PANED (browser->priv->browser_sidebar), browser->priv->file_properties, FALSE, FALSE);
+	gtk_paned_pack2 (GTK_PANED (_gth_browser_get_browser_file_properties_container (browser)),
+			 browser->priv->file_properties,
+			 ! browser->priv->file_properties_on_the_right,
+			 FALSE);
 
 	/* the box that contains the file list and the filter bar.  */
 
 	vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
 	gtk_widget_show (vbox);
-	gtk_paned_pack2 (GTK_PANED (browser->priv->browser_container), vbox, TRUE, TRUE);
+	gtk_paned_pack2 (GTK_PANED (browser->priv->browser_left_container), vbox, TRUE, TRUE);
 
 	/* the list extra widget container */
 
@@ -4578,6 +4628,10 @@ gth_browser_init (GthBrowser *browser)
 			  "changed::" PREF_BROWSER_VIEWER_THUMBNAILS_ORIENT,
 			  G_CALLBACK (pref_ui_viewer_thumbnails_orient_changed),
 			  browser);
+	g_signal_connect (browser->priv->browser_settings,
+			  "changed::" PREF_BROWSER_PROPERTIES_ON_THE_RIGHT,
+			  G_CALLBACK (pref_browser_properties_on_the_right_changed),
+			  browser);
 	g_signal_connect (browser->priv->desktop_interface_settings,
 			  "changed::" PREF_BROWSER_TOOLBAR_STYLE,
 			  G_CALLBACK (pref_ui_toolbar_style_changed),
diff --git a/gthumb/gth-preferences.h b/gthumb/gth-preferences.h
index 172ad04..ff3affa 100644
--- a/gthumb/gth-preferences.h
+++ b/gthumb/gth-preferences.h
@@ -72,6 +72,7 @@ G_BEGIN_DECLS
 #define PREF_BROWSER_FILTERBAR_VISIBLE        "filterbar-visible"
 #define PREF_BROWSER_SIDEBAR_VISIBLE          "sidebar-visible"
 #define PREF_BROWSER_PROPERTIES_VISIBLE       "properties-visible"
+#define PREF_BROWSER_PROPERTIES_ON_THE_RIGHT  "properties-on-the-right"
 #define PREF_BROWSER_THUMBNAIL_LIST_VISIBLE   "thumbnail-list-visible"
 #define PREF_BROWSER_BROWSER_SIDEBAR_WIDTH    "browser-sidebar-width"
 #define PREF_BROWSER_VIEWER_SIDEBAR_WIDTH     "viewer-sidebar-width"



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