config: create a generic button type
This commit is contained in:
parent
0287e68afb
commit
f704c56ae8
@ -246,10 +246,6 @@ class KlipperScreenConfig:
|
|||||||
def _create_configurable_options(self, screen):
|
def _create_configurable_options(self, screen):
|
||||||
|
|
||||||
self.configurable_options = [
|
self.configurable_options = [
|
||||||
{"language": {
|
|
||||||
"section": "main", "name": _("Language"), "type": None, "value": "system_lang",
|
|
||||||
"callback": screen.change_language, "options": [
|
|
||||||
{"name": _("System") + " " + _("(default)"), "value": "system_lang"}]}},
|
|
||||||
{"theme": {
|
{"theme": {
|
||||||
"section": "main", "name": _("Icon Theme"), "type": "dropdown",
|
"section": "main", "name": _("Icon Theme"), "type": "dropdown",
|
||||||
"tooltip": _("Changes how the interface looks"),
|
"tooltip": _("Changes how the interface looks"),
|
||||||
@ -328,22 +324,24 @@ class KlipperScreenConfig:
|
|||||||
|
|
||||||
self.configurable_options.extend(panel_options)
|
self.configurable_options.extend(panel_options)
|
||||||
|
|
||||||
t_path = os.path.join(klipperscreendir, 'styles')
|
i0 = i1 = i2 = None
|
||||||
themes = [d for d in os.listdir(t_path) if (not os.path.isfile(os.path.join(t_path, d)) and d != "z-bolt")]
|
|
||||||
themes.sort()
|
|
||||||
theme_opt = self.configurable_options[1]['theme']['options']
|
|
||||||
|
|
||||||
for theme in themes:
|
|
||||||
theme_opt.append({"name": theme, "value": theme})
|
|
||||||
|
|
||||||
i1 = i2 = None
|
|
||||||
for i, option in enumerate(self.configurable_options):
|
for i, option in enumerate(self.configurable_options):
|
||||||
if list(option)[0] == "screen_blanking":
|
if list(option)[0] == "theme":
|
||||||
|
i0 = i
|
||||||
|
elif list(option)[0] == "screen_blanking":
|
||||||
i1 = i
|
i1 = i
|
||||||
elif list(option)[0] == "screen_blanking_printing":
|
elif list(option)[0] == "screen_blanking_printing":
|
||||||
i2 = i
|
i2 = i
|
||||||
if i1 and i2:
|
if i0 and i1 and i2:
|
||||||
break
|
break
|
||||||
|
|
||||||
|
t_path = os.path.join(klipperscreendir, 'styles')
|
||||||
|
themes = [d for d in os.listdir(t_path) if (not os.path.isfile(os.path.join(t_path, d)) and d != "z-bolt")]
|
||||||
|
themes.sort()
|
||||||
|
|
||||||
|
for theme in themes:
|
||||||
|
self.configurable_options[i0]['theme']['options'].append({"name": theme, "value": theme})
|
||||||
|
|
||||||
for num in SCREEN_BLANKING_OPTIONS:
|
for num in SCREEN_BLANKING_OPTIONS:
|
||||||
hour = num // 3600
|
hour = num // 3600
|
||||||
minute = num // 60
|
minute = num // 60
|
||||||
|
@ -257,9 +257,10 @@ class ScreenPanel:
|
|||||||
open_menu.set_hexpand(False)
|
open_menu.set_hexpand(False)
|
||||||
open_menu.set_halign(Gtk.Align.END)
|
open_menu.set_halign(Gtk.Align.END)
|
||||||
row_box.add(open_menu)
|
row_box.add(open_menu)
|
||||||
elif option['type'] == "lang":
|
elif option['type'] == "button":
|
||||||
select = self._gtk.Button("load", style="color3")
|
select = self._gtk.Button("load", style="color3")
|
||||||
select.connect("clicked", self._screen.change_language, option['name'])
|
if "callback" in option:
|
||||||
|
select.connect("clicked", option['callback'], option['name'])
|
||||||
select.set_hexpand(False)
|
select.set_hexpand(False)
|
||||||
select.set_halign(Gtk.Align.END)
|
select.set_halign(Gtk.Align.END)
|
||||||
row_box.add(select)
|
row_box.add(select)
|
||||||
|
@ -35,7 +35,8 @@ class Panel(ScreenPanel):
|
|||||||
for lang in self._config.lang_list:
|
for lang in self._config.lang_list:
|
||||||
self.langs[lang] = {
|
self.langs[lang] = {
|
||||||
"name": lang,
|
"name": lang,
|
||||||
"type": "lang",
|
"type": "button",
|
||||||
|
"callback": self._screen.change_language,
|
||||||
}
|
}
|
||||||
self.add_option("lang", self.langs, lang, self.langs[lang])
|
self.add_option("lang", self.langs, lang, self.langs[lang])
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user