From c3a160589a9cb41c70a56e5e7b66a65857a0d10e Mon Sep 17 00:00:00 2001 From: Eric Greveson Date: Mon, 1 Jul 2013 21:04:32 +0100 Subject: 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) --- src/main-cmdlineact.cpp | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) (limited to 'src/main-cmdlineact.cpp') 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 #include #include +#include #include #include #include @@ -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(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::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::iterator i = desktops.begin(); i != desktops.end(); ++i) { SPDesktop * desktop = *i; - //Inkscape::UI::View::View * view = dynamic_cast(desktop); - doList(desktop); + //Inkscape::UI::View::View * view = dynamic_cast(desktop); + doList(ActionContext(desktop)); } return false; } -- cgit v1.2.3