[gnome-system-monitor] Save the main window maximized state in gsettings on exit and load it on startup. https://bugzilla



commit edf4163bb2e9ad1dd9b8a5b7c7244ccd8753d4b5
Author: Robert Roth <robert roth off gmail com>
Date:   Thu Sep 27 22:42:20 2012 +0300

    Save the main window maximized state in gsettings on exit
     and load it on startup.
     https://bugzilla.gnome.org/show_bug.cgi?id=683634

 src/interface.cpp                                 |    3 ++
 src/org.gnome.gnome-system-monitor.gschema.xml.in |    7 ++++++
 src/procman.cpp                                   |   22 ++++++++++++++------
 src/procman.h                                     |    1 +
 4 files changed, 26 insertions(+), 7 deletions(-)
---
diff --git a/src/interface.cpp b/src/interface.cpp
index d3154e8..0042b41 100644
--- a/src/interface.cpp
+++ b/src/interface.cpp
@@ -424,6 +424,9 @@ create_main_window (ProcData *procdata)
     ypos = procdata->config.ypos;
     gtk_window_set_default_size (GTK_WINDOW (app), width, height);
     gtk_window_move(GTK_WINDOW (app), xpos, ypos);
+    if (procdata->config.maximized) {
+        gtk_window_maximize(GTK_WINDOW(app));
+    }
 
     /* create the menubar */
     procdata->uimanager = gtk_ui_manager_new ();
diff --git a/src/org.gnome.gnome-system-monitor.gschema.xml.in b/src/org.gnome.gnome-system-monitor.gschema.xml.in
index 478829b..65ddc1f 100644
--- a/src/org.gnome.gnome-system-monitor.gschema.xml.in
+++ b/src/org.gnome.gnome-system-monitor.gschema.xml.in
@@ -14,6 +14,13 @@
       </_summary>
     </key>
 
+    <key name="maximized" type="b">
+      <default>false
+      </default>
+      <_summary>Main Window should open maximized
+      </_summary>
+    </key>
+
     <key name="x-position" type="i">
       <default>0
       </default>
diff --git a/src/procman.cpp b/src/procman.cpp
index 4bb6805..dae076a 100644
--- a/src/procman.cpp
+++ b/src/procman.cpp
@@ -268,6 +268,7 @@ procman_data_new (GSettings *settings)
 
     pd->config.width = g_settings_get_int (settings, "width");
     pd->config.height = g_settings_get_int (settings, "height");
+    pd->config.maximized = g_settings_get_boolean(settings, "maximized");
     pd->config.xpos = g_settings_get_int (settings, "x-position");
     pd->config.ypos = g_settings_get_int (settings, "y-position");
 
@@ -523,14 +524,21 @@ procman_save_config (ProcData *data)
     procman_save_tree_state (data->settings, data->tree, "proctree");
     procman_save_tree_state (data->settings, data->disk_list, "disktreenew");
 
-    data->config.width  = gdk_window_get_width (gtk_widget_get_window (data->app));
-    data->config.height = gdk_window_get_height(gtk_widget_get_window (data->app));
-    gtk_window_get_position(GTK_WINDOW(data->app), &data->config.xpos, &data->config.ypos);
+    data->config.maximized = gdk_window_get_state(gtk_widget_get_window (data->app)) & GDK_WINDOW_STATE_MAXIMIZED;
 
-    g_settings_set_int (settings, "width", data->config.width);
-    g_settings_set_int (settings, "height", data->config.height);
-    g_settings_set_int (settings, "x-position", data->config.xpos);
-    g_settings_set_int (settings, "y-position", data->config.ypos);
+    if (!data->config.maximized) {
+        // we only want to store/overwrite size and position info with non-maximized state info
+        data->config.width  = gdk_window_get_width (gtk_widget_get_window (data->app));
+        data->config.height = gdk_window_get_height(gtk_widget_get_window (data->app));
+
+        gtk_window_get_position(GTK_WINDOW(data->app), &data->config.xpos, &data->config.ypos);
+
+        g_settings_set_int (settings, "width", data->config.width);
+        g_settings_set_int (settings, "height", data->config.height);
+        g_settings_set_int (settings, "x-position", data->config.xpos);
+        g_settings_set_int (settings, "y-position", data->config.ypos);
+    }
+    g_settings_set_boolean (settings, "maximized", data->config.maximized);
 
     g_settings_set_int (settings, "current-tab", data->config.current_tab);
 
diff --git a/src/procman.h b/src/procman.h
index f42bacd..f43897e 100644
--- a/src/procman.h
+++ b/src/procman.h
@@ -86,6 +86,7 @@ struct ProcConfig
 {
     gint            width;
     gint            height;
+    gboolean        maximized;
     gint            xpos;
     gint            ypos;
     gboolean        show_kill_warning;



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