[meld: 4/8] prepare for gear menu customization
- From: Kai Willadsen <kaiw src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [meld: 4/8] prepare for gear menu customization
- Date: Sun, 27 Mar 2022 00:52:21 +0000 (UTC)
commit 018965897fea29c0958465a7eb5e518fa9459fd6
Author: Roberto Vidal <vidal roberto j gmail com>
Date: Sat Mar 12 14:37:36 2022 +0100
prepare for gear menu customization
meld/filediff.py | 4 ++++
meld/meldwindow.py | 27 +++++++++++++++++++++++----
meld/resources/ui/appwindow.ui | 1 +
3 files changed, 28 insertions(+), 4 deletions(-)
---
diff --git a/meld/filediff.py b/meld/filediff.py
index 000b7444..2ff9aa3c 100644
--- a/meld/filediff.py
+++ b/meld/filediff.py
@@ -1432,6 +1432,10 @@ class FileDiff(Gtk.VBox, MeldDoc):
return True
return False
+ def syncpoint_action(self):
+ if self.focus_pane:
+ return self._syncpoint_action(self.textview.index(self.focus_pane))
+
def set_syncpoint_menuitem(self, pane):
action = self._syncpoint_action(pane)
diff --git a/meld/meldwindow.py b/meld/meldwindow.py
index 49c04ee3..d5dd6576 100644
--- a/meld/meldwindow.py
+++ b/meld/meldwindow.py
@@ -30,7 +30,7 @@ from meld.const import (
FileComparisonMode,
)
from meld.dirdiff import DirDiff
-from meld.filediff import FileDiff
+from meld.filediff import FileDiff, SyncpointState
from meld.melddoc import ComparisonState, MeldDoc
from meld.menuhelpers import replace_menu_section
from meld.newdifftab import NewDiffTab
@@ -121,9 +121,9 @@ class MeldWindow(Gtk.ApplicationWindow):
Gtk.ApplicationWindow.do_realize(self)
app = self.get_application()
- menu = app.get_menu_by_id("gear-menu")
+ gear_menu = app.get_menu_by_id("gear-menu")
self.gear_menu_button.set_popover(
- Gtk.Popover.new_from_model(self.gear_menu_button, menu))
+ Gtk.Popover.new_from_model(self.gear_menu_button, gear_menu))
filter_model = app.get_menu_by_id("text-filter-menu")
self.text_filter_button.set_popover(
@@ -147,7 +147,7 @@ class MeldWindow(Gtk.ApplicationWindow):
"file-filters-changed", self.update_filename_filters),
]
- meld.ui.util.extract_accels_from_menu(menu, self.get_application())
+ meld.ui.util.extract_accels_from_menu(gear_menu, self.get_application())
def update_filename_filters(self, settings):
filter_items_model = Gio.Menu()
@@ -363,6 +363,25 @@ class MeldWindow(Gtk.ApplicationWindow):
doc.scheduler.add_task(doc.auto_compare)
return doc
+ @Gtk.Template.Callback()
+ def on_gear_popup_menu(self, menubutton):
+ if not menubutton.get_active():
+ return
+
+ current_page_idx = self.notebook.get_current_page()
+
+ if current_page_idx == -1:
+ return
+
+ page = self.notebook.get_nth_page(current_page_idx)
+
+ if not isinstance(page, FileDiff):
+ return
+
+ action = page.syncpoint_action()
+
+ # TODO: recompute menu items
+
def append_filediff(
self, gfiles, *, encodings=None, merge_output=None, meta=None):
assert len(gfiles) in (1, 2, 3)
diff --git a/meld/resources/ui/appwindow.ui b/meld/resources/ui/appwindow.ui
index 6717a3ff..7b952f54 100644
--- a/meld/resources/ui/appwindow.ui
+++ b/meld/resources/ui/appwindow.ui
@@ -172,6 +172,7 @@
<property name="action-name">win.gear-menu</property>
<property name="visible">true</property>
<property name="can_focus">False</property>
+ <signal name="toggled" handler="on_gear_popup_menu"></signal>
<child>
<object class="GtkImage">
<property name="icon-name">open-menu-symbolic</property>
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]