Skip to content

Commit 7135162

Browse files
committed
cs_themes.py: Separate light/dark/darker themes
and also current vs legacy. Sort themes in a way that Light, Dark, Darker, Legacy themes are shown in separate groups.
1 parent dabf4d3 commit 7135162

File tree

1 file changed

+19
-4
lines changed
  • files/usr/share/cinnamon/cinnamon-settings/modules

1 file changed

+19
-4
lines changed

files/usr/share/cinnamon/cinnamon-settings/modules/cs_themes.py

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -370,11 +370,26 @@ def _on_cinnamon_theme_selected(self, path, theme):
370370
print(detail)
371371
return True
372372

373+
def get_theme_sort_key(self, name):
374+
name = name.lower()
375+
legacy = 0
376+
darker = 0
377+
dark = 0
378+
if "legacy" in name:
379+
legacy = 1
380+
if "darker" in name:
381+
darker = 1
382+
if "dark" in name and "darker" not in name:
383+
dark = 1
384+
name = name.replace("darker", "").replace("dark", "").replace("legacy", "")
385+
name = f"{dark}{darker}{legacy}{name}"
386+
return name
387+
373388
def _load_gtk_themes(self):
374389
""" Only shows themes that have variations for gtk+-3 and gtk+-2 """
375390
dirs = THEME_FOLDERS
376391
valid = walk_directories(dirs, self.filter_func_gtk_dir, return_directories=True)
377-
valid.sort(key=lambda a: a[0].lower())
392+
valid.sort(key=lambda a: self.get_theme_sort_key(a[0]))
378393
res = []
379394
for i in valid:
380395
for j in res:
@@ -413,7 +428,7 @@ def _load_icon_themes(self):
413428
except Exception as e:
414429
print (e)
415430

416-
valid.sort(key=lambda a: a[0].lower())
431+
valid.sort(key=lambda a: self.get_theme_sort_key(a[0]))
417432
res = []
418433
for i in valid:
419434
for j in res:
@@ -428,7 +443,7 @@ def _load_icon_themes(self):
428443
def _load_cursor_themes(self):
429444
dirs = ICON_FOLDERS
430445
valid = walk_directories(dirs, lambda d: os.path.isdir(d) and os.path.exists(os.path.join(d, "cursors")), return_directories=True)
431-
valid.sort(key=lambda a: a[0].lower())
446+
valid.sort(key=lambda a: self.get_theme_sort_key(a[0]))
432447
res = []
433448
for i in valid:
434449
for j in res:
@@ -443,7 +458,7 @@ def _load_cursor_themes(self):
443458
def _load_cinnamon_themes(self):
444459
dirs = THEME_FOLDERS
445460
valid = walk_directories(dirs, lambda d: os.path.exists(os.path.join(d, "cinnamon")), return_directories=True)
446-
valid.sort(key=lambda a: a[0].lower())
461+
valid.sort(key=lambda a: self.get_theme_sort_key(a[0]))
447462
res = []
448463
for i in valid:
449464
for j in res:

0 commit comments

Comments
 (0)