diff options
| author | Eric Greveson <eric@greveson.co.uk> | 2013-07-03 19:06:11 +0000 |
|---|---|---|
| committer | Eric Greveson <eric@greveson.co.uk> | 2013-07-03 19:06:11 +0000 |
| commit | 09ce234c1fc367a2607936e6cf106cb24c60e94f (patch) | |
| tree | 72712240ad3e4782ef9c7e07ea44486dd4de77f6 /src/helper | |
| parent | Added error messages when attempting to use verbs requiring GUI in (diff) | |
| download | inkscape-09ce234c1fc367a2607936e6cf106cb24c60e94f.tar.gz inkscape-09ce234c1fc367a2607936e6cf106cb24c60e94f.zip | |
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)
Diffstat (limited to 'src/helper')
| -rw-r--r-- | src/helper/action-context.cpp | 10 | ||||
| -rw-r--r-- | src/helper/action-context.h | 11 | ||||
| -rw-r--r-- | src/helper/action.cpp | 17 | ||||
| -rw-r--r-- | src/helper/action.h | 2 |
4 files changed, 39 insertions, 1 deletions
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<SPDesktop *>(_view); +} + } // namespace Inkscape /* diff --git a/src/helper/action-context.h b/src/helper/action-context.h index de09f94f4..3a7a19112 100644 --- a/src/helper/action-context.h +++ b/src/helper/action-context.h @@ -12,6 +12,7 @@ #ifndef SEEN_INKSCAPE_ACTION_CONTEXT_H #define SEEN_INKSCAPE_ACTION_CONTEXT_H +class SPDesktop; class SPDocument; namespace Inkscape { @@ -30,6 +31,12 @@ class View; Inkscape::UI::View::View. Actions that do require GUI objects should check to see if the relevant pointers are NULL before attempting to use them. + + TODO: we store a UI::View::View* because that's what the actions and verbs + used to take as parameters in their methods. Why is this? They almost + always seemed to cast straight to an SPDesktop* - so shouldn't we actually + be storing an SPDesktop*? Is there a case where a non-SPDesktop + UI::View::View is used by the actions? ActionContext is designed to be copyable, so it may be used with stack storage if required. */ @@ -60,6 +67,10 @@ public: /** Get the view for the action context. May be NULL. Guaranteed to be NULL if running in console mode. */ UI::View::View *getView() const; + + /** Get the desktop for the action context. May be NULL. Guaranteed to be + NULL if running in console mode. */ + SPDesktop *getDesktop() const; }; } // namespace Inkscape diff --git a/src/helper/action.cpp b/src/helper/action.cpp index 107d0179b..28cb40334 100644 --- a/src/helper/action.cpp +++ b/src/helper/action.cpp @@ -16,6 +16,7 @@ #include "debug/simple-event.h" #include "debug/event-tracker.h" #include "ui/view/view.h" +#include "desktop.h" #include "document.h" #include "helper/action.h" @@ -188,7 +189,7 @@ sp_action_get_selection (SPAction *action) } /** - * Return View associated with the action. + * Return View associated with the action, if any. */ Inkscape::UI::View::View * sp_action_get_view (SPAction *action) @@ -197,6 +198,20 @@ sp_action_get_view (SPAction *action) return action->context.getView(); } +/** + * Return Desktop associated with the action, if any. + */ +SPDesktop * +sp_action_get_desktop (SPAction *action) +{ + // 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<SPDesktop *>(sp_action_get_view(action)); +} + /* Local Variables: mode:c++ diff --git a/src/helper/action.h b/src/helper/action.h index 49816e3c9..1f2de87b4 100644 --- a/src/helper/action.h +++ b/src/helper/action.h @@ -25,6 +25,7 @@ struct SPActionClass; #define SP_ACTION_CLASS(o) (G_TYPE_CHECK_CLASS_CAST((o), SP_TYPE_ACTION, SPActionClass)) #define SP_IS_ACTION(o) (G_TYPE_CHECK_INSTANCE_TYPE((o), SP_TYPE_ACTION)) +class SPDesktop; class SPDocument; namespace Inkscape { @@ -78,6 +79,7 @@ void sp_action_set_name(SPAction *action, Glib::ustring const &name); SPDocument *sp_action_get_document(SPAction *action); Inkscape::Selection *sp_action_get_selection(SPAction *action); Inkscape::UI::View::View *sp_action_get_view(SPAction *action); +SPDesktop *sp_action_get_desktop(SPAction *action); #endif |
