From daf9901dea9679fd697e417b721652569fb84583 Mon Sep 17 00:00:00 2001 From: Tavmjong Bah Date: Sun, 13 Jan 2019 11:43:16 +0100 Subject: Allow window to be closed when operating in batch mode. Most verbs require the presence of a GUI even if not really needed. A new option, --batch-process, allows one to force desktop windows to close after processing actions/verbs. Once all verbs are replaced by actions that don't require a GUI, this option can be removed. --- src/inkscape-application.cpp | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) (limited to 'src/inkscape-application.cpp') diff --git a/src/inkscape-application.cpp b/src/inkscape-application.cpp index 0ae28f16c..0310d0af3 100644 --- a/src/inkscape-application.cpp +++ b/src/inkscape-application.cpp @@ -43,7 +43,7 @@ using Inkscape::IO::Resource::UIS; // flags are set. If the open flag is set and the command line not, the all the remainng arguments // after calling on_handle_local_options() are assumed to be filenames. -InkscapeApplication::InkscapeApplication() : _with_gui(true), _use_shell(false) {} +InkscapeApplication::InkscapeApplication() : _with_gui(true), _batch_process(false), _use_shell(false) {} template ConcreteInkscapeApplication::ConcreteInkscapeApplication() @@ -87,6 +87,7 @@ ConcreteInkscapeApplication::ConcreteInkscapeApplication() // Interface this->add_main_option_entry(T::OPTION_TYPE_BOOL, "with-gui", 'g', N_("GUI: With graphical interface."), ""); this->add_main_option_entry(T::OPTION_TYPE_BOOL, "without-gui", 'G', N_("GUI: Console only."), ""); + this->add_main_option_entry(T::OPTION_TYPE_BOOL, "batch-process", '\0', N_("GUI: Close window after processing actions (needed as some verbs require GUI)."), ""); // Open/Import this->add_main_option_entry(T::OPTION_TYPE_INT, "pdf-page", '\0', N_("Open: PDF page to import"), N_("PAGE")); @@ -263,13 +264,19 @@ ConcreteInkscapeApplication::on_open(const Gio::Application::type_vec_files& if (_with_gui) { // Create a window for each file. - create_window(file); + SPDesktop* desktop = create_window(file); // Process each file. for (auto action: _command_line_actions) { Gio::Application::activate_action( action.first, action.second ); } + // Close window after we're done with file. This may not be the best way... + // but we need to rewrite most of the window handling code so do this for now. + if (_batch_process) { + desktop->getToplevel()->hide(); + } + } else { // Open file @@ -461,7 +468,7 @@ ConcreteInkscapeApplication::shell() } } - T::quit(); // Must quit or segfault. + T::quit(); // Must quit or segfault. (Might be fixed by using desktop->getToplevel()->hide() above.); } // Once we don't need to create a window just to process verbs! @@ -539,7 +546,8 @@ ConcreteInkscapeApplication::on_handle_local_options(const Glib::RefPtrcontains("without-gui")) _with_gui = false; if (options->contains("with-gui")) _with_gui = true; - if (options->contains("shell")) _use_shell = true; + if (options->contains("batch-process")) _batch_process = true; + if (options->contains("shell")) _use_shell = true; // Some options should preclude using gui! if (options->contains("query-id") || -- cgit v1.2.3