~ubuntu-branches/ubuntu/karmic/tasks/karmic

« back to all changes in this revision

Viewing changes to libkoto/koto-task-store.c

  • Committer: Bazaar Package Importer
  • Author(s): Ross Burton
  • Date: 2007-06-26 20:21:10 UTC
  • mfrom: (1.1.5 upstream)
  • Revision ID: james.westby@ubuntu.com-20070626202110-b9ki7a9p9r50fkqz
Tags: 0.9-1
New upstream release.

Show diffs side-by-side

added added

removed removed

Lines of Context:
121
121
}
122
122
 
123
123
/*
124
 
 * Utility method called by objects_added and objects_modified that updates a
125
 
 * row in @store pointed to by @iter with data extracted from @ical.
 
124
 * Utility method called by objects_added and objects_modified that inserts a
 
125
 * new row (@insert is #TRUE) or updates a row (@insert is #FALSE) in @store
 
126
 * pointed to by @iter with data extracted from @ical.
126
127
 */
127
128
static void
128
 
update_row (KotoTaskStore *store, icalcomponent *ical, GtkTreeIter *iter)
 
129
update_row (KotoTaskStore *store, icalcomponent *ical, gboolean insert, GtkTreeIter *iter)
129
130
{
130
131
  icalproperty_status status;
131
132
  icalproperty *prop;
152
153
    icalproperty_free (prop);
153
154
  }
154
155
  
155
 
  /* TODO: if iter is NULL use insert_with_values so that insertions are sorted */
156
 
  gtk_list_store_set (GTK_LIST_STORE (store), iter,
157
 
                      COLUMN_ICAL, koto_task_new (icalcomponent_new_clone (ical)),
158
 
                      COLUMN_DONE, status == ICAL_STATUS_COMPLETED,
159
 
                      COLUMN_PRIORITY, ical_util_get_priority (ical),
160
 
                      COLUMN_WEIGHT, get_weight (ical_util_get_priority (ical), due_time),
161
 
                      COLUMN_DUE, due_date,
162
 
                      COLUMN_SUMMARY, icalcomponent_get_summary (ical),
163
 
                      COLUMN_DESCRIPTION, icalcomponent_get_description (ical),
164
 
                      COLUMN_CATEGORY, categories,
165
 
                      -1);
 
156
  if (insert) {
 
157
    gtk_list_store_insert_with_values (GTK_LIST_STORE (store), iter, 0,
 
158
                                       COLUMN_ICAL, koto_task_new (icalcomponent_new_clone (ical)),
 
159
                                       COLUMN_DONE, status == ICAL_STATUS_COMPLETED,
 
160
                                       COLUMN_PRIORITY, ical_util_get_priority (ical),
 
161
                                       COLUMN_WEIGHT, get_weight (ical_util_get_priority (ical), due_time),
 
162
                                       COLUMN_DUE, due_date,
 
163
                                       COLUMN_SUMMARY, icalcomponent_get_summary (ical),
 
164
                                       COLUMN_DESCRIPTION, icalcomponent_get_description (ical),
 
165
                                       COLUMN_CATEGORY, categories,
 
166
                                       COLUMN_URL, ical_util_get_url (ical),
 
167
                                       -1);
 
168
  } else {
 
169
    gtk_list_store_set (GTK_LIST_STORE (store), iter,
 
170
                        COLUMN_ICAL, koto_task_new (icalcomponent_new_clone (ical)),
 
171
                        COLUMN_DONE, status == ICAL_STATUS_COMPLETED,
 
172
                        COLUMN_PRIORITY, ical_util_get_priority (ical),
 
173
                        COLUMN_WEIGHT, get_weight (ical_util_get_priority (ical), due_time),
 
174
                        COLUMN_DUE, due_date,
 
175
                        COLUMN_SUMMARY, icalcomponent_get_summary (ical),
 
176
                        COLUMN_DESCRIPTION, icalcomponent_get_description (ical),
 
177
                        COLUMN_CATEGORY, categories,
 
178
                        COLUMN_URL, ical_util_get_url (ical),
 
179
                        -1);
 
180
  }
166
181
  
167
182
  g_strfreev (categories);
168
183
  if (due_date)
183
198
 
184
199
    ical = objects->data;
185
200
 
186
 
    gtk_list_store_append (GTK_LIST_STORE (store), &iter);
187
 
    update_row (store, ical, &iter);
 
201
    update_row (store, ical, TRUE, &iter);
188
202
 
189
203
    g_hash_table_insert (priv->uid_hash,
190
204
                         g_strdup (icalcomponent_get_uid (ical)),
209
223
 
210
224
    iter = g_hash_table_lookup (priv->uid_hash, icalcomponent_get_uid (ical));
211
225
 
212
 
    update_row (store, ical, iter);
 
226
    update_row (store, ical, FALSE, iter);
213
227
  }
214
228
}
215
229
 
326
340
    G_TYPE_STRING, /* summary */
327
341
    G_TYPE_STRING, /* description */
328
342
    G_TYPE_STRV, /* categories */
 
343
    G_TYPE_STRING, /* URL */
329
344
  };
330
345
 
331
346
  gtk_list_store_set_column_types (GTK_LIST_STORE (self),
379
394
  if (view) {
380
395
    priv->view = g_object_ref (view);
381
396
    priv->cal = g_object_ref (g_object_get_data (G_OBJECT (view), "koto-ecal"));
382
 
    priv->sig_added = g_signal_connect (priv->view, "objects_added", G_CALLBACK (on_objects_added), store);
383
 
    priv->sig_modified = g_signal_connect (priv->view, "objects_modified", G_CALLBACK (on_objects_modified), store);
384
 
    priv->sig_removed = g_signal_connect (priv->view, "objects_removed", G_CALLBACK (on_objects_removed), store);
 
397
    priv->sig_added = g_signal_connect (priv->view, "objects-added", G_CALLBACK (on_objects_added), store);
 
398
    priv->sig_modified = g_signal_connect (priv->view, "objects-modified", G_CALLBACK (on_objects_modified), store);
 
399
    priv->sig_removed = g_signal_connect (priv->view, "objects-removed", G_CALLBACK (on_objects_removed), store);
385
400
 
386
401
    if (!priv->cal) {
387
402
      g_warning ("koto-ecal not set on cal_view, cannot commit changes");