summaryrefslogtreecommitdiffstats
path: root/src/helper
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
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')
-rw-r--r--src/helper/CMakeLists.txt2
-rw-r--r--src/helper/Makefile_insert2
-rw-r--r--src/helper/action.cpp36
-rw-r--r--src/helper/action.h11
4 files changed, 40 insertions, 11 deletions
diff --git a/src/helper/CMakeLists.txt b/src/helper/CMakeLists.txt
index f709c7386..2e1e724f5 100644
--- a/src/helper/CMakeLists.txt
+++ b/src/helper/CMakeLists.txt
@@ -10,6 +10,7 @@ set(sp_marshal_SRC
set(helper_SRC
action.cpp
+ action-context.cpp
geom.cpp
geom-nodetype.cpp
gnome-utils.cpp
@@ -29,6 +30,7 @@ set(helper_SRC
# -------
# Headers
action.h
+ action-context.h
geom-curves.h
geom-nodetype.h
geom.h
diff --git a/src/helper/Makefile_insert b/src/helper/Makefile_insert
index 2be40e0e0..790d87b14 100644
--- a/src/helper/Makefile_insert
+++ b/src/helper/Makefile_insert
@@ -5,6 +5,8 @@ helper/unit-menu.$(OBJEXT): helper/sp-marshal.h
ink_common_sources += \
helper/action.cpp \
helper/action.h \
+ helper/action-context.cpp \
+ helper/action-context.h \
helper/geom.cpp \
helper/geom.h \
helper/geom-curves.h \
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();
}
/*
diff --git a/src/helper/action.h b/src/helper/action.h
index 0cd010b34..49816e3c9 100644
--- a/src/helper/action.h
+++ b/src/helper/action.h
@@ -12,6 +12,7 @@
#ifndef SEEN_INKSCAPE_SP_ACTION_H
#define SEEN_INKSCAPE_SP_ACTION_H
+#include "helper/action-context.h"
#include <sigc++/sigc++.h>
#include <glibmm/ustring.h>
#include <glib-object.h>
@@ -24,8 +25,12 @@ 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 SPDocument;
namespace Inkscape {
+
+class Selection;
class Verb;
+
namespace UI {
namespace View {
class View;
@@ -39,7 +44,7 @@ class View;
struct SPAction : public GObject {
unsigned sensitive : 1; /**< Value to track whether the action is sensitive */
unsigned active : 1; /**< Value to track whether the action is active */
- Inkscape::UI::View::View *view; /**< The View to which this action is attached */
+ Inkscape::ActionContext context; /**< The context (doc/view) to which this action is attached */
gchar *id; /**< The identifier for the action */
gchar *name; /**< Full text name of the action */
gchar *tip; /**< A tooltip to describe the action */
@@ -59,7 +64,7 @@ struct SPActionClass {
GType sp_action_get_type();
-SPAction *sp_action_new(Inkscape::UI::View::View *view,
+SPAction *sp_action_new(Inkscape::ActionContext const &context,
gchar const *id,
gchar const *name,
gchar const *tip,
@@ -70,6 +75,8 @@ void sp_action_perform(SPAction *action, void *data);
void sp_action_set_active(SPAction *action, unsigned active);
void sp_action_set_sensitive(SPAction *action, unsigned sensitive);
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);
#endif