Skip to content

Commit 4926ca9

Browse files
committed
Add custom actions symbolic icons
Using gresource file and based on the suggestions for the merge menu made in #90.
1 parent ee813f2 commit 4926ca9

10 files changed

+48
-12
lines changed

data/diffuse.gresource.xml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<gresources>
3+
<gresource prefix="/io/github/mightycreak/Diffuse/icons/scalable/actions">
4+
<file preprocess="xml-stripblanks" alias="new-2way-merge-symbolic.svg">icons/hicolor/scalable/actions/new-2way-merge-symbolic.svg</file>
5+
<file preprocess="xml-stripblanks" alias="new-3way-merge-symbolic.svg">icons/hicolor/scalable/actions/new-3way-merge-symbolic.svg</file>
6+
<file preprocess="xml-stripblanks" alias="copy-selection-left-symbolic.svg">icons/hicolor/scalable/actions/copy-selection-left-symbolic.svg</file>
7+
<file preprocess="xml-stripblanks" alias="copy-selection-right-symbolic.svg">icons/hicolor/scalable/actions/copy-selection-right-symbolic.svg</file>
8+
<file preprocess="xml-stripblanks" alias="copy-left-into-selection-symbolic.svg">icons/hicolor/scalable/actions/copy-left-into-selection-symbolic.svg</file>
9+
<file preprocess="xml-stripblanks" alias="copy-right-into-selection-symbolic.svg">icons/hicolor/scalable/actions/copy-right-into-selection-symbolic.svg</file>
10+
</gresource>
11+
</gresources>
Lines changed: 2 additions & 0 deletions
Loading
Lines changed: 2 additions & 0 deletions
Loading
Lines changed: 2 additions & 0 deletions
Loading
Lines changed: 2 additions & 0 deletions
Loading
Lines changed: 2 additions & 0 deletions
Loading
Lines changed: 2 additions & 0 deletions
Loading

data/meson.build

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,12 @@
11
pkgdatadir = join_paths(get_option('prefix'), get_option('datadir'), meson.project_name())
2+
gnome = import('gnome')
3+
4+
gnome.compile_resources(meson.project_name(),
5+
meson.project_name() + '.gresource.xml',
6+
gresource_bundle: true,
7+
install: true,
8+
install_dir: pkgdatadir,
9+
)
210

311
if build_machine.system() == 'linux'
412
desktop_file = i18n.merge_file(

src/diffuse/diffuse.in

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,12 @@
1919
# with this program; if not, write to the Free Software Foundation, Inc.,
2020
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
2121

22+
import os
2223
import sys
2324
import gettext
2425

26+
from gi.repository import Gio
27+
2528
VERSION = '@VERSION@'
2629
PKGDATADIR = '@PKGDATADIR@'
2730
LOCALEDIR = '@LOCALEDIR@'
@@ -34,4 +37,9 @@ gettext.textdomain('diffuse')
3437

3538
if __name__ == '__main__':
3639
from diffuse import main
40+
41+
resource = Gio.resource_load(
42+
os.path.join(PKGDATADIR, 'diffuse.gresource'))
43+
Gio.Resource._register(resource)
44+
3745
sys.exit(main.main(VERSION, SYSCONFIGDIR))

src/diffuse/window.py

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -914,21 +914,21 @@ def __init__(self, rc_dir, **kwargs):
914914
# create toolbar
915915
hbox = Gtk.Box(orientation=Gtk.Orientation.HORIZONTAL, spacing=0)
916916
button_specs = [
917-
[DIFFUSE_STOCK_NEW_2WAY_MERGE, self.new_2_way_file_merge_cb, None, _('New 2-Way File Merge')], # noqa: E501
918-
[DIFFUSE_STOCK_NEW_3WAY_MERGE, self.new_3_way_file_merge_cb, None, _('New 3-Way File Merge')], # noqa: E501
917+
['new-2way-merge-symbolic', self.new_2_way_file_merge_cb, None, _('New 2-Way File Merge')], # noqa: E501
918+
['new-3way-merge-symbolic', self.new_3_way_file_merge_cb, None, _('New 3-Way File Merge')], # noqa: E501
919919
[],
920920
['system-run-symbolic', self.button_cb, 'realign-all', _('Realign All')],
921921
['go-top-symbolic', self.button_cb, 'first-difference', _('First Difference')],
922922
['go-up-symbolic', self.button_cb, 'previous-difference', _('Previous Difference')],
923923
['go-down-symbolic', self.button_cb, 'next-difference', _('Next Difference')],
924924
['go-bottom-symbolic', self.button_cb, 'last-difference', _('Last Difference')],
925925
[],
926-
['go-last-symbolic', self.button_cb, 'copy-selection-right', _('Copy Selection Right')], # noqa: E501
927-
['go-first-symbolic', self.button_cb, 'copy-selection-left', _('Copy Selection Left')],
928-
['go-next-symbolic', self.button_cb, 'copy-left-into-selection', _('Copy Left Into Selection')], # noqa: E501
929-
['go-previous-symbolic', self.button_cb, 'copy-right-into-selection', _('Copy Right Into Selection')], # noqa: E501
930-
[DIFFUSE_STOCK_LEFT_RIGHT, self.button_cb, 'merge-from-left-then-right', _('Merge From Left Then Right')], # noqa: E501
931-
[DIFFUSE_STOCK_RIGHT_LEFT, self.button_cb, 'merge-from-right-then-left', _('Merge From Right Then Left')], # noqa: E501
926+
['copy-selection-right-symbolic', self.button_cb, 'copy-selection-right', _('Copy Selection Right')], # noqa: E501
927+
['copy-selection-left-symbolic', self.button_cb, 'copy-selection-left', _('Copy Selection Left')], # noqa: E501
928+
['copy-left-into-selection-symbolic', self.button_cb, 'copy-left-into-selection', _('Copy Left Into Selection')], # noqa: E501
929+
['copy-right-into-selection-symbolic', self.button_cb, 'copy-right-into-selection', _('Copy Right Into Selection')], # noqa: E501
930+
['document-revert-rtl-symbolic', self.button_cb, 'merge-from-left-then-right', _('Merge From Left Then Right')], # noqa: E501
931+
['document-revert-symbolic', self.button_cb, 'merge-from-right-then-left', _('Merge From Right Then Left')], # noqa: E501
932932
[],
933933
['edit-undo-symbolic', self.button_cb, 'undo', _('Undo')],
934934
['edit-redo-symbolic', self.button_cb, 'redo', _('Redo')],
@@ -1811,10 +1811,7 @@ def _append_buttons(box, size, specs):
18111811
button.set_relief(Gtk.ReliefStyle.NONE)
18121812
button.set_can_focus(False)
18131813
image = Gtk.Image()
1814-
if icon_name.startswith('diffuse'):
1815-
image.set_from_stock(icon_name, size)
1816-
else:
1817-
image.set_from_icon_name(icon_name, size)
1814+
image.set_from_icon_name(icon_name, size)
18181815
button.add(image)
18191816
image.show()
18201817
button.connect('clicked', cb, cb_data)

0 commit comments

Comments
 (0)