Re: [PATCH/RFC 1/2] Only transfer focus once when opening multiple file diffs



On Sat, Apr 28, 2012 at 10:24 PM, Kai Willadsen <kai willadsen gmail com> wrote:
> On 28 April 2012 07:59, Kai Willadsen <kai willadsen gmail com> wrote:
>> On 15 April 2012 06:15, Kai Willadsen <kai willadsen gmail com> wrote:
>>> On 11 April 2012 16:10, Peter Tyser <ptyser gmail com> wrote:
>>>> Currently if a user opens multiple file diffs at the same time from a
>>>> DirDiff or VcView the following happens:
>>>> - the 1st diff is opened in a new tab and focus is moved to this tab
>>>> - the 2nd diff is opened in a new tab and focus is moved to this tab
>>>> - the 3rd diff is opened in a new tab and focus is moved to this tab
>>>> - etc...
>>>>
>>>> This behavior has 2 shortcomings:
>>>> 1. The user is presented with a window that cycles focus through
>>>>   multiple diff tabs which is visually jarring.
>>>> 2. During this period of time when tabs are being cycled through the
>>>>   user can't interact with Meld - the focus shifts too fast to allow
>>>>   the user to do anything.  This is especially painful if the user
>>>>   initiates a large number of diffs, the diffs are on a slow filesystem
>>>>   (eg over a slow NFS share), or if the diffs are of version-controlled
>>>>   files (VC-diffs have more overhead, which slows them down).
>>>>
>>>> To resolve these issues, only transfer focus to a new tab if the current
>>>> tab is a DirDiff or VcView.  This results in the following behavior:
>>>> - the 1st diff is opened in a new tab and focus is moved to this tab
>>>> - the 2nd diff is opened in a new background tab
>>>> - the 3rd diff is opened in a new background tab
>>>> - etc...
>>>>
>>>> While the background tabs are being opened Meld is still usable.
>>>>
>>>> Signed-off-by: Peter Tyser <ptyser gmail com>
>>>> ---
>>>> I frequently diff large git-controlled repositories (eg the Linux
>>>> kernel) shared on an NFS server, which really brings this issue out.
>>>
>>> Both patches look good, thanks. I'll apply them after 1.6 branches.
>>
>> I've pushed these now.
>
> ...and I've only just noticed something. This approach breaks when you
> start any new comparison using the File -> New dialog from a file
> comparison; the new tab isn't focussed, despite that definitely being
> what we want. I'll see if I can't figure something out, but if you get
> a chance to take a look, that would be awesome.

Argh, I rarely use that method to initiate diffs and should have
tested more - thanks for catching that.  The 2 solutions that jumped
to mind are:
1. Adding a "xfer_focus" parameter to append_difdiff(),
append_filediff(), append_vcview(), and potentially their callers.
The File->New dialog path would then set "xfer_focus=True", while most
other callers would set "xfer_focus=False" (or not specify it with a
default of "False").
2. Adding a focus transfer when the File -> New dialog successfully closes.

Neither seems perfect - 1 muddies up the API and would likely add some
additional logic, and 2 makes it so the focus handling is done in more
than 1 spot.  I've attached an example of #2.  Let me know if you have
a preference between the 2 implementations, or have a better idea for
a 3rd.

Peter

--- a/meld/meldwindow.py
+++ b/meld/meldwindow.py
@@ -54,6 +54,7 @@ class NewDocDialog(gnomeglade.Component):
                              parentapp.append_dirdiff,
                              parentapp.append_vcview)
         self.widget.show_all()
+        self.parentapp = parentapp

     def on_entry_activate(self, entry):
         for el in self.entrylists:
@@ -81,6 +82,11 @@ class NewDocDialog(gnomeglade.Component):
                 self.diff_methods[page](paths[0])
             else:
                 self.diff_methods[page](paths)
+
+            # We just opened a new comparison, transfer focus to it
+            parent_notebook = self.parentapp.notebook
+            parent_notebook.set_current_page(parent_notebook.get_n_pages() - 1)
+
         self.widget.destroy()


--


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