[meld] Focus the first tab opened from a new-tab command line



commit 460bde32724469239481f6b32f670b9d05d8e9a3
Author: Kai Willadsen <kai willadsen gmail com>
Date:   Mon Feb 17 06:19:00 2014 +1000

    Focus the first tab opened from a new-tab command line

 meld/meldapp.py    |    5 +++--
 meld/meldwindow.py |    7 ++++++-
 2 files changed, 9 insertions(+), 3 deletions(-)
---
diff --git a/meld/meldapp.py b/meld/meldapp.py
index e0a118d..c651560 100644
--- a/meld/meldapp.py
+++ b/meld/meldapp.py
@@ -211,11 +211,12 @@ class MeldApp(Gtk.Application):
         error = None
         comparisons = options.diff + [args]
         options.newtab = options.newtab or is_first
-        for paths in comparisons:
+        for i, paths in enumerate(comparisons):
             try:
                 tab = self.open_paths(
                     paths, auto_compare=options.auto_compare,
-                    auto_merge=options.auto_merge, new_tab=options.newtab)
+                    auto_merge=options.auto_merge, new_tab=options.newtab,
+                    focus=i == 0)
             except ValueError as err:
                 error = err
 
diff --git a/meld/meldwindow.py b/meld/meldwindow.py
index b3b5f80..64ac077 100644
--- a/meld/meldwindow.py
+++ b/meld/meldwindow.py
@@ -668,7 +668,8 @@ class MeldWindow(gnomeglade.Component):
                     self.append_diff(arg, **kwargs))
         doc.run_diff(path)
 
-    def open_paths(self, paths, auto_compare=False, auto_merge=False):
+    def open_paths(self, paths, auto_compare=False, auto_merge=False,
+                   focus=False):
         tab = None
         if len(paths) == 1:
             a = paths[0]
@@ -681,6 +682,10 @@ class MeldWindow(gnomeglade.Component):
             tab = self.append_diff(paths, auto_compare, auto_merge)
         if tab:
             recent_comparisons.add(tab)
+            if focus:
+                self.notebook.set_current_page(
+                    self.notebook.page_num(tab.widget))
+
         return tab
 
     def current_doc(self):


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