From: gouldtj Date: Thu, 1 Mar 2007 07:14:18 +0000 (+0000) Subject: r14581@tres: ted | 2007-02-27 19:36:54 -0800 X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=63dfc16a2f3d08e01ea186ff798ce9c03b46fbcd;p=inkscape.git r14581@tres: ted | 2007-02-27 19:36:54 -0800 Calling everything on the command line. Good stopping point. --- diff --git a/src/main.cpp b/src/main.cpp index 4476b3892..778928f4c 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -145,6 +145,8 @@ enum { SP_ARG_VERSION, SP_ARG_VACUUM_DEFS, SP_ARG_VERB_LIST, + SP_ARG_VERB, + SP_ARG_SELECT, SP_ARG_LAST }; @@ -372,9 +374,57 @@ struct poptOption options[] = { N_("List the IDs of all the verbs in Inkscape"), NULL}, + {"verb", 0, + POPT_ARG_STRING, NULL, SP_ARG_VERB, + N_("Verb to call when Inkscape opens."), + N_("VERB-ID")}, + + {"select", 0, + POPT_ARG_STRING, NULL, SP_ARG_SELECT, + N_("Object ID to select when Inkscape opens."), + N_("OBJECT-ID")}, + POPT_AUTOHELP POPT_TABLEEND }; +class CmdLineAction { + gint _type; + gchar * _arg; + + static std::list _list; + +public: + CmdLineAction (gint type, gchar const * arg) : _type(type), _arg(NULL) { + if (arg != NULL) { + _arg = g_strdup(arg); + } + + _list.insert(_list.end(), this); + + return; + } + + ~CmdLineAction () { + if (_arg != NULL) { + g_free(_arg); + } + } + + void doIt (SPDocument * doc) { + printf("Doing: %s\n", _arg); + } + + static void doList (SPDocument * doc) { + for (std::list::iterator i = _list.begin(); + i != _list.end(); i++) { + CmdLineAction * entry = *i; + entry->doIt(doc); + } + } +}; +std::list CmdLineAction::_list; + + static bool needToRecodeParams = true; gchar* blankParam = ""; @@ -741,7 +791,10 @@ sp_main_console(int argc, char const **argv) } else if (sp_query_x || sp_query_y) { do_query_dimension (doc, false, sp_query_x? NR::X : NR::Y, sp_query_id); } + + CmdLineAction::doList(doc); } + fl = g_slist_remove(fl, fl->data); } @@ -1386,6 +1439,15 @@ sp_process_args(poptContext ctx) exit(0); break; } + case SP_ARG_VERB: + case SP_ARG_SELECT: { + gchar const *arg = poptGetOptArg(ctx); + if (arg != NULL) { + // printf("Adding in: %s\n", arg); + new CmdLineAction(a, arg); + } + break; + } default: { break; }