[dconf-editor] Move WM events functions to DConfWindow.
- From: Arnaud Bonatti <arnaudb src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [dconf-editor] Move WM events functions to DConfWindow.
- Date: Sat, 26 Sep 2015 20:49:39 +0000 (UTC)
commit e93388466c3048add05fb800180c2146d070e955
Author: Arnaud Bonatti <arnaud bonatti gmail com>
Date: Sat Sep 26 22:48:30 2015 +0200
Move WM events functions to DConfWindow.
editor/dconf-editor.ui | 2 ++
editor/dconf-editor.vala | 39 +++++----------------------------------
editor/dconf-window.vala | 31 ++++++++++++++++++++++++++++++-
3 files changed, 37 insertions(+), 35 deletions(-)
---
diff --git a/editor/dconf-editor.ui b/editor/dconf-editor.ui
index a7bc813..79c1832 100644
--- a/editor/dconf-editor.ui
+++ b/editor/dconf-editor.ui
@@ -7,6 +7,8 @@
<property name="height_request">525</property>
<property name="width_request">700</property>
<signal name="key_press_event" handler="on_key_press_event"/>
+ <signal name="window_state_event" handler="on_window_state_event"/>
+ <signal name="size_allocate" handler="on_size_allocate"/>
<child type="titlebar">
<object class="GtkHeaderBar">
<property name="visible">True</property>
diff --git a/editor/dconf-editor.vala b/editor/dconf-editor.vala
index 1a090d1..2ca220b 100644
--- a/editor/dconf-editor.vala
+++ b/editor/dconf-editor.vala
@@ -19,10 +19,6 @@ class ConfigurationEditor : Gtk.Application
{
private Settings settings;
private DConfWindow window;
- private int window_width = 0;
- private int window_height = 0;
- private bool window_is_maximized = false;
- private bool window_is_fullscreen = false;
private const OptionEntry[] option_entries =
{
@@ -89,9 +85,6 @@ class ConfigurationEditor : Gtk.Application
else if (settings.get_boolean ("window-is-maximized"))
window.maximize ();
- window.window_state_event.connect (window_state_event_cb);
- window.size_allocate.connect (size_allocate_cb);
-
add_window (window);
}
@@ -103,32 +96,10 @@ class ConfigurationEditor : Gtk.Application
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);
- }
-
- /*\
- * * Window callbacks
- \*/
-
- private bool window_state_event_cb (Gtk.Widget widget, Gdk.EventWindowState event)
- {
- if ((event.changed_mask & Gdk.WindowState.MAXIMIZED) != 0)
- 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;
- }
-
- private void size_allocate_cb (Gtk.Allocation allocation)
- {
- if (window_is_maximized || window_is_fullscreen)
- return;
- window_width = allocation.width;
- window_height = allocation.height;
+ settings.set_int ("window-width", window.window_width);
+ settings.set_int ("window-height", window.window_height);
+ settings.set_boolean ("window-is-maximized", window.window_is_maximized);
+ settings.set_boolean ("window-is-fullscreen", window.window_is_fullscreen);
}
/*\
@@ -139,7 +110,7 @@ class ConfigurationEditor : Gtk.Application
{
string[] authors = { "Robert Ancell", "Arnaud Bonatti", null };
string license = _("Dconf Editor is free software: you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of
the License, or (at your option) any later version.\n\nDconf Editor is distributed in the hope that it will
be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
PARTICULAR PURPOSE. See the GNU General Public License for more details.\n\nYou should have received a copy
of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>.");
- Gtk.show_about_dialog (window,
+ Gtk.show_about_dialog (this.get_active_window (),
"program-name", _("dconf Editor"),
"version", Config.VERSION,
"comments", _("Directly edit your entire configuration database"),
diff --git a/editor/dconf-window.vala b/editor/dconf-window.vala
index afec874..1bfd261 100644
--- a/editor/dconf-window.vala
+++ b/editor/dconf-window.vala
@@ -20,6 +20,11 @@ using Gtk;
[GtkTemplate (ui = "/ca/desrt/dconf-editor/ui/dconf-editor.ui")]
class DConfWindow : ApplicationWindow
{
+ public int window_width { get; private set; default = 0; }
+ public int window_height { get; private set; default = 0; }
+ public bool window_is_maximized { get; private set; default = false; }
+ public bool window_is_fullscreen { get; private set; default = false; }
+
private SettingsModel model;
[GtkChild] private TreeView dir_tree_view;
[GtkChild] private TreeSelection dir_tree_selection;
@@ -42,6 +47,30 @@ class DConfWindow : ApplicationWindow
}
/*\
+ * * Window management callbacks
+ \*/
+
+ [GtkCallback]
+ private bool on_window_state_event (Widget widget, Gdk.EventWindowState event)
+ {
+ if ((event.changed_mask & Gdk.WindowState.MAXIMIZED) != 0)
+ 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;
+ }
+
+ [GtkCallback]
+ private void on_size_allocate (Allocation allocation)
+ {
+ if (window_is_maximized || window_is_fullscreen)
+ return;
+ window_width = allocation.width;
+ window_height = allocation.height;
+ }
+
+ /*\
* * Dir TreeView
\*/
@@ -119,8 +148,8 @@ class DConfWindow : ApplicationWindow
search_bar.set_search_mode (!search_bar.get_search_mode ());
return true;
}
- return search_bar.handle_event (event);
+ return search_bar.handle_event (event);
}
[GtkCallback]
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]