Skip to content

Commit a5a4bd8

Browse files
committed
actions: Sort actions consistently.
Actions not affected by a user layout are now sorted overall by filename at runtime. This ensures you see them in this same order in preferences and the layout editor.
1 parent 0512093 commit a5a4bd8

2 files changed

Lines changed: 17 additions & 2 deletions

File tree

action-layout-editor/nemo_action_layout_editor.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
import uuid
1111
import gettext
1212
import locale
13+
from collections import OrderedDict
1314
import subprocess
1415
import os
1516

@@ -481,7 +482,7 @@ def validate_node(self, node):
481482

482483
def load_installed_actions(self):
483484
# Load installed actions from the system
484-
actions = {}
485+
action_list = []
485486

486487
data_dirs = GLib.get_system_data_dirs() + [GLib.get_user_data_dir()]
487488

@@ -497,11 +498,14 @@ def load_installed_actions(self):
497498
kf = GLib.KeyFile()
498499
kf.load_from_file(str(file), GLib.KeyFileFlags.NONE)
499500

500-
actions[uuid] = (file, kf)
501+
action_list.append((uuid, file, kf))
501502
except GLib.Error as e:
502503
print("Error loading action file '%s': %s" % (str(file), e.message))
503504
continue
504505

506+
507+
actions = OrderedDict(sorted((t[0], t[1:]) for t in action_list))
508+
505509
return actions
506510

507511
def fill_model(self, model, parent, items, installed_actions):

src/nemo-action-config-widget.c

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -206,6 +206,15 @@ strip_accel (const gchar *input)
206206
return ret;
207207
}
208208

209+
static gint
210+
sort_actions (gconstpointer a, gconstpointer b)
211+
{
212+
ActionProxy *action_a = (ActionProxy *) a;
213+
ActionProxy *action_b = (ActionProxy *) b;
214+
215+
return g_strcmp0 (action_a->filename, action_b->filename);
216+
}
217+
209218
static void
210219
refresh_widget (NemoActionConfigWidget *widget)
211220
{
@@ -252,6 +261,8 @@ refresh_widget (NemoActionConfigWidget *widget)
252261
gchar **blacklist = g_settings_get_strv (nemo_plugin_preferences,
253262
NEMO_PLUGIN_PREFERENCES_DISABLED_ACTIONS);
254263

264+
widget->actions = g_list_sort (widget->actions, (GCompareFunc) sort_actions);
265+
255266
for (l = widget->actions; l != NULL; l=l->next) {
256267
ActionProxy *proxy = l->data;
257268

0 commit comments

Comments
 (0)