mirror of
https://github.com/NixOS/nixpkgs.git
synced 2024-12-24 22:53:42 +00:00
81 lines
2.9 KiB
Diff
81 lines
2.9 KiB
Diff
From 8e75fe5f1ebd8a140a7306294d2219aea4ac47d2 Mon Sep 17 00:00:00 2001
|
|
From: Jascha Geerds <jascha@jgeerds.name>
|
|
Date: Tue, 19 Sep 2017 03:16:07 +0200
|
|
Subject: [PATCH 2/3] Don't show multiple entries for a single theme
|
|
|
|
---
|
|
gtweak/tweaks/tweak_group_appearance.py | 8 ++++----
|
|
gtweak/utils.py | 16 ++++++++++++++++
|
|
2 files changed, 20 insertions(+), 4 deletions(-)
|
|
|
|
diff --git a/gtweak/tweaks/tweak_group_appearance.py b/gtweak/tweaks/tweak_group_appearance.py
|
|
index 0d12194..8e05077 100644
|
|
--- a/gtweak/tweaks/tweak_group_appearance.py
|
|
+++ b/gtweak/tweaks/tweak_group_appearance.py
|
|
@@ -26,7 +26,7 @@ from gi.repository import Gtk
|
|
from gi.repository import GLib
|
|
|
|
import gtweak
|
|
-from gtweak.utils import walk_directories, make_combo_list_with_default, extract_zip_file, get_resource_dirs
|
|
+from gtweak.utils import walk_directories, make_combo_list_with_default, extract_zip_file, get_resource_dirs, get_unique_resources
|
|
from gtweak.tweakmodel import Tweak
|
|
from gtweak.gshellwrapper import GnomeShellFactory
|
|
from gtweak.gsettings import GSettingsSetting
|
|
@@ -54,7 +54,7 @@ class GtkThemeSwitcher(GSettingsComboTweak):
|
|
os.path.exists(os.path.join(d, "gtk-2.0")) and \
|
|
(os.path.exists(os.path.join(d, "gtk-3.0")) or \
|
|
os.path.exists(os.path.join(d, "gtk-3.{}".format(gtk_ver)))))
|
|
- return valid
|
|
+ return get_unique_resources(valid)
|
|
|
|
class IconThemeSwitcher(GSettingsComboTweak):
|
|
def __init__(self, **options):
|
|
@@ -69,7 +69,7 @@ class IconThemeSwitcher(GSettingsComboTweak):
|
|
valid = walk_directories(get_resource_dirs("icons"), lambda d:
|
|
os.path.isdir(d) and \
|
|
os.path.exists(os.path.join(d, "index.theme")))
|
|
- return valid
|
|
+ return get_unique_resources(valid)
|
|
|
|
class CursorThemeSwitcher(GSettingsComboTweak):
|
|
def __init__(self, **options):
|
|
@@ -84,7 +84,7 @@ class CursorThemeSwitcher(GSettingsComboTweak):
|
|
valid = walk_directories(get_resource_dirs("icons"), lambda d:
|
|
os.path.isdir(d) and \
|
|
os.path.exists(os.path.join(d, "cursors")))
|
|
- return valid
|
|
+ return get_unique_resources(valid)
|
|
|
|
class ShellThemeTweak(Gtk.Box, Tweak):
|
|
|
|
diff --git a/gtweak/utils.py b/gtweak/utils.py
|
|
index 6c60b88..6fd7c6a 100644
|
|
--- a/gtweak/utils.py
|
|
+++ b/gtweak/utils.py
|
|
@@ -134,6 +134,22 @@ def get_resource_dirs(resource):
|
|
|
|
return [dir for dir in dirs if os.path.isdir(dir)]
|
|
|
|
+def get_unique_resources(dirs):
|
|
+ """Filter out duplicated resources.
|
|
+
|
|
+ :param list dirs:
|
|
+ List of resource dirs (e.g. /usr/share/themes/Adwaita)
|
|
+ :return:
|
|
+ List of dirs without duplicated resources
|
|
+ """
|
|
+ unique_dirs = {}
|
|
+ for dir in dirs:
|
|
+ basename = os.path.basename(dir)
|
|
+ if basename not in unique_dirs:
|
|
+ unique_dirs[basename] = dir
|
|
+
|
|
+ return unique_dirs
|
|
+
|
|
@singleton
|
|
class AutostartManager:
|
|
|
|
--
|
|
2.14.1
|
|
|