mirror of
https://github.com/aclist/dztui.git
synced 2026-10-31 07:02:50 +01:00
fix: only save column width on quit
This commit is contained in:
1 parent
167935b963
commit
618ee47e53
2 files changed
+22
-15
No files matched your search
@@ -7,6 +7,8 @@ from pathlib import Path
|
|||||||
from typing import Any, Callable, TYPE_CHECKING
|
from typing import Any, Callable, TYPE_CHECKING
|
||||||
|
|
||||||
import dzgui.api.pefile as PeFile
|
import dzgui.api.pefile as PeFile
|
||||||
|
import dzgui.util._json as JSON # noqa
|
||||||
|
|
||||||
from dzgui.api.probe import test_steam_api, test_bm_api
|
from dzgui.api.probe import test_steam_api, test_bm_api
|
||||||
from dzgui.api.mods import (
|
from dzgui.api.mods import (
|
||||||
get_delimited_mods,
|
get_delimited_mods,
|
||||||
@@ -176,6 +178,26 @@ class Controller:
|
|||||||
self.toggle_config(Preferences.DEBUG)
|
self.toggle_config(Preferences.DEBUG)
|
||||||
|
|
||||||
def save_res_and_quit(self, *args: Any) -> None:
|
def save_res_and_quit(self, *args: Any) -> None:
|
||||||
|
treeview = self.mediator.notebook.servers.get_active_treeview()
|
||||||
|
columns = treeview.get_columns()
|
||||||
|
|
||||||
|
columns_file = self.prefs.paths.columns
|
||||||
|
try:
|
||||||
|
data = JSON.read_json(columns_file)
|
||||||
|
except Exception as e:
|
||||||
|
logger.critical(e)
|
||||||
|
data = {"cols": {}}
|
||||||
|
|
||||||
|
for column in columns:
|
||||||
|
title = column.get_title()
|
||||||
|
size = column.get_width()
|
||||||
|
data["cols"][title] = size
|
||||||
|
|
||||||
|
try:
|
||||||
|
JSON.write_json(data, columns_file)
|
||||||
|
except Exception as e:
|
||||||
|
logger.critical(e)
|
||||||
|
|
||||||
if self.mediator.window.props.is_maximized:
|
if self.mediator.window.props.is_maximized:
|
||||||
Gtk.main_quit()
|
Gtk.main_quit()
|
||||||
return
|
return
|
||||||
|
|||||||
@@ -133,24 +133,9 @@ class ServerTreeView(TreeView):
|
|||||||
"""
|
"""
|
||||||
Propagate width change to other tabs
|
Propagate width change to other tabs
|
||||||
"""
|
"""
|
||||||
# TODO: only update res file on quit
|
|
||||||
title = col.get_title()
|
title = col.get_title()
|
||||||
size = col.get_width()
|
size = col.get_width()
|
||||||
|
|
||||||
prefs = self.controller.get_prefs()
|
|
||||||
columns = prefs.paths.columns
|
|
||||||
try:
|
|
||||||
data = JSON.read_json(columns)
|
|
||||||
data["cols"][title] = size
|
|
||||||
except Exception as e:
|
|
||||||
logger.critical(e)
|
|
||||||
data = {"cols": {title: size}}
|
|
||||||
|
|
||||||
try:
|
|
||||||
JSON.write_json(data, columns)
|
|
||||||
except Exception as e:
|
|
||||||
logger.critical(e)
|
|
||||||
|
|
||||||
# NOTE: get final width after drag action completes
|
# NOTE: get final width after drag action completes
|
||||||
GLib.idle_add(self.controller.propagate_column_width, col)
|
GLib.idle_add(self.controller.propagate_column_width, col)
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user