mirror of
https://github.com/aclist/dztui.git
synced 2026-08-29 11:17:12 +02:00
feat: shrink to fit WIP
This commit is contained in:
parent
2ef51698bd
commit
e49f452ba5
@ -398,13 +398,20 @@ class Grid(Gtk.Grid):
|
|||||||
self.breadcrumbs = Gtk.Label(halign=Gtk.Align.START)
|
self.breadcrumbs = Gtk.Label(halign=Gtk.Align.START)
|
||||||
self.set_breadcrumbs(strings.label_main_menu)
|
self.set_breadcrumbs(strings.label_main_menu)
|
||||||
|
|
||||||
|
self.bu = Gtk.Button(label="Shrink to fit", halign=Gtk.Align.END)
|
||||||
|
self.crumb_box = Gtk.Box(orientation=Gtk.Orientation.HORIZONTAL)
|
||||||
|
self.crumb_box.add(self.breadcrumbs)
|
||||||
|
self.crumb_box.add(self.bu)
|
||||||
|
self.bu.connect("clicked", self._shrink)
|
||||||
|
|
||||||
self.notebook = Notebook()
|
self.notebook = Notebook()
|
||||||
self.conpan = ConnectPanel(MainController)
|
self.conpan = ConnectPanel(MainController)
|
||||||
|
|
||||||
self.attach(self.notebook, 0, 0, MAX_COLS, SINGLE_ROW)
|
self.attach(self.notebook, 0, 0, MAX_COLS, SINGLE_ROW)
|
||||||
|
|
||||||
|
|
||||||
els = (
|
els = (
|
||||||
(self.breadcrumbs, self.notebook, Gtk.PositionType.TOP, MAX_COLS, SINGLE_ROW),
|
(self.crumb_box, self.notebook, Gtk.PositionType.TOP, MAX_COLS, SINGLE_ROW),
|
||||||
(self.conpan, self.notebook, Gtk.PositionType.BOTTOM, 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.statusbar, self.conpan, Gtk.PositionType.BOTTOM, MAX_COLS, SINGLE_ROW),
|
||||||
(self.right_panel, self.notebook, Gtk.PositionType.RIGHT, SINGLE_COL, MAX_ROWS),
|
(self.right_panel, self.notebook, Gtk.PositionType.RIGHT, SINGLE_COL, MAX_ROWS),
|
||||||
@ -414,6 +421,10 @@ class Grid(Gtk.Grid):
|
|||||||
|
|
||||||
self.show_all()
|
self.show_all()
|
||||||
|
|
||||||
|
def _shrink(self, button: Gtk.Button) -> None:
|
||||||
|
tv = MainController.get_active_treeview()
|
||||||
|
tv.shrink_to_fit()
|
||||||
|
|
||||||
def toggle_filter_panel(self, state: bool) -> None:
|
def toggle_filter_panel(self, state: bool) -> None:
|
||||||
self.right_panel.filters_vbox.set_visible(state)
|
self.right_panel.filters_vbox.set_visible(state)
|
||||||
|
|
||||||
|
|||||||
@ -31,15 +31,13 @@ class ServerNotebook(Gtk.ScrolledWindow):
|
|||||||
|
|
||||||
self.browser.set_query_func(self.query_test2)
|
self.browser.set_query_func(self.query_test2)
|
||||||
self.lan.set_query_func(self.query_test)
|
self.lan.set_query_func(self.query_test)
|
||||||
# TODO: set context menu on init
|
|
||||||
|
# TODO: set context menu on init of ServerTreeView?
|
||||||
self.browser.set_context_menu(ContextMenuGroup.SERVER_BROWSER)
|
self.browser.set_context_menu(ContextMenuGroup.SERVER_BROWSER)
|
||||||
self.saved.set_context_menu(ContextMenuGroup.SAVED)
|
self.saved.set_context_menu(ContextMenuGroup.SAVED)
|
||||||
self.recent.set_context_menu(ContextMenuGroup.RECENT)
|
self.recent.set_context_menu(ContextMenuGroup.RECENT)
|
||||||
self.lan.set_context_menu(ContextMenuGroup.SCAN_LAN)
|
self.lan.set_context_menu(ContextMenuGroup.SCAN_LAN)
|
||||||
|
|
||||||
# TODO: set model manager for each tab on init
|
|
||||||
# TODO: add set_ and get_model_manager() methods
|
|
||||||
|
|
||||||
tabs = [
|
tabs = [
|
||||||
(self.browser, server_labels.browser, self.controller.get_server_store),
|
(self.browser, server_labels.browser, self.controller.get_server_store),
|
||||||
(self.saved, server_labels.saved, self.controller.get_saved_store),
|
(self.saved, server_labels.saved, self.controller.get_saved_store),
|
||||||
@ -53,24 +51,9 @@ class ServerNotebook(Gtk.ScrolledWindow):
|
|||||||
pass
|
pass
|
||||||
else:
|
else:
|
||||||
pass
|
pass
|
||||||
#store.append(["BAR", "a", "a", "a", 0, 0, 0, "189.127.165.207:2302", 0, 0, "a", False])
|
|
||||||
#store.append(["BAR", "a", "a", "a", 0, 0, 0, "189.127.165.207:2302", 0, 0, "a", False])
|
|
||||||
#store.append(["BAR", "a", "a", "a", 0, 0, 0, "189.127.165.207:2302", 0, 0, "a", False])
|
|
||||||
#store.append(["BAR", "a", "a", "a", 0, 0, 0, "189.127.165.207:2302", 0, 0, "a", False])
|
|
||||||
#store.append(["BAR", "a", "a", "a", 0, 0, 0, "189.127.165.207:2302", 0, 0, "a", False])
|
|
||||||
#store.append(["BAR", "a", "a", "a", 0, 0, 0, "189.127.165.207:2302", 0, 0, "a", False])
|
|
||||||
#store.append(["BAR", "a", "a", "a", 0, 0, 0, "189.127.165.207:2302", 0, 0, "a", False])
|
|
||||||
#store.append(["BAR", "a", "a", "a", 0, 0, 0, "189.127.165.207:2302", 0, 0, "a", False])
|
|
||||||
#store.append(["BAR", "a", "a", "a", 0, 0, 0, "189.127.165.207:2302", 0, 0, "a", False])
|
|
||||||
#store.append(["BAR", "a", "a", "a", 0, 0, 0, "189.127.165.207:2302", 0, 0, "a", False])
|
|
||||||
#store.append(["BAR", "a", "a", "a", 0, 0, 0, "189.127.165.207:2302", 0, 0, "a", False])
|
|
||||||
#store.append(["BAR", "a", "a", "a", 0, 0, 0, "189.127.165.207:2302", 0, 0, "a", False])
|
|
||||||
#store.append(["BAR", "a", "a", "a", 0, 0, 0, "189.127.165.207:2302", 0, 0, "a", False])
|
|
||||||
#store.append(["BAR", "a", "a", "a", 0, 0, 0, "189.127.165.207:2302", 0, 0, "a", False])
|
|
||||||
#store.append(["BAR", "a", "a", "a", 0, 0, 0, "189.127.165.207:2302", 0, 0, "a", False])
|
|
||||||
#store.append(["BAR", "a", "a", "a", 0, 0, 0, "189.127.165.207:2302", 0, 0, "a", False])
|
|
||||||
#tree.loaded = True
|
|
||||||
# TODO: set model on init of servertreeview
|
# TODO: set model on init of servertreeview
|
||||||
|
# TODO: set model manager for each tab on init
|
||||||
|
# TODO: add set_ and get_model_manager() methods
|
||||||
tree.set_model(store)
|
tree.set_model(store)
|
||||||
|
|
||||||
scrolled = Gtk.ScrolledWindow()
|
scrolled = Gtk.ScrolledWindow()
|
||||||
@ -83,6 +66,8 @@ class ServerNotebook(Gtk.ScrolledWindow):
|
|||||||
self.connect("map", self._on_map)
|
self.connect("map", self._on_map)
|
||||||
self.connect("unmap", self._on_unmap)
|
self.connect("unmap", self._on_unmap)
|
||||||
|
|
||||||
|
self.set_crumbs("Server browser")
|
||||||
|
|
||||||
def _on_map(self, widget: Self) -> None:
|
def _on_map(self, widget: Self) -> None:
|
||||||
self.controller.toggle_server_panels(True)
|
self.controller.toggle_server_panels(True)
|
||||||
|
|
||||||
@ -100,21 +85,24 @@ class ServerNotebook(Gtk.ScrolledWindow):
|
|||||||
return
|
return
|
||||||
self.get_active_treeview().grab_focus()
|
self.get_active_treeview().grab_focus()
|
||||||
|
|
||||||
|
def set_crumbs(self, text: str) -> None:
|
||||||
|
string = f"Servers > {text}"
|
||||||
|
self.controller.set_crumbs(string)
|
||||||
|
self.set_cached_label(string)
|
||||||
|
|
||||||
def _on_page_changed(self, notebook: Gtk.Notebook, child: Gtk.Widget, index: int) -> None:
|
def _on_page_changed(self, notebook: Gtk.Notebook, child: Gtk.Widget, index: int) -> None:
|
||||||
if self.controller.loaded is False:
|
if self.controller.loaded is False:
|
||||||
return
|
return
|
||||||
# TODO: abstract
|
# TODO: abstract
|
||||||
label = self.notebook.get_tab_label_text(child)
|
label = self.notebook.get_tab_label_text(child)
|
||||||
|
|
||||||
if label is None:
|
if label is None:
|
||||||
return
|
return
|
||||||
# TODO: strings
|
# TODO: strings
|
||||||
text = label.strip("*")
|
text = label.strip("*")
|
||||||
self.notebook.set_tab_label_text(child, text)
|
self.notebook.set_tab_label_text(child, text)
|
||||||
|
|
||||||
# TODO: strings
|
self.set_crumbs(text)
|
||||||
string = f"Servers > {text}"
|
|
||||||
self.controller.set_crumbs(string)
|
|
||||||
self.set_cached_label(string)
|
|
||||||
|
|
||||||
self.controller.present_servers()
|
self.controller.present_servers()
|
||||||
self.controller.populate_model()
|
self.controller.populate_model()
|
||||||
|
|||||||
@ -88,6 +88,14 @@ class ServerTreeView(TreeView):
|
|||||||
column.set_fixed_width(800)
|
column.set_fixed_width(800)
|
||||||
if column_title == "Map":
|
if column_title == "Map":
|
||||||
column.set_fixed_width(300)
|
column.set_fixed_width(300)
|
||||||
|
# TODO: standardize widths based on column title and longest content
|
||||||
|
# TODO: resize col width func causes snapping behavior
|
||||||
|
if column_title == "Name":
|
||||||
|
column.set_fixed_width(500)
|
||||||
|
if column_title == "Map":
|
||||||
|
column.set_fixed_width(200)
|
||||||
|
if column_title == "IP":
|
||||||
|
column.set_fixed_width(240)
|
||||||
|
|
||||||
column.connect("notify::fixed-width", self._on_col_width_changed)
|
column.connect("notify::fixed-width", self._on_col_width_changed)
|
||||||
self.append_column(column)
|
self.append_column(column)
|
||||||
@ -104,6 +112,28 @@ class ServerTreeView(TreeView):
|
|||||||
|
|
||||||
GLib.timeout_add(QUEUE_CHECK_DELAY, self._check_result_queue)
|
GLib.timeout_add(QUEUE_CHECK_DELAY, self._check_result_queue)
|
||||||
|
|
||||||
|
def shrink_to_fit(self) -> None:
|
||||||
|
cols = self.get_columns()
|
||||||
|
# TODO: run on only one treeview and propagate results
|
||||||
|
# TODO: does not shrink name, map, ip fields to fit
|
||||||
|
# TODO: col width changed signal is buggy on current treeview
|
||||||
|
for col in cols:
|
||||||
|
title = col.get_title()
|
||||||
|
if title == "Name":
|
||||||
|
continue
|
||||||
|
if title == "Map":
|
||||||
|
continue
|
||||||
|
if title == "IP":
|
||||||
|
continue
|
||||||
|
label = Gtk.Label(title)
|
||||||
|
pango = label.get_layout()
|
||||||
|
size = pango.get_pixel_size()
|
||||||
|
if size.width > 50:
|
||||||
|
width = size.width * 1.30
|
||||||
|
else:
|
||||||
|
width = size.width * 1.65
|
||||||
|
col.set_fixed_width(width)
|
||||||
|
|
||||||
def _on_kb_focus(self, a, b) -> None:
|
def _on_kb_focus(self, a, b) -> None:
|
||||||
self.emit("on_distcalc_started")
|
self.emit("on_distcalc_started")
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user