summaryrefslogtreecommitdiff
path: root/editor
diff options
context:
space:
mode:
authorRobert Ancell <robert.ancell@canonical.com>2012-10-01 09:14:35 +1300
committerRobert Ancell <robert.ancell@canonical.com>2012-10-01 09:14:35 +1300
commitbc450e8e3c236ff25a4a1a8e5cd4b28d616438ae (patch)
treecddd4d38bedb6b14d5f4bbfb0a8a3d858adbaff3 /editor
parente646592d7097c75d2e9c3536e517f9ec6a73786a (diff)
downloaddconf-bc450e8e3c236ff25a4a1a8e5cd4b28d616438ae.tar.gz
editor: Only write window state settings on exit and support fullscreen state
https://bugzilla.gnome.org/show_bug.cgi?id=655046
Diffstat (limited to 'editor')
-rw-r--r--editor/ca.desrt.dconf-editor.gschema.xml11
-rw-r--r--editor/dconf-editor.vala32
2 files changed, 31 insertions, 12 deletions
diff --git a/editor/ca.desrt.dconf-editor.gschema.xml b/editor/ca.desrt.dconf-editor.gschema.xml
index b44ad13..80822b7 100644
--- a/editor/ca.desrt.dconf-editor.gschema.xml
+++ b/editor/ca.desrt.dconf-editor.gschema.xml
@@ -1,20 +1,25 @@
<?xml version="1.0" encoding="UTF-8"?>
<schemalist gettext-domain='dconf'>
<schema id="ca.desrt.dconf-editor.Settings" path="/ca/desrt/dconf-editor/">
- <key name="width" type="i">
+ <key name="window-width" type="i">
<default>800</default>
<summary>The width of the window</summary>
<description>The width of the main window in pixels.</description>
</key>
- <key name="height" type="i">
+ <key name="window-height" type="i">
<default>600</default>
<summary>The height of the window</summary>
<description>The height of the main window in pixels.</description>
</key>
- <key name="maximized" type="b">
+ <key name="window-is-maximized" type="b">
<default>false</default>
<summary>A flag to enable maximized mode</summary>
<description>A flag to enable maximized mode</description>
</key>
+ <key name="window-is-fullscreen" type="b">
+ <default>false</default>
+ <summary>A flag to enable fullscreen mode</summary>
+ <description>A flag to enable fullscreen mode</description>
+ </key>
</schema>
</schemalist>
diff --git a/editor/dconf-editor.vala b/editor/dconf-editor.vala
index 0a114fd..55745f0 100644
--- a/editor/dconf-editor.vala
+++ b/editor/dconf-editor.vala
@@ -5,6 +5,10 @@ class ConfigurationEditor : Gtk.Application
private Settings settings;
private Gtk.Builder ui;
private Gtk.ApplicationWindow window;
+ private int window_width = 0;
+ private int window_height = 0;
+ private bool window_is_maximized = false;
+ private bool window_is_fullscreen = false;
private Gtk.TreeView dir_tree_view;
private Gtk.TreeView key_tree_view;
private Gtk.Grid key_info_grid;
@@ -72,8 +76,10 @@ class ConfigurationEditor : Gtk.Application
}
set_app_menu((MenuModel)menu_ui.get_object("menu"));
- window.set_default_size (settings.get_int ("width"), settings.get_int ("height"));
- if (settings.get_boolean ("maximized"))
+ window.set_default_size (settings.get_int ("window-width"), settings.get_int ("window-height"));
+ if (settings.get_boolean ("window-is-fullscreen"))
+ window.fullscreen ();
+ else if (settings.get_boolean ("window-is-maximized"))
window.maximize ();
dir_tree_view = new DConfDirView();
@@ -124,6 +130,15 @@ class ConfigurationEditor : Gtk.Application
window.present();
}
+ protected override void shutdown ()
+ {
+ base.shutdown();
+ settings.set_int ("window-width", window_width);
+ settings.set_int ("window-height", window_height);
+ settings.set_boolean ("window-is-maximized", window_is_maximized);
+ settings.set_boolean ("window-is-fullscreen", window_is_fullscreen);
+ }
+
private void dir_selected_cb()
{
KeyModel? key_model = null;
@@ -236,10 +251,10 @@ class ConfigurationEditor : Gtk.Application
private bool main_window_configure_event_cb (Gtk.Widget widget, Gdk.EventConfigure event)
{
- if (!settings.get_boolean ("maximized"))
+ if (!window_is_maximized && !window_is_fullscreen)
{
- settings.set_int ("width", event.width);
- settings.set_int ("height", event.height);
+ window_width = event.width;
+ window_height = event.height;
}
return false;
@@ -248,10 +263,9 @@ class ConfigurationEditor : Gtk.Application
private bool main_window_window_state_event_cb (Gtk.Widget widget, Gdk.EventWindowState event)
{
if ((event.changed_mask & Gdk.WindowState.MAXIMIZED) != 0)
- {
- var is_maximized = (event.new_window_state & Gdk.WindowState.MAXIMIZED) != 0;
- settings.set_boolean ("maximized", is_maximized);
- }
+ window_is_maximized = (event.new_window_state & Gdk.WindowState.MAXIMIZED) != 0;
+ if ((event.changed_mask & Gdk.WindowState.FULLSCREEN) != 0)
+ window_is_fullscreen = (event.new_window_state & Gdk.WindowState.FULLSCREEN) != 0;
return false;
}