Using Meld 3.21.0 from
https://download.gnome.org/sources/meld/3.21/meld-3.21.0.tar.xz
on Ubuntu 20.04 (Ubuntu 18.04 doesn't have gtksourceview4) with
gnome-shell 3.36.4 in the local directory without installing.
Firstly some more exposure: changes in meld/resources/meld.css show an
effect, for example increasing the status bar border width is reflected
upon relaunching the application. Also, changes in meld/accelerators.py
work, e.g. rebinding 'view.go-to-line' to any other non-reserved key.
I applied the patch to these two files and double checked manually, but
without success: Ctrl+Tab and Ctrl+Shift+Tab just cycle through the UI
elements, i.e. top bar, left half of the source view, right half of the
source view.
Now I'm not sure if the "next pane" concept refers to just that,
switching between left and right. Or if it actually should cycle through
the tabs that appear in the top row, which is what I want, as outlined
in the original post. That would be "notebook page" concept relevant to
the "notebook.set_current_page()" code, e.g. tabbing through 20
comparisons opened from a directory diff view.
I tried
'view.next-pane': ('Page_Down', 'Tab', 'J'),
which adds Ctrl+J to the - to me useless - left/right switching
behaviour. So independently from the unbinding, 'view.next-pane' appears
to be the wrong functionality.
I'm simply searching for a way to bind the Ctrl+Tab accelerator to
something like this pseudocode:
notebook.set_current_page(get_current_page()+1) # respectively -1
Am I understanding this correctly?
Best
Donjan
On 23.08.2020 23:37, Kai via meld-list wrote:
I believe that the reason none of your options have worked is that you
need
to unbind the Ctrl+Tab and Ctrl+Shift+Tab accelerators as well as
adding
their use. I think if you adapted your (B) attempt and added unbinding
of
the default handling, it may well work. I've attached something that I
tried on current master that appeared to work, but this *will not* work
on
3.18.x.
cheers,
Kai
On Sat, 22 Aug 2020 at 19:01, Donjan Rodic wrote:
I'm using Meld a lot recently and my productivity would be increased
if
Ctrl+Tab and Ctrl+Shift+Tab were available for switching to the next,
respectively previous, tab (notebook page). I'm aware that GNOME
doesn't
like this particular shortcut, but I've set it up in every other GNOME
application I use (Gedit, gnome-terminal, Nautilus) and find it to be
highly efficient.
I've tried to hack it unsuccessfully and would like to request some
help. This was done on Meld 3.18.0 (default Ubuntu 18.04 repo
version).
If newer versions help with this particular issue, I'll sideload...
updates will eventually catch up.
Attempt A)
In meldwindow.py:MeldWindow:__init__() write these built-in Gtk
methods:
from meld.meldapp import app
app.set_accels_for_action("win.tab-previous",
["Tab", "Page_Up"])
app.set_accels_for_action("win.tab-next", ["Tab",
"Page_Down"])
print(app.get_accels_for_action("win.tab-next"))
The keybindings get stored (printed) correctly, but apparently Meld
ignores this feature.
Attempt B)
In meldwindow.py:MeldWindow:__init__(), there is a block "# Add
alternate keybindings ..." setting F5 etc. Just below, write:
(keyval, mask) = Gtk.accelerator_parse("J")
accels.connect(keyval, mask, 0, lambda *_:
self.notebook.set_current_page(1))
(keyval, mask) = Gtk.accelerator_parse("Tab")
accels.connect(keyval, mask, 0, lambda *_:
self.notebook.set_current_page(1))
(keyval, mask) = Gtk.accelerator_parse("KP_Tab")
accels.connect(keyval, mask, 0, lambda *_: print("foo"))
(keyval, mask) =
Gtk.accelerator_parse("ISO_Left_Tab")
accels.connect(keyval, mask, 0, lambda *_: print("bar"))
Now Ctrl+J correctly switches to the second tab from the left, but
Ctrl+Tab and Ctrl+Shift+Tab get ignored (no terminal output either).
They do iterate through Meld's icon list at the top, for what that's
worth.
Attempt C)
In filediff.py:FileDiff:on_key_event(), write:
if event.state & Gdk.ModifierType.CONTROL_MASK and
Gdk.keyval_name(event.keyval) == 'Tab':
print("switch to tab right")
This correctly prints to the terminal when Ctrl+Tab is pressed. But
I'm
at a loss on how to hook it up to notebook.set_current_page() here.
app = Gtk.Application.get_default() is empty and I can't get a
higher
parent than self.widget.
Attempt D)
In meldwindow.py:MeldWindow:__init__(), register the signal:
self.connect("key-press-event",self.on_key_press_event)
#...
def on_key_press_event(self, window, event):
print("key press event")
crashes with "AttributeError: connect", unless I let MeldWindow
additionally inherit from
melddoc.MeldDoc
or
GObject.GObject
and call
melddoc.MeldDoc.__init__(self)
respectively
GObject.Object.__init__(self)
, in which case it simply doesn't know the signal name. Also,