[meld] Slightly improve the VC delete error dialog, introducing a new helper



commit eb1e8f5f7e69f38e9c56634f1d4dd8960ef274b5
Author: Kai Willadsen <kai willadsen gmail com>
Date:   Sat Aug 17 12:45:11 2013 +1000

    Slightly improve the VC delete error dialog, introducing a new helper

 meld/misc.py   |   21 +++++++++++++++++++++
 meld/vcview.py |    5 +++--
 2 files changed, 24 insertions(+), 2 deletions(-)
---
diff --git a/meld/misc.py b/meld/misc.py
index 7c77956..2f3023d 100644
--- a/meld/misc.py
+++ b/meld/misc.py
@@ -49,6 +49,27 @@ def shelljoin( command ):
         return ((whitespace_re.search(s) is None) and s or ('"%s"' % s))
     return " ".join( [ quote(x) for x in command ] )
 
+
+def error_dialog(primary, secondary, parent, messagetype=gtk.MESSAGE_ERROR):
+    """A common error dialog handler for Meld
+
+    This should only ever be used as a last resort, and for errors that
+    a user is unlikely to encounter. If you're tempted to use this,
+    think twice.
+
+    Primary must be plain text. Secondary must be valid markup.
+    """
+    dialog = gtk.MessageDialog(
+        parent=parent,
+        flags=gtk.DIALOG_MODAL | gtk.DIALOG_DESTROY_WITH_PARENT,
+        type=messagetype,
+        buttons=gtk.BUTTONS_CLOSE,
+        message_format=primary)
+    dialog.format_secondary_markup(secondary)
+    dialog.run()
+    dialog.destroy()
+
+
 def run_dialog( text, parent=None, messagetype=gtk.MESSAGE_WARNING, buttonstype=gtk.BUTTONS_OK, 
extrabuttons=()):
     """Run a dialog with text 'text'.
        Extra buttons are passed as tuples of (button label, response id).
diff --git a/meld/vcview.py b/meld/vcview.py
index 7ee0db9..4ae10fe 100644
--- a/meld/vcview.py
+++ b/meld/vcview.py
@@ -41,6 +41,7 @@ from .ui import gnomeglade
 from .ui import vcdialogs
 from meld.vc import _null
 
+from meld.meldapp import app
 
 def _commonprefix(files):
     if len(files) != 1:
@@ -743,8 +744,8 @@ class VcView(melddoc.MeldDoc, gnomeglade.Component):
                 gfile = gio.File(name)
                 gfile.trash()
             except gio.Error as e:
-                misc.run_dialog(_("Error removing %s\n\n%s.") % (name, e),
-                                parent=self)
+                misc.error_dialog(_("Error removing %s") % name, str(e),
+                                  parent=app.window.widget)
         workdir = _commonprefix(files)
         self.refresh_partial(workdir)
 


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