Changeset 3468

Show
Ignore:
Timestamp:
03/05/08 15:17:33
Author:
pvanhoof
Message:
        • Introduction of tny_gtk_header_list_model_set_no_duplicates
Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/ChangeLog

    r3466 r3468  
    22 
    33        * Check-for-duplicates in TnyFolderObserver and TnyFolderMonitor 
     4        * Introduction of tny_gtk_header_list_model_set_no_duplicates 
    45 
    56        * This was a minor API change 
  • trunk/libtinymailui-gtk/tny-gtk-header-list-iterator-priv.h

    r3324 r3468  
    8181        GArray *del_timeouts; 
    8282        TnyIterator *iterator; 
     83        gboolean no_duplicates; 
    8384}; 
    8485 
  • trunk/libtinymailui-gtk/tny-gtk-header-list-model.c

    r3348 r3468  
    152152        return retval; 
    153153} 
    154  
    155154 
    156155static gboolean 
     
    701700 
    702701 
     702static gboolean  
     703uid_matcher (TnyList *list, GObject *item, gpointer match_data) 
     704{ 
     705        const char *uid = tny_header_get_uid ((TnyHeader *) item); 
     706 
     707        if (uid && !strcmp (uid, (const char*) match_data)) 
     708                return TRUE; 
     709 
     710        return FALSE; 
     711} 
     712 
    703713 
    704714/* This will be called often while you are in tny_folder_refresh(_async). It can 
     
    711721 
    712722        g_static_rec_mutex_lock (priv->iterator_lock); 
     723 
     724        if (priv->no_duplicates) { 
     725                const gchar *uid = tny_header_get_uid ((TnyHeader *) item); 
     726                if (uid) 
     727                        tny_list_remove_matches (self, uid_matcher, (gpointer) uid);  
     728        } 
    713729 
    714730        /* Prepend something to the list itself. The get_length will auto update 
     
    11331149        self->priv = priv; 
    11341150 
     1151        priv->no_duplicates = FALSE; 
    11351152        priv->folder = NULL; 
    11361153        priv->iterator_lock = g_new0 (GStaticRecMutex, 1); 
     
    11501167} 
    11511168 
     1169 
     1170/** 
     1171 * tny_gtk_header_list_model_set_no_duplicates: 
     1172 * @self: a #TnyGtkHeaderListModel 
     1173 * @setting: whether or not to allow duplicates 
     1174 * 
     1175 * Sets whether or not @self allows duplicates of TnyHeader instances to be 
     1176 * added. The duplicates will be tested by tny_header_get_uid uniqueness. 
     1177 * Setting this property to TRUE will negatively impact performance of @self. 
     1178 * It'll also influence behaviour of tny_list_prepend and tny_list_append. 
     1179 * 
     1180 * Default value, therefore, is FALSE. 
     1181 *  
     1182 * since: 1.0 
     1183 * audience: application-developer 
     1184 **/ 
     1185void 
     1186tny_gtk_header_list_model_set_no_duplicates (TnyGtkHeaderListModel *self, gboolean setting) 
     1187{ 
     1188        TnyGtkHeaderListModelPriv *priv = TNY_GTK_HEADER_LIST_MODEL_GET_PRIVATE (self); 
     1189        priv->no_duplicates = setting; 
     1190        return; 
     1191} 
    11521192 
    11531193/** 
  • trunk/libtinymailui-gtk/tny-gtk-header-list-model.h

    r3349 r3468  
    7878gint tny_gtk_header_list_model_received_date_sort_func (GtkTreeModel *model, GtkTreeIter *a, GtkTreeIter *b, gpointer user_data); 
    7979gint tny_gtk_header_list_model_sent_date_sort_func (GtkTreeModel *model, GtkTreeIter *a, GtkTreeIter *b, gpointer user_data); 
     80void tny_gtk_header_list_model_set_no_duplicates (TnyGtkHeaderListModel *self, gboolean setting); 
    8081 
    8182G_END_DECLS