mirror of
https://github.com/aclist/dztui.git
synced 2026-08-26 09:47:36 +02:00
fix: only save column width on quit
This commit is contained in:
parent
167935b963
commit
618ee47e53
@ -7,6 +7,8 @@ from pathlib import Path
|
||||
from typing import Any, Callable, TYPE_CHECKING
|
||||
|
||||
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.mods import (
|
||||
get_delimited_mods,
|
||||
@ -176,6 +178,26 @@ class Controller:
|
||||
self.toggle_config(Preferences.DEBUG)
|
||||
|
||||
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:
|
||||
Gtk.main_quit()
|
||||
return
|
||||
|
||||
@ -133,24 +133,9 @@ class ServerTreeView(TreeView):
|
||||
"""
|
||||
Propagate width change to other tabs
|
||||
"""
|
||||
# TODO: only update res file on quit
|
||||
title = col.get_title()
|
||||
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
|
||||
GLib.idle_add(self.controller.propagate_column_width, col)
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user