[hamster-applet] remembering window size and position
- From: Toms Baugis <tbaugis src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [hamster-applet] remembering window size and position
- Date: Thu, 14 Jan 2010 09:34:45 +0000 (UTC)
commit 08bc1dc1f941deb6972d3cb68734763efb90c62e
Author: Toms Bauģis <toms baugis gmail com>
Date: Thu Jan 14 09:12:08 2010 +0000
remembering window size and position
data/stats.ui | 1 +
hamster/stats.py | 31 +++++++++++++++++++++++++------
2 files changed, 26 insertions(+), 6 deletions(-)
---
diff --git a/data/stats.ui b/data/stats.ui
index 6fdb274..27df3f4 100644
--- a/data/stats.ui
+++ b/data/stats.ui
@@ -8,6 +8,7 @@
<property name="window_position">center</property>
<property name="default_width">800</property>
<property name="default_height">600</property>
+ <signal name="delete_event" handler="on_tabs_window_deleted"/>
<child>
<object class="GtkVBox" id="vbox1">
<property name="visible">True</property>
diff --git a/hamster/stats.py b/hamster/stats.py
index ece3096..5459d5d 100644
--- a/hamster/stats.py
+++ b/hamster/stats.py
@@ -106,6 +106,15 @@ class StatsViewer(object):
runtime.dispatcher.add_handler('day_updated', self.after_activity_update)
runtime.dispatcher.add_handler('conf_changed', self.on_conf_change)
+ if conf.get("overview_window_maximized"):
+ self.window.maximize()
+ else:
+ window_box = conf.get("overview_window_box")
+ if window_box:
+ x,y,w,h = (int(i) for i in window_box)
+ self.window.move(x, y)
+ self.window.move(x, y)
+ self.window.resize(w, h)
self.window.show_all()
self.search()
@@ -330,11 +339,7 @@ class StatsViewer(object):
dialogs.edit.show(fact_id = model[iter][0])
-
- def on_close(self, widget, event):
- runtime.dispatcher.del_handler('activity_updated', self.after_activity_update)
- runtime.dispatcher.del_handler('day_updated', self.after_fact_update)
- runtime.dispatcher.del_handler('conf_changed', self.on_conf_change)
+ def on_tabs_window_deleted(self, widget, event):
self.close_window()
def on_window_key_pressed(self, tree, event_key):
@@ -343,8 +348,22 @@ class StatsViewer(object):
and event_key.state & gtk.gdk.CONTROL_MASK)):
self.close_window()
-
def close_window(self):
+ runtime.dispatcher.del_handler('activity_updated', self.after_activity_update)
+ runtime.dispatcher.del_handler('day_updated', self.after_activity_update)
+ runtime.dispatcher.del_handler('conf_changed', self.on_conf_change)
+
+ # properly saving window state and position
+ maximized = self.window.get_window().get_state() & gtk.gdk.WINDOW_STATE_MAXIMIZED
+ conf.set("overview_window_maximized", maximized)
+
+ # make sure to remember dimensions only when in normal state
+ if maximized == False and not self.window.get_window().get_state() & gtk.gdk.WINDOW_STATE_ICONIFIED:
+ x, y = self.window.get_position()
+ w, h = self.window.get_size()
+ conf.set("overview_window_box", [x, y, w, h])
+
+
if not self.parent:
gtk.main_quit()
else:
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]