[meld/ui-next] filediff: Move remaining actions to GActions
- From: Kai Willadsen <kaiw src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [meld/ui-next] filediff: Move remaining actions to GActions
- Date: Sat, 23 Mar 2019 02:02:42 +0000 (UTC)
commit e4d9f95def552cf8d399723cd1239f2a7907add0
Author: Kai Willadsen <kai willadsen gmail com>
Date: Fri Mar 1 11:09:59 2019 +1000
filediff: Move remaining actions to GActions
As with other view-specific actions, this is a very temporary UI.
data/ui/filediff-ui.xml | 21 ---
data/ui/meldapp-ui.xml | 3 -
meld/accelerators.py | 26 +++-
meld/filediff.py | 73 +++------
meld/resources/ui/filediff.ui | 348 ++++++++++++++++++++++++++++++------------
5 files changed, 295 insertions(+), 176 deletions(-)
---
diff --git a/data/ui/meldapp-ui.xml b/data/ui/meldapp-ui.xml
index 3460f4e6..9d17c412 100644
--- a/data/ui/meldapp-ui.xml
+++ b/data/ui/meldapp-ui.xml
@@ -1,8 +1,5 @@
<ui>
<menubar name="Menubar">
- <menu action="ChangesMenu">
- <placeholder name="ChangesActions" />
- </menu>
</menubar>
<popup name="Popup">
diff --git a/meld/accelerators.py b/meld/accelerators.py
index 45dd238d..8449e161 100644
--- a/meld/accelerators.py
+++ b/meld/accelerators.py
@@ -8,10 +8,6 @@ def register_accels(app: Gtk.Application):
('view.find-next', '<Primary>G'),
('view.find-previous', '<Primary><Shift>G'),
('view.find-replace', '<Primary>H'),
- ('view.folder-compare', 'Return'),
- ('view.folder-copy-left', '<Alt>Left'),
- ('view.folder-copy-right', '<Alt>Right'),
- ('view.folder-delete', 'Delete'),
('view.go-to-line', '<Primary>I'),
('view.next-change', ('<Alt>Down', '<Alt>KP_Down', '<Primary>D')),
('view.next-pane', '<Alt>Page_Down'),
@@ -23,11 +19,29 @@ def register_accels(app: Gtk.Application):
('view.save-all', '<Primary><Shift>L'),
('view.save-as', '<Primary><Shift>S'),
('view.undo', '<Primary>Z'),
- ('view.vc-commit', '<Primary>M'),
- ('view.vc-console-visible', 'F9'),
('win.close', '<Primary>W'),
('win.new-tab', '<Primary>N'),
('win.stop', 'Escape'),
+ # File comparison actions
+ ('view.file-previous-conflict', '<Primary>I'),
+ ('view.file-next-conflict', '<Primary>K'),
+ ('view.file-push-left', '<Alt>Left'),
+ ('view.file-push-right', '<Alt>Right'),
+ ('view.file-pull-left', '<Alt><shift>Right'),
+ ('view.file-pull-right', '<Alt><shift>Left'),
+ ('view.file-copy-left-up', '<Alt>bracketleft'),
+ ('view.file-copy-right-up', '<Alt>bracketright'),
+ ('view.file-copy-left-down', '<Alt>semicolon'),
+ ('view.file-copy-right-down', '<Alt>quoteright'),
+ ('view.file-delete', ('<Alt>Delete', '<Alt>KP_Delete')),
+ # Folder comparison actions
+ ('view.folder-compare', 'Return'),
+ ('view.folder-copy-left', '<Alt>Left'),
+ ('view.folder-copy-right', '<Alt>Right'),
+ ('view.folder-delete', 'Delete'),
+ # Version control actions
+ ('view.vc-commit', '<Primary>M'),
+ ('view.vc-console-visible', 'F9'),
)
for (name, accel) in view_accels:
accel = accel if isinstance(accel, tuple) else (accel,)
diff --git a/meld/filediff.py b/meld/filediff.py
index 073a495f..d95b827c 100644
--- a/meld/filediff.py
+++ b/meld/filediff.py
@@ -28,7 +28,7 @@ from gi.repository import GtkSource
# TODO: Don't from-import whole modules
from meld import misc
-from meld.conf import _, ui_file
+from meld.conf import _
from meld.const import ActionMode, ChunkAction, NEWLINES
from meld.gutterrendererchunk import GutterRendererChunkLines
from meld.iohelpers import prompt_save_filename
@@ -121,7 +121,6 @@ class FileDiff(Gtk.VBox, MeldDoc):
)
show_sourcemap = GObject.Property(type=bool, default=True)
- actiongroup = Template.Child('FilediffActions')
actiongutter0 = Template.Child()
actiongutter1 = Template.Child()
actiongutter2 = Template.Child()
@@ -291,6 +290,17 @@ class FileDiff(Gtk.VBox, MeldDoc):
actions = (
('add-sync-point', self.add_sync_point),
('clear-sync-point', self.clear_sync_points),
+ ('file-previous-conflict', self.action_previous_conflict),
+ ('file-next-conflict', self.action_next_conflict),
+ ('file-push-left', self.action_push_change_left),
+ ('file-push-right', self.action_push_change_right),
+ ('file-pull-left', self.action_pull_change_left),
+ ('file-pull-right', self.action_pull_change_right),
+ ('file-copy-left-up', self.action_copy_change_left_up),
+ ('file-copy-right-up', self.action_copy_change_right_up),
+ ('file-copy-left-down', self.action_copy_change_left_down),
+ ('file-copy-right-down', self.action_copy_change_right_down),
+ ('file-delete', self.action_delete_change),
('find', self.action_find),
('find-next', self.action_find_next),
('find-previous', self.action_find_previous),
@@ -330,14 +340,6 @@ class FileDiff(Gtk.VBox, MeldDoc):
buf.undo_sequence = self.undosequence
buf.data.file_changed_signal.connect(self.notify_file_changed)
- self.ui_file = ui_file("filediff-ui.xml")
- self.actiongroup.set_translation_domain("meld")
-
- # Alternate keybindings for a few commands.
- self.extra_accels = (
- ("<Alt>KP_Delete", self.delete_change),
- )
-
self.findbar = FindBar(self.grid)
self.grid.attach(self.findbar, 0, 2, 10, 1)
@@ -413,22 +415,6 @@ class FileDiff(Gtk.VBox, MeldDoc):
self.connect("notify::ignore-blank-lines", self.refresh_comparison)
- def on_container_switch_in_event(self, ui, window):
- MeldDoc.on_container_switch_in_event(self, ui, window)
-
- accel_group = ui.get_accel_group()
- for accel, callback in self.extra_accels:
- keyval, mask = Gtk.accelerator_parse(accel)
- accel_group.connect(keyval, mask, 0, callback)
-
- def on_container_switch_out_event(self, ui, window):
- accel_group = ui.get_accel_group()
- for accel, callback in self.extra_accels:
- keyval, mask = Gtk.accelerator_parse(accel)
- accel_group.disconnect_key(keyval, mask)
-
- MeldDoc.on_container_switch_out_event(self, ui, window)
-
def get_keymask(self):
return self._keymask
@@ -589,24 +575,24 @@ class FileDiff(Gtk.VBox, MeldDoc):
copy_left = editable_left and left_mid_exists and left_exists
copy_right = (
editable_right and right_mid_exists and right_exists)
- self.actiongroup.get_action("PushLeft").set_sensitive(push_left)
- self.actiongroup.get_action("PushRight").set_sensitive(push_right)
- self.actiongroup.get_action("PullLeft").set_sensitive(pull_left)
- self.actiongroup.get_action("PullRight").set_sensitive(pull_right)
- self.actiongroup.get_action("Delete").set_sensitive(delete)
- self.actiongroup.get_action("CopyLeftUp").set_sensitive(copy_left)
- self.actiongroup.get_action("CopyLeftDown").set_sensitive(copy_left)
- self.actiongroup.get_action("CopyRightUp").set_sensitive(copy_right)
- self.actiongroup.get_action("CopyRightDown").set_sensitive(copy_right)
+ self.set_action_enabled('file-push-left', push_left)
+ self.set_action_enabled('file-push-right', push_right)
+ self.set_action_enabled('file-pull-left', pull_left)
+ self.set_action_enabled('file-pull-right', pull_right)
+ self.set_action_enabled('file-delete', delete)
+ self.set_action_enabled('file-copy-left-up', copy_left)
+ self.set_action_enabled('file-copy-left-down', copy_left)
+ self.set_action_enabled('file-copy-right-up', copy_right)
+ self.set_action_enabled('file-copy-right-down', copy_right)
self.set_action_enabled('previous-pane', pane > 0)
self.set_action_enabled('next-pane', pane < self.num_panes - 1)
# FIXME: don't queue_draw() on everything... just on what changed
self.queue_draw()
def on_next_conflict_changed(self, doc, have_prev, have_next):
- self.actiongroup.get_action("PrevConflict").set_sensitive(have_prev)
- self.actiongroup.get_action("NextConflict").set_sensitive(have_next)
+ self.set_action_enabled('file-previous-conflict', have_prev)
+ self.set_action_enabled('file-next-conflict', have_next)
def scroll_to_chunk_index(self, chunk_index, tolerance):
"""Scrolls chunks with the given index on screen in all panes"""
@@ -668,11 +654,9 @@ class FileDiff(Gtk.VBox, MeldDoc):
def action_next_change(self, *args):
self.next_diff(Gdk.ScrollDirection.DOWN)
- @Template.Callback()
def action_previous_conflict(self, *args):
self.go_to_chunk(self.cursor.prev_conflict, self.cursor.pane)
- @Template.Callback()
def action_next_conflict(self, *args):
self.go_to_chunk(self.cursor.next_conflict, self.cursor.pane)
@@ -721,45 +705,37 @@ class FileDiff(Gtk.VBox, MeldDoc):
elif chunk_action == ChunkAction.copy_down:
self.copy_chunk(from_pane, to_pane, chunk, copy_up=False)
- @Template.Callback()
def action_push_change_left(self, *args):
src, dst = self.get_action_panes(PANE_LEFT)
self.replace_chunk(src, dst, self.get_action_chunk(src, dst))
- @Template.Callback()
def action_push_change_right(self, *args):
src, dst = self.get_action_panes(PANE_RIGHT)
self.replace_chunk(src, dst, self.get_action_chunk(src, dst))
- @Template.Callback()
def action_pull_change_left(self, *args):
src, dst = self.get_action_panes(PANE_LEFT, reverse=True)
self.replace_chunk(src, dst, self.get_action_chunk(src, dst))
- @Template.Callback()
def action_pull_change_right(self, *args):
src, dst = self.get_action_panes(PANE_RIGHT, reverse=True)
self.replace_chunk(src, dst, self.get_action_chunk(src, dst))
- @Template.Callback()
def action_copy_change_left_up(self, *args):
src, dst = self.get_action_panes(PANE_LEFT)
self.copy_chunk(
src, dst, self.get_action_chunk(src, dst), copy_up=True)
- @Template.Callback()
def action_copy_change_right_up(self, *args):
src, dst = self.get_action_panes(PANE_RIGHT)
self.copy_chunk(
src, dst, self.get_action_chunk(src, dst), copy_up=True)
- @Template.Callback()
def action_copy_change_left_down(self, *args):
src, dst = self.get_action_panes(PANE_LEFT)
self.copy_chunk(
src, dst, self.get_action_chunk(src, dst), copy_up=False)
- @Template.Callback()
def action_copy_change_right_down(self, *args):
src, dst = self.get_action_panes(PANE_RIGHT)
self.copy_chunk(
@@ -806,9 +782,8 @@ class FileDiff(Gtk.VBox, MeldDoc):
self._sync_vscroll(self.scrolledwindow[0].get_vadjustment(), 0)
self.scheduler.add_task(resync)
- @Template.Callback()
@with_focused_pane
- def delete_change(self, pane, *args):
+ def action_delete_change(self, pane, *args):
chunk = self.linediffer.get_chunk(self.cursor.chunk, pane)
assert(self.cursor.chunk is not None)
assert(chunk is not None)
diff --git a/meld/resources/ui/filediff.ui b/meld/resources/ui/filediff.ui
index e6e13605..55fa23bb 100644
--- a/meld/resources/ui/filediff.ui
+++ b/meld/resources/ui/filediff.ui
@@ -8,6 +8,256 @@
<property name="can_focus">False</property>
<signal name="key-press-event" handler="on_key_event" swapped="no"/>
<signal name="key-release-event" handler="on_key_event" swapped="no"/>
+ <child>
+ <object class="GtkActionBar">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <child>
+ <object class="GtkButton">
+ <property name="visible">True</property>
+ <property name="action-name">view.file-previous-conflict</property>
+ <property name="use-action-appearance">False</property>
+ <property name="tooltip-text">Go to the previous conflict</property>
+ <property name="focus_on_click">False</property>
+ <style>
+ <class name="image-button"/>
+ </style>
+ <child>
+ <object class="GtkImage">
+ <property name="visible">True</property>
+ <property name="icon-name">view-list-symbolic</property>
+ <property name="icon-size">1</property>
+ </object>
+ </child>
+ </object>
+ <packing>
+ <property name="pack-type">start</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkButton">
+ <property name="visible">True</property>
+ <property name="action-name">view.file-next-conflict</property>
+ <property name="use-action-appearance">False</property>
+ <property name="tooltip-text">Go to the next conflict</property>
+ <property name="focus_on_click">False</property>
+ <style>
+ <class name="image-button"/>
+ </style>
+ <child>
+ <object class="GtkImage">
+ <property name="visible">True</property>
+ <property name="icon-name">view-list-symbolic</property>
+ <property name="icon-size">1</property>
+ </object>
+ </child>
+ </object>
+ <packing>
+ <property name="pack-type">start</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkButton">
+ <property name="visible">True</property>
+ <property name="action-name">view.file-push-left</property>
+ <property name="use-action-appearance">False</property>
+ <property name="tooltip-text">Push current change to the left</property>
+ <property name="focus_on_click">False</property>
+ <style>
+ <class name="image-button"/>
+ </style>
+ <child>
+ <object class="GtkImage">
+ <property name="visible">True</property>
+ <property name="icon-name">go-previous-symbolic</property>
+ <property name="icon-size">1</property>
+ </object>
+ </child>
+ </object>
+ <packing>
+ <property name="pack-type">start</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkButton">
+ <property name="visible">True</property>
+ <property name="action-name">view.file-push-right</property>
+ <property name="use-action-appearance">False</property>
+ <property name="tooltip-text">Push current change to the right</property>
+ <property name="focus_on_click">False</property>
+ <style>
+ <class name="image-button"/>
+ </style>
+ <child>
+ <object class="GtkImage">
+ <property name="visible">True</property>
+ <property name="icon-name">go-next-symbolic</property>
+ <property name="icon-size">1</property>
+ </object>
+ </child>
+ </object>
+ <packing>
+ <property name="pack-type">start</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkButton">
+ <property name="visible">True</property>
+ <property name="action-name">view.file-pull-left</property>
+ <property name="use-action-appearance">False</property>
+ <property name="tooltip-text">Pull change from the left</property>
+ <property name="focus_on_click">False</property>
+ <style>
+ <class name="image-button"/>
+ </style>
+ <child>
+ <object class="GtkImage">
+ <property name="visible">True</property>
+ <!-- FIXME: icon abuse -->
+ <property name="icon-name">go-last-symbolic</property>
+ <property name="icon-size">1</property>
+ </object>
+ </child>
+ </object>
+ <packing>
+ <property name="pack-type">start</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkButton">
+ <property name="visible">True</property>
+ <property name="action-name">view.file-pull-right</property>
+ <property name="use-action-appearance">False</property>
+ <property name="tooltip-text">Pull change from the right</property>
+ <property name="focus_on_click">False</property>
+ <style>
+ <class name="image-button"/>
+ </style>
+ <child>
+ <object class="GtkImage">
+ <property name="visible">True</property>
+ <!-- FIXME: icon abuse -->
+ <property name="icon-name">go-first-symbolic</property>
+ <property name="icon-size">1</property>
+ </object>
+ </child>
+ </object>
+ <packing>
+ <property name="pack-type">start</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkButton">
+ <property name="visible">True</property>
+ <property name="action-name">view.file-copy-left-up</property>
+ <property name="use-action-appearance">False</property>
+ <property name="tooltip-text">Copy change above the left chunk</property>
+ <property name="focus_on_click">False</property>
+ <style>
+ <class name="image-button"/>
+ </style>
+ <child>
+ <object class="GtkImage">
+ <property name="visible">True</property>
+ <property name="icon-name">view-list-symbolic</property>
+ <property name="icon-size">1</property>
+ </object>
+ </child>
+ </object>
+ <packing>
+ <property name="pack-type">start</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkButton">
+ <property name="visible">True</property>
+ <property name="action-name">view.file-copy-left-down</property>
+ <property name="use-action-appearance">False</property>
+ <property name="tooltip-text">Copy change below the left chunk</property>
+ <property name="focus_on_click">False</property>
+ <style>
+ <class name="image-button"/>
+ </style>
+ <child>
+ <object class="GtkImage">
+ <property name="visible">True</property>
+ <property name="icon-name">view-list-symbolic</property>
+ <property name="icon-size">1</property>
+ </object>
+ </child>
+ </object>
+ <packing>
+ <property name="pack-type">start</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkButton">
+ <property name="visible">True</property>
+ <property name="action-name">view.file-copy-right-up</property>
+ <property name="use-action-appearance">False</property>
+ <property name="tooltip-text">Copy change above the right chunk</property>
+ <property name="focus_on_click">False</property>
+ <style>
+ <class name="image-button"/>
+ </style>
+ <child>
+ <object class="GtkImage">
+ <property name="visible">True</property>
+ <property name="icon-name">view-list-symbolic</property>
+ <property name="icon-size">1</property>
+ </object>
+ </child>
+ </object>
+ <packing>
+ <property name="pack-type">start</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkButton">
+ <property name="visible">True</property>
+ <property name="action-name">view.file-copy-right-down</property>
+ <property name="use-action-appearance">False</property>
+ <property name="tooltip-text">Copy change below the right chunk</property>
+ <property name="focus_on_click">False</property>
+ <style>
+ <class name="image-button"/>
+ </style>
+ <child>
+ <object class="GtkImage">
+ <property name="visible">True</property>
+ <property name="icon-name">view-list-symbolic</property>
+ <property name="icon-size">1</property>
+ </object>
+ </child>
+ </object>
+ <packing>
+ <property name="pack-type">start</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkButton">
+ <property name="visible">True</property>
+ <property name="action-name">view.file-delete</property>
+ <property name="use-action-appearance">False</property>
+ <property name="tooltip-text">Delete change</property>
+ <property name="focus_on_click">False</property>
+ <style>
+ <class name="image-button"/>
+ </style>
+ <child>
+ <object class="GtkImage">
+ <property name="visible">True</property>
+ <property name="icon-name">edit-delete-symbolic</property>
+ <property name="icon-size">1</property>
+ </object>
+ </child>
+ </object>
+ <packing>
+ <property name="pack-type">start</property>
+ </packing>
+ </child>
+ </object>
+ </child>
<child>
<object class="DiffGrid" id="grid">
<property name="visible">True</property>
@@ -725,104 +975,8 @@
<packing>
<property name="expand">True</property>
<property name="fill">True</property>
- <property name="position">0</property>
+ <property name="position">1</property>
</packing>
</child>
</template>
- <object class="GtkActionGroup" id="FilediffActions">
- <child>
- <object class="GtkAction" id="PrevConflict">
- <property name="label" translatable="yes">Previous Conflict</property>
- <property name="tooltip" translatable="yes">Go to the previous conflict</property>
- <signal name="activate" handler="action_previous_conflict" swapped="no"/>
- </object>
- <accelerator key="I" modifiers="GDK_CONTROL_MASK"/>
- </child>
- <child>
- <object class="GtkAction" id="NextConflict">
- <property name="label" translatable="yes">Next Conflict</property>
- <property name="tooltip" translatable="yes">Go to the next conflict</property>
- <signal name="activate" handler="action_next_conflict" swapped="no"/>
- </object>
- <accelerator key="K" modifiers="GDK_CONTROL_MASK"/>
- </child>
- <child>
- <object class="GtkAction" id="PushLeft">
- <property name="label" translatable="yes">Push to Left</property>
- <property name="tooltip" translatable="yes">Push current change to the left</property>
- <property name="stock_id">gtk-go-back</property>
- <signal name="activate" handler="action_push_change_left" swapped="no"/>
- </object>
- <accelerator key="Left" modifiers="GDK_MOD1_MASK"/>
- </child>
- <child>
- <object class="GtkAction" id="PushRight">
- <property name="label" translatable="yes">Push to Right</property>
- <property name="tooltip" translatable="yes">Push current change to the right</property>
- <property name="stock_id">gtk-go-forward</property>
- <signal name="activate" handler="action_push_change_right" swapped="no"/>
- </object>
- <accelerator key="Right" modifiers="GDK_MOD1_MASK"/>
- </child>
- <!-- FIXME: using LAST and FIRST is terrible and unreliable icon abuse -->
- <child>
- <object class="GtkAction" id="PullLeft">
- <property name="label" translatable="yes">Pull from Left</property>
- <property name="tooltip" translatable="yes">Pull change from the left</property>
- <property name="stock_id">gtk-goto-last</property>
- <signal name="activate" handler="action_pull_change_left" swapped="no"/>
- </object>
- <accelerator key="Right" modifiers="GDK_SHIFT_MASK | GDK_MOD1_MASK"/>
- </child>
- <child>
- <object class="GtkAction" id="PullRight">
- <property name="label" translatable="yes">Pull from Right</property>
- <property name="tooltip" translatable="yes">Pull change from the right</property>
- <property name="stock_id">gtk-goto-first</property>
- <signal name="activate" handler="action_pull_change_right" swapped="no"/>
- </object>
- <accelerator key="Left" modifiers="GDK_SHIFT_MASK | GDK_MOD1_MASK"/>
- </child>
- <child>
- <object class="GtkAction" id="CopyLeftUp">
- <property name="label" translatable="yes">Copy Above Left</property>
- <property name="tooltip" translatable="yes">Copy change above the left chunk</property>
- <signal name="activate" handler="action_copy_change_left_up" swapped="no"/>
- </object>
- <accelerator key="bracketleft" modifiers="GDK_MOD1_MASK"/>
- </child>
- <child>
- <object class="GtkAction" id="CopyLeftDown">
- <property name="label" translatable="yes">Copy Below Left</property>
- <property name="tooltip" translatable="yes">Copy change below the left chunk</property>
- <signal name="activate" handler="action_copy_change_left_down" swapped="no"/>
- </object>
- <accelerator key="semicolon" modifiers="GDK_MOD1_MASK"/>
- </child>
- <child>
- <object class="GtkAction" id="CopyRightUp">
- <property name="label" translatable="yes">Copy Above Right</property>
- <property name="tooltip" translatable="yes">Copy change above the right chunk</property>
- <signal name="activate" handler="action_copy_change_right_up" swapped="no"/>
- </object>
- <accelerator key="bracketright" modifiers="GDK_MOD1_MASK"/>
- </child>
- <child>
- <object class="GtkAction" id="CopyRightDown">
- <property name="label" translatable="yes">Copy Below Right</property>
- <property name="tooltip" translatable="yes">Copy change below the right chunk</property>
- <signal name="activate" handler="action_copy_change_right_down" swapped="no"/>
- </object>
- <accelerator key="apostrophe" modifiers="GDK_MOD1_MASK"/>
- </child>
- <child>
- <object class="GtkAction" id="Delete">
- <property name="label" translatable="yes">Delete</property>
- <property name="tooltip" translatable="yes">Delete change</property>
- <property name="stock_id">gtk-delete</property>
- <signal name="activate" handler="delete_change" swapped="no"/>
- </object>
- <accelerator key="Delete" modifiers="GDK_MOD1_MASK"/>
- </child>
- </object>
</interface>
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]