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):
|
||||
|
||||
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": {
|
||||
"section": "main", "name": _("Icon Theme"), "type": "dropdown",
|
||||
"tooltip": _("Changes how the interface looks"),
|
||||
@ -328,22 +324,24 @@ class KlipperScreenConfig:
|
||||
|
||||
self.configurable_options.extend(panel_options)
|
||||
|
||||
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()
|
||||
theme_opt = self.configurable_options[1]['theme']['options']
|
||||
|
||||
for theme in themes:
|
||||
theme_opt.append({"name": theme, "value": theme})
|
||||
|
||||
i1 = i2 = None
|
||||
i0 = i1 = i2 = None
|
||||
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
|
||||
elif list(option)[0] == "screen_blanking_printing":
|
||||
i2 = i
|
||||
if i1 and i2:
|
||||
if i0 and i1 and i2:
|
||||
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:
|
||||
hour = num // 3600
|
||||
minute = num // 60
|
||||
|
@ -257,9 +257,10 @@ class ScreenPanel:
|
||||
open_menu.set_hexpand(False)
|
||||
open_menu.set_halign(Gtk.Align.END)
|
||||
row_box.add(open_menu)
|
||||
elif option['type'] == "lang":
|
||||
elif option['type'] == "button":
|
||||
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_halign(Gtk.Align.END)
|
||||
row_box.add(select)
|
||||
|
@ -35,7 +35,8 @@ class Panel(ScreenPanel):
|
||||
for lang in self._config.lang_list:
|
||||
self.langs[lang] = {
|
||||
"name": lang,
|
||||
"type": "lang",
|
||||
"type": "button",
|
||||
"callback": self._screen.change_language,
|
||||
}
|
||||
self.add_option("lang", self.langs, lang, self.langs[lang])
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user