[hamster-applet] listening to size-request signal to resize columns and reposition popup. fixes bug 607374



commit 080c47516cf50c1f990005581447d7ff723b1dbd
Author: Toms Bauģis <toms baugis gmail com>
Date:   Mon Jan 18 23:52:33 2010 +0000

    listening to size-request signal to resize columns and reposition popup. fixes bug 607374

 data/applet.ui    |    2 +-
 hamster/applet.py |   37 ++++++++++++++++++++++---------------
 2 files changed, 23 insertions(+), 16 deletions(-)
---
diff --git a/data/applet.ui b/data/applet.ui
index 2df65a5..a35b8d1 100644
--- a/data/applet.ui
+++ b/data/applet.ui
@@ -14,7 +14,7 @@
     <property name="skip_pager_hint">True</property>
     <property name="decorated">False</property>
     <signal name="key_press_event" handler="on_windows_keys"/>
-    <signal name="configure_event" handler="on_window_configure_event"/>
+    <signal name="size_request" handler="on_window_size_request"/>
     <child>
       <object class="GtkEventBox" id="hamster-box">
         <property name="visible">True</property>
diff --git a/hamster/applet.py b/hamster/applet.py
index 2d88896..489fe7b 100755
--- a/hamster/applet.py
+++ b/hamster/applet.py
@@ -277,6 +277,8 @@ class HamsterApplet(object):
 
         self._gui.connect_signals(self)
 
+        self.prev_size = None
+
 
     def init_workspace_tracking(self):
         if not WNCK: # can't track if we don't have the trackable
@@ -467,6 +469,20 @@ class HamsterApplet(object):
         self.load_day() # reload day each time before showing to avoid outdated last activity
         self.update_label() #update also label, otherwise we can get 1 minute difference in durations (due to timers refreshed once a minute)
 
+        self.position_popup()
+
+
+        # doing unstick / stick here, because sometimes while switching
+        # between workplaces window still manages to dissappear
+        self.window.unstick()
+        self.window.stick() #show on all desktops
+
+        self.new_name.set_text("");
+        self.new_tags.set_text("");
+        gobject.idle_add(self._delayed_display)
+
+
+    def position_popup(self):
         label_geom = self.button.get_allocation()
         window_geom = self.window.get_allocation()
 
@@ -484,17 +500,6 @@ class HamsterApplet(object):
 
         self.window.move(x, y)
 
-
-
-        # doing unstick / stick here, because sometimes while switching
-        # between workplaces window still manages to dissappear
-        self.window.unstick()
-        self.window.stick() #show on all desktops
-
-        self.new_name.set_text("");
-        self.new_tags.set_text("");
-        gobject.idle_add(self._delayed_display)
-
     def _delayed_display(self):
         """show window only when gtk has become idle. otherwise we get
         mixed results. TODO - this looks like a hack though"""
@@ -695,10 +700,12 @@ class HamsterApplet(object):
         self.last_activity = None
         runtime.dispatcher.dispatch('panel_visible', False)
 
-    def on_window_configure_event(self, window, event):
-        # this is required so that the rows would grow on resize
-        self.treeview.fix_row_heights()
-
+    def on_window_size_request(self, window, event):
+        box = self.window.get_allocation()
+        if self.prev_size and self.prev_size != (box.width, box.height):
+            self.treeview.fix_row_heights()
+            self.position_popup()
+        self.prev_size = (box.width, box.height)
 
     def show(self):
         self.window.show_all()



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