return rtm_tasks;
}
+char*
+milk_auth_timeline_create (MilkAuth *auth,
+ GError **error)
+{
+ MilkAuthPrivate *priv;
+
+ g_return_val_if_fail (MILK_IS_AUTH (auth), NULL);
+
+ priv = MILK_AUTH_PRIVATE (auth);
+
+ return rtm_glib_timelines_create (priv->rtm_glib, error);
+}
+
+char*
+milk_auth_task_complete (MilkAuth *auth,
+ char *timeline,
+ RtmTask *task,
+ GError **error)
+{
+ MilkAuthPrivate *priv;
+
+ g_return_val_if_fail (MILK_IS_AUTH (auth), NULL);
+
+ priv = MILK_AUTH_PRIVATE (auth);
+
+ return rtm_glib_tasks_complete (priv->rtm_glib, timeline, task, error);
+}
+
void
milk_auth_log_in (MilkAuth *auth)
{
GType milk_auth_get_type (void);
-MilkAuth* milk_auth_get_default (void);
-void milk_auth_log_in (MilkAuth *auth);
-MilkAuthState milk_auth_get_state (MilkAuth *auth);
-GList* milk_auth_get_tasks (MilkAuth *auth,
- const char *last_sync,
- GError **error);
+MilkAuth* milk_auth_get_default (void);
+void milk_auth_log_in (MilkAuth *auth);
+MilkAuthState milk_auth_get_state (MilkAuth *auth);
+GList* milk_auth_get_tasks (MilkAuth *auth,
+ const char *last_sync,
+ GError **error);
+char* milk_auth_timeline_create (MilkAuth *auth,
+ GError **error);
+char* milk_auth_task_complete (MilkAuth *auth,
+ char *timeline,
+ RtmTask *task,
+ GError **error);
#endif /* _MILK_AUTH_H */
g_debug ("FIXME: implement 'new task' action");
}
+/* XXX: The latency between clicking "complete" and actually removing the task
+ * from the view after polling the server is very long, so there's an obvious
+ * lag -- it will be completely transparent (and look very fast) as soon as
+ * we've got a cache in place */
static void
complete_clicked_cb (GtkButton *button,
MilkMainWindow *window)
{
- g_debug ("FIXME: implement 'complete' action");
+ MilkMainWindowPrivate *priv;
+ GList *rows;
+ GtkTreeModel *model;
+ char *timeline;
+ GError *error = NULL;
+
+ priv = MILK_MAIN_WINDOW_PRIVATE (window);
+
+ rows = hildon_touch_selector_get_selected_rows (
+ HILDON_TOUCH_SELECTOR (priv->task_view),
+ TASK_VIEW_COLUMN_TITLE);
+ model = hildon_touch_selector_get_model (
+ HILDON_TOUCH_SELECTOR (priv->task_view),
+ TASK_VIEW_COLUMN_TITLE);
+
+ timeline = milk_auth_timeline_create (priv->auth, &error);
+
+ if (error) {
+ g_warning (G_STRLOC ": failed to create a timeline: %s",
+ error->message);
+ g_clear_error (&error);
+ } else {
+ while (rows) {
+ GtkTreeIter iter;
+ RtmTask *task;
+
+ gtk_tree_model_get_iter (model, &iter, rows->data);
+ gtk_tree_model_get (model, &iter,
+ MILK_TASK_MODEL_COLUMN_TASK, &task,
+ -1);
+
+ milk_auth_task_complete (priv->auth, timeline, task,
+ &error);
+ if (error != NULL) {
+ g_warning (G_STRLOC ": failed to complete task "
+ "%s: %s",
+ rtm_task_get_id (task),
+ error->message);
+ g_clear_error (&error);
+ }
+
+ rows = g_list_delete_link (rows, rows);
+ }
+ }
}
static void