Changeset 1916
- Timestamp:
- 05/08/07 17:07:35
- Files:
-
- trunk/libtinymailui-gtk/tny-gtk-header-list-model.c (modified) (9 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
r1915 r1916 39 39 #include "tny-gtk-header-list-iterator-priv.h" 40 40 41 static gint 42 add_del_timeout (TnyGtkHeaderListModel *me, guint num) 43 { 44 gint retval = 0; 45 g_mutex_lock (me->to_lock); 46 if (!me->del_timeouts) 47 me->del_timeouts = g_array_new (FALSE, FALSE, sizeof (guint)); 48 g_array_append_val (me->del_timeouts, num); 49 retval = me->del_timeouts->len-1; 50 g_mutex_unlock (me->to_lock); 51 return retval; 52 } 53 54 static void 55 remove_del_timeouts (TnyGtkHeaderListModel *me) 56 { 57 gint i; 58 guint src; 59 60 g_mutex_lock (me->to_lock); 61 62 if (!me->del_timeouts) 63 { 64 g_mutex_unlock (me->to_lock); 65 return; 66 } 67 68 for (i = 0; i < me->del_timeouts->len; i++) 69 { 70 src = g_array_index (me->del_timeouts, guint, i); 71 if (src > 0) 72 g_source_remove (src); 73 g_array_index (me->del_timeouts, guint, i) = 0; 74 } 75 g_array_free (me->del_timeouts, TRUE); 76 me->del_timeouts = NULL; 77 g_mutex_unlock (me->to_lock); 78 } 41 79 42 80 static guint … … 574 612 GObject *item; 575 613 GMainLoop *loop; 614 guint src; 576 615 } notify_views_data_t; 577 616 … … 583 622 TnyGtkHeaderListModel *me = (TnyGtkHeaderListModel*) stuff->self; 584 623 585 me->del_timeout = 0; 624 g_mutex_lock (me->to_lock); 625 if (stuff->src != 0 && stuff->src < me->del_timeouts->len) 626 g_array_index (me->del_timeouts, guint, stuff->src) = 0; 627 g_mutex_unlock (me->to_lock); 628 586 629 g_object_unref (stuff->item); 587 630 g_object_unref (stuff->self); … … 644 687 TnyGtkHeaderListModel *me = (TnyGtkHeaderListModel*) self; 645 688 notify_views_data_t *stuff; 689 guint src; 646 690 647 691 stuff = g_slice_new (notify_views_data_t); 692 stuff->src = 0; 648 693 stuff->self = g_object_ref (self); 649 694 stuff->item = g_object_ref (item); … … 651 696 stuff->loop = g_main_loop_new (NULL, FALSE); 652 697 653 if (me->del_timeout > 0) { 654 g_source_remove (me->del_timeout); 655 me->del_timeout = 0; 656 } 657 658 me->del_timeout = g_timeout_add_full (0, G_PRIORITY_HIGH_IDLE, 698 src = g_timeout_add_full (0, G_PRIORITY_HIGH_IDLE, 659 699 notify_views_delete, stuff, notify_views_delete_destroy); 700 stuff->src = add_del_timeout (me, src); 660 701 661 702 /* This truly sucks :-( */ … … 764 805 } 765 806 766 if (self->del_timeout > 0) { 767 g_source_remove (self->del_timeout); 768 self->del_timeout = 0; 769 } 807 remove_del_timeouts (self); 770 808 771 809 g_ptr_array_foreach (self->items, (GFunc)g_object_unref, NULL); … … 780 818 self->iterator_lock = NULL; 781 819 782 783 820 g_mutex_free (self->ra_lock); 784 821 self->ra_lock = NULL; 822 823 g_mutex_free (self->to_lock); 824 self->to_lock = NULL; 785 825 786 826 parent_class->finalize (object); … … 811 851 self->cur_len = 0; 812 852 813 self->del_timeout = 0;853 self->del_timeouts = NULL; 814 854 self->add_timeout = 0; 815 855 self->items = g_ptr_array_sized_new (1000); 816 856 self->updating_views = -1; 817 857 self->ra_lock = g_mutex_new (); 858 self->to_lock = g_mutex_new (); 818 859 self->registered = 0; 819 860 … … 844 885 } 845 886 846 if (self->del_timeout > 0) { 847 g_source_remove (self->del_timeout); 848 self->del_timeout = 0; 849 } 887 remove_del_timeouts (self); 850 888 851 889 /* Set it to 1 as initial value, else you cause the length > 0 trunk/libtinymailui-gtk/tny-gtk-header-list-model.h
r1915 r1916 68 68 gint stamp, registered; 69 69 gint updating_views; 70 GMutex *ra_lock ;70 GMutex *ra_lock, *to_lock; 71 71 gint cur_len; 72 guint add_timeout , del_timeout;72 guint add_timeout; 73 73 74 74 GPtrArray *items; 75 GArray *del_timeouts; 75 76 TnyIterator *iterator; 76 77 };
