mirror of
https://github.com/aclist/dztui.git
synced 2026-10-28 13:42:42 +01:00
The old method was checking the active ComboBox string after the Options page was initialized, but before it was actually populated with the real setting. This caused it to always return the string 'Steam' instead of the actual client name.
61 lines
1.8 KiB
Python
61 lines
1.8 KiB
Python
from dzgui.const.constants import ERROR, FLATPAK_RUN_CMD, FLATPAK_SANDBOX, STEAM_CMD
|
|
from dzgui.strings import options
|
|
from dzgui.views.components.box import HBox
|
|
from dzgui.views.components.buttons import Icon
|
|
|
|
|
|
import gi
|
|
|
|
gi.require_version("Gtk", "3.0")
|
|
from gi.repository import Gtk # noqa
|
|
|
|
|
|
class ClientCombo(Gtk.ComboBox):
|
|
def __init__(self) -> None:
|
|
super().__init__()
|
|
|
|
self.client_store = Gtk.ListStore(str, str)
|
|
self.clients = (
|
|
(
|
|
options.steam_combo,
|
|
STEAM_CMD,
|
|
),
|
|
(
|
|
options.flatpak_combo,
|
|
FLATPAK_RUN_CMD,
|
|
),
|
|
(
|
|
options.flatpak_container_combo,
|
|
FLATPAK_SANDBOX,
|
|
),
|
|
)
|
|
for client in self.clients:
|
|
self.client_store.append(client)
|
|
self.set_model(self.client_store)
|
|
renderer_text = Gtk.CellRendererText()
|
|
self.pack_start(renderer_text, True)
|
|
self.add_attribute(renderer_text, "text", 0)
|
|
self.set_active(0)
|
|
|
|
def get_client_human_readable(self, cmd: str) -> str:
|
|
for client in self.clients:
|
|
human, command = client
|
|
if command == cmd:
|
|
return human
|
|
raise TypeError("Not a valid Steam client selection")
|
|
|
|
class ErrorPopover(Gtk.Popover):
|
|
def __init__(self, relative_to: Gtk.Widget, position: Gtk.PositionType) -> None:
|
|
super().__init__(relative_to=relative_to, position=position)
|
|
|
|
self.hbox = HBox()
|
|
self.label = Gtk.Label(label="", margin_start=10, margin_end=10)
|
|
error_icon = Icon(ERROR, margin_start=10)
|
|
self.hbox.extend([error_icon, self.label])
|
|
self.add(self.hbox)
|
|
self.show_all()
|
|
self.popdown()
|
|
|
|
def set_label(self, label: str) -> None:
|
|
self.label.set_label(label)
|