From 6fe6a37589cbd6e53bf763879503ace16260e7a2 Mon Sep 17 00:00:00 2001 From: Eric Greveson Date: Mon, 1 Jul 2013 21:09:53 +0100 Subject: Added new files referenced in previous commit message (forgot to add!) (bzr r12387.1.2) --- src/helper/action-context.cpp | 74 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 74 insertions(+) create mode 100644 src/helper/action-context.cpp (limited to 'src/helper/action-context.cpp') diff --git a/src/helper/action-context.cpp b/src/helper/action-context.cpp new file mode 100644 index 000000000..c88086f7f --- /dev/null +++ b/src/helper/action-context.cpp @@ -0,0 +1,74 @@ +/* + * ActionContext implementation. + * + * Author: + * Eric Greveson + * + * Copyright (C) 2013 Eric Greveson + * + * This code is in public domain + */ + +#include "desktop.h" +#include "document.h" +#include "layer-model.h" +#include "selection.h" +#include "helper/action-context.h" +#include "ui/view/view.h" + +namespace Inkscape { + +ActionContext::ActionContext() + : _selection(NULL) + , _view(NULL) +{ +} + +ActionContext::ActionContext(Selection *selection) + : _selection(selection) + , _view(NULL) +{ +} + +ActionContext::ActionContext(UI::View::View *view) + : _selection(NULL) + , _view(view) +{ + SPDesktop *desktop = static_cast(view); + if (desktop) { + _selection = desktop->selection; + } +} + +SPDocument *ActionContext::getDocument() const +{ + if (_selection == NULL) { + return NULL; + } + + // Should be the same as the view's document, if view is non-NULL + return _selection->layerModel()->getDocument(); +} + +Selection *ActionContext::getSelection() const +{ + return _selection; +} + +UI::View::View *ActionContext::getView() const +{ + return _view; +} + +} // namespace Inkscape + +/* + Local Variables: + mode:c++ + c-file-style:"stroustrup" + c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +)) + indent-tabs-mode:nil + fill-column:99 + End: +*/ +// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4 : -- cgit v1.2.3 From 09ce234c1fc367a2607936e6cf106cb24c60e94f Mon Sep 17 00:00:00 2001 From: Eric Greveson Date: Wed, 3 Jul 2013 20:06:11 +0100 Subject: Modified dbus interface so that it works in console mode (--dbus-listen) Modified action context setup so that in console mode, when a document is added to the main inkscape app instance, it gets a selection model and layer model automatically set up for it Made a couple more verbs work in console mode (bzr r12387.1.4) --- src/helper/action-context.cpp | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'src/helper/action-context.cpp') diff --git a/src/helper/action-context.cpp b/src/helper/action-context.cpp index c88086f7f..f211d775d 100644 --- a/src/helper/action-context.cpp +++ b/src/helper/action-context.cpp @@ -60,6 +60,16 @@ UI::View::View *ActionContext::getView() const return _view; } +SPDesktop *ActionContext::getDesktop() const +{ + // TODO: this slightly horrible storage of a UI::View::View*, and + // casting to an SPDesktop*, is only done because that's what was + // already the norm in the Inkscape codebase. This seems wrong. Surely + // we should store an SPDesktop* in the first place? Is there a case + // of actions being carried out on a View that is not an SPDesktop? + return static_cast(_view); +} + } // namespace Inkscape /* -- cgit v1.2.3 From 104efe4e3ecadc975ab76748c66f041abf8ee7b1 Mon Sep 17 00:00:00 2001 From: Eric Greveson Date: Thu, 4 Jul 2013 15:01:44 +0100 Subject: Code readability improvements and licence changes for action-context.* based on merge request code review and feedback (bzr r12387.1.7) --- src/helper/action-context.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/helper/action-context.cpp') diff --git a/src/helper/action-context.cpp b/src/helper/action-context.cpp index f211d775d..d52e43d96 100644 --- a/src/helper/action-context.cpp +++ b/src/helper/action-context.cpp @@ -6,7 +6,7 @@ * * Copyright (C) 2013 Eric Greveson * - * This code is in public domain + * Released under GNU GPL, read the file 'COPYING' for more information */ #include "desktop.h" @@ -47,7 +47,7 @@ SPDocument *ActionContext::getDocument() const } // Should be the same as the view's document, if view is non-NULL - return _selection->layerModel()->getDocument(); + return _selection->layers()->getDocument(); } Selection *ActionContext::getSelection() const -- cgit v1.2.3