store maximized windows

Andreas Köhler andi5.py at gmx.net
Wed Dec 14 19:24:24 EST 2005


Hi,

attached is a patch to save which open windows were maximized, so
that they can be maximized again after a restart.

I was wondering why this was not possibble yet, maybe there is some
consensus against this feature? But here it is :D

-- andi5
-------------- next part --------------
Index: src/gnome-utils/gnc-main-window.c
===================================================================
--- src/gnome-utils/gnc-main-window.c	(Revision 12157)
+++ src/gnome-utils/gnc-main-window.c	(Arbeitskopie)
@@ -366,6 +366,7 @@
 #define WINDOW_STRING		"Window %d"
 #define WINDOW_GEOMETRY		"Window Geometry"
 #define WINDOW_POSITION		"Window Position"
+#define WINDOW_MAXIMIZED	"Window Maximized"
 #define WINDOW_FIRSTPAGE	"First Page"
 #define WINDOW_PAGECOUNT	"Page Count"
 #define PAGE_TYPE		"Page Type"
@@ -472,6 +473,7 @@
   GncMainWindowPrivate *priv;
   gint *pos, *geom;
   gsize length;
+  gboolean max;
   gchar *window_group;
   gint page_start, page_count, i;
   GError *error = NULL;
@@ -513,6 +515,17 @@
     DEBUG("window (%p) size %dx%d", window, geom[0], geom[1]);
   }
 
+  max = g_key_file_get_boolean(data->key_file, window_group,
+			       WINDOW_MAXIMIZED, &error);
+  if (error) {
+    g_warning("error reading group %s key %s: %s",
+	      window_group, WINDOW_MAXIMIZED, error->message);
+    g_error_free(error);
+    error = NULL;
+  } else if (max) {
+    gtk_window_maximize(GTK_WINDOW(window));
+  }
+
   /* Get this window's notebook info */
   page_start = g_key_file_get_integer(data->key_file,
 				      window_group, WINDOW_FIRSTPAGE, &error);
@@ -716,6 +729,7 @@
 {
   GncMainWindowPrivate *priv;
   gint num_pages, coords[4];
+  gboolean maximized;
   gchar *window_group;
 
   /* Setup */
@@ -727,12 +741,17 @@
   /* Save the window coordinates, etc. */
   gtk_window_get_position(GTK_WINDOW(window), &coords[0], &coords[1]);
   gtk_window_get_size(GTK_WINDOW(window), &coords[2], &coords[3]);
+  maximized = (gdk_window_get_state((GTK_WIDGET(window))->window)
+	       & GDK_WINDOW_STATE_MAXIMIZED) != 0;
   g_key_file_set_integer_list(data->key_file, window_group,
 			      WINDOW_POSITION, &coords[0], 2);
   g_key_file_set_integer_list(data->key_file, window_group,
 			      WINDOW_GEOMETRY, &coords[2], 2);
-  DEBUG("window (%p) position %dx%d, size %dx%d", window,  coords[0], coords[1],
-	coords[2], coords[3]);
+  g_key_file_set_boolean(data->key_file, window_group,
+			 WINDOW_MAXIMIZED, maximized);
+  DEBUG("window (%p) position %dx%d, size %dx%d, %s", window,  coords[0], coords[1],
+	coords[2], coords[3],
+	maximized ? "maximized" : "not maximized");
 
   /* Save this window's notebook info */
   num_pages = gtk_notebook_get_n_pages(GTK_NOTEBOOK(priv->notebook));


More information about the gnucash-patches mailing list