mirror of
https://github.com/aclist/dztui.git
synced 2026-10-31 15:12:48 +01:00
fix: fallback for missing entries in columns file
This commit is contained in:
1 parent
6d7ed80996
commit
ba7a2b7ab4
2 files changed
+12
-5
No files matched your search
@@ -18,15 +18,20 @@ def has_new_config(config: Path) -> bool:
|
|||||||
|
|
||||||
|
|
||||||
def migrate_cols_file(res: Path) -> None:
|
def migrate_cols_file(res: Path) -> None:
|
||||||
# NOTE: dzg.columns.json is API 7 spec
|
# NOTE: filename "dzg.columns.json" is API 7 spec
|
||||||
old_res = Path.home() / LEGACY_COLS_PATH
|
old_res = Path.home() / LEGACY_COLS_PATH
|
||||||
if old_res.is_file():
|
if old_res.is_file():
|
||||||
j = read_json(old_res)
|
j = read_json(old_res)
|
||||||
cols = j["cols"]
|
cols = j["cols"]
|
||||||
|
# NOTE: implies prior conversion
|
||||||
if "View" in cols:
|
if "View" in cols:
|
||||||
return
|
return
|
||||||
cols["View"] = cols.pop("Perspective")
|
# NOTE: user may not have changed these widths in API 6
|
||||||
cols["Max"] = cols.pop("Maximum")
|
try:
|
||||||
|
cols["View"] = cols.pop("Perspective")
|
||||||
|
cols["Max"] = cols.pop("Maximum")
|
||||||
|
except Exception:
|
||||||
|
pass
|
||||||
write_json(j, res)
|
write_json(j, res)
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -72,6 +72,7 @@ class ServerTreeView(ContextMixin, TreeView): # type: ignore
|
|||||||
logger.critical(e)
|
logger.critical(e)
|
||||||
valid_json = False
|
valid_json = False
|
||||||
|
|
||||||
|
# NOTE: reasonable defaults for long columns
|
||||||
width_map = {
|
width_map = {
|
||||||
"Name": 800,
|
"Name": 800,
|
||||||
"Map": 300,
|
"Map": 300,
|
||||||
@@ -96,8 +97,9 @@ class ServerTreeView(ContextMixin, TreeView): # type: ignore
|
|||||||
column.set_fixed_width(saved_size)
|
column.set_fixed_width(saved_size)
|
||||||
column.set_expand(True)
|
column.set_expand(True)
|
||||||
else:
|
else:
|
||||||
w = width_map[column_title]
|
if column_title in width_map:
|
||||||
column.set_fixed_width(w)
|
w = width_map[column_title]
|
||||||
|
column.set_fixed_width(w)
|
||||||
if column_title == "Ping":
|
if column_title == "Ping":
|
||||||
column.set_cell_data_func(renderer, self._get_ping)
|
column.set_cell_data_func(renderer, self._get_ping)
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user