[meld] ui.msgarea: Remove remainder of MsgArea class, keeping the manager



commit 2c81c0aa08074d63a18ef8405b41b5a0a83b4ea6
Author: Kai Willadsen <kai willadsen gmail com>
Date:   Sun Sep 8 10:06:21 2013 +1000

    ui.msgarea: Remove remainder of MsgArea class, keeping the manager

 meld/ui/catalog.xml |    2 -
 meld/ui/msgarea.py  |   86 +++++++++++++++++++++++++-------------------------
 2 files changed, 43 insertions(+), 45 deletions(-)
---
diff --git a/meld/ui/catalog.xml b/meld/ui/catalog.xml
index 4487ef9..e867e52 100644
--- a/meld/ui/catalog.xml
+++ b/meld/ui/catalog.xml
@@ -9,7 +9,6 @@
         <glade-widget-class title="HistoryEntry" name="HistoryEntry" generic-name="historyentry"/>
         <glade-widget-class title="HistoryFileEntry" name="HistoryFileEntry" 
generic-name="historyfileentry"/>
         <glade-widget-class title="MeldSourceView" name="MeldSourceView" generic-name="meldsourceview"/>
-        <glade-widget-class title="MsgArea" name="MsgArea" generic-name="msgarea"/>
         <glade-widget-class title="MsgAreaController" name="MsgAreaController" 
generic-name="msgareacontroller"/>
     </glade-widget-classes>
 
@@ -20,7 +19,6 @@
         <glade-widget-class-ref name="HistoryEntry"/>
         <glade-widget-class-ref name="HistoryFileEntry"/>
         <glade-widget-class-ref name="MeldSourceView"/>
-        <glade-widget-class-ref name="MsgArea"/>
         <glade-widget-class-ref name="MsgAreaController"/>
     </glade-widget-group>
 </glade-catalog>
diff --git a/meld/ui/msgarea.py b/meld/ui/msgarea.py
index 3c461f2..3091654 100644
--- a/meld/ui/msgarea.py
+++ b/meld/ui/msgarea.py
@@ -26,47 +26,42 @@ import gtk
 from meld.ui.wraplabel import WrapLabel
 
 
-class MsgArea(gtk.InfoBar):
-    __gtype_name__ = "MsgArea"
-
-    def set_text_and_icon(self, stockid, primary_text, secondary_text=None):
-        hbox_content = gtk.HBox(False, 8)
-        hbox_content.show()
-
-        image = gtk.Image()
-        image.set_from_stock(stockid, gtk.ICON_SIZE_DIALOG)
-        image.show()
-        hbox_content.pack_start(image, False, False, 0)
-        image.set_alignment(0.5, 0.5)
-
-        vbox = gtk.VBox(False, 6)
-        vbox.show()
-        hbox_content.pack_start(vbox, True, True, 0)
-
-        primary_markup = "<b>%s</b>" % (primary_text,)
-        primary_label = WrapLabel(primary_markup)
-        primary_label.show()
-        vbox.pack_start(primary_label, True, True, 0)
-        primary_label.set_use_markup(True)
-        primary_label.set_line_wrap(True)
-        primary_label.set_alignment(0, 0.5)
-        primary_label.set_flags(gtk.CAN_FOCUS)
-        primary_label.set_selectable(True)
-
-        if secondary_text:
-            secondary_markup = "<small>%s</small>" % (secondary_text,)
-            secondary_label = WrapLabel(secondary_markup)
-            secondary_label.show()
-            vbox.pack_start(secondary_label, True, True, 0)
-            secondary_label.set_flags(gtk.CAN_FOCUS)
-            secondary_label.set_use_markup(True)
-            secondary_label.set_line_wrap(True)
-            secondary_label.set_selectable(True)
-            secondary_label.set_alignment(0, 0.5)
-
-        content_area = self.get_content_area()
-        content_area.foreach(content_area.remove)
-        content_area.add(hbox_content)
+def layout_text_and_icon(stockid, primary_text, secondary_text=None):
+    hbox_content = gtk.HBox(False, 8)
+    hbox_content.show()
+
+    image = gtk.Image()
+    image.set_from_stock(stockid, gtk.ICON_SIZE_DIALOG)
+    image.show()
+    hbox_content.pack_start(image, False, False, 0)
+    image.set_alignment(0.5, 0.5)
+
+    vbox = gtk.VBox(False, 6)
+    vbox.show()
+    hbox_content.pack_start(vbox, True, True, 0)
+
+    primary_markup = "<b>%s</b>" % (primary_text,)
+    primary_label = WrapLabel(primary_markup)
+    primary_label.show()
+    vbox.pack_start(primary_label, True, True, 0)
+    primary_label.set_use_markup(True)
+    primary_label.set_line_wrap(True)
+    primary_label.set_alignment(0, 0.5)
+    primary_label.set_flags(gtk.CAN_FOCUS)
+    primary_label.set_selectable(True)
+
+    if secondary_text:
+        secondary_markup = "<small>%s</small>" % (secondary_text,)
+        secondary_label = WrapLabel(secondary_markup)
+        secondary_label.show()
+        vbox.pack_start(secondary_label, True, True, 0)
+        secondary_label.set_flags(gtk.CAN_FOCUS)
+        secondary_label.set_use_markup(True)
+        secondary_label.set_line_wrap(True)
+        secondary_label.set_selectable(True)
+        secondary_label.set_alignment(0, 0.5)
+
+    return hbox_content
 
 
 class MsgAreaController(gtk.HBox):
@@ -96,11 +91,16 @@ class MsgAreaController(gtk.HBox):
 
     def new_from_text_and_icon(self, stockid, primary, secondary=None, buttons=[]):
         self.clear()
-        msgarea = self.__msgarea = MsgArea()
+        msgarea = self.__msgarea = gtk.InfoBar()
 
         for (text, respid) in buttons:
             self.add_button(text, respid)
 
-        msgarea.set_text_and_icon(stockid, primary, secondary)
+        content = layout_text_and_icon(stockid, primary, secondary)
+
+        content_area = msgarea.get_content_area()
+        content_area.foreach(content_area.remove)
+        content_area.add(content)
+
         self.pack_start(msgarea, expand=True)
         return msgarea


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