Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove deprecated STOCK constant #203

Merged
merged 4 commits into from
Apr 11, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
11 changes: 11 additions & 0 deletions data/diffuse.gresource.xml
Original file line number Diff line number Diff line change
@@ -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>
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
8 changes: 8 additions & 0 deletions data/meson.build
Original file line number Diff line number Diff line change
@@ -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(
Expand Down
10 changes: 5 additions & 5 deletions src/diffuse/dialogs.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ def _current_folder_changed_cb(widget):

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)
Expand Down Expand Up @@ -120,8 +120,8 @@ def get_filename(self) -> str:
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)
Expand Down Expand Up @@ -164,8 +164,8 @@ def __init__(self, parent, pattern=None, history=None):
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)
Expand Down
8 changes: 8 additions & 0 deletions src/diffuse/diffuse.in
Original file line number Diff line number Diff line change
Expand Up @@ -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@'
Expand All @@ -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))
8 changes: 4 additions & 4 deletions src/diffuse/preferences.py
Original file line number Diff line number Diff line change
Expand Up @@ -257,8 +257,8 @@ def _toggled_cb(self, widget, widgets, name):
# 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)
Expand Down Expand Up @@ -473,7 +473,7 @@ def __init__(self, parent: Gtk.Widget, title: str) -> None:
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)
Expand All @@ -486,7 +486,7 @@ def chooseFile(self, widget: Gtk.Widget) -> None:
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())
Expand Down
16 changes: 8 additions & 8 deletions src/diffuse/widgets.py
Original file line number Diff line number Diff line change
Expand Up @@ -1854,16 +1854,16 @@ def darea_button_press_cb(self, widget, event, f):
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]
])
Expand All @@ -1875,13 +1875,13 @@ def _create_menu(specs):
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)
Expand Down
Loading