Merge pull request #203 from oscfdezdz/deprecated

Remove deprecated STOCK constants
This commit is contained in:
Creak 2023-04-11 19:41:38 -04:00 committed by GitHub
commit a28f194123
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
14 changed files with 98 additions and 122 deletions

View File

@ -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

View File

@ -0,0 +1,11 @@
<?xml version="1.0" encoding="UTF-8"?>
<gresources>
<gresource prefix="/io/github/mightycreak/Diffuse/icons/scalable/actions">
<file preprocess="xml-stripblanks" alias="new-2way-merge-symbolic.svg">icons/hicolor/scalable/actions/new-2way-merge-symbolic.svg</file>
<file preprocess="xml-stripblanks" alias="new-3way-merge-symbolic.svg">icons/hicolor/scalable/actions/new-3way-merge-symbolic.svg</file>
<file preprocess="xml-stripblanks" alias="copy-selection-left-symbolic.svg">icons/hicolor/scalable/actions/copy-selection-left-symbolic.svg</file>
<file preprocess="xml-stripblanks" alias="copy-selection-right-symbolic.svg">icons/hicolor/scalable/actions/copy-selection-right-symbolic.svg</file>
<file preprocess="xml-stripblanks" alias="copy-left-into-selection-symbolic.svg">icons/hicolor/scalable/actions/copy-left-into-selection-symbolic.svg</file>
<file preprocess="xml-stripblanks" alias="copy-right-into-selection-symbolic.svg">icons/hicolor/scalable/actions/copy-right-into-selection-symbolic.svg</file>
</gresource>
</gresources>

View File

@ -0,0 +1,2 @@
<?xml version="1.0" encoding="UTF-8"?>
<svg height="16" width="16" xmlns="http://www.w3.org/2000/svg"><path d="M11 14a1 1 0 0 0 .707-.293l4-4a1 1 0 0 0 0-1.414l-4-4a1 1 0 1 0-1.414 1.414L13.586 9l-3.293 3.293A1 1 0 0 0 11 14zm-4 0a1 1 0 0 0 .707-.293l4-4a1 1 0 0 0 0-1.414l-4-4a1 1 0 1 0-1.414 1.414L8.586 8H4c-1.117 0-2-.883-2-2V3c0-.55-.45-1-1-1s-1 .45-1 1v3c0 .023 0 .047.004.07A4.01 4.01 0 0 0 4 10h4.586l-2.293 2.293A1 1 0 0 0 7 14zm0 0" fill="#2e3436"/></svg>

After

Width:  |  Height:  |  Size: 466 B

View File

@ -0,0 +1,2 @@
<?xml version="1.0" encoding="UTF-8"?>
<svg height="16" width="16" xmlns="http://www.w3.org/2000/svg"><path d="M5 14a1 1 0 0 1-.707-.293l-4-4a1 1 0 0 1 0-1.414l4-4a1 1 0 1 1 1.414 1.414L2.414 9l3.293 3.293A1 1 0 0 1 5 14zm4 0a1 1 0 0 1-.707-.293l-4-4a1 1 0 0 1 0-1.414l4-4a1 1 0 1 1 1.414 1.414L7.414 8H12c1.117 0 2-.883 2-2V3c0-.55.45-1 1-1s1 .45 1 1v3c0 .023 0 .047-.004.07A4.01 4.01 0 0 1 12 10H7.414l2.293 2.293A1 1 0 0 1 9 14zm0 0" fill="#2e3436"/></svg>

After

Width:  |  Height:  |  Size: 460 B

View File

@ -0,0 +1,2 @@
<?xml version="1.0" encoding="UTF-8"?>
<svg xmlns="http://www.w3.org/2000/svg" height="16px" viewBox="0 0 16 16" width="16px"><g fill="#2e3436"><path d="m 9 2.933594 c 4.042969 0 5.890625 3.613281 5.890625 3.613281 l -1.785156 0.902344 s -1.246094 -2.515625 -4.105469 -2.515625 c -2.054688 0 -3.097656 1.394531 -3.484375 2.074218 h 0.910156 c 1.332031 0 1.574219 1.253907 1.574219 2.035157 l -6 -0.046875 l -0.046875 -6 c 1.046875 0 2.035156 0.523437 2.035156 1.667968 v 0.929688 l 0.0625 0.0625 c 0.757813 -1.089844 2.3125 -2.722656 4.949219 -2.722656 z m 0 0"/><path d="m 13.617188 8.996094 c 0.683593 0 1.265624 0.582031 1.265624 1.265625 v 3.46875 c 0 0.683593 -0.582031 1.265625 -1.265624 1.265625 h -3.46875 c -0.683594 0 -1.265626 -0.582032 -1.265626 -1.265625 v -3.46875 c 0 -0.683594 0.582032 -1.265625 1.265626 -1.265625 z m -0.734376 2 h -2 v 2 h 2 z m 0 0"/></g></svg>

