[meld] Avoid some GTK+ warnings by ensuring a style is set on required widgets



commit 1cce4d0d0f55fed4b0a3f8c08eddc2535f555716
Author: Kai Willadsen <kai willadsen gmail com>
Date:   Mon Mar 4 06:22:36 2013 +1000

    Avoid some GTK+ warnings by ensuring a style is set on required widgets

 meld/diffmap.py    |    5 +++++
 meld/dirdiff.py    |    3 ++-
 meld/filediff.py   |    3 ++-
 meld/ui/msgarea.py |    1 +
 4 files changed, 10 insertions(+), 2 deletions(-)
---
diff --git a/meld/diffmap.py b/meld/diffmap.py
index f9111c9..7d3d987 100644
--- a/meld/diffmap.py
+++ b/meld/diffmap.py
@@ -42,6 +42,7 @@ class DiffMap(gtk.DrawingArea):
         self._h_offset = 0
         self._scroll_y = 0
         self._scroll_height = 0
+        self._setup = False
 
     def setup(self, scrollbar, change_chunk_fn, color_map):
         for (o, h) in self._handlers:
@@ -50,6 +51,7 @@ class DiffMap(gtk.DrawingArea):
         self._scrolladj = scrollbar.get_adjustment()
         self.on_scrollbar_style_set(scrollbar, None)
         self.on_scrollbar_size_allocate(scrollbar, scrollbar.allocation)
+        scrollbar.ensure_style()
         scroll_style_hid = scrollbar.connect("style-set",
                                              self.on_scrollbar_style_set)
         scroll_size_hid = scrollbar.connect("size-allocate",
@@ -64,6 +66,7 @@ class DiffMap(gtk.DrawingArea):
                           (self._scrolladj, adj_val_hid)]
         self._difffunc = change_chunk_fn
         self.set_color_scheme(color_map)
+        self._setup = True
         self.queue_draw()
 
     def set_color_scheme(self, color_map):
@@ -94,6 +97,8 @@ class DiffMap(gtk.DrawingArea):
         self.queue_draw()
 
     def do_expose_event(self, event):
+        if not self._setup:
+            return
         height = self._scroll_height - self._h_offset - 1
         y_start = self._scroll_y - self.allocation.y + self._y_offset + 1
         xpad = self.style_get_property('x-padding')
diff --git a/meld/dirdiff.py b/meld/dirdiff.py
index 1343cea..af53384 100644
--- a/meld/dirdiff.py
+++ b/meld/dirdiff.py
@@ -289,8 +289,9 @@ class DirDiff(melddoc.MeldDoc, gnomeglade.Component):
                                      "diffmap", "linkmap", "msgarea_mgr",
                                      "vbox"])
 
-        self.widget.connect("style-set", self.on_style_set)
         self.widget.ensure_style()
+        self.on_style_set(self.widget, None)
+        self.widget.connect("style-set", self.on_style_set)
 
         self.custom_labels = []
         self.set_num_panes(num_panes)
diff --git a/meld/filediff.py b/meld/filediff.py
index 6bca05f..61541b9 100644
--- a/meld/filediff.py
+++ b/meld/filediff.py
@@ -248,8 +248,9 @@ class FileDiff(melddoc.MeldDoc, gnomeglade.Component):
         self.actiongroup.add_toggle_actions(toggle_actions)
         self.findbar = findbar.FindBar(self.table)
 
-        self.widget.connect("style-set", self.on_style_set)
         self.widget.ensure_style()
+        self.on_style_set(self.widget, None)
+        self.widget.connect("style-set", self.on_style_set)
 
         self.set_num_panes(num_panes)
         gobject.idle_add( lambda *args: self.load_font()) # hack around Bug 316730
diff --git a/meld/ui/msgarea.py b/meld/ui/msgarea.py
index 3259515..e662cd6 100644
--- a/meld/ui/msgarea.py
+++ b/meld/ui/msgarea.py
@@ -61,6 +61,7 @@ class MsgArea(gtk.HBox):
         # widgets, not on the message area itself, since gtk does
         # not deliver any further style-set signals for a widget on
         # which the style has been forced with gtk_widget_set_style()
+        self.__main_hbox.ensure_style()
         self.__main_hbox.connect("style-set", self.__on_style_set)
 
         self.add_buttons(buttons)


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