From fe3b707e6e0cfc1f2e525ce5d8c8ffeb6e0b19be Mon Sep 17 00:00:00 2001 From: John Darrington Date: Wed, 4 Mar 2009 09:54:58 +0900 Subject: [PATCH] Save and recall window geometry for dialog boxes --- src/ui/gui/psppire-dialog.c | 45 ++++++++++++++++++++++++++++++++++++- 1 file changed, 44 insertions(+), 1 deletion(-) diff --git a/src/ui/gui/psppire-dialog.c b/src/ui/gui/psppire-dialog.c index 6945c2a9..85438003 100644 --- a/src/ui/gui/psppire-dialog.c +++ b/src/ui/gui/psppire-dialog.c @@ -23,6 +23,7 @@ #include "psppire-dialog.h" #include "psppire-buttonbox.h" #include "psppire-selector.h" +#include "psppire-conf.h" #include static void psppire_dialog_class_init (PsppireDialogClass *); @@ -264,6 +265,39 @@ delete_event_callback (GtkWidget *w, GdkEvent *e, gpointer data) } +static gboolean +configure_event_callback (GtkDialog *dialog, + GdkEventConfigure *event, gpointer data) +{ + gchar *base = NULL; + + PsppireConf *conf = psppire_conf_new (); + + if ( ! GTK_WIDGET_MAPPED (dialog)) + return FALSE; + + g_object_get (dialog, "name", &base, NULL); + + psppire_conf_save_window_geometry (conf, base, event); + + return FALSE; +} + + +static void +on_realize (GtkWindow *dialog, gpointer data) +{ + PsppireConf *conf = psppire_conf_new (); + + const gchar *base = NULL; + + g_object_get (dialog, "name", &base, NULL); + + psppire_conf_set_window_geometry (conf, base, dialog); +} + + + static void psppire_dialog_init (PsppireDialog *dialog) { @@ -282,10 +316,19 @@ psppire_dialog_init (PsppireDialog *dialog) g_value_unset (&value); - g_signal_connect (G_OBJECT (dialog), "delete-event", + g_signal_connect (dialog, "delete-event", G_CALLBACK (delete_event_callback), dialog); + g_signal_connect (dialog, "configure-event", + G_CALLBACK (configure_event_callback), + dialog); + + g_signal_connect (dialog, "realize", + G_CALLBACK (on_realize), + dialog); + + gtk_window_set_type_hint (GTK_WINDOW (dialog), GDK_WINDOW_TYPE_HINT_DIALOG); -- 2.30.2