mirror of
https://github.com/aclist/dztui.git
synced 2026-08-26 09:47:36 +02:00
fix: allocate correct grid rows to right panel
This commit is contained in:
parent
b6210e450f
commit
46ade773b3
@ -39,6 +39,7 @@ WEB_BROWSER = "web-browser-symbolic"
|
||||
|
||||
SEPARATOR = "SEPARATOR"
|
||||
|
||||
NO_PADDING = 0
|
||||
NO_EXPAND = False
|
||||
NO_FILL = False
|
||||
EXPAND = True
|
||||
|
||||
@ -19,7 +19,7 @@ from enum import Enum
|
||||
from pathlib import Path
|
||||
|
||||
from dzgui.const.enum import NotebookPage, VAdjustment
|
||||
from dzgui.const.constants import NO_EXPAND, NO_FILL
|
||||
from dzgui.const.constants import NO_EXPAND, NO_FILL, NO_PADDING
|
||||
from dzgui.const.constants import APP_NAME, APP_NAME_LOWER
|
||||
from dzgui.controllers.mc import Controller
|
||||
from dzgui.util import css, strings
|
||||
@ -209,16 +209,16 @@ class OuterWindow(Gtk.Window):
|
||||
self.connect("delete-event", self._on_delete_event)
|
||||
self.connect("key-press-event", self._on_keypress)
|
||||
|
||||
MainController.set_resolution(self)
|
||||
|
||||
self.grid = Grid()
|
||||
self.add(self.grid)
|
||||
|
||||
MainController.set_resolution(self)
|
||||
self.show_all()
|
||||
|
||||
self.grid.right_panel.filters_vbox.set_visible(False)
|
||||
self.grid.right_panel.enable_ping_button(False)
|
||||
self.grid.sel_panel.set_visible(False)
|
||||
# TODO:
|
||||
#self.grid.right_panel.enable_ping_button(False)
|
||||
|
||||
css.load_css()
|
||||
AppNav.grid.notebook.set_page_by_enum(NotebookPage.SERVERS)
|
||||
@ -279,7 +279,7 @@ class ScrollableNote(ScrollableMixin, Gtk.Box):
|
||||
|
||||
class Notebook(ScrollableMixin, Gtk.Notebook):
|
||||
def __init__(self) -> None:
|
||||
super().__init__(show_tabs=False, show_border=False)
|
||||
super().__init__(show_tabs=False)
|
||||
|
||||
AppNav.notebook = self
|
||||
self.prior_page: NotebookPage
|
||||
@ -298,15 +298,13 @@ class Notebook(ScrollableMixin, Gtk.Notebook):
|
||||
self.settings = Options(MainController)
|
||||
|
||||
# TODO: make all treeviews internally scrollable in base class
|
||||
# server and quad tables should have hexpand property set to True
|
||||
# NOTE: server and quad tables should have hexpand property set to True
|
||||
# add all treeviews as page and register them to AppNav and self.indexes
|
||||
# when switching to a treeview, update relevant view and just pop that page
|
||||
# instead of loading/unloading the model each time
|
||||
self.servers = ServerNotebook(MainController)
|
||||
AppNav.servers = self.servers
|
||||
|
||||
self.quad = Gtk.ScrolledWindow()
|
||||
|
||||
self.scroll_mod = Gtk.ScrolledWindow()
|
||||
# TODO: register this table
|
||||
self.quad_table = ModTreeView(MainController)
|
||||
@ -454,12 +452,14 @@ class Notebook(ScrollableMixin, Gtk.Notebook):
|
||||
case NotebookPage.SERVERS:
|
||||
# TODO: consolidate in mc.py
|
||||
AppNav.grid.show_connect_panel()
|
||||
AppNav.grid.show_filter_panel()
|
||||
self.servers.get_active_treeview().grab_focus()
|
||||
MainController.update_server_status()
|
||||
crumbs = self.servers.get_cached_label()
|
||||
MainController.set_crumbs(crumbs)
|
||||
case _:
|
||||
AppNav.grid.hide_connect_panel()
|
||||
AppNav.grid.hide_filter_panel()
|
||||
|
||||
def _on_page_changed(
|
||||
self, notebook: "Notebook", page: Gtk.Widget, page_num: int
|
||||
@ -475,8 +475,12 @@ class Notebook(ScrollableMixin, Gtk.Notebook):
|
||||
|
||||
class Grid(Gtk.Grid):
|
||||
def __init__(self) -> None:
|
||||
super().__init__()
|
||||
self.set_column_homogeneous(True)
|
||||
super().__init__(column_homogeneous=True)
|
||||
|
||||
MAX_ROWS = 3
|
||||
MAX_COLS = 3
|
||||
SINGLE_ROW = 1
|
||||
SINGLE_COL = 1
|
||||
|
||||
self.statusbar = Statusbar(MainController)
|
||||
self.breadcrumbs = Gtk.Label(halign=Gtk.Align.START)
|
||||
@ -487,29 +491,32 @@ class Grid(Gtk.Grid):
|
||||
|
||||
# FIXME: do not pass AppNav to right panel
|
||||
self.right_panel = RightPanel(AppNav, MainController)
|
||||
# TODO: move into right panel
|
||||
self.sel_panel = ModSelectionPanel(MainController)
|
||||
self.right_panel.pack_start(self.sel_panel, NO_EXPAND, NO_FILL, 0)
|
||||
self.right_panel.pack_start(self.sel_panel, NO_EXPAND, NO_FILL, NO_PADDING)
|
||||
|
||||
self.notebook = Notebook()
|
||||
|
||||
self.attach(self.notebook, 0, 0, 3, 1)
|
||||
self.attach_next_to(
|
||||
self.breadcrumbs, self.notebook, Gtk.PositionType.TOP, 3, 1
|
||||
)
|
||||
|
||||
self.conpan = ConnectPanel()
|
||||
self.attach_next_to(
|
||||
self.conpan, self.notebook, Gtk.PositionType.BOTTOM, 3, 1
|
||||
)
|
||||
|
||||
self.attach_next_to(
|
||||
self.statusbar, self.conpan, Gtk.PositionType.BOTTOM, 3, 1
|
||||
)
|
||||
self.attach_next_to(
|
||||
self.right_panel, self.notebook, Gtk.PositionType.RIGHT, 1, 1
|
||||
self.attach(self.notebook, 0, 0, MAX_COLS, 1)
|
||||
|
||||
els = (
|
||||
(self.breadcrumbs, self.notebook, Gtk.PositionType.TOP, MAX_COLS, SINGLE_ROW),
|
||||
(self.conpan, self.notebook, Gtk.PositionType.BOTTOM, MAX_COLS, SINGLE_ROW),
|
||||
(self.statusbar, self.conpan, Gtk.PositionType.BOTTOM, MAX_COLS, SINGLE_ROW),
|
||||
(self.right_panel, self.notebook, Gtk.PositionType.RIGHT, SINGLE_COL, MAX_ROWS),
|
||||
)
|
||||
for el, sibling, pos, h_span, v_span in els:
|
||||
self.attach_next_to(el, sibling, pos, h_span, v_span)
|
||||
|
||||
self.show_all()
|
||||
|
||||
def hide_filter_panel(self) -> None:
|
||||
self.right_panel.filters_vbox.set_visible(False)
|
||||
|
||||
def show_filter_panel(self) -> None:
|
||||
self.right_panel.filters_vbox.set_visible(True)
|
||||
|
||||
def hide_connect_panel(self) -> None:
|
||||
self.conpan.set_visible(False)
|
||||
|
||||
@ -540,11 +547,6 @@ class App(Gtk.Application):
|
||||
)
|
||||
self.win.add_accel_group(accel)
|
||||
|
||||
# FIXME: hacky
|
||||
AppNav.notebook.servers.notebook.next_page()
|
||||
AppNav.notebook.servers.notebook.prev_page()
|
||||
MainController.focus_notebook()
|
||||
|
||||
GLib.unix_signal_add(
|
||||
GLib.PRIORITY_DEFAULT, signal.SIGINT, self._catch_sigint
|
||||
)
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
import logging
|
||||
|
||||
from dzgui.const.enum import ButtonType
|
||||
from dzgui.const.constants import NO_EXPAND, NO_FILL
|
||||
from dzgui.const.constants import NO_EXPAND, NO_FILL, NO_PADDING
|
||||
|
||||
import gi
|
||||
gi.require_version("Gtk", "3.0")
|
||||
@ -20,7 +20,7 @@ class ContextualButton(Gtk.Button):
|
||||
self.opens = opens
|
||||
|
||||
class ButtonBox(Gtk.Box):
|
||||
def __init__(self, controller):
|
||||
def __init__(self, controller) -> None:
|
||||
super().__init__(
|
||||
spacing=6,
|
||||
margin_top=0,
|
||||
@ -43,24 +43,17 @@ class ButtonBox(Gtk.Box):
|
||||
)
|
||||
|
||||
# FIXME: if debug log fails to load, still opens table
|
||||
|
||||
size = (10, 10) if prefs.is_steam_deck else (50, 50)
|
||||
x, y = size
|
||||
button.set_size_request(x, y)
|
||||
|
||||
self.buttons.append(button)
|
||||
button.connect("clicked", self._on_selection_button_clicked)
|
||||
self.pack_start(button, NO_EXPAND, NO_FILL, 0)
|
||||
self.pack_start(button, NO_EXPAND, NO_FILL, NO_PADDING)
|
||||
|
||||
|
||||
def _on_selection_button_clicked(self, button: Gtk.Button) -> None:
|
||||
# # TODO: maybe drop this and just ensure buttons respond correctly
|
||||
self.controller.open_page_by_button(button)
|
||||
# if button.context != ButtonType.HELP:
|
||||
# button.set_sensitive(False)
|
||||
# for b in self.buttons:
|
||||
# if b != button:
|
||||
# b.set_sensitive(True)
|
||||
|
||||
def _walk_buttons(self, increment: int) -> None:
|
||||
for i, button in enumerate(self.buttons):
|
||||
|
||||
@ -8,13 +8,13 @@ from typing import Literal
|
||||
from dzgui.util import strings
|
||||
from dzgui.util.margins import set_surrounding_margins
|
||||
from dzgui.const.enum import FilterMode
|
||||
from dzgui.const.constants import NO_EXPAND, NO_FILL
|
||||
from dzgui.const.constants import NO_EXPAND, NO_FILL, NO_PADDING
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
class FilterPanel(Gtk.Box):
|
||||
def __init__(self, appnav, controller):
|
||||
super().__init__(spacing=6)
|
||||
super().__init__(spacing=6, vexpand=False)
|
||||
|
||||
# TODO: set strings in constants
|
||||
self.default_filters = {
|
||||
@ -71,6 +71,8 @@ class FilterPanel(Gtk.Box):
|
||||
set_surrounding_margins(self, 10)
|
||||
self.set_margin_top(1)
|
||||
|
||||
# TODO: strings
|
||||
# TODO: embolden
|
||||
self.filters_label = Gtk.Label(label="Filters")
|
||||
|
||||
self.keyword_entry = Gtk.Entry()
|
||||
@ -96,15 +98,16 @@ class FilterPanel(Gtk.Box):
|
||||
self.maps_entry.connect("key-press-event", self._on_map_entry_keypress)
|
||||
|
||||
# FIXME: only giving two params to pack_start
|
||||
# cf. EXPAND
|
||||
self.maps_combo.pack_start(renderer_text, True)
|
||||
self.maps_combo.connect("changed", self._on_map_changed)
|
||||
self.maps_combo.connect("key-press-event", self._on_combo_keypress)
|
||||
|
||||
self.pack_start(self.filters_label, NO_EXPAND, NO_FILL, 0)
|
||||
self.pack_start(self.keyword_entry, NO_EXPAND, NO_FILL, 0)
|
||||
self.pack_start(self.maps_combo, NO_EXPAND, NO_FILL, 0)
|
||||
|
||||
self.pack_start(button_grid, NO_EXPAND, NO_FILL, 0)
|
||||
# TODO: consolidate
|
||||
self.pack_start(self.filters_label, NO_EXPAND, NO_FILL, NO_PADDING)
|
||||
self.pack_start(self.keyword_entry, NO_EXPAND, NO_FILL, NO_PADDING)
|
||||
self.pack_start(self.maps_combo, NO_EXPAND, NO_FILL, NO_PADDING)
|
||||
self.pack_start(button_grid, NO_EXPAND, NO_FILL, NO_PADDING)
|
||||
|
||||
def set_unique_maps(self, maps: list) -> None:
|
||||
if len(maps) < 1:
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
from typing import TYPE_CHECKING
|
||||
|
||||
from dzgui.const.enum import ModButton
|
||||
from dzgui.const.constants import NO_EXPAND, FILL
|
||||
from dzgui.const.constants import NO_EXPAND, FILL, NO_PADDING
|
||||
from dzgui.util.strings import mod_panel
|
||||
from dzgui.util.format import embolden
|
||||
|
||||
@ -42,18 +42,18 @@ class ModSelectionPanel(Gtk.Box):
|
||||
for button in buttons:
|
||||
b = EnumeratedModButton(button)
|
||||
b.connect("clicked", self._on_button_clicked)
|
||||
self.main_panel.pack_start(b, NO_EXPAND, FILL, 0)
|
||||
self.main_panel.pack_start(b, NO_EXPAND, FILL, NO_PADDING)
|
||||
|
||||
self.extra_panel = Gtk.Box(orientation=Gtk.Orientation.VERTICAL, spacing=6)
|
||||
for button in (ModButton.SELECT_STALE, ModButton.UNHIGHLIGHT_STALE):
|
||||
b = EnumeratedModButton(button)
|
||||
b.connect("clicked", self._on_button_clicked)
|
||||
b.set_sensitive(False)
|
||||
self.extra_panel.pack_start(b, NO_EXPAND, FILL, 0)
|
||||
self.extra_panel.pack_start(b, NO_EXPAND, FILL, NO_PADDING)
|
||||
|
||||
self.pack_start(self.header, NO_EXPAND, FILL, 0)
|
||||
self.pack_start(self.main_panel, NO_EXPAND, FILL, 0)
|
||||
self.pack_start(self.extra_panel, NO_EXPAND, FILL, 0)
|
||||
self.pack_start(self.header, NO_EXPAND, FILL, NO_PADDING)
|
||||
self.pack_start(self.main_panel, NO_EXPAND, FILL, NO_PADDING)
|
||||
self.pack_start(self.extra_panel, NO_EXPAND, FILL, NO_PADDING)
|
||||
|
||||
def after_colorize(self) -> None:
|
||||
self.controller.unselect_all_mods()
|
||||
|
||||
@ -8,7 +8,7 @@ from dzgui.views.components.filter_panel import FilterPanel
|
||||
from dzgui.views.components.icon import Icon
|
||||
from dzgui.views.components.web_button import RefreshButton
|
||||
# TODO: rename web_button
|
||||
from dzgui.const.constants import NO_EXPAND, NO_FILL, EXPAND, FILL, INPUT_KEYBOARD
|
||||
from dzgui.const.constants import NO_EXPAND, NO_FILL, EXPAND, FILL, INPUT_KEYBOARD, NO_PADDING
|
||||
from dzgui.util import strings
|
||||
|
||||
# TODO: refactor depends on ServerTreeView
|
||||
@ -23,10 +23,6 @@ class RightPanel(Gtk.Box):
|
||||
self.button_vbox = ButtonBox(controller)
|
||||
self.filters_vbox = FilterPanel(appnav, controller)
|
||||
|
||||
for el in self.button_vbox, self.filters_vbox:
|
||||
padding = 0
|
||||
self.pack_start(el, NO_EXPAND, NO_FILL, padding)
|
||||
|
||||
# TODO: more custom button classes
|
||||
self.ping = Gtk.Button(
|
||||
label=strings.ping_servers,
|
||||
@ -70,9 +66,8 @@ class RightPanel(Gtk.Box):
|
||||
self.question.set_image_position(Gtk.PositionType.RIGHT)
|
||||
self.question.connect("clicked", self._on_question_clicked)
|
||||
|
||||
for el in self.ping, self.debug_toggle, self.question, self.refresh_button:
|
||||
padding = 0
|
||||
self.pack_start(el, NO_EXPAND, FILL, padding)
|
||||
for el in self.button_vbox, self.question, self.filters_vbox, self.refresh_button:
|
||||
self.pack_start(el, NO_EXPAND, FILL, NO_PADDING)
|
||||
|
||||
def enable_ping_button(self, state: bool) -> None:
|
||||
self.ping.set_visible(state)
|
||||
|
||||
@ -2,6 +2,7 @@ import gi
|
||||
gi.require_version("Gtk", "3.0")
|
||||
from gi.repository import Gtk, GLib, Gdk, GObject, Pango # noqa
|
||||
|
||||
from dzgui.const.constants import NO_EXPAND, NO_FILL, NO_PADDING
|
||||
from dzgui.const.enum import Popup
|
||||
|
||||
class EntryDialog(GenericDialog):
|
||||
@ -24,14 +25,14 @@ class EntryDialog(GenericDialog):
|
||||
self.user_entry.set_margin_top(0)
|
||||
self.user_entry.set_size_request(250, 0)
|
||||
self.user_entry.set_activates_default(True)
|
||||
self.dialogBox.pack_start(self.user_entry, NO_EXPAND, NO_FILL, 0)
|
||||
self.dialogBox.pack_start(self.user_entry, NO_EXPAND, NO_FILL, NO_PADDING)
|
||||
|
||||
if link:
|
||||
button = Gtk.Button(label=link)
|
||||
button.set_margin_start(60)
|
||||
button.set_margin_end(60)
|
||||
button.connect("clicked", self._on_button_clicked, button_type)
|
||||
self.dialogBox.pack_end(button, NO_EXPAND, NO_FILL, 0)
|
||||
self.dialogBox.pack_end(button, NO_EXPAND, NO_FILL, NO_PADDING)
|
||||
|
||||
self.ok = self.dialog.action_area.get_children()[1]
|
||||
self.ok.set_sensitive(False)
|
||||
|
||||
@ -4,6 +4,7 @@ import gi
|
||||
gi.require_version("Gtk", "3.0")
|
||||
from gi.repository import Gtk, GLib, Gdk, GObject, Pango # noqa
|
||||
|
||||
from dzgui.const.constants import NO_EXPAND, NO_FILL, NO_PADDING
|
||||
from dzgui.util.import strings
|
||||
|
||||
class LanDialog(Gtk.MessageDialog):
|
||||
@ -55,7 +56,7 @@ class LanDialog(Gtk.MessageDialog):
|
||||
self.button_box.add(self.warn_label)
|
||||
|
||||
content = self.get_content_area()
|
||||
content.pack_start(self.button_box, NO_EXPAND, NO_FILL, 0)
|
||||
content.pack_start(self.button_box, NO_EXPAND, NO_FILL, NO_PADDING)
|
||||
content.set_margin_start(30)
|
||||
content.set_margin_end(30)
|
||||
content.show_all()
|
||||
|
||||
@ -2,6 +2,7 @@ import gi
|
||||
gi.require_version("Gtk", "3.0")
|
||||
from gi.repository import Gtk, GLib, Gdk, GObject, Pango # noqa
|
||||
|
||||
from dzgui.const.constants import EXPAND, FILL, NO_PADDING
|
||||
from dzgui.const.enum import Popup
|
||||
|
||||
class ServerDetailsDialog(GenericDialog):
|
||||
@ -57,8 +58,8 @@ class ServerDetailsDialog(GenericDialog):
|
||||
box.add(el)
|
||||
scrollable_message.add(box)
|
||||
|
||||
dialog_box.pack_start(scrollable_tree, EXPAND, FILL, 0)
|
||||
dialog_box.pack_start(scrollable_message, EXPAND, FILL, 0)
|
||||
dialog_box.pack_start(scrollable_tree, EXPAND, FILL, NO_PADDING)
|
||||
dialog_box.pack_start(scrollable_message, EXPAND, FILL, NO_PADDING)
|
||||
|
||||
self.wait_dialog = GenericDialog(strings.details, Popup.WAIT)
|
||||
self.wait_dialog.show_all()
|
||||
|
||||
@ -23,6 +23,7 @@ from dzgui.const.constants import (
|
||||
FLATPAK_SANDBOX,
|
||||
NO_EXPAND,
|
||||
NO_FILL,
|
||||
NO_PADDING,
|
||||
STEAM_CMD,
|
||||
VIEW_CONCEAL,
|
||||
VIEW_REVEAL,
|
||||
@ -91,7 +92,7 @@ class Options(Gtk.Box):
|
||||
self.client_combo.set_active(0)
|
||||
self.client_combo.connect("changed", self._on_client_changed)
|
||||
hbox = Gtk.Box(spacing=5, halign=Gtk.Align.START)
|
||||
hbox.pack_start(self.client_combo, NO_EXPAND, NO_FILL, 0)
|
||||
hbox.pack_start(self.client_combo, NO_EXPAND, NO_FILL, NO_PADDING)
|
||||
|
||||
self.distance_toggle = self.make_binary_radio(
|
||||
strings.options.km, strings.options.mi, Preferences.DIST
|
||||
@ -402,8 +403,8 @@ class Options(Gtk.Box):
|
||||
radio2 = Gtk.RadioButton.new_from_widget(radio1)
|
||||
radio2.set_label(second_option)
|
||||
radio1.connect("toggled", self._on_radio_toggled, context)
|
||||
hbox.pack_start(radio1, NO_EXPAND, NO_FILL, 0)
|
||||
hbox.pack_start(radio2, NO_EXPAND, NO_FILL, 0)
|
||||
hbox.pack_start(radio1, NO_EXPAND, NO_FILL, NO_PADDING)
|
||||
hbox.pack_start(radio2, NO_EXPAND, NO_FILL, NO_PADDING)
|
||||
|
||||
return hbox
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user