From ee813f22a465974504c5944ca35dfbe4499176cc Mon Sep 17 00:00:00 2001
From: oscfdezdz <42654671+oscfdezdz@users.noreply.github.com>
Date: Sat, 8 Apr 2023 12:34:48 +0200
Subject: [PATCH 1/4] Remove deprecated STOCK constant
---
src/diffuse/dialogs.py | 10 ++---
src/diffuse/preferences.py | 8 ++--
src/diffuse/widgets.py | 16 ++++----
src/diffuse/window.py | 75 ++++++++++++++++++++------------------
4 files changed, 56 insertions(+), 53 deletions(-)
diff --git a/src/diffuse/dialogs.py b/src/diffuse/dialogs.py
index 3ca2a83..ef74e81 100644
--- a/src/diffuse/dialogs.py
+++ b/src/diffuse/dialogs.py
@@ -77,7 +77,7 @@ class FileChooserDialog(Gtk.FileChooserDialog):
def __init__(self, title, parent, prefs, action, accept, rev=False):
Gtk.FileChooserDialog.__init__(self, title=title, transient_for=parent, action=action)
- self.add_button(Gtk.STOCK_CANCEL, Gtk.ResponseType.CANCEL)
+ self.add_button(_('_Cancel'), Gtk.ResponseType.CANCEL)
self.add_button(accept, Gtk.ResponseType.OK)
self.prefs = prefs
hbox = Gtk.Box(orientation=Gtk.Orientation.HORIZONTAL, spacing=0, border_width=5)
@@ -120,8 +120,8 @@ class FileChooserDialog(Gtk.FileChooserDialog):
class NumericDialog(Gtk.Dialog):
def __init__(self, parent, title, text, val, lower, upper, step=1, page=0):
Gtk.Dialog.__init__(self, title=title, transient_for=parent, destroy_with_parent=True)
- self.add_button(Gtk.STOCK_CANCEL, Gtk.ResponseType.REJECT)
- self.add_button(Gtk.STOCK_OK, Gtk.ResponseType.ACCEPT)
+ self.add_button(_('_Cancel'), Gtk.ResponseType.REJECT)
+ self.add_button(_('_OK'), Gtk.ResponseType.ACCEPT)
vbox = Gtk.Box(orientation=Gtk.Orientation.VERTICAL, spacing=0)
vbox.set_border_width(10)
@@ -164,8 +164,8 @@ class SearchDialog(Gtk.Dialog):
title=_('Find...'),
transient_for=parent,
destroy_with_parent=True)
- self.add_button(Gtk.STOCK_CANCEL, Gtk.ResponseType.REJECT)
- self.add_button(Gtk.STOCK_OK, Gtk.ResponseType.ACCEPT)
+ self.add_button(_('_Cancel'), Gtk.ResponseType.REJECT)
+ self.add_button(_('_OK'), Gtk.ResponseType.ACCEPT)
vbox = Gtk.Box(orientation=Gtk.Orientation.VERTICAL, spacing=0)
vbox.set_border_width(10)
diff --git a/src/diffuse/preferences.py b/src/diffuse/preferences.py
index 3e57988..9be157c 100644
--- a/src/diffuse/preferences.py
+++ b/src/diffuse/preferences.py
@@ -257,8 +257,8 @@ class Preferences:
# button was pressed
def runDialog(self, parent: Gtk.Widget) -> None:
dialog = Gtk.Dialog(_('Preferences'), parent=parent, destroy_with_parent=True)
- dialog.add_button(Gtk.STOCK_CANCEL, Gtk.ResponseType.REJECT)
- dialog.add_button(Gtk.STOCK_OK, Gtk.ResponseType.OK)
+ dialog.add_button(_('_Cancel'), Gtk.ResponseType.REJECT)
+ dialog.add_button(_('_OK'), Gtk.ResponseType.OK)
widgets: Dict[str, Gtk.Widget] = {}
w = self._buildPrefsDialog(parent, widgets, self.template)
@@ -473,7 +473,7 @@ class _FileEntry(Gtk.Box):
entry.show()
button = Gtk.Button()
image = Gtk.Image()
- image.set_from_stock(Gtk.STOCK_OPEN, Gtk.IconSize.MENU)
+ image.set_from_icon_name('document-open-symbolic', Gtk.IconSize.MENU)
button.add(image)
image.show()
button.connect('clicked', self.chooseFile)
@@ -486,7 +486,7 @@ class _FileEntry(Gtk.Box):
self.title,
self.toplevel,
Gtk.FileChooserAction.OPEN,
- (Gtk.STOCK_CANCEL, Gtk.ResponseType.CANCEL, Gtk.STOCK_OPEN, Gtk.ResponseType.OK))
+ (_('_Cancel'), Gtk.ResponseType.CANCEL, _('_Open'), Gtk.ResponseType.OK))
dialog.set_current_folder(os.path.realpath(os.curdir))
if dialog.run() == Gtk.ResponseType.OK:
self.entry.set_text(dialog.get_filename())
diff --git a/src/diffuse/widgets.py b/src/diffuse/widgets.py
index f9379cb..c4d77ee 100644
--- a/src/diffuse/widgets.py
+++ b/src/diffuse/widgets.py
@@ -1854,16 +1854,16 @@ class FileDiffViewerBase(Gtk.Grid):
can_swap = (f != self.current_pane)
menu = self._create_menu([
- [_('Align with Selection'), self.align_with_selection_cb, [f, i], Gtk.STOCK_EXECUTE, can_align], # noqa: E501
+ [_('Align with Selection'), self.align_with_selection_cb, [f, i], 'system-run-symbolic', can_align], # noqa: E501
[_('Isolate'), self.button_cb, 'isolate', None, can_isolate],
[_('Merge Selection'), self.merge_lines_cb, f, None, can_merge],
[],
- [_('Cut'), self.button_cb, 'cut', Gtk.STOCK_CUT, can_select],
- [_('Copy'), self.button_cb, 'copy', Gtk.STOCK_COPY, can_select],
- [_('Paste'), self.button_cb, 'paste', Gtk.STOCK_PASTE, can_select],
+ [_('Cut'), self.button_cb, 'cut', 'edit-cut-symbolic', can_select],
+ [_('Copy'), self.button_cb, 'copy', 'edit-copy-symbolic', can_select],
+ [_('Paste'), self.button_cb, 'paste', 'edit-paste-symbolic', can_select],
[],
[_('Select All'), self.button_cb, 'select-all', None, can_select],
- [_('Clear Edits'), self.button_cb, 'clear-edits', Gtk.STOCK_CLEAR, can_isolate], # noqa: E501
+ [_('Clear Edits'), self.button_cb, 'clear-edits', 'edit-clear-symbolic', can_isolate], # noqa: E501
[],
[_('Swap with Selected Pane'), self.swap_panes_cb, f, None, can_swap]
])
@@ -1875,13 +1875,13 @@ class FileDiffViewerBase(Gtk.Grid):
menu = Gtk.Menu()
for spec in specs:
if len(spec) > 0:
- (label, cb, cb_data, image_stock_name, sensitive) = spec
+ (label, cb, cb_data, image_icon_name, sensitive) = spec
item = Gtk.ImageMenuItem.new_with_mnemonic(label)
item.set_use_underline(True)
item.set_sensitive(sensitive)
- if image_stock_name is not None:
+ if image_icon_name is not None:
image = Gtk.Image()
- image.set_from_stock(image_stock_name, Gtk.IconSize.MENU)
+ image.set_from_icon_name(image_icon_name, Gtk.IconSize.MENU)
item.set_image(image)
if cb is not None:
item.connect('activate', cb, cb_data)
diff --git a/src/diffuse/window.py b/src/diffuse/window.py
index f8e3e69..b3be3af 100644
--- a/src/diffuse/window.py
+++ b/src/diffuse/window.py
@@ -57,13 +57,13 @@ class NotebookTab(Gtk.EventBox):
signals can be connected for MMB and RMB button presses.
"""
- def __init__(self, name: str, stock: str) -> None:
+ def __init__(self, name: str, icon_name: str) -> None:
Gtk.EventBox.__init__(self)
self.set_visible_window(False)
hbox = Gtk.Box(orientation=Gtk.Orientation.HORIZONTAL, spacing=0)
- if stock is not None:
+ if icon_name is not None:
image = Gtk.Image()
- image.set_from_stock(stock, Gtk.IconSize.MENU)
+ image.set_from_icon_name(icon_name, Gtk.IconSize.MENU)
hbox.pack_start(image, False, False, 5)
image.show()
@@ -78,7 +78,7 @@ class NotebookTab(Gtk.EventBox):
button = Gtk.Button()
button.set_relief(Gtk.ReliefStyle.NONE)
image = Gtk.Image()
- image.set_from_stock(Gtk.STOCK_CLOSE, Gtk.IconSize.MENU)
+ image.set_from_icon_name('window-close-symbolic', Gtk.IconSize.MENU)
button.add(image)
image.show()
button.set_tooltip_text(_('Close Tab'))
@@ -124,10 +124,10 @@ class PaneHeader(Gtk.Box):
def __init__(self) -> None:
Gtk.Box.__init__(self, orientation=Gtk.Orientation.HORIZONTAL, spacing=0)
button_specs = [
- [Gtk.STOCK_OPEN, self.button_cb, 'open', _('Open File...')],
- [Gtk.STOCK_REFRESH, self.button_cb, 'reload', _('Reload File')],
- [Gtk.STOCK_SAVE, self.button_cb, 'save', _('Save File')],
- [Gtk.STOCK_SAVE_AS, self.button_cb, 'save_as', _('Save File As...')]
+ ['document-open-symbolic', self.button_cb, 'open', _('Open File...')],
+ ['view-refresh-symbolic', self.button_cb, 'reload', _('Reload File')],
+ ['document-save-symbolic', self.button_cb, 'save', _('Save File')],
+ ['document-save-as-symbolic', self.button_cb, 'save_as', _('Save File As...')]
]
_append_buttons(self, Gtk.IconSize.MENU, button_specs)
@@ -307,9 +307,9 @@ class FileDiffViewer(FileDiffViewerBase):
Gtk.ButtonsType.NONE, _('Save changes before loading the new file?')
)
dialog.set_title(constants.APP_NAME)
- dialog.add_button(Gtk.STOCK_CANCEL, Gtk.ResponseType.CANCEL)
- dialog.add_button(Gtk.STOCK_NO, Gtk.ResponseType.REJECT)
- dialog.add_button(Gtk.STOCK_YES, Gtk.ResponseType.OK)
+ dialog.add_button(_('_Cancel'), Gtk.ResponseType.CANCEL)
+ dialog.add_button(_('_No'), Gtk.ResponseType.REJECT)
+ dialog.add_button(_('_Yes'), Gtk.ResponseType.OK)
dialog.set_default_response(Gtk.ResponseType.CANCEL)
response = dialog.run()
dialog.destroy()
@@ -444,7 +444,7 @@ class FileDiffViewer(FileDiffViewerBase):
self.get_toplevel(),
self.prefs,
Gtk.FileChooserAction.OPEN,
- Gtk.STOCK_OPEN,
+ _('_Open'),
True
)
if info.name is not None:
@@ -497,7 +497,7 @@ class FileDiffViewer(FileDiffViewerBase):
self.get_toplevel(),
self.prefs,
Gtk.FileChooserAction.SAVE,
- Gtk.STOCK_SAVE
+ _('_Save')
)
if name is not None:
dialog.set_filename(os.path.abspath(name))
@@ -917,25 +917,25 @@ class DiffuseWindow(Gtk.ApplicationWindow):
[DIFFUSE_STOCK_NEW_2WAY_MERGE, self.new_2_way_file_merge_cb, None, _('New 2-Way File Merge')], # noqa: E501
[DIFFUSE_STOCK_NEW_3WAY_MERGE, self.new_3_way_file_merge_cb, None, _('New 3-Way File Merge')], # noqa: E501
[],
- [Gtk.STOCK_EXECUTE, self.button_cb, 'realign-all', _('Realign All')],
- [Gtk.STOCK_GOTO_TOP, self.button_cb, 'first-difference', _('First Difference')],
- [Gtk.STOCK_GO_UP, self.button_cb, 'previous-difference', _('Previous Difference')],
- [Gtk.STOCK_GO_DOWN, self.button_cb, 'next-difference', _('Next Difference')],
- [Gtk.STOCK_GOTO_BOTTOM, self.button_cb, 'last-difference', _('Last Difference')],
+ ['system-run-symbolic', self.button_cb, 'realign-all', _('Realign All')],
+ ['go-top-symbolic', self.button_cb, 'first-difference', _('First Difference')],
+ ['go-up-symbolic', self.button_cb, 'previous-difference', _('Previous Difference')],
+ ['go-down-symbolic', self.button_cb, 'next-difference', _('Next Difference')],
+ ['go-bottom-symbolic', self.button_cb, 'last-difference', _('Last Difference')],
[],
- [Gtk.STOCK_GOTO_LAST, self.button_cb, 'copy-selection-right', _('Copy Selection Right')], # noqa: E501
- [Gtk.STOCK_GOTO_FIRST, self.button_cb, 'copy-selection-left', _('Copy Selection Left')],
- [Gtk.STOCK_GO_FORWARD, self.button_cb, 'copy-left-into-selection', _('Copy Left Into Selection')], # noqa: E501
- [Gtk.STOCK_GO_BACK, self.button_cb, 'copy-right-into-selection', _('Copy Right Into Selection')], # noqa: E501
+ ['go-last-symbolic', self.button_cb, 'copy-selection-right', _('Copy Selection Right')], # noqa: E501
+ ['go-first-symbolic', self.button_cb, 'copy-selection-left', _('Copy Selection Left')],
+ ['go-next-symbolic', self.button_cb, 'copy-left-into-selection', _('Copy Left Into Selection')], # noqa: E501
+ ['go-previous-symbolic', self.button_cb, 'copy-right-into-selection', _('Copy Right Into Selection')], # noqa: E501
[DIFFUSE_STOCK_LEFT_RIGHT, self.button_cb, 'merge-from-left-then-right', _('Merge From Left Then Right')], # noqa: E501
[DIFFUSE_STOCK_RIGHT_LEFT, self.button_cb, 'merge-from-right-then-left', _('Merge From Right Then Left')], # noqa: E501
[],
- [Gtk.STOCK_UNDO, self.button_cb, 'undo', _('Undo')],
- [Gtk.STOCK_REDO, self.button_cb, 'redo', _('Redo')],
- [Gtk.STOCK_CUT, self.button_cb, 'cut', _('Cut')],
- [Gtk.STOCK_COPY, self.button_cb, 'copy', _('Copy')],
- [Gtk.STOCK_PASTE, self.button_cb, 'paste', _('Paste')],
- [Gtk.STOCK_CLEAR, self.button_cb, 'clear-edits', _('Clear Edits')]
+ ['edit-undo-symbolic', self.button_cb, 'undo', _('Undo')],
+ ['edit-redo-symbolic', self.button_cb, 'redo', _('Redo')],
+ ['edit-cut-symbolic', self.button_cb, 'cut', _('Cut')],
+ ['edit-copy-symbolic', self.button_cb, 'copy', _('Copy')],
+ ['edit-paste-symbolic', self.button_cb, 'paste', _('Paste')],
+ ['edit-clear-symbolic', self.button_cb, 'clear-edits', _('Clear Edits')]
]
_append_buttons(hbox, Gtk.IconSize.LARGE_TOOLBAR, button_specs)
# avoid the button bar from dictating the minimum window size
@@ -1170,11 +1170,11 @@ class DiffuseWindow(Gtk.ApplicationWindow):
dialog.vbox.pack_start(sw, True, True, 0)
sw.show()
# add custom set of action buttons
- dialog.add_button(Gtk.STOCK_CANCEL, Gtk.ResponseType.CANCEL)
+ dialog.add_button(_('_Cancel'), Gtk.ResponseType.CANCEL)
button = Gtk.Button.new_with_mnemonic(_('Close _Without Saving'))
dialog.add_action_widget(button, Gtk.ResponseType.REJECT)
button.show()
- dialog.add_button(Gtk.STOCK_SAVE, Gtk.ResponseType.OK)
+ dialog.add_button(_('_Save'), Gtk.ResponseType.OK)
dialog.set_default_response(Gtk.ResponseType.CANCEL)
response = dialog.run()
dialog.destroy()
@@ -1288,7 +1288,7 @@ class DiffuseWindow(Gtk.ApplicationWindow):
def newFileDiffViewer(self, n: int) -> FileDiffViewer:
self.viewer_count += 1
tabname = _('File Merge %d') % (self.viewer_count, )
- tab = NotebookTab(tabname, Gtk.STOCK_FILE)
+ tab = NotebookTab(tabname, 'text-x-generic-symbolic')
viewer = FileDiffViewer(n, self.prefs, tabname)
tab.button.connect('clicked', self.remove_tab_cb, viewer)
tab.connect('button-press-event', self.notebooktab_button_press_cb, viewer)
@@ -1476,7 +1476,7 @@ class DiffuseWindow(Gtk.ApplicationWindow):
self.get_toplevel(),
self.prefs,
Gtk.FileChooserAction.OPEN,
- Gtk.STOCK_OPEN,
+ _('_Open'),
True
)
dialog.set_default_response(Gtk.ResponseType.OK)
@@ -1499,7 +1499,7 @@ class DiffuseWindow(Gtk.ApplicationWindow):
parent,
self.prefs,
Gtk.FileChooserAction.SELECT_FOLDER,
- Gtk.STOCK_OPEN
+ _('_Open')
)
dialog.set_default_response(Gtk.ResponseType.OK)
accept = (dialog.run() == Gtk.ResponseType.OK)
@@ -1522,7 +1522,7 @@ class DiffuseWindow(Gtk.ApplicationWindow):
_('Choose Folder With Commit'),
parent, self.prefs,
Gtk.FileChooserAction.SELECT_FOLDER,
- Gtk.STOCK_OPEN,
+ _('_Open'),
True
)
dialog.set_default_response(Gtk.ResponseType.OK)
@@ -1806,12 +1806,15 @@ def _append_buttons(box, size, specs):
"""Convenience method for packing buttons into a container."""
for spec in specs:
if len(spec) > 0:
- (stock_id, cb, cb_data, label) = spec
+ (icon_name, cb, cb_data, label) = spec
button = Gtk.Button()
button.set_relief(Gtk.ReliefStyle.NONE)
button.set_can_focus(False)
image = Gtk.Image()
- image.set_from_stock(stock_id, size)
+ if icon_name.startswith('diffuse'):
+ image.set_from_stock(icon_name, size)
+ else:
+ image.set_from_icon_name(icon_name, size)
button.add(image)
image.show()
button.connect('clicked', cb, cb_data)
From 4926ca91de8b77181afd3de269ab150387fdaaf7 Mon Sep 17 00:00:00 2001
From: oscfdezdz <42654671+oscfdezdz@users.noreply.github.com>
Date: Sun, 9 Apr 2023 01:51:54 +0200
Subject: [PATCH 2/4] Add custom actions symbolic icons
Using gresource file and based on the suggestions for the merge menu
made in https://github.com/MightyCreak/diffuse/issues/90.
---
data/diffuse.gresource.xml | 11 ++++++++++
.../copy-left-into-selection-symbolic.svg | 2 ++
.../copy-right-into-selection-symbolic.svg | 2 ++
.../actions/copy-selection-left-symbolic.svg | 2 ++
.../actions/copy-selection-right-symbolic.svg | 2 ++
.../actions/new-2way-merge-symbolic.svg | 2 ++
.../actions/new-3way-merge-symbolic.svg | 2 ++
data/meson.build | 8 +++++++
src/diffuse/diffuse.in | 8 +++++++
src/diffuse/window.py | 21 ++++++++-----------
10 files changed, 48 insertions(+), 12 deletions(-)
create mode 100644 data/diffuse.gresource.xml
create mode 100644 data/icons/hicolor/scalable/actions/copy-left-into-selection-symbolic.svg
create mode 100644 data/icons/hicolor/scalable/actions/copy-right-into-selection-symbolic.svg
create mode 100644 data/icons/hicolor/scalable/actions/copy-selection-left-symbolic.svg
create mode 100644 data/icons/hicolor/scalable/actions/copy-selection-right-symbolic.svg
create mode 100644 data/icons/hicolor/scalable/actions/new-2way-merge-symbolic.svg
create mode 100644 data/icons/hicolor/scalable/actions/new-3way-merge-symbolic.svg
diff --git a/data/diffuse.gresource.xml b/data/diffuse.gresource.xml
new file mode 100644
index 0000000..bc602bb
--- /dev/null
+++ b/data/diffuse.gresource.xml
@@ -0,0 +1,11 @@
+
+
+
+ icons/hicolor/scalable/actions/new-2way-merge-symbolic.svg
+ icons/hicolor/scalable/actions/new-3way-merge-symbolic.svg
+ icons/hicolor/scalable/actions/copy-selection-left-symbolic.svg
+ icons/hicolor/scalable/actions/copy-selection-right-symbolic.svg
+ icons/hicolor/scalable/actions/copy-left-into-selection-symbolic.svg
+ icons/hicolor/scalable/actions/copy-right-into-selection-symbolic.svg
+
+
diff --git a/data/icons/hicolor/scalable/actions/copy-left-into-selection-symbolic.svg b/data/icons/hicolor/scalable/actions/copy-left-into-selection-symbolic.svg
new file mode 100644
index 0000000..14dc140
--- /dev/null
+++ b/data/icons/hicolor/scalable/actions/copy-left-into-selection-symbolic.svg
@@ -0,0 +1,2 @@
+
+
diff --git a/data/icons/hicolor/scalable/actions/copy-right-into-selection-symbolic.svg b/data/icons/hicolor/scalable/actions/copy-right-into-selection-symbolic.svg
new file mode 100644
index 0000000..126d701
--- /dev/null
+++ b/data/icons/hicolor/scalable/actions/copy-right-into-selection-symbolic.svg
@@ -0,0 +1,2 @@
+
+
diff --git a/data/icons/hicolor/scalable/actions/copy-selection-left-symbolic.svg b/data/icons/hicolor/scalable/actions/copy-selection-left-symbolic.svg
new file mode 100644
index 0000000..55890ed
--- /dev/null
+++ b/data/icons/hicolor/scalable/actions/copy-selection-left-symbolic.svg
@@ -0,0 +1,2 @@
+
+
diff --git a/data/icons/hicolor/scalable/actions/copy-selection-right-symbolic.svg b/data/icons/hicolor/scalable/actions/copy-selection-right-symbolic.svg
new file mode 100644
index 0000000..88a9e9e
--- /dev/null
+++ b/data/icons/hicolor/scalable/actions/copy-selection-right-symbolic.svg
@@ -0,0 +1,2 @@
+
+
diff --git a/data/icons/hicolor/scalable/actions/new-2way-merge-symbolic.svg b/data/icons/hicolor/scalable/actions/new-2way-merge-symbolic.svg
new file mode 100644
index 0000000..35d079d
--- /dev/null
+++ b/data/icons/hicolor/scalable/actions/new-2way-merge-symbolic.svg
@@ -0,0 +1,2 @@
+
+
diff --git a/data/icons/hicolor/scalable/actions/new-3way-merge-symbolic.svg b/data/icons/hicolor/scalable/actions/new-3way-merge-symbolic.svg
new file mode 100644
index 0000000..2fb375c
--- /dev/null
+++ b/data/icons/hicolor/scalable/actions/new-3way-merge-symbolic.svg
@@ -0,0 +1,2 @@
+
+
diff --git a/data/meson.build b/data/meson.build
index 52ed78a..ab3d4d0 100644
--- a/data/meson.build
+++ b/data/meson.build
@@ -1,4 +1,12 @@
pkgdatadir = join_paths(get_option('prefix'), get_option('datadir'), meson.project_name())
+gnome = import('gnome')
+
+gnome.compile_resources(meson.project_name(),
+ meson.project_name() + '.gresource.xml',
+ gresource_bundle: true,
+ install: true,
+ install_dir: pkgdatadir,
+)
if build_machine.system() == 'linux'
desktop_file = i18n.merge_file(
diff --git a/src/diffuse/diffuse.in b/src/diffuse/diffuse.in
index 4a60c6b..7f405a6 100755
--- a/src/diffuse/diffuse.in
+++ b/src/diffuse/diffuse.in
@@ -19,9 +19,12 @@
# with this program; if not, write to the Free Software Foundation, Inc.,
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+import os
import sys
import gettext
+from gi.repository import Gio
+
VERSION = '@VERSION@'
PKGDATADIR = '@PKGDATADIR@'
LOCALEDIR = '@LOCALEDIR@'
@@ -34,4 +37,9 @@ gettext.textdomain('diffuse')
if __name__ == '__main__':
from diffuse import main
+
+ resource = Gio.resource_load(
+ os.path.join(PKGDATADIR, 'diffuse.gresource'))
+ Gio.Resource._register(resource)
+
sys.exit(main.main(VERSION, SYSCONFIGDIR))
diff --git a/src/diffuse/window.py b/src/diffuse/window.py
index b3be3af..b1dda3b 100644
--- a/src/diffuse/window.py
+++ b/src/diffuse/window.py
@@ -914,8 +914,8 @@ class DiffuseWindow(Gtk.ApplicationWindow):
# create toolbar
hbox = Gtk.Box(orientation=Gtk.Orientation.HORIZONTAL, spacing=0)
button_specs = [
- [DIFFUSE_STOCK_NEW_2WAY_MERGE, self.new_2_way_file_merge_cb, None, _('New 2-Way File Merge')], # noqa: E501
- [DIFFUSE_STOCK_NEW_3WAY_MERGE, self.new_3_way_file_merge_cb, None, _('New 3-Way File Merge')], # noqa: E501
+ ['new-2way-merge-symbolic', self.new_2_way_file_merge_cb, None, _('New 2-Way File Merge')], # noqa: E501
+ ['new-3way-merge-symbolic', self.new_3_way_file_merge_cb, None, _('New 3-Way File Merge')], # noqa: E501
[],
['system-run-symbolic', self.button_cb, 'realign-all', _('Realign All')],
['go-top-symbolic', self.button_cb, 'first-difference', _('First Difference')],
@@ -923,12 +923,12 @@ class DiffuseWindow(Gtk.ApplicationWindow):
['go-down-symbolic', self.button_cb, 'next-difference', _('Next Difference')],
['go-bottom-symbolic', self.button_cb, 'last-difference', _('Last Difference')],
[],
- ['go-last-symbolic', self.button_cb, 'copy-selection-right', _('Copy Selection Right')], # noqa: E501
- ['go-first-symbolic', self.button_cb, 'copy-selection-left', _('Copy Selection Left')],
- ['go-next-symbolic', self.button_cb, 'copy-left-into-selection', _('Copy Left Into Selection')], # noqa: E501
- ['go-previous-symbolic', self.button_cb, 'copy-right-into-selection', _('Copy Right Into Selection')], # noqa: E501
- [DIFFUSE_STOCK_LEFT_RIGHT, self.button_cb, 'merge-from-left-then-right', _('Merge From Left Then Right')], # noqa: E501
- [DIFFUSE_STOCK_RIGHT_LEFT, self.button_cb, 'merge-from-right-then-left', _('Merge From Right Then Left')], # noqa: E501
+ ['copy-selection-right-symbolic', self.button_cb, 'copy-selection-right', _('Copy Selection Right')], # noqa: E501
+ ['copy-selection-left-symbolic', self.button_cb, 'copy-selection-left', _('Copy Selection Left')], # noqa: E501
+ ['copy-left-into-selection-symbolic', self.button_cb, 'copy-left-into-selection', _('Copy Left Into Selection')], # noqa: E501
+ ['copy-right-into-selection-symbolic', self.button_cb, 'copy-right-into-selection', _('Copy Right Into Selection')], # noqa: E501
+ ['document-revert-rtl-symbolic', self.button_cb, 'merge-from-left-then-right', _('Merge From Left Then Right')], # noqa: E501
+ ['document-revert-symbolic', self.button_cb, 'merge-from-right-then-left', _('Merge From Right Then Left')], # noqa: E501
[],
['edit-undo-symbolic', self.button_cb, 'undo', _('Undo')],
['edit-redo-symbolic', self.button_cb, 'redo', _('Redo')],
@@ -1811,10 +1811,7 @@ def _append_buttons(box, size, specs):
button.set_relief(Gtk.ReliefStyle.NONE)
button.set_can_focus(False)
image = Gtk.Image()
- if icon_name.startswith('diffuse'):
- image.set_from_stock(icon_name, size)
- else:
- image.set_from_icon_name(icon_name, size)
+ image.set_from_icon_name(icon_name, size)
button.add(image)
image.show()
button.connect('clicked', cb, cb_data)
From e15eba2f2e59653fed08d27355dd942f9b9512ff Mon Sep 17 00:00:00 2001
From: oscfdezdz <42654671+oscfdezdz@users.noreply.github.com>
Date: Sun, 9 Apr 2023 01:53:02 +0200
Subject: [PATCH 3/4] Remove code to generate custom icons
Now that custom icons are bundled in the build, this code is no longer
used.
---
src/diffuse/window.py | 66 +------------------------------------------
1 file changed, 1 insertion(+), 65 deletions(-)
diff --git a/src/diffuse/window.py b/src/diffuse/window.py
index b1dda3b..805658d 100644
--- a/src/diffuse/window.py
+++ b/src/diffuse/window.py
@@ -39,11 +39,10 @@ from diffuse.widgets import FileDiffViewerBase, EditMode
import gi # type: ignore
gi.require_version('Gdk', '3.0')
gi.require_version('GObject', '2.0')
-gi.require_version('GdkPixbuf', '2.0')
gi.require_version('Gtk', '3.0')
gi.require_version('Pango', '1.0')
gi.require_version('PangoCairo', '1.0')
-from gi.repository import Gdk, GdkPixbuf, Gio, GLib, GObject, Gtk, Pango # type: ignore # noqa: E402, E501
+from gi.repository import Gdk, Gio, GLib, GObject, Gtk, Pango # type: ignore # noqa: E402
theVCSs = VcsRegistry()
@@ -713,69 +712,6 @@ class DiffuseWindow(Gtk.ApplicationWindow):
# create a Box for our contents
vbox = Gtk.Box(orientation=Gtk.Orientation.VERTICAL)
- # create some custom icons for merging
- DIFFUSE_STOCK_NEW_2WAY_MERGE = 'diffuse-new-2way-merge'
- DIFFUSE_STOCK_NEW_3WAY_MERGE = 'diffuse-new-3way-merge'
- DIFFUSE_STOCK_LEFT_RIGHT = 'diffuse-left-right'
- DIFFUSE_STOCK_RIGHT_LEFT = 'diffuse-right-left'
-
- # get default theme and window scale factor
- default_theme = Gtk.IconTheme.get_default()
- scale_factor = self.get_scale_factor()
-
- icon_size = Gtk.IconSize.lookup(Gtk.IconSize.LARGE_TOOLBAR).height
- factory = Gtk.IconFactory()
-
- # render the base item used to indicate a new document
- p0 = default_theme.load_icon_for_scale('document-new', icon_size, scale_factor, 0)
- w, h = p0.get_width(), p0.get_height()
-
- # render new 2-way merge icon
- s = 0.8
- sw, sh = int(s * w), int(s * h)
- w1, h1 = w - sw, h - sh
- p = GdkPixbuf.Pixbuf.new(GdkPixbuf.Colorspace.RGB, True, 8, w, h)
- p.fill(0)
- p0.composite(p, 0, 0, sw, sh, 0, 0, s, s, GdkPixbuf.InterpType.BILINEAR, 255)
- p0.composite(p, w1, h1, sw, sh, w1, h1, s, s, GdkPixbuf.InterpType.BILINEAR, 255)
- factory.add(DIFFUSE_STOCK_NEW_2WAY_MERGE, Gtk.IconSet.new_from_pixbuf(p))
-
- # render new 3-way merge icon
- s = 0.7
- sw, sh = int(s * w), int(s * h)
- w1, h1 = (w - sw) / 2, (h - sh) / 2
- w2, h2 = w - sw, h - sh
- p = GdkPixbuf.Pixbuf.new(GdkPixbuf.Colorspace.RGB, True, 8, w, h)
- p.fill(0)
- p0.composite(p, 0, 0, sw, sh, 0, 0, s, s, GdkPixbuf.InterpType.BILINEAR, 255)
- p0.composite(p, w1, h1, sw, sh, w1, h1, s, s, GdkPixbuf.InterpType.BILINEAR, 255)
- p0.composite(p, w2, h2, sw, sh, w2, h2, s, s, GdkPixbuf.InterpType.BILINEAR, 255)
- factory.add(DIFFUSE_STOCK_NEW_3WAY_MERGE, Gtk.IconSet.new_from_pixbuf(p))
-
- # render the left and right arrow we will use in our custom icons
- p0 = default_theme.load_icon_for_scale('go-next', icon_size, scale_factor, 0)
- p1 = default_theme.load_icon_for_scale('go-previous', icon_size, scale_factor, 0)
- w, h, s = p0.get_width(), p0.get_height(), 0.65
- sw, sh = int(s * w), int(s * h)
- w1, h1 = w - sw, h - sh
-
- # create merge from left then right icon
- p = GdkPixbuf.Pixbuf.new(GdkPixbuf.Colorspace.RGB, True, 8, w, h)
- p.fill(0)
- p1.composite(p, w1, h1, sw, sh, w1, h1, s, s, GdkPixbuf.InterpType.BILINEAR, 255)
- p0.composite(p, 0, 0, sw, sh, 0, 0, s, s, GdkPixbuf.InterpType.BILINEAR, 255)
- factory.add(DIFFUSE_STOCK_LEFT_RIGHT, Gtk.IconSet.new_from_pixbuf(p))
-
- # create merge from right then left icon
- p = GdkPixbuf.Pixbuf.new(GdkPixbuf.Colorspace.RGB, True, 8, w, h)
- p.fill(0)
- p0.composite(p, 0, h1, sw, sh, 0, h1, s, s, GdkPixbuf.InterpType.BILINEAR, 255)
- p1.composite(p, w1, 0, sw, sh, w1, 0, s, s, GdkPixbuf.InterpType.BILINEAR, 255)
- factory.add(DIFFUSE_STOCK_RIGHT_LEFT, Gtk.IconSet.new_from_pixbuf(p))
-
- # make the icons available for use
- factory.add_default()
-
menu_specs = []
menu_specs.append([_('_File'), [
[
From f858c380ddd333967020c4a9255a96b4c63e37b1 Mon Sep 17 00:00:00 2001
From: Creak
Date: Tue, 11 Apr 2023 19:35:10 -0400
Subject: [PATCH 4/4] Update CHANGELOG.md
---
CHANGELOG.md | 1 +
1 file changed, 1 insertion(+)
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 963a51d..ef84080 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -15,6 +15,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Replace `_` by `-` in the action names to be compatible with GTK action names (@MightyCreak)
- The About dialog is now transient for the main window (@oscfdezdz)
+- Remove deprecated STOCK constants and use more modern, symbolic icons (@oscfdezdz)
### Fixed