[gnumeric] GUI: Remember dialog sizes and positions.



commit 05c24f7ff27122e2880fd191f87c5c8638ff5724
Author: Morten Welinder <terra gnome org>
Date:   Sat Jun 20 18:45:18 2009 -0400

    GUI: Remember dialog sizes and positions.

 ChangeLog                        |    3 ++
 NEWS                             |    4 +-
 src/dialogs/dialog-cell-format.c |    5 +++
 src/dialogs/dialog-search.c      |    3 ++
 src/gui-util.c                   |   55 +++++++++++++++++++------------------
 src/gui-util.h                   |    2 +
 6 files changed, 43 insertions(+), 29 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index 81407a3..f83d6e9 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,8 @@
 2009-06-20  Morten Welinder  <terra gnome org>
 
+	* src/gui-util.c (gnumeric_restore_window_geometry): Split out
+	from gnumeric_keyed_dialog.
+
 	* src/value.c (criteria_test_match): New function.
 	(free_criteria): Free regexp if needed.
 	(criteria_inspect_values, criteria_test_equal,
diff --git a/NEWS b/NEWS
index 21f91ac..6ac492d 100644
--- a/NEWS
+++ b/NEWS
@@ -1,8 +1,8 @@
 Gnumeric 1.9.10
 
 Morten:
-	* Make SUMIF/COUNTIF and the D* functions understand pattern.
-	[#586215]
+	* Make SUMIF/COUNTIF and the D* functions understand pattern. [#586215]
+	* Make dialogs remember their sizes and positions.
 
 --------------------------------------------------------------------------
 Gnumeric 1.9.9
diff --git a/src/dialogs/dialog-cell-format.c b/src/dialogs/dialog-cell-format.c
index bcb202a..95c1404 100644
--- a/src/dialogs/dialog-cell-format.c
+++ b/src/dialogs/dialog-cell-format.c
@@ -61,6 +61,8 @@
 
 #include <string.h>
 
+#define CELL_FORMAT_KEY "cell-format-dialog"
+
 static struct {
 	char const *Cname;
 	GnmUnderline ut;
@@ -2322,6 +2324,9 @@ fmt_dialog_impl (FormatState *state, FormatDialogPosition_t pageno)
 	g_object_set_data_full (G_OBJECT (state->dialog),
 		"state", state, (GDestroyNotify)cb_fmt_dialog_dialog_destroy);
 
+	gnumeric_restore_window_geometry (GTK_WINDOW (state->dialog),
+					  CELL_FORMAT_KEY);
+
 	go_gtk_nonmodal_dialog (wbcg_toplevel (state->wbcg),
 				   GTK_WINDOW (state->dialog));
 	gtk_widget_show (GTK_WIDGET (state->dialog));
diff --git a/src/dialogs/dialog-search.c b/src/dialogs/dialog-search.c
index 61bf8d0..aafe41d 100644
--- a/src/dialogs/dialog-search.c
+++ b/src/dialogs/dialog-search.c
@@ -47,6 +47,8 @@
 #include <gtk/gtk.h>
 #include <string.h>
 
+#define SEARCH_KEY "search-dialog"
+
 enum {
 	COL_SHEET = 0,
 	COL_CELL,
@@ -550,6 +552,7 @@ dialog_search (WBCGtk *wbcg)
 	gnumeric_init_help_button (
 		glade_xml_get_widget (gui, "help_button"),
 		GNUMERIC_HELP_LINK_SEARCH);
+	gnumeric_restore_window_geometry (GTK_WINDOW (dialog), SEARCH_KEY);
 
 	go_gtk_nonmodal_dialog (wbcg_toplevel (wbcg), GTK_WINDOW (dialog));
 	gtk_widget_show_all (GTK_WIDGET (dialog));
diff --git a/src/gui-util.c b/src/gui-util.c
index bb3f7a5..01e60dc 100644
--- a/src/gui-util.c
+++ b/src/gui-util.c
@@ -209,6 +209,33 @@ cb_save_sizes (GtkWidget *dialog, const char *key)
 	g_hash_table_replace (h, g_strdup (key), r);
 }
 
+void
+gnumeric_restore_window_geometry (GtkWindow *dialog, const char *key)
+{
+	GtkWidget *top = gtk_widget_get_toplevel (GTK_WIDGET (dialog));
+	GdkScreen *screen = gtk_widget_get_screen (GTK_WIDGET (dialog));
+	GHashTable *h = g_object_get_data (G_OBJECT (screen), SAVE_SIZES_SCREEN_KEY);
+	GdkRectangle *allocation = h ? g_hash_table_lookup (h, key) : NULL;
+
+	if (allocation) {
+#if 0
+		g_printerr ("Restoring %s to %dx%d at (%d,%d)\n",
+			    key, allocation->width, allocation->height,
+			    allocation->x, allocation->y);
+#endif
+		gtk_window_move
+			(GTK_WINDOW (top),
+			 allocation->x, allocation->y);
+		gtk_window_set_default_size
+			(GTK_WINDOW (top),
+			 allocation->width, allocation->height);
+	}
+
+	g_signal_connect (G_OBJECT (dialog), "unrealize",
+			  G_CALLBACK (cb_save_sizes),
+			  (gpointer)key);
+}
+
 /**
  * gnumeric_keyed_dialog
  *
@@ -225,10 +252,6 @@ void
 gnumeric_keyed_dialog (WBCGtk *wbcg, GtkWindow *dialog, char const *key)
 {
 	KeyedDialogContext *ctxt;
-	GtkWindow *top;
-	GdkScreen *screen;
-	GHashTable *h;
-	GdkRectangle *allocation;
 
 	g_return_if_fail (IS_WBC_GTK (wbcg));
 	g_return_if_fail (GTK_IS_WINDOW (dialog));
@@ -250,29 +273,7 @@ gnumeric_keyed_dialog (WBCGtk *wbcg, GtkWindow *dialog, char const *key)
 	g_signal_connect (G_OBJECT (dialog), "key_press_event",
 			  G_CALLBACK (cb_keyed_dialog_keypress), NULL);
 
-	top = GTK_WINDOW (gtk_widget_get_toplevel (GTK_WIDGET (dialog)));
-	screen = gtk_widget_get_screen (GTK_WIDGET (dialog));
-	h = g_object_get_data (G_OBJECT (screen), SAVE_SIZES_SCREEN_KEY);
-	allocation = h ? g_hash_table_lookup (h, key) : NULL;
-
-	/* TECHOLOGY PREVIEW -- ZOOM & COMMENT DIALOG ONLY.  */
-	if ((strcmp (key, "zoom-dialog") == 0) ||
-	    (strcmp (key, "cell-comment-dialog") == 0)) {
-		if (allocation) {
-#if 0
-			g_print ("Restoring %s to %dx%d at (%d,%d)\n",
-				 key, allocation->width, allocation->height,
-				 allocation->x, allocation->y);
-#endif
-			gtk_window_move (top, allocation->x, allocation->y);
-			gtk_window_set_default_size
-				(top, allocation->width, allocation->height);
-		}
-
-		g_signal_connect (G_OBJECT (dialog), "unrealize",
-				  G_CALLBACK (cb_save_sizes),
-				  (gpointer)key);
-	}
+	gnumeric_restore_window_geometry (dialog, key);
 }
 
 /**
diff --git a/src/gui-util.h b/src/gui-util.h
index 30ba476..eb42025 100644
--- a/src/gui-util.h
+++ b/src/gui-util.h
@@ -19,6 +19,8 @@ G_BEGIN_DECLS
 GtkWidget* gnumeric_error_info_dialog_new (ErrorInfo *error);
 void       gnumeric_error_info_dialog_show (GtkWindow *parent,
                                             ErrorInfo *error);
+void       gnumeric_restore_window_geometry (GtkWindow *dialog,
+					     const char *key);
 void       gnumeric_keyed_dialog (WBCGtk *wbcg,
 				  GtkWindow *dialog,
 				  char const *key);



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