summaryrefslogtreecommitdiffstats
path: root/src/inkscape-application.cpp
diff options
context:
space:
mode:
authorTavmjong Bah <tavmjong@free.fr>2019-01-30 14:54:01 +0000
committerTavmjong Bah <tavmjong@free.fr>2019-01-30 14:54:01 +0000
commit7531449fc6f5c3113802747db11a2bca2e308555 (patch)
treeeb1e211ef0f68674f3f929516e00b3a0c288a800 /src/inkscape-application.cpp
parentGradientToolbar: GtkAction migration (diff)
downloadinkscape-7531449fc6f5c3113802747db11a2bca2e308555.tar.gz
inkscape-7531449fc6f5c3113802747db11a2bca2e308555.zip
Allow InkscapeApplication to track current document, selection, and desktop.
Diffstat (limited to 'src/inkscape-application.cpp')
-rw-r--r--src/inkscape-application.cpp23
1 files changed, 15 insertions, 8 deletions
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<class T>
ConcreteInkscapeApplication<T>::ConcreteInkscapeApplication()
@@ -154,13 +161,6 @@ ConcreteInkscapeApplication<T>::ConcreteInkscapeApplication()
T::register_application();
}
-Inkscape::Selection*
-InkscapeApplication::get_active_selection()
-{
- Inkscape::ActionContext context = INKSCAPE.action_context_for_document(_active_document);
- return context.getSelection();
-}
-
template<class T>
void
ConcreteInkscapeApplication<T>::on_startup()
@@ -268,6 +268,7 @@ ConcreteInkscapeApplication<T>::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<T>::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<T>::on_open(const Gio::Application::type_vec_files&
}
_active_document = nullptr;
+ _active_selection = nullptr;
+ _active_view = nullptr;
// Close file
INKSCAPE.remove_document(doc);