From 268f2560dbb7c11743e63891b021eb36d799a119 Mon Sep 17 00:00:00 2001 From: Michael Webster Date: Fri, 28 Jun 2024 00:47:10 -0400 Subject: [PATCH] layout editor: Update the disabled list immediately when an action is toggled. Listen for changes to the list also. --- .../nemo_action_layout_editor.py | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/action-layout-editor/nemo_action_layout_editor.py b/action-layout-editor/nemo_action_layout_editor.py index bb94692e5..8bc90f3fa 100644 --- a/action-layout-editor/nemo_action_layout_editor.py +++ b/action-layout-editor/nemo_action_layout_editor.py @@ -152,6 +152,8 @@ def __init__(self, window, builder=None): self.down_button.connect("clicked", self.down_button_clicked) self.nemo_plugin_settings = Gio.Settings(schema_id="org.nemo.plugins") + # Disabled/Enabled may be toggled in nemo preferences directly, keep us in sync. + self.nemo_plugin_settings.connect("changed", self.on_disabled_settings_list_changed) # Icon MenuButton menu = Gtk.Menu() @@ -437,6 +439,23 @@ def get_disabled(model, path, iter, data=None): self.nemo_plugin_settings.set_strv("disabled-actions", disabled) + def on_disabled_settings_list_changed(self, settings, key, data=None): + disabled_actions = self.nemo_plugin_settings.get_strv("disabled-actions") + + def update_disabled(model, path, iter, data=None): + row = model.get_value(iter, ROW_OBJ) + row_uuid = model.get_value(iter, ROW_UUID) + old_enabled = row.enabled + row.enabled = (row_uuid not in disabled_actions) + if old_enabled != row.enabled: + self.model.row_changed(path, iter) + return False + + self.updating_model = True + self.model.foreach(update_disabled) + self.updating_model = False + self.queue_draw() + def serialize_model(self, parent, model): used_uuids = {} result = [] @@ -753,6 +772,7 @@ def on_action_enabled_switch_notify(self, switch, pspec): # The layout file does not track active/inactive actions, # so this shouldn't prompt a layout save. self.selected_row_changed(needs_saved=False) + self.save_disabled_list() # Cell render functions