summaryrefslogtreecommitdiffstats
path: root/src/helper/action.cpp
diff options
context:
space:
mode:
authorEric Greveson <eric@greveson.co.uk>2013-07-01 20:04:32 +0000
committerEric Greveson <eric@greveson.co.uk>2013-07-01 20:04:32 +0000
commitc3a160589a9cb41c70a56e5e7b66a65857a0d10e (patch)
tree46860c161eda2e11687aff38141e04b40185798b /src/helper/action.cpp
parentCorrectly ignore symbolic link to ltmain.sh (diff)
downloadinkscape-c3a160589a9cb41c70a56e5e7b66a65857a0d10e.tar.gz
inkscape-c3a160589a9cb41c70a56e5e7b66a65857a0d10e.zip
Factored layer model out into new Inkscape::LayerModel class. This allows
Inkscape::Selection to use a LayerModel that is not associated with a UI. Changed the interface of verbs (SPAction) to use a new ActionContext rather than UI::View::View, again so that verbs may be used in a console mode. Modified boolean operation verbs to work in console-only mode. Fixed up DESKTOP_IS_ACTIVE macro to work in the case of no desktops. Modified main.cpp to process selections and verbs in no-GUI mode. Other changes are all consequences of the SPDesktop, Selection and LayerModel interface changes. (bzr r12387.1.1)
Diffstat (limited to 'src/helper/action.cpp')
-rw-r--r--src/helper/action.cpp36
1 files changed, 27 insertions, 9 deletions
diff --git a/src/helper/action.cpp b/src/helper/action.cpp
index 0e9957ca3..107d0179b 100644
--- a/src/helper/action.cpp
+++ b/src/helper/action.cpp
@@ -41,7 +41,7 @@ sp_action_init (SPAction *action)
{
action->sensitive = 0;
action->active = 0;
- action->view = NULL;
+ action->context = Inkscape::ActionContext();
action->id = action->name = action->tip = NULL;
action->image = NULL;
@@ -76,7 +76,7 @@ sp_action_finalize (GObject *object)
* Create new SPAction object and set its properties.
*/
SPAction *
-sp_action_new(Inkscape::UI::View::View *view,
+sp_action_new(Inkscape::ActionContext const &context,
const gchar *id,
const gchar *name,
const gchar *tip,
@@ -85,7 +85,7 @@ sp_action_new(Inkscape::UI::View::View *view,
{
SPAction *action = (SPAction *)g_object_new(SP_TYPE_ACTION, NULL);
- action->view = view;
+ action->context = context;
action->sensitive = TRUE;
action->id = g_strdup (id);
action->name = g_strdup (name);
@@ -111,11 +111,9 @@ public:
: ActionEventBase(share_static_string("action"))
{
_addProperty(share_static_string("timestamp"), timestamp());
- if (action->view) {
- SPDocument *document = action->view->doc();
- if (document) {
- _addProperty(share_static_string("document"), document->serial());
- }
+ SPDocument *document = action->context.getDocument();
+ if (document) {
+ _addProperty(share_static_string("document"), document->serial());
}
_addProperty(share_static_string("verb"), action->id);
}
@@ -170,13 +168,33 @@ sp_action_set_name (SPAction *action, Glib::ustring const &name)
}
/**
+ * Return Document associated with the action.
+ */
+SPDocument *
+sp_action_get_document (SPAction *action)
+{
+ g_return_val_if_fail (SP_IS_ACTION (action), NULL);
+ return action->context.getDocument();
+}
+
+/**
+ * Return Selection associated with the action
+ */
+Inkscape::Selection *
+sp_action_get_selection (SPAction *action)
+{
+ g_return_val_if_fail (SP_IS_ACTION (action), NULL);
+ return action->context.getSelection();
+}
+
+/**
* Return View associated with the action.
*/
Inkscape::UI::View::View *
sp_action_get_view (SPAction *action)
{
g_return_val_if_fail (SP_IS_ACTION (action), NULL);
- return action->view;
+ return action->context.getView();
}
/*