After

Width:  |  Height:  |  Size: 881 B

View File

@ -0,0 +1,2 @@
<?xml version="1.0" encoding="UTF-8"?>
<svg xmlns="http://www.w3.org/2000/svg" height="16px" viewBox="0 0 16 16" width="16px"><g fill="#2e3436"><path d="m 7 2.933594 c -4.042969 0 -5.894531 3.613281 -5.894531 3.613281 l 1.785156 0.902344 s 1.25 -2.515625 4.109375 -2.515625 c 2.054688 0 3.097656 1.394531 3.484375 2.074218 h -0.910156 c -1.332031 0 -1.574219 1.253907 -1.574219 2.035157 l 6 -0.046875 l 0.042969 -6 c -1.042969 0 -2.03125 0.523437 -2.03125 1.667968 v 0.929688 l -0.0625 0.0625 c -0.757813 -1.089844 -2.316407 -2.722656 -4.949219 -2.722656 z m 0 0"/><path d="m 2.382812 8.996094 c -0.683593 0 -1.265624 0.582031 -1.265624 1.265625 v 3.46875 c 0 0.683593 0.582031 1.265625 1.265624 1.265625 h 3.46875 c 0.683594 0 1.265626 -0.582032 1.265626 -1.265625 v -3.46875 c 0 -0.683594 -0.582032 -1.265625 -1.265626 -1.265625 z m 0.734376 2 h 2 v 2 h -2 z m 0 0"/></g></svg>

After

Width:  |  Height:  |  Size: 880 B

View File

@ -0,0 +1,2 @@
<?xml version="1.0" encoding="UTF-8"?>
<svg height="16" width="16" xmlns="http://www.w3.org/2000/svg"><path d="M3.094.25A2.45 2.45 0 0 0 .656 2.688v8.124c0 1.324 1.18 2.416 2.5 2.436v.064a2.45 2.45 0 0 0 2.438 2.438H8.03a.814.814 0 0 0 0-1.625H5.594a.794.794 0 0 1-.813-.813V5.187c0-.463.35-.812.813-.812h4.539l2.773 2.773v.477a.814.814 0 0 0 1.625 0v-.813a.812.812 0 0 0-.238-.574l-3.102-3.101-.148-.149-2.5-2.5A.812.812 0 0 0 7.969.25zm0 1.625H7.63l.875.875H5.594a2.45 2.45 0 0 0-2.438 2.438v6.433c-.45-.018-.875-.358-.875-.809V2.688c0-.464.35-.813.813-.813zM11.28 9.25v2.438H8.844v1.624h2.437v2.438h1.625v-2.438h2.438v-1.624h-2.438V9.25z" fill="#2e3436"/></svg>

After

Width:  |  Height:  |  Size: 665 B

View File

@ -0,0 +1,2 @@
<?xml version="1.0" encoding="UTF-8"?>
<svg height="16" width="16" xmlns="http://www.w3.org/2000/svg"><path d="M2.656.25C1.526.25.594 1.182.594 2.313v6.874c0 1.094 1.151 1.999 2.25 2.057v.193c0 1.127 1.123 2.057 2.25 2.063v.187c0 1.131.932 2.063 2.062 2.063H9.22a.689.689 0 0 0 0-1.375H7.156a.672.672 0 0 1-.687-.688V6.812c0-.392.295-.687.687-.687h3.84l2.348 2.348v.402a.688.688 0 0 0 1.375 0v-.688a.687.687 0 0 0-.201-.486l-2.65-2.65-.1-.1-2.15-2.15L7.267.45a.687.687 0 0 0-.487-.2zm0 1.375h3.84l.875.875H4.906c-1.13 0-2.062.932-2.062 2.063v5.302c-.384-.047-.875-.32-.875-.677V2.311c0-.392.295-.687.687-.687zm2.25 2.25h3.84l.875.875H7.156c-1.13 0-2.062.932-2.062 2.063v5.31c-.39-.006-.875-.297-.875-.685V4.561c0-.392.295-.687.687-.687zm7.063 6.375v2.063H9.906v1.374h2.063v2.063h1.375v-2.063h2.062v-1.374h-2.062V10.25z" fill="#2e3436"/></svg>

After

Width:  |  Height:  |  Size: 843 B

View File

@ -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(

View File

@ -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)

View File

@ -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))

View File

@ -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())

View File

@ -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)

View File

@ -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()
@ -57,13 +56,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 +77,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 +123,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 +306,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 +443,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 +496,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))
@ -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'), [
[
@ -914,28 +850,28 @@ 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
[],
[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
[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
[],
[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 +1106,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 +1224,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 +1412,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 +1435,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 +1458,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 +1742,12 @@ 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)
image.set_from_icon_name(icon_name, size)
button.add(image)
image.show()
button.connect('clicked', cb, cb_data)