mirror of
https://github.com/aclist/dztui.git
synced 2026-08-25 17:32:36 +02:00
fix: evaluate str type
This commit is contained in:
parent
38883626f5
commit
e1d84ec7be
@ -31,6 +31,7 @@
|
||||
|
||||
## Fixed
|
||||
- Longstanding issue with left clicks not registering as tree selection changes after spamming keyboard input
|
||||
- Rare segfaults when changing maps (threading)
|
||||
|
||||
## Unreleased
|
||||
- Setup wizard
|
||||
|
||||
@ -72,7 +72,7 @@ class PackedData:
|
||||
def unpack(cls, data: BinaryIO):
|
||||
r = []
|
||||
for key, value in cls.__annotations__.items():
|
||||
if type(value) is str:
|
||||
if value is str:
|
||||
f = data.read(8).rstrip(b"\x00\x00").decode()
|
||||
else:
|
||||
fmt = endian + (value.fmt)
|
||||
|
||||
@ -362,6 +362,7 @@ class Controller(GObject.GObject):
|
||||
self.mediator.notebook.set_page_by_enum(button.opens)
|
||||
|
||||
def dump_api(self) -> None:
|
||||
self.first_iteration = True
|
||||
key = self.query_config(Preferences.STEAM)
|
||||
job = Servers.query_api
|
||||
params = Servers.params
|
||||
@ -390,7 +391,6 @@ class Controller(GObject.GObject):
|
||||
|
||||
# TODO: additional ping column pass, collated
|
||||
parsed = Servers.parse_json(serv)
|
||||
self.first_iteration = True
|
||||
self.new_maps = parsed
|
||||
self.push_data(parsed, FilterMode.INITIAL, success=True)
|
||||
|
||||
@ -795,9 +795,6 @@ class Controller(GObject.GObject):
|
||||
self.set_callback(None, None)
|
||||
self.thread_data_func(func)
|
||||
|
||||
def focus_button_box(self) -> None:
|
||||
self.mediator.right_panel.focus_button_box()
|
||||
|
||||
def get_favorite(self) -> tuple[str, str] | tuple[None, None]:
|
||||
fav = str(self.query_config(Preferences.FAV_LBL))
|
||||
if len(fav) < 1:
|
||||
|
||||
@ -31,6 +31,7 @@
|
||||
|
||||
## Fixed
|
||||
- Longstanding issue with left clicks not registering as tree selection changes after spamming keyboard input
|
||||
- Rare segfaults when changing maps (threading)
|
||||
|
||||
## Unreleased
|
||||
- Setup wizard
|
||||
|
||||
@ -61,10 +61,10 @@ def format_player_count(model: Gtk.TreeModel | None, control: list) -> str:
|
||||
hits = len(model)
|
||||
for row in model:
|
||||
players += row[4]
|
||||
players_pretty = pluralize("players", players)
|
||||
hits_pretty = pluralize("matches", hits)
|
||||
control_total = len(control)
|
||||
status = f"Showing {hits:n}/{control_total:n} {hits_pretty} with {players:n} {players_pretty}"
|
||||
players_pretty = pluralize("players", players)
|
||||
control_pretty = pluralize("matches", control_total)
|
||||
status = f"Showing {hits:n}/{control_total:n} {control_pretty} with {players:n} {players_pretty}"
|
||||
return status
|
||||
|
||||
|
||||
|
||||
@ -231,7 +231,7 @@ class Notebook(ScrollableMixin, Gtk.Notebook): # type: ignore
|
||||
case Gdk.KEY_Right | Gdk.KEY_l:
|
||||
if event.state is Gdk.ModifierType.CONTROL_MASK:
|
||||
return
|
||||
MainController.focus_button_box()
|
||||
MainController.get_emitter().emit("request_button_box_focus")
|
||||
case Gdk.KEY_question:
|
||||
self.toggle_keybindings()
|
||||
|
||||
|
||||
@ -1,4 +1,5 @@
|
||||
import logging
|
||||
from typing import TYPE_CHECKING
|
||||
|
||||
from dzgui.const.enum import ButtonType
|
||||
from dzgui.const.constants import NO_EXPAND, NO_FILL, NO_PADDING
|
||||
@ -10,6 +11,9 @@ from gi.repository import Gtk, Gdk # noqa E402
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from dzgui.controllers.emitter import Emitter
|
||||
|
||||
|
||||
class ContextualButton(Gtk.Button):
|
||||
def __init__(self, label, opens, tooltip, context):
|
||||
@ -34,6 +38,9 @@ class ButtonBox(Gtk.Box):
|
||||
)
|
||||
|
||||
self.controller = controller
|
||||
self.emitter = controller.get_emitter()
|
||||
self.emitter.connect("request_button_box_focus", self._focus_first_button)
|
||||
|
||||
self.buttons = list()
|
||||
self.connect("key-press-event", self._on_keypress)
|
||||
prefs = controller.get_prefs()
|
||||
@ -55,6 +62,9 @@ class ButtonBox(Gtk.Box):
|
||||
button.connect("clicked", self._on_selection_button_clicked)
|
||||
self.pack_start(button, NO_EXPAND, NO_FILL, NO_PADDING)
|
||||
|
||||
def _focus_first_button(self, emitter: "Emitter") -> None:
|
||||
self.buttons[0].grab_focus()
|
||||
|
||||
def _on_selection_button_clicked(self, button: Gtk.Button) -> None:
|
||||
self.controller.open_page_by_button(button)
|
||||
|
||||
|
||||
@ -59,7 +59,6 @@ class ValidatedEntry(Gtk.Entry):
|
||||
|
||||
def mark_valid(self) -> None:
|
||||
self.emit("string_validated", True)
|
||||
self.emitter.emit("widget_changed", self)
|
||||
remove_class(self, self.classname)
|
||||
|
||||
def mark_invalid(self) -> None:
|
||||
|
||||
@ -25,14 +25,13 @@ class RightPanel(Gtk.Box):
|
||||
self.controller.register_widget("right_panel", self)
|
||||
|
||||
emitter = controller.get_emitter()
|
||||
emitter.connect("request_button_box_focus", self.focus_button_box)
|
||||
emitter.connect("servers_loaded", self.toggle_refresh_button)
|
||||
|
||||
self.button_vbox = ButtonBox(controller)
|
||||
self.filters_vbox = FilterPanel(controller)
|
||||
|
||||
self.sel_panel = ModSelectionPanel(controller)
|
||||
|
||||
emitter.connect("servers_loaded", self.toggle_refresh_button)
|
||||
self.refresh_button = RefreshButton(controller)
|
||||
self.keys = KeysButton(controller)
|
||||
|
||||
@ -42,22 +41,15 @@ class RightPanel(Gtk.Box):
|
||||
self.pack_start(self.sel_panel, NO_EXPAND, NO_FILL, NO_PADDING)
|
||||
|
||||
def toggle_refresh_button(self, emitter: "Emitter", context: "ServerTab") -> None:
|
||||
# TODO: when a row is added, make sure "servers_loaded" signal is emitted
|
||||
# TODO: when a row is added to a previously empty table,
|
||||
# make sure "servers_loaded" signal is emitted
|
||||
self.refresh_button.set_sensitive(True)
|
||||
model = self.controller.get_active_treeview().get_model()
|
||||
# NOTE: if saved servers or history are empty, there is nothing to refresh
|
||||
if model is None:
|
||||
if context in (ServerTab.RECENT, ServerTab.SAVED):
|
||||
self.refresh_button.set_sensitive(False)
|
||||
|
||||
# TODO: move to filter panel
|
||||
# def reinit_maps(self, rows: list) -> None:
|
||||
# self.controller.reinit_map_store()
|
||||
# # TODO: communicate with controller
|
||||
# # self.controller.clear_map_store()
|
||||
# # map_store.append(["All maps"])
|
||||
# self.selected = "All maps"
|
||||
# self.filters_vbox.set_unique_maps(rows)
|
||||
|
||||
# TODO: reference
|
||||
# def _on_ping_clicked(self, button: Gtk.Button) -> None:
|
||||
# block_signals()
|
||||
@ -89,6 +81,3 @@ class RightPanel(Gtk.Box):
|
||||
# treeview.wait_dialog.show_all()
|
||||
# thread = threading.Thread(target=_update_pings, args=())
|
||||
# thread.start()
|
||||
|
||||
def focus_button_box(self, emitter: Optional["Emitter"] = None) -> None:
|
||||
self.button_vbox.buttons[0].grab_focus()
|
||||
|
||||
@ -311,8 +311,7 @@ class Options(Gtk.Box):
|
||||
|
||||
def _on_branch_changed(self, combo: Gtk.ComboBoxText) -> None:
|
||||
branch = combo.get_active_text()
|
||||
print("UNIMPLEMENTED")
|
||||
print(branch)
|
||||
print("UNIMPLEMENTED: ", branch)
|
||||
## TODO: needs to trigger download process
|
||||
# self.controller.toggle_branch(branch)
|
||||
# branch = combo.get_active_text().lower()
|
||||
|
||||
Loading…
Reference in New Issue
Block a user