[gedit] quickopen: handle size using configure-event



commit 00105f389b9b37f71be5b29fbf0c11367042c346
Author: Ignacio Casal Quinteiro <icq gnome org>
Date:   Thu Mar 28 23:08:28 2013 +0100

    quickopen: handle size using configure-event

 plugins/quickopen/quickopen/__init__.py |    3 +--
 plugins/quickopen/quickopen/popup.py    |   11 +++++++++++
 2 files changed, 12 insertions(+), 2 deletions(-)
---
diff --git a/plugins/quickopen/quickopen/__init__.py b/plugins/quickopen/quickopen/__init__.py
index 9a32187..bc1beb2 100644
--- a/plugins/quickopen/quickopen/__init__.py
+++ b/plugins/quickopen/quickopen/__init__.py
@@ -181,8 +181,7 @@ class QuickOpenPlugin(GObject.Object, Gedit.WindowActivatable):
         self._popup.show()
 
     def on_popup_destroy(self, popup, user_data=None):
-        alloc = popup.get_allocation()
-        self.set_popup_size((alloc.width, alloc.height))
+        self.set_popup_size(popup.get_final_size())
 
         self._popup = None
 
diff --git a/plugins/quickopen/quickopen/popup.py b/plugins/quickopen/quickopen/popup.py
index 4945adb..aa66d09 100644
--- a/plugins/quickopen/quickopen/popup.py
+++ b/plugins/quickopen/quickopen/popup.py
@@ -39,6 +39,7 @@ class Popup(Gtk.Dialog):
         self._handler = handler
         self._build_ui()
 
+        self._size = (0, 0)
         self._dirs = []
         self._cache = {}
         self._theme = None
@@ -61,6 +62,9 @@ class Popup(Gtk.Dialog):
 
         self.connect('show', self.on_show)
 
+    def get_final_size(self):
+        return self._size
+
     def _build_ui(self):
         self.set_border_width(5)
         vbox = self.get_content_area()
@@ -530,6 +534,13 @@ class Popup(Gtk.Dialog):
         if response != Gtk.ResponseType.ACCEPT or not self._activate():
             self.destroy()
 
+    def do_configure_event(self, event):
+        if self.get_realized():
+            alloc = self.get_allocation()
+            self._size = (alloc.width, alloc.height)
+
+        return Gtk.Dialog.do_configure_event(self, event)
+
     def on_selection_changed(self, selection):
         model, rows = selection.get_selected_rows()
 


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