diff options
| author | Tavmjong Bah <tavmjong@free.fr> | 2019-01-30 14:54:01 +0000 |
|---|---|---|
| committer | Tavmjong Bah <tavmjong@free.fr> | 2019-01-30 14:54:01 +0000 |
| commit | 7531449fc6f5c3113802747db11a2bca2e308555 (patch) | |
| tree | eb1e211ef0f68674f3f929516e00b3a0c288a800 /src/inkscape-window.cpp | |
| parent | GradientToolbar: GtkAction migration (diff) | |
| download | inkscape-7531449fc6f5c3113802747db11a2bca2e308555.tar.gz inkscape-7531449fc6f5c3113802747db11a2bca2e308555.zip | |
Allow InkscapeApplication to track current document, selection, and desktop.
Diffstat (limited to 'src/inkscape-window.cpp')
| -rw-r--r-- | src/inkscape-window.cpp | 36 |
1 files changed, 32 insertions, 4 deletions
diff --git a/src/inkscape-window.cpp b/src/inkscape-window.cpp index bf2213a88..24718c316 100644 --- a/src/inkscape-window.cpp +++ b/src/inkscape-window.cpp @@ -19,6 +19,7 @@ #include "inkscape.h" // SP_ACTIVE_DESKTOP #include "enums.h" // PREFS_WINDOW_GEOMETRY_NONE #include "shortcuts.h" +#include "inkscape-application.h" #include "object/sp-namedview.h" // TODO Remove need for this! @@ -40,11 +41,11 @@ InkscapeWindow::InkscapeWindow(SPDocument* document) return; } - // Register window with application. Glib::RefPtr<Gio::Application> gio_app = Gio::Application::get_default(); - Glib::RefPtr<Gtk::Application> app = Glib::RefPtr<Gtk::Application>::cast_dynamic(gio_app); - if (app) { - set_application(app); // Same as Gtk::Application::add_window() + Glib::RefPtr<Gtk::Application> gtk_app = Glib::RefPtr<Gtk::Application>::cast_dynamic(gio_app); + _app = Glib::RefPtr<InkscapeApplication>::cast_dynamic(gtk_app); + if (gtk_app) { + set_application(gtk_app); // Same as Gtk::Application::add_window() } else { std::cerr << "InkscapeWindow::InkscapeWindow:: Didn't get app!" << std::endl; } @@ -99,6 +100,19 @@ InkscapeWindow::InkscapeWindow(SPDocument* document) } +// Change a document, leaving desktop/view the same. (Eventually move all code here.) +void +InkscapeWindow::change_document(SPDocument* document) +{ + _document = document; + if (_app) { + _app->set_active_document(_document); + } else { + std::cerr << "Inkscapewindow::change_document: app is nullptr!" << std::endl; + } +} + +// We don't override on_key_press() as it steals key strokes from text tool. bool InkscapeWindow::key_press(GdkEventKey* event) { @@ -106,6 +120,20 @@ InkscapeWindow::key_press(GdkEventKey* event) return sp_shortcut_invoke (shortcut, _desktop); } +bool +InkscapeWindow::on_focus_in_event(GdkEventFocus* event) +{ + if (_app) { + _app->set_active_document(_document); + _app->set_active_view(_desktop); + _app->set_active_selection(_desktop->selection); + } else { + std::cerr << "Inkscapewindow::on_focus_in_event: app is nullptr!" << std::endl; + } + + return true; +} + /* Local Variables: mode:c++ |
