Changeset 1763

Show
Ignore:
Timestamp:
03/30/07 16:08:07
Author:
pvanhoof
Message:

Updating the views

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/ChangeLog

    r1761 r1763  
    44        * Auto updating the unread count of TnyFolderObservers when unread 
    55        flags are set on a TnyHeader 
     6         
    67 
    78        * This was a major API change 
  • trunk/libtinymailui-gtk/tny-gtk-header-list-model.c

    r1752 r1763  
    441441notify_views_add (gpointer data) 
    442442{ 
    443         notify_views_data_t *stuff = data; 
    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  
    450         gtk_tree_model_row_inserted (GTK_TREE_MODEL (stuff->self), stuff->path, &(stuff->iter)); 
    451         gtk_tree_path_free (stuff->path); 
    452         g_object_unref (G_OBJECT (stuff->self)); 
    453         g_slice_free (notify_views_data_t, data); 
     443        TnyGtkHeaderListModel *me = (TnyGtkHeaderListModel*) data; 
     444        gint i, added; GtkTreePath *path; 
     445 
     446        g_mutex_lock (me->ra_lock); 
     447        added = me->recent_added; 
     448        me->recent_added = 0; 
     449        me->going_to_update_views = FALSE; 
     450        g_mutex_unlock (me->ra_lock); 
     451 
     452        path = gtk_tree_path_new (); 
     453        gtk_tree_path_append_index (path, 0); 
     454 
     455        for (i = 0; i< added; i++) 
     456        { 
     457                GtkTreeIter iter; 
     458                iter.stamp = me->stamp; 
     459                iter.user_data = (gpointer) (me->items->len - 1); 
     460                gtk_tree_model_row_inserted (GTK_TREE_MODEL (me), path, &iter); 
     461        } 
     462 
     463        gtk_tree_path_free (path); 
     464        g_object_unref (G_OBJECT (me)); 
    454465 
    455466        return FALSE; 
     
    481492         * speed, based. Therefore: alter this to use time in stead of counts. */ 
    482493 
    483         if (me->delayer == 100) 
     494        g_mutex_lock (me->ra_lock); 
     495        me->recent_added++; 
     496        if (!me->going_to_update_views) 
    484497        { 
    485                 notify_views_data_t *stuff; 
    486  
    487                 stuff = g_slice_new (notify_views_data_t); 
    488                 stuff->self = g_object_ref (G_OBJECT (self)); 
    489                 stuff->path = gtk_tree_path_new (); 
    490                 gtk_tree_path_append_index (stuff->path, 0); 
    491                 stuff->iter.stamp = me->stamp; 
    492                 stuff->iter.user_data = (gpointer) (me->items->len - 1); 
    493  
    494                 /* Letting the model observers know about this (the GtkTreeViews). 
    495                  * The g_timeout_add stuff keeps it possible to launch the pre- 
    496                  * pender in a thread. Else wouldn't the GtkTreeViews like this. */ 
    497  
    498                 if (stuff->path) 
    499                         g_timeout_add (0, notify_views_add, stuff); 
    500                 else { 
    501                         g_object_unref (G_OBJECT (stuff->self)); 
    502                         g_slice_free (notify_views_data_t, stuff); 
    503                 } 
    504  
    505                 me->delayer = 0; 
    506         } 
    507  
    508         me->delayer++; 
     498                g_object_ref (G_OBJECT (me)); 
     499                me->going_to_update_views = TRUE; 
     500                g_timeout_add (2000, notify_views_add, me); 
     501        } 
     502        g_mutex_unlock (me->ra_lock); 
    509503 
    510504        g_static_rec_mutex_unlock (me->iterator_lock); 
     
    682676        g_static_rec_mutex_unlock (self->iterator_lock); 
    683677 
    684  
    685678        g_static_rec_mutex_free (self->iterator_lock); 
    686679        self->iterator_lock = NULL; 
     680        g_mutex_free (self->ra_lock); 
     681        self->ra_lock = NULL; 
    687682 
    688683        parent_class->finalize (object); 
     
    712707        g_static_rec_mutex_init (self->iterator_lock); 
    713708        self->items = g_ptr_array_sized_new (1000); 
    714         self->delayer = 0; 
     709        self->going_to_update_views = FALSE; 
     710        self->ra_lock = g_mutex_new (); 
     711        self->recent_added = 0; 
    715712 
    716713        return; 
  • trunk/libtinymailui-gtk/tny-gtk-header-list-model.h

    r1749 r1763  
    6666        GStaticRecMutex *iterator_lock; 
    6767        TnyFolder *folder; 
    68         gint stamp, delayer; 
     68        gint stamp, recent_added; 
     69        gboolean going_to_update_views; 
     70        GMutex *ra_lock; 
    6971 
    7072        GPtrArray *items;