Changeset 1750
- Timestamp:
- 03/25/07 15:19:30
- Files:
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/libtinymailui-gtk/tny-gtk-header-list-model.c
r1749 r1750 127 127 g_static_rec_mutex_lock (list_model->iterator_lock); 128 128 129 i = (gint) iter->user_data;129 i = (gint) iter->user_data; 130 130 131 131 if (i < 0 || i >= list_model->items->len) { … … 179 179 time_t recv_a, recv_b; 180 180 181 /* Get the index out of the iter, and use the item by looking it up in 182 * the GPtrArray. This must be quite efficient, as this is called lots 183 * of times while you are sorting things. */ 184 181 185 hdr_a = list_model->items->pdata[(gint)a->user_data]; 182 186 hdr_b = list_model->items->pdata[(gint)b->user_data]; … … 207 211 time_t recv_a, recv_b; 208 212 213 /* Get the index out of the iter, and use the item by looking it up in 214 * the GPtrArray. This must be quite efficient, as this is called lots 215 * of times while you are sorting things. */ 216 209 217 hdr_a = list_model->items->pdata[(gint)a->user_data]; 210 218 hdr_b = list_model->items->pdata[(gint)b->user_data]; … … 228 236 229 237 g_static_rec_mutex_lock (list_model->iterator_lock); 238 239 /* Get the index out of the iter, and use the item by looking it up in 240 * the GPtrArray. This must be quite efficient, as this is called lots 241 * of times while you are sorting things. */ 230 242 231 243 i = (gint) iter->user_data; … … 324 336 g_static_rec_mutex_lock (list_model->iterator_lock); 325 337 338 /* The next will simply be the current plus one: That's because we are 339 * storing the GPtrArray's index in the iters. Simple, efficient. Just 340 * always make sure that such an iter doesn't contain an index that 341 * can't be part of the GPtrArray instance (would be devastating). */ 342 326 343 newv = ((gint)iter->user_data); 327 newv++; 344 newv++; 328 345 iter->user_data = (gpointer) newv; 329 346 … … 343 360 tny_gtk_header_list_model_iter_has_child (GtkTreeModel *self, GtkTreeIter *iter) 344 361 { 362 /* This is a flat list (we don't yet support threaded views anyway), so 363 * the answer is flat-out no. Always. */ 364 345 365 return FALSE; 346 366 } … … 423 443 notify_views_data_t *stuff = data; 424 444 445 /* Caused by the delayer (see below), this one wont trigger for each 446 * added item. Let's hope that the GtkTreeView copes with this by 447 * reading the get_length property each time. March 2007 it did, as far 448 * as I know. */ 449 425 450 gtk_tree_model_row_inserted (GTK_TREE_MODEL (stuff->self), stuff->path, &(stuff->iter)); 426 451 gtk_tree_path_free (stuff->path); … … 431 456 } 432 457 458 /* This will be called often while you are in tny_folder_refresh(_async). It can 459 * and will be called from a thread, so we must cope with that in case we want 460 * to update the GtkTreeViews that have been attached to this model (self). */ 433 461 static void 434 462 tny_gtk_header_list_model_prepend (TnyList *self, GObject* item) 435 463 { 436 464 TnyGtkHeaderListModel *me = (TnyGtkHeaderListModel*)self; 437 GtkTreePath *path;438 465 439 466 g_static_rec_mutex_lock (me->iterator_lock); 440 467 441 /* Prepend something to the list */ 468 /* Prepend something to the list itself. The get_length will auto update 469 * because that one uses GPtrArray's len property. We are reusing the 470 * iterator_lock for locking this out, by the way. */ 471 442 472 g_object_ref (G_OBJECT (item)); 443 473 g_ptr_array_add (me->items, item); 444 474 475 /* This will prepend happen very often, the allocation and the notificating 476 * of the view is, however, quite slow. So we delay it per 100 or so. */ 445 477 if (me->delayer == 100) 446 478 { 447 479 notify_views_data_t *stuff; 480 448 481 stuff = g_slice_new (notify_views_data_t); 449 482 stuff->self = g_object_ref (G_OBJECT (self)); … … 453 486 stuff->iter.user_data = (gpointer) (me->items->len - 1); 454 487 455 /* Letting the model observers know about this (the GtkTreeViews). The456 * g_timeout_add stuff keeps it possible to launch the prepender in a457 * thread. Else wouldn't the GtkTreeViews like this. */488 /* Letting the model observers know about this (the GtkTreeViews). 489 * The g_timeout_add stuff keeps it possible to launch the pre- 490 * pender in a thread. Else wouldn't the GtkTreeViews like this. */ 458 491 459 492 if (stuff->path) … … 463 496 g_slice_free (notify_views_data_t, stuff); 464 497 } 498 465 499 me->delayer = 0; 466 500 } … … 500 534 501 535 536 /* TNY TODO: massive removals would be slow due to the g_timeout_add being 537 * called often. Take a look at the prepend to see how this can be solved. */ 502 538 static void 503 539 tny_gtk_header_list_model_remove (TnyList *self, GObject* item)
