[gnumeric] GUI: Fix restoring size of dialog.
- From: Morten Welinder <mortenw src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnumeric] GUI: Fix restoring size of dialog.
- Date: Tue, 12 Nov 2019 19:11:59 +0000 (UTC)
commit af288e3420c08b941042bdce61de5443d1274be4
Author: Morten Welinder <terra gnome org>
Date: Tue Nov 12 14:10:53 2019 -0500
GUI: Fix restoring size of dialog.
Another kitten killed by Gtk+.
ChangeLog | 6 ++++++
NEWS | 3 +++
src/gui-util.c | 34 +++++++++++++++++++++++-----------
3 files changed, 32 insertions(+), 11 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index ba6e4a04e..fb6276d49 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2019-11-12 Morten Welinder <terra gnome org>
+
+ * src/gui-util.c (gnm_restore_window_geometry): Something changed
+ in Gtk+ in the past decade. Attach to size-allocate instead of
+ unrealize.
+
2019-11-06 Morten Welinder <terra gnome org>
* configure.ac: Post-release bump.
diff --git a/NEWS b/NEWS
index 623b30c54..8bb069dee 100644
--- a/NEWS
+++ b/NEWS
@@ -1,5 +1,8 @@
Gnumeric 1.12.47
+Morten:
+ * Fix dialog size problem.
+
--------------------------------------------------------------------------
Gnumeric 1.12.46
diff --git a/src/gui-util.c b/src/gui-util.c
index 069811671..ae2888c2c 100644
--- a/src/gui-util.c
+++ b/src/gui-util.c
@@ -234,14 +234,19 @@ cb_keyed_dialog_keypress (GtkWidget *dialog, GdkEventKey *event,
#define SAVE_SIZES_SCREEN_KEY "geometry-hash"
+static gboolean debug_dialog_size;
+
static void
-cb_save_sizes (GtkWidget *dialog, const char *key)
+cb_save_sizes (GtkWidget *dialog,
+ const GtkAllocation *allocation,
+ const char *key)
{
GdkRectangle *r;
- GtkAllocation da;
GdkScreen *screen = gtk_widget_get_screen (dialog);
GHashTable *h = g_object_get_data (G_OBJECT (screen),
SAVE_SIZES_SCREEN_KEY);
+ GdkWindow *window = gtk_widget_get_window (dialog);
+
if (!h) {
h = g_hash_table_new_full (g_str_hash, g_str_equal,
(GDestroyNotify)g_free,
@@ -259,9 +264,14 @@ cb_save_sizes (GtkWidget *dialog, const char *key)
(GDestroyNotify)g_hash_table_destroy);
}
- gtk_widget_get_allocation (dialog, &da);
- r = g_memdup (&da, sizeof (da));
- gdk_window_get_position (gtk_widget_get_window (dialog), &r->x, &r->y);
+ r = g_memdup (allocation, sizeof (*allocation));
+ if (window)
+ gdk_window_get_position (gtk_widget_get_window (dialog), &r->x, &r->y);
+
+ if (debug_dialog_size) {
+ g_printerr ("Saving %s to %dx%d at (%d,%d)\n",
+ key, r->width, r->height, r->x, r->y);
+ }
g_hash_table_replace (h, g_strdup (key), r);
}
@@ -273,12 +283,14 @@ gnm_restore_window_geometry (GtkWindow *dialog, const char *key)
GHashTable *h = g_object_get_data (G_OBJECT (screen), SAVE_SIZES_SCREEN_KEY);
GdkRectangle *allocation = h ? g_hash_table_lookup (h, key) : NULL;
+ debug_dialog_size = gnm_debug_flag ("dialog-size");
+
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
+ if (debug_dialog_size)
+ g_printerr ("Restoring %s to %dx%d at (%d,%d)\n",
+ key, allocation->width, allocation->height,
+ allocation->x, allocation->y);
+
gtk_window_move
(GTK_WINDOW (top),
allocation->x, allocation->y);
@@ -287,7 +299,7 @@ gnm_restore_window_geometry (GtkWindow *dialog, const char *key)
allocation->width, allocation->height);
}
- g_signal_connect (G_OBJECT (dialog), "unrealize",
+ g_signal_connect (G_OBJECT (dialog), "size-allocate",
G_CALLBACK (cb_save_sizes),
(gpointer)key);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]