mirror of
https://github.com/aclist/dztui.git
synced 2026-11-21 17:09:30 +01:00
Compare commits
2
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
5423d9ad56 | ||
|
|
1aed045149 |
No files matched your search
+4
-2
@@ -207,7 +207,8 @@ class RowType(Enum):
|
|||||||
CHANGELOG = RowMeta(rows.changelog_label, rows.changelog_status)
|
CHANGELOG = RowMeta(rows.changelog_label, rows.changelog_status)
|
||||||
SHOW_LOG = RowMeta(rows.log_label, rows.log_status)
|
SHOW_LOG = RowMeta(rows.log_label, rows.log_status)
|
||||||
SEPARATOR = RowMeta(rows.separator_label, rows.separator_status)
|
SEPARATOR = RowMeta(rows.separator_label, rows.separator_status)
|
||||||
DUMP_LOG = RowMeta(rows.system_log_label, rows.system_log_status)
|
DUMP_DIAGNOSTIC = RowMeta(rows.system_log_label, rows.system_log_status)
|
||||||
|
DUMP_DEBUG = RowMeta(rows.debug_log_label, rows.debug_log_status)
|
||||||
DOCS = RowMeta(rows.docs_label, rows.docs_status)
|
DOCS = RowMeta(rows.docs_label, rows.docs_status)
|
||||||
DOCS_FALLBACK = RowMeta(rows.docs_fallback_label, rows.docs_fallback_status)
|
DOCS_FALLBACK = RowMeta(rows.docs_fallback_label, rows.docs_fallback_status)
|
||||||
BUGS = RowMeta(rows.bugs_label, rows.bugs_status)
|
BUGS = RowMeta(rows.bugs_label, rows.bugs_status)
|
||||||
@@ -302,7 +303,8 @@ class ButtonType(Enum):
|
|||||||
HELP_MENU_ROWS = (
|
HELP_MENU_ROWS = (
|
||||||
RowType.CHANGELOG,
|
RowType.CHANGELOG,
|
||||||
RowType.SHOW_LOG,
|
RowType.SHOW_LOG,
|
||||||
RowType.DUMP_LOG,
|
RowType.DUMP_DIAGNOSTIC,
|
||||||
|
RowType.DUMP_DEBUG,
|
||||||
RowType.SEPARATOR,
|
RowType.SEPARATOR,
|
||||||
RowType.DOCS,
|
RowType.DOCS,
|
||||||
RowType.DOCS_FALLBACK,
|
RowType.DOCS_FALLBACK,
|
||||||
|
|||||||
+24
-9
@@ -2,6 +2,7 @@ import gi
|
|||||||
import logging
|
import logging
|
||||||
import threading
|
import threading
|
||||||
|
|
||||||
|
from pathlib import Path
|
||||||
from typing import Any, TYPE_CHECKING, Union
|
from typing import Any, TYPE_CHECKING, Union
|
||||||
|
|
||||||
from dzgui.config.userprefs import UserPrefs
|
from dzgui.config.userprefs import UserPrefs
|
||||||
@@ -23,7 +24,7 @@ from dzgui.model.servers import ServerModelManager
|
|||||||
from dzgui.util.diag import write_diagnostic
|
from dzgui.util.diag import write_diagnostic
|
||||||
from dzgui.util.format import format_exception, format_player_count
|
from dzgui.util.format import format_exception, format_player_count
|
||||||
from dzgui.util.open_links import open_user_workshop, open_workshop_page
|
from dzgui.util.open_links import open_user_workshop, open_workshop_page
|
||||||
from dzgui.views.dialogs.filepicker import FilePicker
|
from dzgui.views.dialogs.filepicker import DebugLogPicker, DiagnosticLogPicker
|
||||||
from dzgui.views.dialogs.generic import ExceptionDialog
|
from dzgui.views.dialogs.generic import ExceptionDialog
|
||||||
|
|
||||||
gi.require_version("Gtk", "3.0")
|
gi.require_version("Gtk", "3.0")
|
||||||
@@ -297,15 +298,29 @@ class Controller(GObject.GObject):
|
|||||||
return self.get_active_treeview().get_filter_man()
|
return self.get_active_treeview().get_filter_man()
|
||||||
|
|
||||||
def dump_diagnostics(self) -> None:
|
def dump_diagnostics(self) -> None:
|
||||||
picker = FilePicker(self.mediator.window)
|
picker = DiagnosticLogPicker(self.mediator.window)
|
||||||
file = picker.pick_file()
|
file = picker.pick_file()
|
||||||
if file is not None:
|
if file is None:
|
||||||
try:
|
return
|
||||||
write_diagnostic(self.prefs.paths.config, file)
|
try:
|
||||||
except Exception as e:
|
write_diagnostic(self.prefs.paths.config, file)
|
||||||
dialog = ExceptionDialog(self, str(e))
|
except Exception as e:
|
||||||
dialog.show_all()
|
dialog = ExceptionDialog(self, str(e))
|
||||||
dialog.run() # type: ignore[no-untyped-call]
|
dialog.show_all()
|
||||||
|
dialog.run() # type: ignore[no-untyped-call]
|
||||||
|
|
||||||
|
def dump_log(self) -> None:
|
||||||
|
picker = DebugLogPicker(self.mediator.window)
|
||||||
|
file = picker.pick_file()
|
||||||
|
if file is None:
|
||||||
|
return
|
||||||
|
try:
|
||||||
|
log = self.prefs.paths.debug.read_text()
|
||||||
|
Path(file).write_text(log)
|
||||||
|
except Exception as e:
|
||||||
|
dialog = ExceptionDialog(self, str(e))
|
||||||
|
dialog.show_all()
|
||||||
|
dialog.run() # type: ignore[no-untyped-call]
|
||||||
|
|
||||||
def update_steam_api_key(self, text: str) -> None:
|
def update_steam_api_key(self, text: str) -> None:
|
||||||
self.config_man.update_steam_api_key(text)
|
self.config_man.update_steam_api_key(text)
|
||||||
|
|||||||
@@ -0,0 +1,2 @@
|
|||||||
|
debug_picker_title = "Save the debug log to a file"
|
||||||
|
diagnostic_picker_title = "Save system diagnostics to a file"
|
||||||
@@ -7,9 +7,12 @@ log_status = "Read the DZGUI log generated since startup"
|
|||||||
separator_label = "SEPARATOR"
|
separator_label = "SEPARATOR"
|
||||||
separator_status = ""
|
separator_status = ""
|
||||||
|
|
||||||
system_log_label = "Output system info to log file"
|
system_log_label = "Output system info to a file"
|
||||||
system_log_status = "Dump diagnostic data for troubleshooting"
|
system_log_status = "Dump diagnostic data for troubleshooting"
|
||||||
|
|
||||||
|
debug_log_label = "Output debug log to a file"
|
||||||
|
debug_log_status = "Dump a summary of errors/events since DZGUI started"
|
||||||
|
|
||||||
docs_label = "Documentation/help files (GitHub) ⧉"
|
docs_label = "Documentation/help files (GitHub) ⧉"
|
||||||
docs_status = "Open the DZGUI documentation in a browser"
|
docs_status = "Open the DZGUI documentation in a browser"
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
|
|
||||||
from dzgui.util.strings import picker
|
from dzgui.const.constants import DEBUG_LOG, SYSTEM_LOG
|
||||||
|
from dzgui.strings.filepickers import diagnostic_picker_title, debug_picker_title
|
||||||
|
|
||||||
import gi
|
import gi
|
||||||
|
|
||||||
@@ -9,9 +10,9 @@ from gi.repository import Gtk
|
|||||||
|
|
||||||
|
|
||||||
class FilePicker(Gtk.FileChooserDialog):
|
class FilePicker(Gtk.FileChooserDialog):
|
||||||
def __init__(self, parent: Gtk.Window) -> None:
|
def __init__(self, parent: Gtk.Window, title: str, placeholder: str) -> None:
|
||||||
super().__init__(
|
super().__init__(
|
||||||
title=picker.title,
|
title=title,
|
||||||
action=Gtk.FileChooserAction.SAVE,
|
action=Gtk.FileChooserAction.SAVE,
|
||||||
transient_for=parent,
|
transient_for=parent,
|
||||||
resizable=True,
|
resizable=True,
|
||||||
@@ -20,7 +21,7 @@ class FilePicker(Gtk.FileChooserDialog):
|
|||||||
self.add_buttons("_Save", Gtk.ResponseType.OK) # type: ignore[no-untyped-call]
|
self.add_buttons("_Save", Gtk.ResponseType.OK) # type: ignore[no-untyped-call]
|
||||||
self.set_default_response(Gtk.ResponseType.OK)
|
self.set_default_response(Gtk.ResponseType.OK)
|
||||||
|
|
||||||
self.set_current_name(picker.placeholder)
|
self.set_current_name(placeholder)
|
||||||
|
|
||||||
def pick_file(self) -> Path | None:
|
def pick_file(self) -> Path | None:
|
||||||
res = self.run() # type: ignore[no-untyped-call]
|
res = self.run() # type: ignore[no-untyped-call]
|
||||||
@@ -35,6 +36,16 @@ class FilePicker(Gtk.FileChooserDialog):
|
|||||||
return None
|
return None
|
||||||
|
|
||||||
|
|
||||||
|
class DiagnosticLogPicker(FilePicker):
|
||||||
|
def __init__(self, parent: Gtk.Window) -> None:
|
||||||
|
super().__init__(parent, diagnostic_picker_title, SYSTEM_LOG)
|
||||||
|
|
||||||
|
|
||||||
|
class DebugLogPicker(FilePicker):
|
||||||
|
def __init__(self, parent: Gtk.Window) -> None:
|
||||||
|
super().__init__(parent, debug_picker_title, DEBUG_LOG)
|
||||||
|
|
||||||
|
|
||||||
class FolderPicker(Gtk.FileChooserDialog):
|
class FolderPicker(Gtk.FileChooserDialog):
|
||||||
def __init__(self, parent: Gtk.Window, title: str) -> None:
|
def __init__(self, parent: Gtk.Window, title: str) -> None:
|
||||||
super().__init__(
|
super().__init__(
|
||||||
|
|||||||
@@ -56,19 +56,18 @@ class MenuTreeView(TreeView):
|
|||||||
self.controller.populate_log()
|
self.controller.populate_log()
|
||||||
case RowType.CHANGELOG:
|
case RowType.CHANGELOG:
|
||||||
self.controller.open_page(NotebookPage.CHANGELOG)
|
self.controller.open_page(NotebookPage.CHANGELOG)
|
||||||
case RowType.DUMP_LOG:
|
case RowType.DUMP_DIAGNOSTIC:
|
||||||
self.controller.dump_diagnostics()
|
self.controller.dump_diagnostics()
|
||||||
pass
|
case RowType.DUMP_DEBUG:
|
||||||
|
self.controller.dump_log()
|
||||||
docs = [
|
case (
|
||||||
RowType.DOCS,
|
RowType.DOCS
|
||||||
RowType.DOCS_FALLBACK,
|
| RowType.DOCS_FALLBACK
|
||||||
RowType.BUGS,
|
| RowType.BUGS
|
||||||
RowType.FORUM,
|
| RowType.FORUM
|
||||||
RowType.SPONSOR,
|
| RowType.SPONSOR
|
||||||
]
|
):
|
||||||
if row_type in docs:
|
open_link_by_rowtype(row_type)
|
||||||
open_link_by_rowtype(row_type)
|
|
||||||
|
|
||||||
def get_row_enum(self) -> str:
|
def get_row_enum(self) -> str:
|
||||||
# NOTE: col 1 contains a RowType enum
|
# NOTE: col 1 contains a RowType enum
|
||||||
|
|||||||
Reference in new issue
Block a user