Skip to content

Commit

Permalink
layout editor: Update the disabled list immediately when an action
Browse files Browse the repository at this point in the history
is toggled.

Listen for changes to the list also.
  • Loading branch information
mtwebster committed Jun 28, 2024
1 parent 2d2b69c commit 268f256
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions action-layout-editor/nemo_action_layout_editor.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down Expand Up @@ -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 = []
Expand Down Expand Up @@ -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

Expand Down

0 comments on commit 268f256

Please sign in to comment.