[meld] meldwindow: Stop using configure-event
- From: Kai Willadsen <kaiw src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [meld] meldwindow: Stop using configure-event
- Date: Fri, 30 Sep 2016 23:28:35 +0000 (UTC)
commit ca682eb231cd7f3ba88f2978fb9ff62ffee6ffa2
Author: Kai Willadsen <kai willadsen gmail com>
Date: Thu Sep 29 06:49:53 2016 +1000
meldwindow: Stop using configure-event
According to https://wiki.gnome.org/HowDoI/SaveWindowState, we should
be using size-allocate and window-state-event.
data/ui/meldapp.ui | 3 ++-
meld/meldwindow.py | 13 ++++++++++---
2 files changed, 12 insertions(+), 4 deletions(-)
---
diff --git a/data/ui/meldapp.ui b/data/ui/meldapp.ui
index 42ada89..b33c20e 100644
--- a/data/ui/meldapp.ui
+++ b/data/ui/meldapp.ui
@@ -7,7 +7,8 @@
<property name="title" translatable="yes">Meld</property>
<property name="icon_name">meld</property>
<signal name="delete-event" handler="on_delete_event" swapped="no"/>
- <signal name="configure-event" handler="on_configure_event" swapped="no"/>
+ <signal name="size-allocate" handler="on_size_allocate" swapped="no"/>
+ <signal name="window-state-event" handler="on_window_state_event" swapped="no"/>
<child>
<object class="GtkVBox" id="appvbox">
<property name="visible">True</property>
diff --git a/meld/meldwindow.py b/meld/meldwindow.py
index e5c2e86..9b92fd7 100644
--- a/meld/meldwindow.py
+++ b/meld/meldwindow.py
@@ -410,15 +410,22 @@ class MeldWindow(gnomeglade.Component):
self.actiongroup.get_action("PrevChange").set_sensitive(have_prev)
self.actiongroup.get_action("NextChange").set_sensitive(have_next)
- def on_configure_event(self, window, event):
- state = event.window.get_state()
+ def on_size_allocate(self, window, allocation):
+ gdk_window = window.get_window()
+ if not gdk_window:
+ return
nosave = Gdk.WindowState.FULLSCREEN | Gdk.WindowState.MAXIMIZED
- if not (state & nosave):
+ if not (gdk_window.get_state() & nosave):
width, height = self.widget.get_size()
variant = GLib.Variant('(ii)', (width, height))
settings.set_value('window-size', variant)
+ def on_window_state_event(self, window, event):
+ state = event.window.get_state()
+
+ # TODO: Handle fullscreen
maximised = state & Gdk.WindowState.MAXIMIZED
+ # fullscreen = state & Gdk.WindowState.FULLSCREEN
window_state = 'maximized' if maximised else 'normal'
settings.set_string('window-state', window_state)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]