Here is a patch which makes Gscreen look in the user's local .theme directory for themes as well as in /usr/share/themes.

It also filters out all the directories that do not contain gtk-2.0 themes. Let me know if this could be implemented better or needs more checks than I put in.

This patch is against the 2.7 branch

Thanks,
Moses
diff --git a/src/emc/usr_intf/gscreen/gscreen.py b/src/emc/usr_intf/gscreen/gscreen.py
index df2c440..b1a4aa7 100755
--- a/src/emc/usr_intf/gscreen/gscreen.py
+++ b/src/emc/usr_intf/gscreen/gscreen.py
@@ -75,7 +75,7 @@ except:
 # libdir is the path to Gscreen python files
 # datadir is where the standarad GLADE files are
 # imagedir is for icons
-# themesdir is path to system's GTK2 theme folder
+# themedir is path to system's GTK2 theme folder
 BASE = os.path.abspath(os.path.join(os.path.dirname(sys.argv[0]), ".."))
 libdir = os.path.join(BASE, "lib", "python")
 datadir = os.path.join(BASE, "share", "linuxcnc")
@@ -83,6 +83,7 @@ imagedir = os.path.join(BASE, "share","gscreen","images")
 SKINPATH = os.path.join(BASE, "share","gscreen","skins")
 sys.path.insert(0, libdir)
 themedir = "/usr/share/themes"
+userthemedir = os.path.join(os.path.expanduser("~"), ".themes")
 
 xmlname = os.path.join(datadir,"gscreen.glade")
 xmlname2 = os.path.join(datadir,"gscreen2.glade")
@@ -742,7 +743,7 @@ class Gscreen:
         self.data.show_dtg = self.prefs.getpref('show_dtg', False, bool)
 
     def init_theme_pref(self):
-        self.data.theme_name = self.prefs.getpref('gtk_theme', 'Redmond', str)
+        self.data.theme_name = self.prefs.getpref('gtk_theme', 'Follow System Theme', str)
 
     def init_window_geometry_pref(self):
         self.data.fullscreen1 = self.prefs.getpref('fullscreen1', False, bool)
@@ -960,18 +961,30 @@ class Gscreen:
 
     def init_themes(self):
         # If there are themes then add them to combo box
+        model = self.widgets.theme_choice.get_model()
+        model.clear()
+        model.append(("Follow System Theme",))
+        themes = []
+        if os.path.exists(userthemedir):
+            names = os.listdir(userthemedir)
+            names.sort()
+            for dirs in names:
+                sbdirs = os.listdir(os.path.join(userthemedir, dirs))
+                if 'gtk-2.0' in sbdirs:
+                    themes.append(dirs)
         if os.path.exists(themedir):
-            model = self.widgets.theme_choice.get_model()
-            model.clear()
-            model.append(("Follow System Theme",))
-            temp = 0
             names = os.listdir(themedir)
             names.sort()
-            for search,dirs in enumerate(names):
-                model.append((dirs,))
-                if dirs  == self.data.theme_name:
-                    temp = search+1
-            self.widgets.theme_choice.set_active(temp)
+            for dirs in names:
+                sbdirs = os.listdir(os.path.join(themedir, dirs))
+                if 'gtk-2.0' in sbdirs:
+                    themes.append(dirs)
+        temp = 0
+        for index,theme in enumerate(themes):
+            model.append((theme,))
+            if theme == self.data.theme_name:
+                temp = index+1
+        self.widgets.theme_choice.set_active(temp)
         settings = gtk.settings_get_default()
         if not self.data.theme_name == "Follow System Theme":
             settings.set_string_property("gtk-theme-name", self.data.theme_name, "")
------------------------------------------------------------------------------
Dive into the World of Parallel Programming The Go Parallel Website, sponsored
by Intel and developed in partnership with Slashdot Media, is your hub for all
things parallel software development, from weekly thought leadership blogs to
news, videos, case studies, tutorials and more. Take a look and join the 
conversation now. http://goparallel.sourceforge.net/
_______________________________________________
Emc-developers mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/emc-developers

Reply via email to