[gtk+] filechooser: Move saving geometry to where it belongs
- From: Benjamin Otte <otte src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+] filechooser: Move saving geometry to where it belongs
- Date: Sat, 26 Jan 2013 20:05:15 +0000 (UTC)
commit e26031e0c7e96dea0d9a0b5bf52bbcfd6df709e8
Author: Benjamin Otte <otte redhat com>
Date: Sat Jan 26 18:29:21 2013 +0100
filechooser: Move saving geometry to where it belongs
Move it from the filechooserwidget to the filechooserdialog unmap
function. It was previously only working for filechooserdialogs, too.
gtk/gtkfilechooserdefault.c | 23 -----------------------
gtk/gtkfilechooserdialog.c | 31 +++++++++++++++++++++++++++++++
2 files changed, 31 insertions(+), 23 deletions(-)
---
diff --git a/gtk/gtkfilechooserdefault.c b/gtk/gtkfilechooserdefault.c
index 59022c6..3eff220 100644
--- a/gtk/gtkfilechooserdefault.c
+++ b/gtk/gtkfilechooserdefault.c
@@ -6042,27 +6042,6 @@ settings_load (GtkFileChooserDefault *impl)
}
static void
-save_dialog_geometry (GtkFileChooserDefault *impl)
-{
- GtkWindow *toplevel;
- int x, y, width, height;
- GSettings *settings;
-
- toplevel = get_toplevel (GTK_WIDGET (impl));
-
- if (!(toplevel && GTK_IS_FILE_CHOOSER_DIALOG (toplevel)))
- return;
-
- settings = _gtk_file_chooser_get_settings_for_widget (GTK_WIDGET (toplevel));
-
- gtk_window_get_position (toplevel, &x, &y);
- gtk_window_get_size (toplevel, &width, &height);
-
- g_settings_set (settings, SETTINGS_KEY_WINDOW_POSITION, "(ii)", x, y);
- g_settings_set (settings, SETTINGS_KEY_WINDOW_SIZE, "(ii)", width, height);
-}
-
-static void
settings_save (GtkFileChooserDefault *impl)
{
GSettings *settings;
@@ -6080,8 +6059,6 @@ settings_save (GtkFileChooserDefault *impl)
g_settings_set_int (settings, SETTINGS_KEY_SIDEBAR_WIDTH,
gtk_paned_get_position (GTK_PANED (impl->browse_widgets_hpaned)));
- save_dialog_geometry (impl);
-
/* Now apply the settings */
g_settings_apply (settings);
}
diff --git a/gtk/gtkfilechooserdialog.c b/gtk/gtkfilechooserdialog.c
index 01fe9af..6ed41b6 100644
--- a/gtk/gtkfilechooserdialog.c
+++ b/gtk/gtkfilechooserdialog.c
@@ -210,6 +210,7 @@ static void gtk_file_chooser_dialog_get_property (GObject *obj
GParamSpec *pspec);
static void gtk_file_chooser_dialog_map (GtkWidget *widget);
+static void gtk_file_chooser_dialog_unmap (GtkWidget *widget);
static void response_cb (GtkDialog *dialog,
gint response_id);
@@ -230,6 +231,7 @@ gtk_file_chooser_dialog_class_init (GtkFileChooserDialogClass *class)
gobject_class->finalize = gtk_file_chooser_dialog_finalize;
widget_class->map = gtk_file_chooser_dialog_map;
+ widget_class->unmap = gtk_file_chooser_dialog_unmap;
gtk_widget_class_set_accessible_role (widget_class, ATK_ROLE_FILE_CHOOSER);
@@ -537,6 +539,35 @@ gtk_file_chooser_dialog_map (GtkWidget *widget)
GTK_WIDGET_CLASS (gtk_file_chooser_dialog_parent_class)->map (widget);
}
+static void
+save_dialog_geometry (GtkFileChooserDialog *dialog)
+{
+ GtkWindow *window;
+ GSettings *settings;
+ int x, y, width, height;
+
+ settings = _gtk_file_chooser_get_settings_for_widget (GTK_WIDGET (dialog));
+
+ window = GTK_WINDOW (dialog);
+
+ gtk_window_get_position (window, &x, &y);
+ gtk_window_get_size (window, &width, &height);
+
+ g_settings_set (settings, SETTINGS_KEY_WINDOW_POSITION, "(ii)", x, y);
+ g_settings_set (settings, SETTINGS_KEY_WINDOW_SIZE, "(ii)", width, height);
+}
+
+/* GtkWidget::unmap handler */
+static void
+gtk_file_chooser_dialog_unmap (GtkWidget *widget)
+{
+ GtkFileChooserDialog *dialog = GTK_FILE_CHOOSER_DIALOG (widget);
+
+ save_dialog_geometry (dialog);
+
+ GTK_WIDGET_CLASS (gtk_file_chooser_dialog_parent_class)->unmap (widget);
+}
+
/* GtkDialog::response handler */
static void
response_cb (GtkDialog *dialog,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]