return milk_auth_task_delete (priv->auth, timeline, task, error);
}
+char*
+milk_cache_task_set_priority (MilkCache *cache,
+ char *timeline,
+ RtmTask *task,
+ const char *priority,
+ GError **error)
+{
+ MilkCachePrivate *priv;
+
+ g_return_val_if_fail (MILK_IS_CACHE (cache), NULL);
+
+ priv = MILK_CACHE_PRIVATE (cache);
+
+ /* FIXME: update the task in the database and mark it as having local
+ * changes; then immediately emit the "task-changed" signal, so the
+ * model will immediately reflect that */
+
+ return milk_auth_task_set_priority (priv->auth, timeline, task,
+ priority, error);
+}
+
/* XXX: this won't be necessary when the auth handles this transparently; or at
* least this will merely be a signal to the auth that we're ready to
* authenticate when it is */
priority_plus_clicked_cb (GtkButton *button,
MilkMainWindow *window)
{
- g_debug ("FIXME: implement 'priority plus' action");
+ MilkMainWindowPrivate *priv;
+ GList *tasks;
+ char *timeline;
+ GError *error = NULL;
+
+ priv = MILK_MAIN_WINDOW_PRIVATE (window);
+
+ tasks = get_selected_tasks (window);
+ timeline = milk_cache_timeline_create (priv->cache, &error);
+
+ if (error) {
+ g_warning (G_STRLOC ": failed to create a timeline: %s",
+ error->message);
+ g_clear_error (&error);
+ } else {
+ while (tasks) {
+ const char *priority;
+ const char *priority_new;
+
+ priority = rtm_task_get_priority (tasks->data);
+
+ if (FALSE) {
+ } else if (!g_strcmp0 (priority, "1")) {
+ priority_new = "1";
+ } else if (!g_strcmp0 (priority, "2")) {
+ priority_new = "1";
+ } else if (!g_strcmp0 (priority, "3")) {
+ priority_new = "2";
+ } else if (!g_strcmp0 (priority, "N")) {
+ priority_new = "3";
+ } else {
+ g_warning ("unknown priority '%s'; setting to "
+ "unprioritized", priority);
+ priority_new = "N";
+ }
+
+ milk_cache_task_set_priority (priv->cache, timeline,
+ tasks->data, priority_new, NULL);
+ tasks = g_list_delete_link (tasks, tasks);
+ }
+ }
+
+ /* XXX: it would be nicer to select the tasks in their new positions */
+ hildon_touch_selector_unselect_all (
+ HILDON_TOUCH_SELECTOR (priv->task_view),
+ TASK_VIEW_COLUMN_TITLE);
}
static void
priority_minus_clicked_cb (GtkButton *button,
MilkMainWindow *window)
{
- g_debug ("FIXME: implement 'priority minus' action");
+ MilkMainWindowPrivate *priv;
+ GList *tasks;
+ char *timeline;
+ GError *error = NULL;
+
+ priv = MILK_MAIN_WINDOW_PRIVATE (window);
+
+ tasks = get_selected_tasks (window);
+ timeline = milk_cache_timeline_create (priv->cache, &error);
+
+ if (error) {
+ g_warning (G_STRLOC ": failed to create a timeline: %s",
+ error->message);
+ g_clear_error (&error);
+ } else {
+ while (tasks) {
+ const char *priority;
+ const char *priority_new;
+
+ priority = rtm_task_get_priority (tasks->data);
+
+ if (FALSE) {
+ } else if (!g_strcmp0 (priority, "1")) {
+ priority_new = "2";
+ } else if (!g_strcmp0 (priority, "2")) {
+ priority_new = "3";
+ } else if (!g_strcmp0 (priority, "3")) {
+ priority_new = "N";
+ } else if (!g_strcmp0 (priority, "N")) {
+ priority_new = "N";
+ } else {
+ g_warning ("unknown priority '%s'; setting to "
+ "unprioritized", priority);
+ priority_new = "N";
+ }
+
+ milk_cache_task_set_priority (priv->cache, timeline,
+ tasks->data, priority_new, NULL);
+ tasks = g_list_delete_link (tasks, tasks);
+ }
+ }
+
+ /* XXX: it would be nicer to select the tasks in their new positions */
+ hildon_touch_selector_unselect_all (
+ HILDON_TOUCH_SELECTOR (priv->task_view),
+ TASK_VIEW_COLUMN_TITLE);
}
static void