summaryrefslogtreecommitdiffstats
path: root/src/main-cmdlineact.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/main-cmdlineact.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/main-cmdlineact.cpp')
-rw-r--r--src/main-cmdlineact.cpp24
1 files changed, 13 insertions, 11 deletions
diff --git a/src/main-cmdlineact.cpp b/src/main-cmdlineact.cpp
index 9f700292e..6af616e34 100644
--- a/src/main-cmdlineact.cpp
+++ b/src/main-cmdlineact.cpp
@@ -11,6 +11,7 @@
#include <desktop.h>
#include <desktop-handles.h>
#include <helper/action.h>
+#include <helper/action-context.h>
#include <selection.h>
#include <verbs.h>
#include <inkscape.h>
@@ -41,7 +42,7 @@ CmdLineAction::~CmdLineAction () {
}
void
-CmdLineAction::doIt (Inkscape::UI::View::View * view) {
+CmdLineAction::doIt (ActionContext const & context) {
//printf("Doing: %s\n", _arg);
if (_isVerb) {
Inkscape::Verb * verb = Inkscape::Verb::getbyid(_arg);
@@ -49,32 +50,33 @@ CmdLineAction::doIt (Inkscape::UI::View::View * view) {
printf(_("Unable to find verb ID '%s' specified on the command line.\n"), _arg);
return;
}
- SPAction * action = verb->get_action(view);
+ SPAction * action = verb->get_action(context);
sp_action_perform(action, NULL);
} else {
- SPDesktop * desktop = dynamic_cast<SPDesktop *>(view);
- if (desktop == NULL) { return; }
+ if (context.getDocument() == NULL || context.getSelection() == NULL) { return; }
- SPDocument * doc = view->doc();
+ SPDocument * doc = context.getDocument();
SPObject * obj = doc->getObjectById(_arg);
if (obj == NULL) {
printf(_("Unable to find node ID: '%s'\n"), _arg);
return;
}
- Inkscape::Selection * selection = sp_desktop_selection(desktop);
+ Inkscape::Selection * selection = context.getSelection();
selection->add(obj, false);
}
return;
}
-void
-CmdLineAction::doList (Inkscape::UI::View::View * view) {
+bool
+CmdLineAction::doList (ActionContext const & context) {
+ bool hasActions = !_list.empty();
for (std::list<CmdLineAction *>::iterator i = _list.begin();
i != _list.end(); ++i) {
CmdLineAction * entry = *i;
- entry->doIt(view);
+ entry->doIt(context);
}
+ return hasActions;
}
bool
@@ -87,8 +89,8 @@ CmdLineAction::idle (void) {
for (std::list<SPDesktop *>::iterator i = desktops.begin();
i != desktops.end(); ++i) {
SPDesktop * desktop = *i;
- //Inkscape::UI::View::View * view = dynamic_cast<Inkscape::UI::View::View *>(desktop);
- doList(desktop);
+ //Inkscape::UI::View::View * view = dynamic_cast<Inkscape::UI::View::View *>(desktop);
+ doList(ActionContext(desktop));
}
return false;
}