diff options
| author | Tavmjong Bah <tavmjong@free.fr> | 2019-01-13 10:43:16 +0000 |
|---|---|---|
| committer | Tavmjong Bah <tavmjong@free.fr> | 2019-01-13 10:43:16 +0000 |
| commit | daf9901dea9679fd697e417b721652569fb84583 (patch) | |
| tree | 42af0c29c184f4229096b03de4d83e93f4e19636 /src/inkscape-application.cpp | |
| parent | Fix CI (diff) | |
| download | inkscape-daf9901dea9679fd697e417b721652569fb84583.tar.gz inkscape-daf9901dea9679fd697e417b721652569fb84583.zip | |
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.
Diffstat (limited to 'src/inkscape-application.cpp')
| -rw-r--r-- | src/inkscape-application.cpp | 16 |
1 files changed, 12 insertions, 4 deletions
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<class T> ConcreteInkscapeApplication<T>::ConcreteInkscapeApplication() @@ -87,6 +87,7 @@ ConcreteInkscapeApplication<T>::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<T>::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<T>::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<T>::on_handle_local_options(const Glib::RefPtr<Glib: // ================== GUI and Shell ================ if (options->contains("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") || |
