[meld: 5/63] ui.msgarea: Move dismissable message helper to msgarea



commit b5e31047b2c2be2b5d621dae7a8ae4840049da34
Author: Kai Willadsen <kai willadsen gmail com>
Date:   Sun Jul 19 08:16:15 2015 +1000

    ui.msgarea: Move dismissable message helper to msgarea

 meld/dirdiff.py    |   13 ++-----------
 meld/filediff.py   |   13 ++-----------
 meld/ui/msgarea.py |    8 ++++++++
 3 files changed, 12 insertions(+), 22 deletions(-)
---
diff --git a/meld/dirdiff.py b/meld/dirdiff.py
index 212dba7..d7d1c58 100644
--- a/meld/dirdiff.py
+++ b/meld/dirdiff.py
@@ -902,17 +902,8 @@ class DirDiff(melddoc.MeldDoc, gnomeglade.Component):
                 else:
                     continue
                 secondary = "\n".join(messages)
-                self.add_dismissable_msg(pane, Gtk.STOCK_DIALOG_ERROR, header,
-                                         secondary)
-
-    def add_dismissable_msg(self, pane, icon, primary, secondary):
-        msgarea = self.msgarea_mgr[pane].new_from_text_and_icon(
-                        icon, primary, secondary)
-        msgarea.add_button(_("Hi_de"), Gtk.ResponseType.CLOSE)
-        msgarea.connect("response",
-                        lambda *args: self.msgarea_mgr[pane].clear())
-        msgarea.show_all()
-        return msgarea
+                self.msgarea_mgr[pane].add_dismissable_msg(
+                    Gtk.STOCK_DIALOG_ERROR, header, secondary)
 
     def copy_selected(self, direction):
         assert direction in (-1, 1)
diff --git a/meld/filediff.py b/meld/filediff.py
index 8ba80ef..ab65933 100644
--- a/meld/filediff.py
+++ b/meld/filediff.py
@@ -1075,15 +1075,6 @@ class FileDiff(melddoc.MeldDoc, gnomeglade.Component):
 
     def file_loaded(self, loader, result, user_data):
 
-        def add_dismissable_msg(pane, icon, primary, secondary):
-            msgarea = self.msgarea_mgr[pane].new_from_text_and_icon(
-                icon, primary, secondary)
-            msgarea.add_button(_("Hi_de"), Gtk.ResponseType.CLOSE)
-            msgarea.connect("response",
-                            lambda *args: self.msgarea_mgr[pane].clear())
-            msgarea.show_all()
-            return msgarea
-
         gfile = loader.get_location()
         pane = user_data[0]
 
@@ -1102,8 +1093,8 @@ class FileDiff(melddoc.MeldDoc, gnomeglade.Component):
                 gfile.get_parse_name()).decode('utf-8')
             primary = _(
                 u"There was a problem opening the file ā€œ%sā€." % filename)
-            add_dismissable_msg(
-                pane, Gtk.STOCK_DIALOG_ERROR, primary, err.message)
+            self.msgarea_mgr[pane].add_dismissable_msg(
+                Gtk.STOCK_DIALOG_ERROR, primary, err.message)
 
         buf = loader.get_buffer()
 
diff --git a/meld/ui/msgarea.py b/meld/ui/msgarea.py
index dd44ed8..0665a38 100644
--- a/meld/ui/msgarea.py
+++ b/meld/ui/msgarea.py
@@ -21,6 +21,7 @@
 
 from gi.repository import Gtk
 
+from meld.conf import _
 from meld.ui.wraplabel import WrapLabel
 
 
@@ -103,3 +104,10 @@ class MsgAreaController(Gtk.HBox):
 
         self.pack_start(msgarea, True, True, 0)
         return msgarea
+
+    def add_dismissable_msg(self, icon, primary, secondary):
+        msgarea = self.new_from_text_and_icon(icon, primary, secondary)
+        msgarea.add_button(_("Hi_de"), Gtk.ResponseType.CLOSE)
+        msgarea.connect("response", lambda *args: self.clear())
+        msgarea.show_all()
+        return msgarea


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