Changeset 1748
- Timestamp:
- 03/25/07 15:02:08
- Files:
-
- trunk/libtinymailui-gtk/tny-gtk-header-list-model.c (modified) (12 diffs)
- trunk/libtinymailui-gtk/tny-gtk-header-list-model.h (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/libtinymailui-gtk/tny-gtk-header-list-model.c
r1747 r1748 419 419 420 420 static gboolean 421 notify_views (gpointer data)421 notify_views_add (gpointer data) 422 422 { 423 423 notify_views_data_t *stuff = data; … … 437 437 GtkTreePath *path; 438 438 notify_views_data_t *stuff; 439 static int delayer = 0;440 439 441 440 g_static_rec_mutex_lock (me->iterator_lock); 442 441 443 if (delayer == 100) 444 { 445 stuff = g_slice_new (notify_views_data_t); 446 stuff->self = g_object_ref (G_OBJECT (self)); 447 stuff->path = gtk_tree_path_new (); 448 gtk_tree_path_append_index (stuff->path, 0); 449 stuff->iter.stamp = me->stamp; 450 } 442 stuff = g_slice_new (notify_views_data_t); 443 stuff->self = g_object_ref (G_OBJECT (self)); 444 stuff->path = gtk_tree_path_new (); 445 gtk_tree_path_append_index (stuff->path, 0); 446 stuff->iter.stamp = me->stamp; 451 447 452 448 /* Prepend something to the list */ … … 459 455 * thread. Else wouldn't the GtkTreeViews like this. */ 460 456 461 if (delayer == 100) 462 { 463 if (stuff->path) 464 g_timeout_add (0, notify_views, stuff); 465 else { 466 g_object_unref (G_OBJECT (stuff->self)); 467 g_slice_free (notify_views_data_t, stuff); 468 } 469 delayer = 0; 470 } 471 472 delayer++; 457 if (stuff->path) 458 g_timeout_add (0, notify_views_add, stuff); 459 else { 460 g_object_unref (G_OBJECT (stuff->self)); 461 g_slice_free (notify_views_data_t, stuff); 462 } 473 463 474 464 g_static_rec_mutex_unlock (me->iterator_lock); … … 484 474 } 485 475 486 static guint 487 tny_gtk_header_list_model_get_length (TnyList *self) 488 { 489 TnyGtkHeaderListModel *me = (TnyGtkHeaderListModel*)self; 490 guint retval = 0; 491 492 g_static_rec_mutex_lock (me->iterator_lock); 493 retval = me->items->len; 494 g_static_rec_mutex_unlock (me->iterator_lock); 495 496 return retval; 497 } 476 477 478 static gboolean 479 notify_views_delete (gpointer data) 480 { 481 notify_views_data_t *stuff = data; 482 483 stuff->path = tny_gtk_header_list_model_get_path (GTK_TREE_MODEL (stuff->self), &(stuff->iter)); 484 if (stuff->path) 485 { 486 gtk_tree_model_row_deleted (GTK_TREE_MODEL (stuff->self), stuff->path); 487 gtk_tree_path_free (stuff->path); 488 } 489 g_object_unref (G_OBJECT (stuff->self)); 490 g_slice_free (notify_views_data_t, data); 491 492 return FALSE; 493 } 494 498 495 499 496 static void … … 520 517 if (found) 521 518 { 522 GtkTreeIter iter; 523 iter.stamp = me->stamp; 524 iter.user_data = (gpointer) i; 525 path = tny_gtk_header_list_model_get_path (GTK_TREE_MODEL (me), &iter); 526 if (path) 527 { 528 /* Letting the observers know about this (the GtkTreeView) */ 529 gtk_tree_model_row_deleted (GTK_TREE_MODEL (me), path); 530 gtk_tree_path_free (path); 531 } 519 notify_views_data_t *stuff; 520 521 stuff = g_slice_new (notify_views_data_t); 522 stuff->iter.stamp = me->stamp; 523 stuff->iter.user_data = (gpointer) i; 524 stuff->self = g_object_ref (G_OBJECT (self)); 525 g_timeout_add (0, notify_views_delete, stuff); 526 532 527 g_ptr_array_remove (me->items, item); 533 528 } 534 529 535 530 g_static_rec_mutex_unlock (me->iterator_lock); 536 537 531 g_object_unref (G_OBJECT (item)); 538 532 } 533 534 static guint 535 tny_gtk_header_list_model_get_length (TnyList *self) 536 { 537 TnyGtkHeaderListModel *me = (TnyGtkHeaderListModel*)self; 538 guint retval = 0; 539 540 g_static_rec_mutex_lock (me->iterator_lock); 541 retval = me->items->len; 542 g_static_rec_mutex_unlock (me->iterator_lock); 543 544 return retval; 539 545 } 540 546 … … 618 624 TnyGtkHeaderListModel *self = (TnyGtkHeaderListModel *)object; 619 625 620 g_mutex_lock (self->folder_lock);621 626 g_static_rec_mutex_lock (self->iterator_lock); 622 627 … … 628 633 629 634 g_static_rec_mutex_unlock (self->iterator_lock); 630 g_mutex_unlock (self->folder_lock); 631 632 g_mutex_free (self->folder_lock); 633 self->folder_lock = NULL; 635 634 636 635 637 g_static_rec_mutex_free (self->iterator_lock); … … 659 661 { 660 662 self->folder = NULL; 661 self->folder_lock = g_mutex_new ();662 663 self->iterator_lock = g_new0 (GStaticRecMutex, 1); 663 664 g_static_rec_mutex_init (self->iterator_lock); … … 683 684 GtkTreePath *path; 684 685 685 g_mutex_lock (self->folder_lock);686 686 g_static_rec_mutex_lock (self->iterator_lock); 687 687 … … 694 694 695 695 g_static_rec_mutex_unlock (self->iterator_lock); 696 g_mutex_unlock (self->folder_lock);697 696 698 697 /* Get a new list of headers */ … … 704 703 path = tny_gtk_header_list_model_get_path (GTK_TREE_MODEL (self), &iter); 705 704 706 g_mutex_lock (self->folder_lock);707 705 g_static_rec_mutex_lock (self->iterator_lock); 708 706 … … 717 715 718 716 g_static_rec_mutex_unlock (self->iterator_lock); 719 g_mutex_unlock (self->folder_lock);720 717 721 718 return; trunk/libtinymailui-gtk/tny-gtk-header-list-model.h
r1708 r1748 64 64 GObject parent; 65 65 66 GMutex *folder_lock;67 66 GStaticRecMutex *iterator_lock; 68 67 TnyFolder *folder;
