From 7531449fc6f5c3113802747db11a2bca2e308555 Mon Sep 17 00:00:00 2001 From: Tavmjong Bah Date: Wed, 30 Jan 2019 15:54:01 +0100 Subject: Allow InkscapeApplication to track current document, selection, and desktop. --- src/inkscape-application.cpp | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) (limited to 'src/inkscape-application.cpp') diff --git a/src/inkscape-application.cpp b/src/inkscape-application.cpp index cc8d2ca0f..7c36d148d 100644 --- a/src/inkscape-application.cpp +++ b/src/inkscape-application.cpp @@ -43,7 +43,14 @@ 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), _batch_process(false), _use_shell(false) {} +InkscapeApplication::InkscapeApplication() + : _with_gui(true) + , _batch_process(false) + , _use_shell(false) + , _active_document(nullptr) + , _active_selection(nullptr) + , _active_view(nullptr) +{} template ConcreteInkscapeApplication::ConcreteInkscapeApplication() @@ -154,13 +161,6 @@ ConcreteInkscapeApplication::ConcreteInkscapeApplication() T::register_application(); } -Inkscape::Selection* -InkscapeApplication::get_active_selection() -{ - Inkscape::ActionContext context = INKSCAPE.action_context_for_document(_active_document); - return context.getSelection(); -} - template void ConcreteInkscapeApplication::on_startup() @@ -268,6 +268,7 @@ ConcreteInkscapeApplication::on_open(const Gio::Application::type_vec_files& } } else { + // Open file bool cancelled = false; SPDocument *doc = ink_file_open(file, cancelled); @@ -275,6 +276,10 @@ ConcreteInkscapeApplication::on_open(const Gio::Application::type_vec_files& // Add to Inkscape::Application... INKSCAPE.add_document(doc); + // ActionContext should be removed once verbs are gone but we use it for now. + Inkscape::ActionContext context = INKSCAPE.action_context_for_document(doc); + set_active_selection(context.getSelection()); + set_active_view( context.getView() ); doc->ensureUpToDate(); // Or queries don't work! @@ -294,6 +299,8 @@ ConcreteInkscapeApplication::on_open(const Gio::Application::type_vec_files& } _active_document = nullptr; + _active_selection = nullptr; + _active_view = nullptr; // Close file INKSCAPE.remove_document(doc); -- cgit v1.2.3