From 6efece51f99980b824b199bbeb6452f03e6736c6 Mon Sep 17 00:00:00 2001 From: Dmitry Zhulanov Date: Tue, 27 Sep 2016 00:23:14 +0700 Subject: add x-verbs support (bzr r15136.1.1) --- src/main-cmdlineact.cpp | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) (limited to 'src/main-cmdlineact.cpp') diff --git a/src/main-cmdlineact.cpp b/src/main-cmdlineact.cpp index c1b756ad5..2d0a5cfd6 100644 --- a/src/main-cmdlineact.cpp +++ b/src/main-cmdlineact.cpp @@ -14,6 +14,7 @@ #include #include #include +#include #include @@ -22,6 +23,7 @@ namespace Inkscape { std::list CmdLineAction::_list; +bool CmdLineAction::_requestQuit = false; CmdLineAction::CmdLineAction (bool isVerb, gchar const * arg) : _isVerb(isVerb), _arg(NULL) { if (arg != NULL) { @@ -39,10 +41,34 @@ CmdLineAction::~CmdLineAction () { } } +bool +CmdLineAction::isExtended() { + return false; +} + +void +CmdLineAction::doItX (ActionContext const & context) +{ + (void)context; + printf("CmdLineAction::doItX() %s\n", _arg); +} + void CmdLineAction::doIt (ActionContext const & context) { //printf("Doing: %s\n", _arg); if (_isVerb) { + if (isExtended()) { + //printf("Is extended\n"); + + doItX(context); + return; + } + + static std::string quit_verb_name = "FileQuit"; + if (quit_verb_name == _arg) { + _requestQuit = true; + return; + } Inkscape::Verb * verb = Inkscape::Verb::getbyid(_arg); if (verb == NULL) { printf(_("Unable to find verb ID '%s' specified on the command line.\n"), _arg); @@ -69,10 +95,19 @@ CmdLineAction::doIt (ActionContext const & context) { bool CmdLineAction::doList (ActionContext const & context) { bool hasActions = !_list.empty(); + if (!hasActions && _requestQuit) { + sp_file_exit(); + return true; + } + for (std::list::iterator i = _list.begin(); i != _list.end(); ++i) { CmdLineAction * entry = *i; entry->doIt(context); + if (_requestQuit) { + sp_file_exit(); + return true; + } } return hasActions; } -- cgit v1.2.3 From 10476bfa9f215afe2d5ea368269c44eebe5d0628 Mon Sep 17 00:00:00 2001 From: Dmitry Zhulanov Date: Tue, 27 Sep 2016 21:25:42 +0700 Subject: fix indention (bzr r15136.1.4) --- src/main-cmdlineact.cpp | 144 ++++++++++++++++++++++++------------------------ 1 file changed, 72 insertions(+), 72 deletions(-) (limited to 'src/main-cmdlineact.cpp') diff --git a/src/main-cmdlineact.cpp b/src/main-cmdlineact.cpp index 2d0a5cfd6..cea1291c7 100644 --- a/src/main-cmdlineact.cpp +++ b/src/main-cmdlineact.cpp @@ -26,106 +26,106 @@ std::list CmdLineAction::_list; bool CmdLineAction::_requestQuit = false; CmdLineAction::CmdLineAction (bool isVerb, gchar const * arg) : _isVerb(isVerb), _arg(NULL) { - if (arg != NULL) { - _arg = g_strdup(arg); - } + if (arg != NULL) { + _arg = g_strdup(arg); + } - _list.insert(_list.end(), this); + _list.insert(_list.end(), this); - return; + return; } CmdLineAction::~CmdLineAction () { - if (_arg != NULL) { - g_free(_arg); - } + if (_arg != NULL) { + g_free(_arg); + } } bool CmdLineAction::isExtended() { - return false; + return false; } void CmdLineAction::doItX (ActionContext const & context) { - (void)context; - printf("CmdLineAction::doItX() %s\n", _arg); + (void)context; + printf("CmdLineAction::doItX() %s\n", _arg); } void CmdLineAction::doIt (ActionContext const & context) { - //printf("Doing: %s\n", _arg); - if (_isVerb) { - if (isExtended()) { - //printf("Is extended\n"); - - doItX(context); - return; - } - - static std::string quit_verb_name = "FileQuit"; - if (quit_verb_name == _arg) { - _requestQuit = true; - return; - } - Inkscape::Verb * verb = Inkscape::Verb::getbyid(_arg); - if (verb == NULL) { - printf(_("Unable to find verb ID '%s' specified on the command line.\n"), _arg); - return; - } - SPAction * action = verb->get_action(context); - sp_action_perform(action, NULL); - } else { - if (context.getDocument() == NULL || context.getSelection() == NULL) { return; } - - 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 = context.getSelection(); - selection->add(obj); - } - return; + //printf("Doing: %s\n", _arg); + if (_isVerb) { + if (isExtended()) { + //printf("Is extended\n"); + + doItX(context); + return; + } + + static std::string quit_verb_name = "FileQuit"; + if (quit_verb_name == _arg) { + _requestQuit = true; + return; + } + Inkscape::Verb * verb = Inkscape::Verb::getbyid(_arg); + if (verb == NULL) { + printf(_("Unable to find verb ID '%s' specified on the command line.\n"), _arg); + return; + } + SPAction * action = verb->get_action(context); + sp_action_perform(action, NULL); + } else { + if (context.getDocument() == NULL || context.getSelection() == NULL) { return; } + + 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 = context.getSelection(); + selection->add(obj); + } + return; } bool CmdLineAction::doList (ActionContext const & context) { bool hasActions = !_list.empty(); - if (!hasActions && _requestQuit) { - sp_file_exit(); - return true; - } - - for (std::list::iterator i = _list.begin(); - i != _list.end(); ++i) { - CmdLineAction * entry = *i; - entry->doIt(context); - if (_requestQuit) { - sp_file_exit(); - return true; - } - } + if (!hasActions && _requestQuit) { + sp_file_exit(); + return true; + } + + for (std::list::iterator i = _list.begin(); + i != _list.end(); ++i) { + CmdLineAction * entry = *i; + entry->doIt(context); + if (_requestQuit) { + sp_file_exit(); + return true; + } + } return hasActions; } bool CmdLineAction::idle (void) { - std::list desktops; - INKSCAPE.get_all_desktops(desktops); - - // We're going to assume one desktop per document, because no one - // should have had time to make more at this point. - for (std::list::iterator i = desktops.begin(); - i != desktops.end(); ++i) { - SPDesktop * desktop = *i; - //Inkscape::UI::View::View * view = dynamic_cast(desktop); - doList(ActionContext(desktop)); - } - return false; + std::list desktops; + INKSCAPE.get_all_desktops(desktops); + + // We're going to assume one desktop per document, because no one + // should have had time to make more at this point. + for (std::list::iterator i = desktops.begin(); + i != desktops.end(); ++i) { + SPDesktop * desktop = *i; + //Inkscape::UI::View::View * view = dynamic_cast(desktop); + doList(ActionContext(desktop)); + } + return false; } } // Inkscape -- cgit v1.2.3 From ef6e004b46469da3419554758bd0c0ed47df286f Mon Sep 17 00:00:00 2001 From: Dmitry Zhulanov Date: Tue, 27 Sep 2016 21:38:32 +0700 Subject: no need to FileQuit verb checking (bzr r15136.1.5) --- src/main-cmdlineact.cpp | 15 --------------- 1 file changed, 15 deletions(-) (limited to 'src/main-cmdlineact.cpp') diff --git a/src/main-cmdlineact.cpp b/src/main-cmdlineact.cpp index cea1291c7..fc0f50cd4 100644 --- a/src/main-cmdlineact.cpp +++ b/src/main-cmdlineact.cpp @@ -23,7 +23,6 @@ namespace Inkscape { std::list CmdLineAction::_list; -bool CmdLineAction::_requestQuit = false; CmdLineAction::CmdLineAction (bool isVerb, gchar const * arg) : _isVerb(isVerb), _arg(NULL) { if (arg != NULL) { @@ -64,11 +63,6 @@ CmdLineAction::doIt (ActionContext const & context) { return; } - static std::string quit_verb_name = "FileQuit"; - if (quit_verb_name == _arg) { - _requestQuit = true; - return; - } Inkscape::Verb * verb = Inkscape::Verb::getbyid(_arg); if (verb == NULL) { printf(_("Unable to find verb ID '%s' specified on the command line.\n"), _arg); @@ -95,19 +89,10 @@ CmdLineAction::doIt (ActionContext const & context) { bool CmdLineAction::doList (ActionContext const & context) { bool hasActions = !_list.empty(); - if (!hasActions && _requestQuit) { - sp_file_exit(); - return true; - } - for (std::list::iterator i = _list.begin(); i != _list.end(); ++i) { CmdLineAction * entry = *i; entry->doIt(context); - if (_requestQuit) { - sp_file_exit(); - return true; - } } return hasActions; } -- cgit v1.2.3 From f9a55c6269f20bfe98e1eeb0dd07f5bb3036b7ab Mon Sep 17 00:00:00 2001 From: Dmitry Zhulanov Date: Mon, 3 Oct 2016 22:19:23 +0700 Subject: beautify idents (bzr r15136.1.14) --- src/main-cmdlineact.cpp | 2 -- 1 file changed, 2 deletions(-) (limited to 'src/main-cmdlineact.cpp') diff --git a/src/main-cmdlineact.cpp b/src/main-cmdlineact.cpp index fc0f50cd4..f5c6e52eb 100644 --- a/src/main-cmdlineact.cpp +++ b/src/main-cmdlineact.cpp @@ -57,8 +57,6 @@ CmdLineAction::doIt (ActionContext const & context) { //printf("Doing: %s\n", _arg); if (_isVerb) { if (isExtended()) { - //printf("Is extended\n"); - doItX(context); return; } -- cgit v1.2.3 From d43d0384c8f95baa781beaaca79b938e680b727a Mon Sep 17 00:00:00 2001 From: Dmitry Zhulanov Date: Mon, 3 Oct 2016 22:25:41 +0700 Subject: beautify idents (bzr r15136.1.15) --- src/main-cmdlineact.cpp | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) (limited to 'src/main-cmdlineact.cpp') diff --git a/src/main-cmdlineact.cpp b/src/main-cmdlineact.cpp index f5c6e52eb..03bf4083c 100644 --- a/src/main-cmdlineact.cpp +++ b/src/main-cmdlineact.cpp @@ -86,13 +86,12 @@ CmdLineAction::doIt (ActionContext const & context) { bool CmdLineAction::doList (ActionContext const & context) { - bool hasActions = !_list.empty(); - for (std::list::iterator i = _list.begin(); - i != _list.end(); ++i) { + bool hasActions = !_list.empty(); + for (std::list::iterator i = _list.begin(); i != _list.end(); ++i) { CmdLineAction * entry = *i; entry->doIt(context); } - return hasActions; + return hasActions; } bool -- cgit v1.2.3