[gtk+] filechooser: remember sidebar width



commit 2f8c2a32445128e5f9eb5a4e3295fb691df5bc4d
Author: Jonny Lamb <jonnylamb gnome org>
Date:   Wed Nov 14 13:10:59 2012 +0100

    filechooser: remember sidebar width
    
    https://bugzilla.gnome.org/show_bug.cgi?id=524295
    
    Signed-off-by: Jonny Lamb <jonnylamb gnome org>

 gtk/gtkfilechooserdefault.c                  |   10 ++++++++--
 gtk/gtkfilechooserprivate.h                  |    1 +
 gtk/org.gtk.Settings.FileChooser.gschema.xml |    3 +++
 3 files changed, 12 insertions(+), 2 deletions(-)
---
diff --git a/gtk/gtkfilechooserdefault.c b/gtk/gtkfilechooserdefault.c
index ceab128..8f446c4 100644
--- a/gtk/gtkfilechooserdefault.c
+++ b/gtk/gtkfilechooserdefault.c
@@ -264,6 +264,7 @@ typedef enum {
 #define SETTINGS_KEY_SORT_ORDER          "sort-order"
 #define SETTINGS_KEY_WINDOW_POSITION     "window-position"
 #define SETTINGS_KEY_WINDOW_SIZE         "window-size"
+#define SETTINGS_KEY_SIDEBAR_WIDTH       "sidebar-width"
 
 static void gtk_file_chooser_default_iface_init       (GtkFileChooserIface        *iface);
 static void gtk_file_chooser_embed_default_iface_init (GtkFileChooserEmbedIface   *iface);
@@ -5057,7 +5058,7 @@ browse_widgets_create (GtkFileChooserDefault *impl)
 
   /* Paned widget */
 
-  hpaned = gtk_paned_new (GTK_ORIENTATION_HORIZONTAL);
+  hpaned = impl->browse_widgets_hpaned = gtk_paned_new (GTK_ORIENTATION_HORIZONTAL);
   gtk_widget_show (hpaned);
   gtk_box_pack_start (GTK_BOX (impl->browse_widgets_box), hpaned, TRUE, TRUE, 0);
 
@@ -5065,7 +5066,6 @@ browse_widgets_create (GtkFileChooserDefault *impl)
   gtk_paned_pack1 (GTK_PANED (hpaned), widget, FALSE, FALSE);
   widget = file_pane_create (impl, size_group);
   gtk_paned_pack2 (GTK_PANED (hpaned), widget, TRUE, FALSE);
-  gtk_paned_set_position (GTK_PANED (hpaned), 148);
   g_object_unref (size_group);
 }
 
@@ -6037,6 +6037,7 @@ settings_load (GtkFileChooserDefault *impl)
   gboolean show_size_column;
   gint sort_column;
   GtkSortType sort_order;
+  gint sidebar_width;
 
   settings_ensure (impl);
 
@@ -6045,6 +6046,7 @@ settings_load (GtkFileChooserDefault *impl)
   show_size_column = g_settings_get_boolean (impl->settings, SETTINGS_KEY_SHOW_SIZE_COLUMN);
   sort_column = g_settings_get_enum (impl->settings, SETTINGS_KEY_SORT_COLUMN);
   sort_order = g_settings_get_enum (impl->settings, SETTINGS_KEY_SORT_ORDER);
+  sidebar_width = g_settings_get_int (impl->settings, SETTINGS_KEY_SIDEBAR_WIDTH);
 
   location_mode_set (impl, location_mode, TRUE);
 
@@ -6059,6 +6061,8 @@ settings_load (GtkFileChooserDefault *impl)
    * created yet.  The individual functions that create and set the models will
    * call set_sort_column() themselves.
    */
+
+  gtk_paned_set_position (GTK_PANED (impl->browse_widgets_hpaned), sidebar_width);
 }
 
 static void
@@ -6106,6 +6110,8 @@ settings_save (GtkFileChooserDefault *impl)
   g_settings_set_boolean (impl->settings, SETTINGS_KEY_SHOW_SIZE_COLUMN, impl->show_size_column);
   g_settings_set_enum (impl->settings, SETTINGS_KEY_SORT_COLUMN, impl->sort_column);
   g_settings_set_enum (impl->settings, SETTINGS_KEY_SORT_ORDER, impl->sort_order);
+  g_settings_set_int (impl->settings, SETTINGS_KEY_SIDEBAR_WIDTH,
+                     gtk_paned_get_position (GTK_PANED (impl->browse_widgets_hpaned)));
 
   save_dialog_geometry (impl);
 
diff --git a/gtk/gtkfilechooserprivate.h b/gtk/gtkfilechooserprivate.h
index e51a041..76380a1 100644
--- a/gtk/gtkfilechooserprivate.h
+++ b/gtk/gtkfilechooserprivate.h
@@ -166,6 +166,7 @@ struct _GtkFileChooserDefault
 
   /* The file browsing widgets */
   GtkWidget *browse_widgets_box;
+  GtkWidget *browse_widgets_hpaned;
   GtkWidget *browse_header_box;
   GtkWidget *browse_shortcuts_tree_view;
   GtkWidget *browse_shortcuts_add_button;
diff --git a/gtk/org.gtk.Settings.FileChooser.gschema.xml b/gtk/org.gtk.Settings.FileChooser.gschema.xml
index 849e8ff..b53abfc 100644
--- a/gtk/org.gtk.Settings.FileChooser.gschema.xml
+++ b/gtk/org.gtk.Settings.FileChooser.gschema.xml
@@ -61,6 +61,9 @@
     <key name='window-size' type='(ii)'>
       <default>(-1, -1)</default>
     </key>
+    <key name='sidebar-width' type='i'>
+      <default>148</default>
+    </key>
   </schema>
 
 </schemalist>



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