From 8c1484da3f3d48ed623faba673afc85f7996ea45 Mon Sep 17 00:00:00 2001 From: Tomas Zigo Date: Fri, 12 Aug 2022 10:46:23 +0200 Subject: [PATCH] Incorporate suggestions --- general/g.gui/main.c | 15 +-------------- gui/wxpython/wxgui.py | 22 +++++++++++----------- 2 files changed, 12 insertions(+), 25 deletions(-) diff --git a/general/g.gui/main.c b/general/g.gui/main.c index c80b27aa408..cf2a0d001a8 100644 --- a/general/g.gui/main.c +++ b/general/g.gui/main.c @@ -26,7 +26,7 @@ int main(int argc, char *argv[]) { - struct Option *type, *rc_file, *recent_files; + struct Option *type, *rc_file; struct Flag *update_ui, *fglaunch, *nolaunch; struct GModule *module; const char *gui_type_env; @@ -66,13 +66,6 @@ int main(int argc, char *argv[]) rc_file->label = _("Name of workspace file to load on start-up"); rc_file->description = _("This is valid only for wxGUI (wxpython)"); - recent_files = G_define_option(); - recent_files->key = "recent_files"; - recent_files->type = TYPE_STRING; - recent_files->options = "main,pyedit"; - recent_files->label = _("wxGUI component name"); - recent_files->description = _("This is valid only for wxGUI (wxpython)"); - fglaunch = G_define_flag(); fglaunch->key = 'f'; fglaunch->label = _("Start GUI in the foreground"); @@ -114,12 +107,6 @@ int main(int argc, char *argv[]) if (access(progname, F_OK) == -1) G_fatal_error(_("Your installation doesn't include GUI, exiting.")); - if (recent_files->answer) { - G_spawn_ex(getenv("GRASS_PYTHON"), getenv("GRASS_PYTHON"), progname, - "--recent_files", recent_files->answer, NULL); - exit(EXIT_SUCCESS); - } - if (fglaunch->answer) { G_message(_("Launching <%s> GUI, please wait..."), type->answer); if (rc_file->answer) { diff --git a/gui/wxpython/wxgui.py b/gui/wxpython/wxgui.py index c40afca73ba..4a619a456d6 100644 --- a/gui/wxpython/wxgui.py +++ b/gui/wxpython/wxgui.py @@ -160,20 +160,18 @@ def process_opt(opts, args): return parsed_args -def print_wxgui_component_recent_files(args): +def print_wxgui_component_recent_files(recent_files): """Print wxGUI component recent files - :param args dict: parsed command-line args + :param str recent_files: app recent files name """ - recent_files_app_name = args.get("r") - if recent_files_app_name: - from gui_core.menu import RecentFilesConfig + from gui_core.menu import RecentFilesConfig - app = wx.App() - config = RecentFilesConfig(appName=recent_files_app_name) - for i in config.GetRecentFiles(): - print(i, file=sys.stderr) - sys.exit(1) + app = wx.App() + config = RecentFilesConfig(appName=recent_files) + for i in config.GetRecentFiles(): + print(i, file=sys.stderr) + sys.exit(1) def main(argv=None): @@ -196,7 +194,9 @@ def main(argv=None): parsed_args = process_opt(opts, args) - print_wxgui_component_recent_files(args=parsed_args) + recent_files = parsed_args.get("r") + if recent_files: + print_wxgui_component_recent_files(recent_files) app = GMApp(workspace=parsed_args.get("w"))