Skip to content

Commit a878e1a

Browse files
committed
keybinding settings: Fix keybinding lookup for standalone widgets.
Just the label isn't enough - some applet keybinding labels are identical. Make the uuid and instance id available for accurate lookups.
1 parent 7be781a commit a878e1a

File tree

4 files changed

+27
-7
lines changed

4 files changed

+27
-7
lines changed

files/usr/share/cinnamon/cinnamon-settings/bin/JsonSettingsWidgets.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@
4242
OPERATIONS_MAP = {'<': operator.lt, '<=': operator.le, '>': operator.gt, '>=': operator.ge, '!=': operator.ne, '=': operator.eq}
4343

4444
class JSONSettingsHandler(object):
45-
def __init__(self, filepath, notify_callback=None):
45+
def __init__(self, filepath, uuid = None, instance_id = None, notify_callback=None):
4646
super(JSONSettingsHandler, self).__init__()
4747

4848
self.notify_callback = notify_callback
@@ -54,6 +54,8 @@ def __init__(self, filepath, notify_callback=None):
5454
self.bindings = {}
5555
self.listeners = {}
5656
self.deps = {}
57+
self.uuid = uuid
58+
self.instance_id = instance_id
5759

5860
self.timeout_id = 0
5961
self.file_monitor_id = 0
@@ -320,6 +322,7 @@ def connect_widget_handlers(self, *args):
320322
def json_settings_factory(subclass):
321323
class NewClass(globals()[subclass], JSONSettingsBackend):
322324
def __init__(self, key, settings, properties):
325+
self.backend = "json"
323326
self.key = key
324327
self.settings = settings
325328

files/usr/share/cinnamon/cinnamon-settings/bin/KeybindingTable.py

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -938,10 +938,20 @@ def reset_bindings(self, keybinding):
938938
keybinding.resetDefaults()
939939
self._proxy_send_kb_changed(keybinding)
940940

941-
def find_keybinding_by_label(self, label):
942-
for cat in self.main_store:
941+
def lookup_gsettings_keybinding(self, schema_id, key):
942+
for cat in self._static_store + self._custom_store:
943+
for keybinding in cat.keybindings:
944+
if keybinding.schema == schema_id and keybinding.key == key:
945+
return keybinding
946+
return None
947+
948+
def lookup_json_keybinding(self, uuid, instance_id, key):
949+
for cat in self._spice_store:
950+
cat_uuid = cat.int_name.split("_")[0]
951+
if cat_uuid != uuid:
952+
continue
943953
for keybinding in cat.keybindings:
944-
if keybinding.label == label:
954+
if instance_id == keybinding.dbus_info["config_id"] and keybinding.key == key:
945955
return keybinding
946956
return None
947957

files/usr/share/cinnamon/cinnamon-settings/bin/SettingsWidgets.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -475,7 +475,12 @@ def __init__(self, label, num_bind=2, size_group=None, dep_key=None, tooltip="")
475475
self.num_bind = num_bind
476476
self.kb_table = KeybindingTable.get_default()
477477
self.kb_label = label
478-
self.keybinding = self.kb_table.find_keybinding_by_label(self.kb_label)
478+
479+
if self.backend == "gsettings":
480+
self.keybinding = self.kb_table.lookup_gsettings_keybinding(self.settings.props.schema_id, self.key)
481+
else:
482+
self.keybinding = self.kb_table.lookup_json_keybinding(self.settings.uuid, self.settings.instance_id, self.key)
483+
479484
self.keybinding.connect("changed", self.on_kb_table_entry_changed)
480485

481486
self.label = SettingsLabel(label)
@@ -535,6 +540,7 @@ def connect_widget_handlers(self, *args):
535540
def g_settings_factory(subclass):
536541
class NewClass(globals()[subclass], PXGSettingsBackend):
537542
def __init__(self, label, schema, key, *args, **kwargs):
543+
self.backend = "gsettings"
538544
self.key = key
539545
if schema not in settings_objects:
540546
settings_objects[schema] = Gio.Settings(schema_id=schema)

files/usr/share/cinnamon/cinnamon-settings/xlet-settings.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -281,8 +281,9 @@ def load_instances(self):
281281
if not instance_exists:
282282
continue
283283

284-
settings = JSONSettingsHandler(os.path.join(path if item in new_items else old_path, item), self.notify_dbus)
285-
settings.instance_id = instance_id
284+
settings = JSONSettingsHandler(
285+
os.path.join(path if item in new_items else old_path, item), self.uuid, instance_id, self.notify_dbus
286+
)
286287
instance_box = Gtk.Box(orientation=Gtk.Orientation.VERTICAL)
287288
self.instance_stack.add_named(instance_box, instance_id)
288289

0 commit comments

Comments
 (0)