817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
|
# Gtk callback to update ListStore when entries get edited
def edited_player_row(self, cell, path, new_text, user_data=None, column=0):
main.config_play[path][column] = new_text
def edited_player_row_2(self, cell, path, new_text, user_data=None):
self.edited_player_row(cell, path, new_text, column=1)
# fill combobox
def combobox_theme(self):
# self.theme.combo_box_new_text()
# find themes
themedirs = (conf.share+"/themes", conf.dir+"/themes", "/usr/share/themes")
themes = ["no theme"]
[[themes.append(e) for e in os.listdir(dir)] for dir in themedirs if os.path.exists(dir)]
__print__(dbg.STAT, themes)
# prepare liststore
store = gtk.ListStore(gobject.TYPE_STRING)
self.theme.set_model(store)
cell = gtk.CellRendererText()
self.theme.pack_start(cell, True)
self.theme.add_attribute(cell, "text", 0)
# add to combobox
for num,themename in enumerate(themes):
store.append([themename])
if conf.theme == themename:
self.theme.set_active(num)
# erase this function, so it only ever gets called once
self.combobox_theme = lambda: None
# retrieve currently selected value
def apply_theme(self):
if self.theme.get_active() >= 0:
conf.theme = self.theme.get_model()[ self.theme.get_active()][0]
main.load_theme()
# add configuration setting definitions from plugins
def add_plugins(self):
for name,meta in channels.module_meta().items():
# add plugin load entry
if name:
cb = gtk.CheckButton(name)
cb.get_children()[0].set_markup("<b>%s</b> <i>(%s)</i> %s\n<small>%s</small>" % (meta["title"], meta["type"], meta.get("version", ""), meta["description"]))
self.add_( "config_plugins_"+name, cb )
# look up individual plugin options, if loaded
if self.channels.get(name) or self.features.get(name):
c = self.channels.get(name) or self.features.get(name)
for opt in c.config:
# default values are already in conf[] dict (now done in conf.add_plugin_defaults)
# display checkbox
if opt["type"] == "boolean":
cb = gtk.CheckButton(opt["description"])
#cb.set_line_wrap(True)
self.add_( "config_"+opt["name"], cb )
# drop down list
elif opt["type"] == "select":
cb = ComboBoxText(opt["select"].split("|")) # custom mygtk widget
self.add_( "config_"+opt["name"], cb, opt["description"] )
# text entry
else:
self.add_( "config_"+opt["name"], gtk.Entry(), opt["description"] )
# spacer
self.add_( "filler_pl_"+name, gtk.HSeparator() )
# Put config widgets into config dialog notebook
def add_(self, id, w, label=None, color=""):
w.set_property("visible", True)
main.widgets[id] = w
if label:
if type(w) is gtk.Entry:
w.set_width_chars(11)
w = self.hbox(w, self.label(label))
if color:
w = mygtk.bg(w, color)
self.plugin_options.pack_start(w)
# Create GtkLabel
def label(self, label):
label = gtk.Label(label)
label.set_property("visible", True)
label.set_line_wrap(True)
label.set_size_request(400, -1)
return label
# Wrap two widgets in vertical box
def hbox(self, w1, w2):
vbox = gtk.HBox(homogeneous=False, spacing=10)
vbox.set_property("visible", True)
vbox.pack_start(w1, expand=False, fill=False)
vbox.pack_start(w2, expand=True, fill=True)
return vbox
# save config
def save(self, widget):
self.save_config(conf.__dict__, "config_")
self.save_config(conf.plugins, "config_plugins_")
self.apply_theme()
conf.save(nice=1)
|
|
<
<
<
<
<
<
<
|
|
<
|
|
<
<
<
|
|
>
<
|
|
|
|
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
|
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
|
# Gtk callback to update ListStore when entries get edited
def edited_player_row(self, cell, path, new_text, user_data=None, column=0):
main.config_play[path][column] = new_text
def edited_player_row_2(self, cell, path, new_text, user_data=None):
self.edited_player_row(cell, path, new_text, column=1)
# list of Gtk themes in dropdown
def combobox_theme(self):
# find themes
themedirs = (conf.share+"/themes", conf.dir+"/themes", "/usr/share/themes")
themes = ["no theme"]
[[themes.append(e) for e in os.listdir(dir)] for dir in themedirs if os.path.exists(dir)]
__print__(dbg.STAT, themes)
# add dropdown
main.widgets["theme"] = ComboBoxText(themes)
self.theme_cb_placeholder.pack_start(self.theme)
self.theme_cb_placeholder.pack_end(mygtk.label(""))
# retrieve currently selected value
def apply_theme(self):
conf.theme = self.theme.get_active_text()
main.load_theme()
# add configuration setting definitions from plugins
def add_plugins(self):
for name,meta in channels.module_meta().items():
# add plugin load entry
if name:
cb = gtk.CheckButton(name)
cb.get_children()[0].set_markup("<b>%s</b> <i>(%s)</i> %s\n<small>%s</small>" % (meta["title"], meta["type"], meta.get("version", ""), meta["description"]))
self.add_( "config_plugins_"+name, cb )
# look up individual plugin options, if loaded
if self.channels.get(name) or self.features.get(name):
c = self.channels.get(name) or self.features.get(name)
for opt in c.config:
# default values are already in conf[] dict (now done in conf.add_plugin_defaults)
color = opt.get("color", None)
# display checkbox
if opt["type"] == "boolean":
cb = gtk.CheckButton(opt["description"])
self.add_( "config_"+opt["name"], cb, color=color )
# drop down list
elif opt["type"] == "select":
cb = ComboBoxText(opt["select"].split("|")) # custom mygtk widget
self.add_( "config_"+opt["name"], cb, opt["description"], color )
# text entry
else:
self.add_( "config_"+opt["name"], gtk.Entry(), opt["description"], color )
# spacer
self.add_( "filler_pl_"+name, gtk.HSeparator() )
# Put config widgets into config dialog notebook
def add_(self, id, w, label=None, color=""):
w.set_property("visible", True)
main.widgets[id] = w
if label:
if type(w) is gtk.Entry:
w.set_width_chars(11)
w = mygtk.hbox(w, mygtk.label(label))
if color:
w = mygtk.bg(w, color)
self.plugin_options.pack_start(w)
# save config
def save(self, widget):
self.save_config(conf.__dict__, "config_")
self.save_config(conf.plugins, "config_plugins_")
self.apply_theme()
conf.save(nice=1)
|