? gtk2-2.10-153828-chooser-save-expanded-state.patch
Index: ChangeLog
===================================================================
RCS file: /cvs/gnome/gtk+/ChangeLog,v
retrieving revision 1.8296.2.162
diff -u -p -r1.8296.2.162 ChangeLog
--- ChangeLog	29 Dec 2006 19:21:34 -0000	1.8296.2.162
+++ ChangeLog	5 Jan 2007 15:33:13 -0000
@@ -1,3 +1,12 @@
+2006-01-05  Peter Teichman  <peter@novell.com>
+
+	* gtk/gtkfilechooserdefault.c:
+	* gtk/gtkfilechoosersettings.c:
+	* gtk/gtkfilechoosersettings.h:
+	Save the expanded state of the folder browser with the file
+	chooser settings.  Resolves the expander portions of (#153828,
+	Lemmit Kaplinski)
+
 2006-12-29  Matthias Clasen  <mclasen@redhat.com>
 
 	* gtk/gtkentry.c (blink_cb):
Index: gtk/gtkfilechooserdefault.c
===================================================================
RCS file: /cvs/gnome/gtk+/gtk/gtkfilechooserdefault.c,v
retrieving revision 1.329.2.7
diff -u -p -r1.329.2.7 gtkfilechooserdefault.c
--- gtk/gtkfilechooserdefault.c	22 Sep 2006 16:32:45 -0000	1.329.2.7
+++ gtk/gtkfilechooserdefault.c	5 Jan 2007 15:33:13 -0000
@@ -4239,6 +4239,7 @@ expander_changed_cb (GtkExpander        
 		     GParamSpec            *pspec,
 		     GtkFileChooserDefault *impl)
 {
+  impl->expand_folders = gtk_expander_get_expanded(GTK_EXPANDER (impl->save_expander));
   update_appearance (impl);
 }
 
@@ -5439,16 +5440,21 @@ settings_load (GtkFileChooserDefault *im
   GtkFileChooserSettings *settings;
   LocationMode location_mode;
   gboolean show_hidden;
+  gboolean expand_folders;
 
   settings = _gtk_file_chooser_settings_new ();
 
   location_mode = _gtk_file_chooser_settings_get_location_mode (settings);
   show_hidden = _gtk_file_chooser_settings_get_show_hidden (settings);
+  expand_folders = _gtk_file_chooser_settings_get_expand_folders (settings);
 
   g_object_unref (settings);
 
   location_mode_set (impl, location_mode, TRUE);
   gtk_file_chooser_set_show_hidden (GTK_FILE_CHOOSER (impl), show_hidden);
+  impl->expand_folders = expand_folders;
+  if (impl->save_expander)
+    gtk_expander_set_expanded (GTK_EXPANDER (impl->save_expander), expand_folders);
 }
 
 static void
@@ -5460,6 +5466,7 @@ settings_save (GtkFileChooserDefault *im
 
   _gtk_file_chooser_settings_set_location_mode (settings, impl->location_mode);
   _gtk_file_chooser_settings_set_show_hidden (settings, gtk_file_chooser_get_show_hidden (GTK_FILE_CHOOSER (impl)));
+  _gtk_file_chooser_settings_set_expand_folders (settings, impl->expand_folders);
 
   /* NULL GError */
   _gtk_file_chooser_settings_save (settings, NULL);
Index: gtk/gtkfilechoosersettings.c
===================================================================
RCS file: /cvs/gnome/gtk+/gtk/gtkfilechoosersettings.c,v
retrieving revision 1.3.2.1
diff -u -p -r1.3.2.1 gtkfilechoosersettings.c
--- gtk/gtkfilechoosersettings.c	10 Sep 2006 06:33:13 -0000	1.3.2.1
+++ gtk/gtkfilechoosersettings.c	5 Jan 2007 15:33:13 -0000
@@ -42,6 +42,7 @@
 #define ELEMENT_TOPLEVEL	"gtkfilechooser"
 #define ELEMENT_LOCATION	"location"
 #define ELEMENT_SHOW_HIDDEN     "show_hidden"
+#define ELEMENT_EXPAND_FOLDERS  "expand_folders"
 #define ATTRIBUTE_VERSION       "version"
 #define ATTRIBUTE_MODE		"mode"
 #define ATTRIBUTE_VALUE         "value"
@@ -69,6 +70,7 @@ set_defaults (GtkFileChooserSettings *se
 {
   settings->location_mode = LOCATION_MODE_PATH_BAR;
   settings->show_hidden = FALSE;
+  settings->expand_folders = FALSE;
 }
 
 typedef enum {
@@ -77,7 +79,8 @@ typedef enum {
   STATE_ERROR,
   STATE_IN_TOPLEVEL,
   STATE_IN_LOCATION,
-  STATE_IN_SHOW_HIDDEN
+  STATE_IN_SHOW_HIDDEN,
+  STATE_IN_EXPAND_FOLDERS
 } State;
 
 struct parse_state {
@@ -271,6 +274,34 @@ parse_start_element_cb (GMarkupParseCont
 			   value_str);
 	    }
 	}
+      else if (EQ (element_name, ELEMENT_EXPAND_FOLDERS))
+	{
+	  const char *value_str;
+
+	  state->state = STATE_IN_EXPAND_FOLDERS;
+
+	  value_str = get_attribute_value (attribute_names, attribute_values, ATTRIBUTE_VALUE);
+
+	  if (!value_str)
+	    set_missing_attribute_error (state, line, col, ATTRIBUTE_VALUE, error);
+	  else if (EQ (value_str, VALUE_TRUE))
+	    state->settings->expand_folders = TRUE;
+	  else if (EQ (value_str, VALUE_FALSE))
+	    state->settings->expand_folders = FALSE;
+	  else
+	    {
+	      state->state = STATE_ERROR;
+	      g_set_error (error,
+			   G_MARKUP_ERROR,
+			   G_MARKUP_ERROR_INVALID_CONTENT,
+			   _("Line %d, column %d: expected \"%s\" or \"%s\", but found \"%s\" instead"),
+			   line,
+			   col,
+			   VALUE_FALSE,
+			   VALUE_TRUE,
+			   value_str);
+	    }
+	}
       else
 	set_unexpected_element_error (state, line, col, element_name, error);
 
@@ -336,6 +367,14 @@ parse_end_element_cb (GMarkupParseContex
 
       break;
 
+    case STATE_IN_EXPAND_FOLDERS:
+      if (EQ (element_name, ELEMENT_EXPAND_FOLDERS))
+	state->state = STATE_IN_TOPLEVEL;
+      else
+	set_unexpected_element_end_error (state, line, col, ELEMENT_EXPAND_FOLDERS, element_name, error);
+
+      break;
+
     default:
       g_assert_not_reached ();
     }
@@ -454,11 +493,26 @@ _gtk_file_chooser_settings_set_show_hidd
   settings->show_hidden = show_hidden ? TRUE : FALSE;
 }
 
+gboolean
+_gtk_file_chooser_settings_get_expand_folders (GtkFileChooserSettings *settings)
+{
+  ensure_settings_read (settings);
+  return settings->expand_folders;
+}
+
+void
+_gtk_file_chooser_settings_set_expand_folders (GtkFileChooserSettings *settings,
+					       gboolean expand_folders)
+{
+  settings->expand_folders = expand_folders ? TRUE : FALSE;
+}
+
 static char *
 settings_to_markup (GtkFileChooserSettings *settings)
 {
   const char *location_mode_str;
   const char *show_hidden_str;
+  const char *expand_folders_str;
 
   if (settings->location_mode == LOCATION_MODE_PATH_BAR)
     location_mode_str = MODE_PATH_BAR;
@@ -471,14 +525,17 @@ settings_to_markup (GtkFileChooserSettin
     }
 
   show_hidden_str = settings->show_hidden ? VALUE_TRUE : VALUE_FALSE;
+  expand_folders_str = settings->expand_folders ? VALUE_TRUE : VALUE_FALSE;
 
   return g_strdup_printf
     ("<" ELEMENT_TOPLEVEL ">\n"						/* <gtkfilechooser>               */
      "  <" ELEMENT_LOCATION " " ATTRIBUTE_MODE "=\"%s\"/>\n"		/*   <location mode="path-bar"/>  */
      "  <" ELEMENT_SHOW_HIDDEN " " ATTRIBUTE_VALUE "=\"%s\"/>\n"	/*   <show_hidden value="false"/> */
+     "  <" ELEMENT_EXPAND_FOLDERS " " ATTRIBUTE_VALUE "=\"%s\"/>\n"	/*   <expand_folders value="false"/> */
      "</" ELEMENT_TOPLEVEL ">\n",					/* </gtkfilechooser>              */
      location_mode_str,
-     show_hidden_str);
+     show_hidden_str,
+     expand_folders_str);
 }
 
 gboolean
Index: gtk/gtkfilechoosersettings.h
===================================================================
RCS file: /cvs/gnome/gtk+/gtk/gtkfilechoosersettings.h,v
retrieving revision 1.2
diff -u -p -r1.2 gtkfilechoosersettings.h
--- gtk/gtkfilechoosersettings.h	3 May 2006 22:29:48 -0000	1.2
+++ gtk/gtkfilechoosersettings.h	5 Jan 2007 15:33:13 -0000
@@ -42,6 +42,8 @@ struct _GtkFileChooserSettings
   guint settings_read : 1;
 
   guint show_hidden : 1;
+
+  guint expand_folders : 1;
 };
 
 struct _GtkFileChooserSettingsClass
@@ -60,6 +62,10 @@ void         _gtk_file_chooser_settings_
 gboolean _gtk_file_chooser_settings_get_show_hidden (GtkFileChooserSettings *settings);
 void     _gtk_file_chooser_settings_set_show_hidden (GtkFileChooserSettings *settings,
 						     gboolean                show_hidden);
+
+gboolean _gtk_file_chooser_settings_get_expand_folders (GtkFileChooserSettings *settings);
+void     _gtk_file_chooser_settings_set_expand_folders (GtkFileChooserSettings *settings,
+							gboolean                expand_folders);
 
 gboolean _gtk_file_chooser_settings_save (GtkFileChooserSettings *settings,
 					  GError                **error);
