Index: channels/pluginmanager2.py
==================================================================
--- channels/pluginmanager2.py
+++ channels/pluginmanager2.py
@@ -108,15 +108,10 @@
self.add_(gtk.image_new_from_stock("gtk-info", gtk.ICON_SIZE_LARGE_TOOLBAR), "While plugins are generally compatible across releases, newer versions may also require to update the streamtuner2 core setup.")
for i in range(1,10):
self.add_(uikit.label(""))
- # Append to vbox
- def add_(self, w, label=None, markup=0):
- w = uikit.wrap(w=w, label=label, align=10, label_size=400, label_markup=1)
- self.vbox.add(w)
-
# Create button, connect click signal
def button(self, label, stock=None, cb=None):
b = gtk.Button(label, stock=stock)
b.connect("clicked", cb)
return b
@@ -145,10 +140,15 @@
# Readd some filler labels
_ = [self.add_(uikit.label("")) for i in range(1,3)]
+ # Append to vbox
+ def add_(self, w, label=None, markup=0, align=10, label_size=400):
+ w = uikit.wrap(w=w, label=label, align=align, label_size=label_size, label_markup=markup)
+ self.vbox.add(w)
+
# Entry for plugin list
def add_plugin(self, p):
b = self.button("Install", stock="gtk-save", cb=lambda *w:self.install(p))
p = self.update_p(p)
text = "$title, "\
@@ -155,11 +155,11 @@
"version: $version, "\
"type: $type "\
"category: $category\n"\
"$description\n"\
"$extras, view src"
- self.add_(b, safe_format(text, **p), markup=1)
+ self.add_(b, label=safe_format(text, **p), markup=1, align=10, label_size=375)
# Add placeholder fields
def update_p(self, p):
fields = ("status", "priority", "support", "author", "depends")
ADDED contrib/gtk_theme.py
Index: contrib/gtk_theme.py
==================================================================
--- contrib/gtk_theme.py
+++ contrib/gtk_theme.py
@@ -0,0 +1,96 @@
+# api: streamtuner2
+# title: Gtk theme setting
+# description: Gtk theme switching in Streamtuner2. (Beware of crashes!)
+# type: feature
+# category: ui
+# version: 0.2
+# config:
+# { name: theme, type: select, select: "default=default", description: "Theme name" }
+# { name: theme_instant, type: bool, value=0, description: "Activate on the fly." }
+# priority: experimental
+#
+# Brings back the theme switching option - for Gtk2 + Gtk3 now.
+#
+# Note that not all themes can be loaded on the fly. And may hang
+# streamtuner2 even. Most require an application restart still.
+# Which is why this is not a built-in feature anymore.
+#
+# Btw, you could alternatively use GTK2_RC_FILES= or GTK_THEME=
+# environment variables for this.
+
+
+import os
+from config import *
+import uikit
+from compat2and3 import *
+
+
+
+# register a key
+class gtk_theme(object):
+
+ # plugin info
+ module = "gtk_theme"
+ meta = plugin_meta()
+ theme_dirs = [uikit.gtk.rc_get_theme_dir(), conf.dir + "/themes", conf.share + "/themes"]
+
+ # register
+ def __init__(self, parent):
+ self.parent = parent
+ parent.hooks["config_load"].append(self.list_themes)
+ parent.hooks["config_save"].append(self.apply_theme)
+ self.apply_theme(True)
+
+ # gtk.rc_parse() called on configwin.save and ST2 startup
+ def apply_theme(self, now=False):
+ if conf.theme == "default":
+ return
+ # path depends on version
+ if uikit.ver == 2:
+ rc = "gtk-2.0/gtkrc"
+ else:
+ rc = "gtk-3.0/gtk.css"
+
+ # look if theme exists
+ for fn in ["%s/%s/%s" % (dir, conf.theme, rc) for dir in self.theme_dirs]:
+ if not os.path.exists(fn):
+ continue
+ log.GTK_THEME_FILE(fn)
+ # .GTKRC/Gtk2
+ if uikit.ver == 2:
+ uikit.gtk.rc_parse(fn)
+ if now or conf.theme_instant:
+ uikit.gtk.rc_reparse_all()
+ # .CSS/Gtk3
+ elif now or conf.theme_instant:
+ #ctx = uikit.gtk.StyleContext # global
+ ctx = self.parent.win_streamtuner2.get_style_context() # main window
+ screen = uikit.gtk.gdk.Screen.get_default()
+ style = uikit.gtk.CssProvider()
+ style.load_from_file(fn)
+ ctx.add_provider_for_screen(screen, style, uikit.gtk.STYLE_PROVIDER_PRIORITY_APPLICATION)
+
+ # list Gtk themes, append to existing dropdown box
+ def list_themes(self):
+
+ # get ComboBoxText widget (wrapper object)
+ cb = self.parent.widgets["config_theme"]
+ cb.ls.clear()
+
+ # search themes
+ themes = []
+ for dir in self.theme_dirs:
+ if os.path.exists(dir):
+ for fn in os.listdir(dir):
+ if os.path.exists("%s/%s/gtk-%s.0" % (dir, fn, uikit.ver)):
+ themes.append(fn)
+ themes = ["default"] + sorted(themes)
+
+ # add to list
+ for t in themes:
+ cb.ls.append([t, t])
+ if conf.theme in themes:
+ cb.set_default(conf.theme)
+ else:
+ cb.set_default("default")
+
Index: uikit.py
==================================================================
--- uikit.py
+++ uikit.py
@@ -475,12 +475,12 @@
label.set_size_request(size, -1)
return label
# Wrap two widgets in horizontal box
@staticmethod
- def hbox(w1, w2, exr=True):
- b = gtk.HBox(homogeneous=False, spacing=5)
+ def hbox(w1, w2, exr=True, spacing=5):
+ b = gtk.HBox(homogeneous=False, spacing=spacing)
######b.set_property("visible", True)
b.pack_start(w1, expand=not exr, fill=not exr)
b.pack_start(w2, expand=exr, fill=exr)
return b
@@ -491,11 +491,11 @@
if id:
widgetstore[id] = w
if label:
if type(w) is gtk.Entry:
w.set_width_chars(11)
- w = uikit.hbox(w, uikit.label(label, size=label_size, markup=label_markup))
+ w = uikit.hbox(w, uikit.label(label, size=label_size, markup=label_markup), exr=True)
if image:
pix = gtk.image_new_from_pixbuf(uikit.pixbuf(image))
if pix:
w = uikit.hbox(w, pix, exr=False)
if color: