Skip to content

Commit 0fbc2e5

Browse files
committed
fix: quick fix for the GTK accelerators
1 parent 390df24 commit 0fbc2e5

File tree

2 files changed

+13
-8
lines changed

2 files changed

+13
-8
lines changed

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1515
`logError` logs on stderr (@MightyCreak)
1616
- Change Git default branch from `master` to `main` (@MightyCreak)
1717

18+
### Fixed
19+
20+
- Shortcuts were not working since the move to Gtk.Application
21+
(issue [#188](https://github.com/MightyCreak/diffuse/issues/188)) (@MightyCreak)
22+
1823
## 0.8.0 - 2023-04-03
1924

2025
### Added

src/diffuse/window.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -973,20 +973,20 @@ def _create_menu(self, sections):
973973
else:
974974
if cb_data is not None:
975975
cb_data = GLib.Variant.new_string(cb_data)
976-
accel = accel.replace('_', '-')
976+
gtk_compliant_accel = accel.replace('_', '-')
977977
if cb is not None:
978-
action = Gio.SimpleAction.new(accel, cb_data and cb_data.get_type())
978+
cb_data_type = cb_data and cb_data.get_type()
979+
action = Gio.SimpleAction.new(gtk_compliant_accel, cb_data_type)
979980
action.connect('activate', cb)
980981
self.add_action(action)
981982
item = Gio.MenuItem.new(label)
982-
item.set_action_and_target_value('win.' + accel, cb_data)
983+
item.set_action_and_target_value('win.' + gtk_compliant_accel, cb_data)
983984
key_binding = theResources.getKeyBindings('menu', accel)
984985
if len(key_binding) > 0:
985-
key, modifier = key_binding[0]
986-
self.get_application().set_accels_for_action(
987-
Gio.Action.print_detailed_name('win.' + accel, cb_data),
988-
[Gtk.accelerator_name(key, modifier)],
989-
)
986+
action_name = 'win.' + gtk_compliant_accel
987+
detailed_action_name = Gio.Action.print_detailed_name(action_name, cb_data)
988+
accels = [Gtk.accelerator_name(*key_binding[0])]
989+
self.get_application().set_accels_for_action(detailed_action_name, accels)
990990
section_menu.append_item(item)
991991
menu.append_section(None, section_menu)
992992
return menu

0 commit comments

Comments
 (0)