[meld] meldapp: Hold the command line instead of disabling single instance



commit 27a67b9d112194ad11b98ef5b5d8e3161cd531e5
Author: Kai Willadsen <kai willadsen gmail com>
Date:   Sun Feb 16 10:04:22 2014 +1000

    meldapp: Hold the command line instead of disabling single instance

 bin/meld         |   10 ++--------
 meld/dirdiff.py  |    2 +-
 meld/filediff.py |    2 ++
 meld/meldapp.py  |   16 +++++++++++++---
 meld/melddoc.py  |    1 +
 meld/vcview.py   |    1 +
 6 files changed, 20 insertions(+), 12 deletions(-)
---
diff --git a/bin/meld b/bin/meld
index e2f398e..29f2754 100755
--- a/bin/meld
+++ b/bin/meld
@@ -200,12 +200,6 @@ if __name__ == '__main__':
     setup_settings()
     setup_resources()
 
-    from gi.repository import Gio
-    from meld.meldapp import app
-
-    if not ("-n" in sys.argv or "--newtab" in sys.argv):
-        app.set_flags(Gio.ApplicationFlags.HANDLES_COMMAND_LINE |
-                      Gio.ApplicationFlags.NON_UNIQUE)
-
-    status = app.run(sys.argv)
+    import meld.meldapp
+    status = meld.meldapp.app.run(sys.argv)
     sys.exit(status)
diff --git a/meld/dirdiff.py b/meld/dirdiff.py
index 623631f..8cc20dc 100644
--- a/meld/dirdiff.py
+++ b/meld/dirdiff.py
@@ -1507,7 +1507,7 @@ class DirDiff(melddoc.MeldDoc, gnomeglade.Component):
     def on_delete_event(self, appquit=0):
         for h in self.settings_handlers:
             meldsettings.disconnect(h)
-
+        self.emit('close', 0)
         return Gtk.ResponseType.OK
 
     def on_find_activate(self, *extra):
diff --git a/meld/filediff.py b/meld/filediff.py
index 7349c6d..1118d19 100644
--- a/meld/filediff.py
+++ b/meld/filediff.py
@@ -896,6 +896,8 @@ class FileDiff(melddoc.MeldDoc, gnomeglade.Component):
         if response == Gtk.ResponseType.OK:
             for h in self.settings_handlers:
                 meldsettings.disconnect(h)
+        # TODO: Base the return code on something meaningful for VC tools
+        self.emit('close', 0)
         return response
 
         #
diff --git a/meld/meldapp.py b/meld/meldapp.py
index a9977a5..d59d3b6 100644
--- a/meld/meldapp.py
+++ b/meld/meldapp.py
@@ -69,11 +69,19 @@ class MeldApp(Gtk.Application):
             self.window.widget.present()
 
     def do_command_line(self, command_line):
-        # FIXME: Command line handling is backwards
         self.register(None)
         self.activate()
-        self.parse_args(command_line.get_arguments()[1:])
-        if not self.window.has_pages():
+        tab = self.parse_args(command_line.get_arguments()[1:])
+        if tab:
+            def done(tab, status):
+                self.release()
+                tab.command_line.set_exit_status(status)
+                tab.command_line = None
+
+            self.hold()
+            tab.command_line = command_line
+            tab.connect('close', done)
+        elif not self.window.has_pages():
             self.window.append_new_comparison()
         return 0
 
@@ -214,6 +222,8 @@ class MeldApp(Gtk.Application):
             else:
                 print(error)
 
+        return tab if len(comparisons) == 1 else None
+
 
 app = MeldApp()
 
diff --git a/meld/melddoc.py b/meld/melddoc.py
index 1791932..a852b2b 100644
--- a/meld/melddoc.py
+++ b/meld/melddoc.py
@@ -66,6 +66,7 @@ class MeldDoc(GObject.GObject):
                                  ()),
         'next-diff-changed':    (GObject.SignalFlags.RUN_FIRST, None,
                                  (bool, bool)),
+        'close': (GObject.SignalFlags.RUN_FIRST, None, (bool,)),
     }
 
     def __init__(self):
diff --git a/meld/vcview.py b/meld/vcview.py
index 35eba60..80ed4b4 100644
--- a/meld/vcview.py
+++ b/meld/vcview.py
@@ -452,6 +452,7 @@ class VcView(melddoc.MeldDoc, gnomeglade.Component):
 
     def on_delete_event(self, appquit=0):
         self.scheduler.remove_all_tasks()
+        self.emit('close', 0)
         return Gtk.ResponseType.OK
 
     def on_row_activated(self, treeview, path, tvc):


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