mirror of
https://github.com/aclist/dztui.git
synced 2026-10-30 14:42:54 +01:00
change: use ListStore for combos
This commit is contained in:
1 parent
3857b69b70
commit
f8e62d05a8
1 file changed
+25
-18
@@ -102,13 +102,28 @@ class Options(Gtk.Box):
|
|||||||
Preferences.WINDOW,
|
Preferences.WINDOW,
|
||||||
)
|
)
|
||||||
|
|
||||||
self.client_combo = Gtk.ComboBoxText()
|
# TODO: make this an abstract class
|
||||||
for text in (
|
client_store = Gtk.ListStore(str, str)
|
||||||
options.steam_combo,
|
clients = (
|
||||||
options.flatpak_combo,
|
(
|
||||||
options.flatpak_container_combo,
|
options.steam_combo,
|
||||||
):
|
STEAM_CMD,
|
||||||
self.client_combo.append_text(text)
|
),
|
||||||
|
(
|
||||||
|
options.flatpak_combo,
|
||||||
|
FLATPAK_RUN_CMD,
|
||||||
|
),
|
||||||
|
(
|
||||||
|
options.flatpak_container_combo,
|
||||||
|
FLATPAK_SANDBOX,
|
||||||
|
),
|
||||||
|
)
|
||||||
|
for client in clients:
|
||||||
|
client_store.append(client)
|
||||||
|
self.client_combo = Gtk.ComboBox.new_with_model(client_store) # Text()
|
||||||
|
renderer_text = Gtk.CellRendererText()
|
||||||
|
self.client_combo.pack_start(renderer_text, True)
|
||||||
|
self.client_combo.add_attribute(renderer_text, "text", 0)
|
||||||
self.client_combo.set_active(0)
|
self.client_combo.set_active(0)
|
||||||
self.client_combo.connect("changed", self._on_client_changed)
|
self.client_combo.connect("changed", self._on_client_changed)
|
||||||
|
|
||||||
@@ -342,16 +357,9 @@ class Options(Gtk.Box):
|
|||||||
self.controller.update_config(Preferences.START_TAB, index)
|
self.controller.update_config(Preferences.START_TAB, index)
|
||||||
|
|
||||||
def _on_client_changed(self, combo: Gtk.ComboBoxText) -> None:
|
def _on_client_changed(self, combo: Gtk.ComboBoxText) -> None:
|
||||||
# TODO: use two columns or constants here, not strings
|
_iter = combo.get_active_iter()
|
||||||
client = combo.get_active_text()
|
real_cmd = combo.get_model()[_iter][1]
|
||||||
match client:
|
self.controller.update_config(Preferences.CLIENT, real_cmd)
|
||||||
case "Steam":
|
|
||||||
value = STEAM_CMD
|
|
||||||
case "Flatpak":
|
|
||||||
value = FLATPAK_RUN_CMD
|
|
||||||
case "Flatpak (container)":
|
|
||||||
value = FLATPAK_SANDBOX
|
|
||||||
self.controller.update_config(Preferences.CLIENT, value)
|
|
||||||
|
|
||||||
def _on_radio_toggled(self, button: Gtk.RadioButton, context: Preferences) -> None:
|
def _on_radio_toggled(self, button: Gtk.RadioButton, context: Preferences) -> None:
|
||||||
try:
|
try:
|
||||||
@@ -501,7 +509,6 @@ class Options(Gtk.Box):
|
|||||||
# TODO: not happy with this
|
# TODO: not happy with this
|
||||||
active_combo = query.get_client_index(config["client"])
|
active_combo = query.get_client_index(config["client"])
|
||||||
self.client_combo.set_active(active_combo)
|
self.client_combo.set_active(active_combo)
|
||||||
# active_combo = 0
|
|
||||||
|
|
||||||
start_tab = self.controller.query_config(Preferences.START_TAB)
|
start_tab = self.controller.query_config(Preferences.START_TAB)
|
||||||
self.start_tab_combo.set_active(start_tab)
|
self.start_tab_combo.set_active(start_tab)
|
||||||
|
|||||||
Reference in new issue
Block a user