summaryrefslogtreecommitdiffstats
path: root/src/main.cpp
diff options
context:
space:
mode:
authorTed Gould <ted@gould.cx>2007-03-01 07:14:18 +0000
committergouldtj <gouldtj@users.sourceforge.net>2007-03-01 07:14:18 +0000
commit3820528769b0db183882f1093087fb39743ac6bd (patch)
treefa316e13d6facf5d72a58f102b127303601f4920 /src/main.cpp
parentr14579@tres: ted | 2007-02-27 19:00:22 -0800 (diff)
downloadinkscape-3820528769b0db183882f1093087fb39743ac6bd.tar.gz
inkscape-3820528769b0db183882f1093087fb39743ac6bd.zip
r14581@tres: ted | 2007-02-27 19:36:54 -0800
Calling everything on the command line. Good stopping point. (bzr r2477)
Diffstat (limited to 'src/main.cpp')
-rw-r--r--src/main.cpp62
1 files changed, 62 insertions, 0 deletions
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 <CmdLineAction *> _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<CmdLineAction *>::iterator i = _list.begin();
+ i != _list.end(); i++) {
+ CmdLineAction * entry = *i;
+ entry->doIt(doc);
+ }
+ }
+};
+std::list <CmdLineAction *> 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;
}