[tasks] Turn any extra arguments on the command line into a new task
- From: Ross Burton <rburton src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [tasks] Turn any extra arguments on the command line into a new task
- Date: Thu, 11 Feb 2010 09:40:47 +0000 (UTC)
commit 988e1e30b6dd7436656039786c7950f92234cac4
Author: Ross Burton <ross linux intel com>
Date: Wed Feb 10 18:18:45 2010 +0000
Turn any extra arguments on the command line into a new task
src/gtk/main.c | 37 ++++++++++++++++++++++++++++++++++++-
1 files changed, 36 insertions(+), 1 deletions(-)
---
diff --git a/src/gtk/main.c b/src/gtk/main.c
index 3fe60c9..1df31f4 100644
--- a/src/gtk/main.c
+++ b/src/gtk/main.c
@@ -517,6 +517,28 @@ edit_loaded (KotoTaskStore *store, gpointer user_data)
g_signal_handlers_disconnect_by_func (store, edit_loaded, user_data);
}
+/*
+ * Callback when the store has loaded if we have been asked to create a new task
+ * from the command line.
+ */
+static void
+cli_new_loaded (KotoTaskStore *store, gpointer user_data)
+{
+ char **remaining = user_data;
+ char *text;
+ icalcomponent *comp;
+
+ text = g_strjoinv (" ", remaining);
+ /* TODO: group matching won't work unless we've populated the store, so we
+ should enter a main loop and let the view run first */
+ comp = create_component (text, NULL);
+ g_free (text);
+
+ koto_action_create_task (cal, comp, NULL, NULL);
+
+ gtk_main_quit ();
+}
+
void
koto_platform_open_url (const char *url)
{
@@ -601,8 +623,10 @@ main (int argc, char **argv)
GtkActionGroup *action_group, *task_action_group;
GtkUIManager *ui_manager;
char *edit_uid = NULL;
+ char **remaining = NULL;
GOptionEntry entries[] = {
{ "edit", 'e', 0, G_OPTION_ARG_STRING, &edit_uid, "Edit item", "<UID>" },
+ { G_OPTION_REMAINING, 0, 0, G_OPTION_ARG_STRING_ARRAY, &remaining, "New task", "<NEW TASK>" },
{ NULL }
};
@@ -793,9 +817,20 @@ main (int argc, char **argv)
g_signal_connect (task_store, "loaded", G_CALLBACK (edit_loaded), edit_uid);
}
+ /*
+ * If we've been asked to do manipulation from the shell then wait until we've
+ * loaded everything for group matching, otherwise show the UI.
+ */
+ if (remaining) {
+ g_signal_connect (task_store, "loaded", G_CALLBACK (cli_new_loaded), remaining);
+ } else {
+ gtk_widget_show_all (window);
+ }
+
+ /* Go go go */
e_cal_view_start (cal_view);
- gtk_widget_show_all (window);
+
gtk_main ();
#if WITH_UNIQUE
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]