Ubuntu Pastebin

Paste from muktupavels at Tue, 27 Jun 2017 18:26:57 +0000

Download as text
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
diff --git a/gtweak/tweaks/tweak_group_appearance.py b/gtweak/tweaks/tweak_group_appearance.py
index ccadefc..2d26a6a 100644
--- a/gtweak/tweaks/tweak_group_appearance.py
+++ b/gtweak/tweaks/tweak_group_appearance.py
@@ -35,6 +35,13 @@ from gtweak.widgets import ListBoxTweakGroup, GSettingsSwitchTweak, GSettingsCom
 _shell = GnomeShellFactory().get_shell()
 _shell_loaded = _shell is not None
 
+_metacity_theme = False
+try:
+    GSettingsSetting("org.gnome.metacity.theme")
+    _metacity_theme = True
+except:
+    pass
+
 class GtkThemeSwitcher(GSettingsComboTweak):
     def __init__(self, **options):
         GSettingsComboTweak.__init__(self,
@@ -252,6 +259,31 @@ class ShellThemeTweak(Gtk.Box, Tweak):
         val = combo.get_model().get_value(combo.get_active_iter(), 0)
         self._settings.set_string(ShellThemeTweak.THEME_GSETTINGS_NAME, val)
 
+class MetacityThemeTypeSwitcher(GSettingsComboTweak):
+    def __init__(self, **options):
+        GSettingsComboTweak.__init__(self,
+            _("Type"),
+            "org.gnome.metacity.theme",
+            "type",
+            [("gtk", _("GTK+")), ("metacity", "Metacity")],
+            **options)
+
+class MetacityThemeNameSwitcher(GSettingsComboTweak):
+    def __init__(self, **options):
+        GSettingsComboTweak.__init__(self,
+            _("Name"),
+            "org.gnome.metacity.theme",
+            "name",
+            make_combo_list_with_default(self._get_valid_themes(), ""),
+            **options)
+
+    def _get_valid_themes(self):
+        dirs = ( os.path.join(gtweak.DATA_DIR, "themes"),
+                 os.path.join(GLib.get_user_data_dir(), "themes"),
+                 os.path.join(os.path.expanduser("~"), ".themes"))
+        valid = walk_directories(dirs, lambda d:
+                    os.path.exists(os.path.join(d, "metacity-1")))
+        return valid
 
 TWEAK_GROUPS = [
     ListBoxTweakGroup(_("Appearance"),
@@ -264,5 +296,8 @@ TWEAK_GROUPS = [
         CursorThemeSwitcher(),
         IconThemeSwitcher(),
         ShellThemeTweak(loaded=_shell_loaded),
+        Title(_("Metacity Theme"), "", uid="title-metacity", loaded=_metacity_theme),
+        MetacityThemeTypeSwitcher(loaded=_metacity_theme),
+        MetacityThemeNameSwitcher(loaded=_metacity_theme),
     ),
 ]
Download as text