Changeset 949

Show
Ignore:
Timestamp:
09/13/06 21:05:28
Author:
pvanhoof
Message:

Bugfixes and api changes

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/ChangeLog

    r947 r949  
    112006-09-13  Philip Van Hoof <pvanhoof@gnome.org> 
    22 
     3        * Removed silly API in TnySessionCamel, solved the need for the API internally 
     4        * Bug fixes in TnySessionCamel 
    35        * Introduction of TnyGtkFolderTreeModel (however, it's atm unfinished) 
    46        * Introduction of TnyGtkAccountListModel which could be useful for for 
     
    1517        * Added documentation about tinymail enumerations 
    1618 
     19        * This wasa major API change in libtinymail-camel 
     20         
    17212006-09-11  Philip Van Hoof <pvanhoof@gnome.org> 
    1822 
  • trunk/docs/devel/reference/tmpl/tny-gtk-account-list-model-iterator-priv.sgml

    r944 r949  
    2626@model:  
    2727@current:  
    28 @previous:  
    29 @has_first:  
    30 @has_next:  
    3128 
  • trunk/docs/devel/reference/tmpl/tny-gtk-account-tree-model.sgml

    r944 r949  
    9595</para> 
    9696 
     97@async:  
    9798@Returns:  
    9899 
  • trunk/docs/devel/reference/tmpl/tny-gtk-folder-tree-model-iterator-priv.sgml

    r947 r949  
    1010</para> 
    1111 
    12  
    1312<!-- ##### SECTION See_Also ##### --> 
    1413<para> 
    1514 
    1615</para> 
    17  
    1816 
    1917<!-- ##### SECTION Stability_Level ##### --> 
  • trunk/docs/devel/reference/tmpl/tny-gtk-folder-tree-model.sgml

    r947 r949  
    2929</para> 
    3030 
    31  
    32  
    3331<!-- ##### SECTION See_Also ##### --> 
    3432<para> 
    3533 
    3634</para> 
    37  
    3835 
    3936<!-- ##### SECTION Stability_Level ##### --> 
  • trunk/docs/devel/reference/tmpl/tny-session-camel.sgml

    r911 r949  
    8888 
    8989 
    90 <!-- ##### FUNCTION tny_session_camel_set_current_accounts ##### --> 
    91 <para> 
    92  
    93 </para> 
    94  
    95 @self:  
    96 @list:  
    97  
    98  
  • trunk/libtinymail-camel/Makefile.am

    r853 r949  
    2626 
    2727libtinymail_camel_1_0_la_SOURCES =              \ 
     28        tny-session-camel-priv.h                \ 
    2829        tny-camel-common.c                      \ 
    2930        tny-camel-common-priv.h                 \ 
  • trunk/libtinymail-camel/tny-camel-account.c

    r900 r949  
    4545 
    4646#include "tny-camel-account-priv.h" 
     47#include "tny-session-camel-priv.h" 
    4748 
    4849static GObjectClass *parent_class = NULL; 
     
    231232        TNY_CAMEL_ACCOUNT_GET_CLASS (self)->reconnect_func (self); 
    232233 
     234        _tny_session_camel_add_account (session, self); 
     235     
    233236        g_static_rec_mutex_unlock (priv->service_lock); 
    234237 
     
    545548        TnyCamelAccountPriv *priv = TNY_CAMEL_ACCOUNT_GET_PRIVATE (self); 
    546549 
     550        _tny_session_camel_forget_account (priv->session, (TnyCamelAccount*) object);     
    547551        _tny_camel_account_start_camel_operation (self, NULL, NULL, NULL); 
    548552        _tny_camel_account_stop_camel_operation (self); 
  • trunk/libtinymail-camel/tny-session-camel.c

    r906 r949  
    3030#include <camel/camel-filter-driver.h> 
    3131 
    32  
    3332#include <camel/camel-store.h> 
    3433#include <camel/camel.h> 
     
    4241#include <tny-camel-transport-account.h> 
    4342 
     43#include "tny-session-camel-priv.h" 
    4444#include "tny-camel-store-account-priv.h" 
    4545#include "tny-camel-transport-account-priv.h" 
     
    443443 
    444444void  
    445 tny_session_camel_set_current_accounts (TnySessionCamel *self, TnyList *list) 
    446 
    447         self->current_accounts = list; 
     445_tny_session_camel_add_account (TnySessionCamel *self, TnyCamelAccount *account) 
     446
     447        self->current_accounts = g_list_prepend (self->current_accounts, account); 
     448
     449 
     450void  
     451_tny_session_camel_forget_account (TnySessionCamel *self, TnyCamelAccount *account) 
     452
     453        self->current_accounts = g_list_remove (self->current_accounts, account); 
     454
     455 
     456static void 
     457foreach_account_set_connectivity (gpointer data, gpointer udata) 
     458
     459        gboolean online = (gboolean)udata; 
     460        if (data && TNY_IS_CAMEL_ACCOUNT (data)) 
     461                tny_camel_account_set_online_status (TNY_CAMEL_ACCOUNT (data), !online); 
    448462} 
    449463 
     
    455469        camel_session_set_online ((CamelSession *) self, online);  
    456470 
    457         if (self->current_accounts && TNY_IS_LIST (self->current_accounts) && 
    458                 !self->first_switch && self->prev_constat != online  
     471        if (self->current_accounts && !self->first_switch && self->prev_constat != online  
    459472                && self->account_store) 
    460473        { 
    461                 TnyList *accounts = self->current_accounts; 
    462                 TnyIterator *iterator; 
    463  
    464                 iterator = tny_list_create_iterator (accounts); 
    465          
    466                 while (!tny_iterator_is_done (iterator)) 
    467                 { 
    468                         TnyStoreAccount *account = (TnyStoreAccount*)tny_iterator_get_current (iterator); 
    469                          
    470                         tny_camel_account_set_online_status (TNY_CAMEL_ACCOUNT (account), !online); 
    471          
    472                         g_object_unref (G_OBJECT(account)); 
    473                          
    474                         tny_iterator_next (iterator); 
    475                 } 
    476  
    477                 g_object_unref (G_OBJECT (iterator)); 
     474                g_list_foreach (self->current_accounts,  
     475                        foreach_account_set_connectivity, (gpointer) online); 
    478476        } 
    479477 
     
    481479                g_signal_emit (self->account_store,  
    482480                        tny_account_store_signals [TNY_ACCOUNT_STORE_ACCOUNTS_RELOADED], 0); 
    483  
    484481 
    485482        self->first_switch = FALSE; 
  • trunk/libtinymail-camel/tny-session-camel.h

    r900 r949  
    4141        gboolean interactive, prev_constat, first_switch; 
    4242        guint connchanged_signal; 
    43         TnyList *current_accounts; 
     43        GList *current_accounts; 
    4444}; 
    4545 
     
    4848        CamelSessionClass parent_class; 
    4949 
    50         void        (*set_pass_func_func)        (TnySessionCamel *self, TnyAccount *account, TnyGetPassFunc get_pass_func); 
    51         void        (*set_forget_pass_func_func) (TnySessionCamel *self, TnyAccount *account, TnyForgetPassFunc forget_pass_func); 
    52         void        (*set_account_store_func)    (TnySessionCamel *self, TnyAccountStore *account_store); 
     50        void (*set_pass_func_func) (TnySessionCamel *self, TnyAccount *account, TnyGetPassFunc get_pass_func); 
     51        void (*set_forget_pass_func_func) (TnySessionCamel *self, TnyAccount *account, TnyForgetPassFunc forget_pass_func); 
     52        void (*set_account_store_func) (TnySessionCamel *self, TnyAccountStore *account_store); 
    5353 
    5454}; 
    5555 
    56 CamelType         tny_session_camel_get_type      (void); 
     56CamelType tny_session_camel_get_type (void); 
    5757 
    58 void              tny_session_camel_set_pass_func (TnySessionCamel *self, TnyAccount *account, TnyGetPassFunc get_pass_func); 
    59 void              tny_session_camel_set_forget_pass_func (TnySessionCamel *self, TnyAccount *account, TnyForgetPassFunc get_forget_pass_func); 
    60  
    61 void              tny_session_camel_set_account_store (TnySessionCamel *self, TnyAccountStore *account_store); 
    62 void              tny_session_camel_set_device (TnySessionCamel *self, TnyDevice *device); 
    63 void              tny_session_camel_set_current_accounts (TnySessionCamel *self, TnyList *list); 
     58void tny_session_camel_set_pass_func (TnySessionCamel *self, TnyAccount *account, TnyGetPassFunc get_pass_func); 
     59void tny_session_camel_set_forget_pass_func (TnySessionCamel *self, TnyAccount *account, TnyForgetPassFunc get_forget_pass_func); 
     60void tny_session_camel_set_account_store (TnySessionCamel *self, TnyAccountStore *account_store); 
     61void tny_session_camel_set_device (TnySessionCamel *self, TnyDevice *device); 
    6462 
    6563G_END_DECLS 
  • trunk/libtinymail-gnome-desktop/tny-gnome-account-store.c

    r906 r949  
    487487        } 
    488488 
    489         tny_session_camel_set_current_accounts (priv->session, list); 
    490  
    491489        return;  
    492490} 
  • trunk/libtinymail-gpe/tny-gpe-account-store.c

    r906 r949  
    370370        } 
    371371 
    372         tny_session_camel_set_current_accounts (priv->session, list); 
    373  
    374372        return;  
    375373} 
  • trunk/libtinymail-maemo/tny-maemo-account-store.c

    r906 r949  
    372372        } 
    373373 
    374         tny_session_camel_set_current_accounts (priv->session, list); 
    375  
    376374        return;  
    377375} 
  • trunk/libtinymail-olpc/tny-olpc-account-store.c

    r906 r949  
    304304        g_dir_close (dir); 
    305305 
    306  
    307         tny_session_camel_set_current_accounts (priv->session, list); 
    308  
    309306        return;  
    310307} 
  • trunk/libtinymailui-gtk/tny-gtk-account-list-model-iterator-priv.h

    r941 r949  
    4444        GObject parent; 
    4545        TnyGtkAccountListModel *model; 
    46         GtkTreeIter *current, *previous; 
    47         gboolean has_first, has_next; 
     46        GList *current; 
    4847}; 
    4948 
  • trunk/libtinymailui-gtk/tny-gtk-account-list-model-iterator.c

    r941 r949  
    2828GType _tny_gtk_account_list_model_iterator_get_type (void); 
    2929 
    30 static void 
    31 prep_iterator (TnyGtkAccountListModelIterator *self) 
    32 { 
    33         if (!self->has_first)  
    34         { 
    35                 GtkTreeIter iter; 
    36              
    37                 self->has_first = gtk_tree_model_get_iter_first (GTK_TREE_MODEL (self->model),  
    38                         self->current);              
    39                 self->has_next = gtk_tree_model_iter_next (GTK_TREE_MODEL (self->model), &iter); 
    40         } 
    41 } 
    4230 
    4331void  
     
    4533{ 
    4634        self->model = model; 
    47         prep_iterator (self); 
     35        self->current = model->first; 
     36 
    4837        return; 
    4938} 
     
    6857        self->model = NULL; 
    6958        self->current = NULL; 
    70         self->has_first = FALSE; 
    71         self->has_next = FALSE; 
    72         self->previous = NULL; 
    73      
     59 
    7460        return; 
    7561} 
     
    7864tny_gtk_account_list_model_iterator_finalize (GObject *object) 
    7965{ 
    80         TnyGtkAccountListModelIterator *self = (TnyGtkAccountListModelIterator *) object; 
    81         self->has_first = FALSE; 
    82         self->has_next = FALSE; 
    83      
    8466        (*parent_class->finalize) (object); 
    8567 
     
    9375        TnyGtkAccountListModelIterator *me = (TnyGtkAccountListModelIterator*) self; 
    9476 
     77        if (G_UNLIKELY (!me || !me->current || !me->model)) 
     78                return; 
    9579 
    9680        /* Move the iterator to the next node */ 
    9781 
    9882        g_mutex_lock (me->model->iterator_lock); 
    99      
    100         prep_iterator (me); 
    101      
    102         me->previous = me->current; 
    103         me->has_next = gtk_tree_model_iter_next (GTK_TREE_MODEL (me->model), 
    104                         me->current); 
    105          
     83        me->current = g_list_next (me->current); 
    10684        g_mutex_unlock (me->model->iterator_lock); 
    10785 
     
    11795                return; 
    11896 
    119         /* Move the iterator to the previous node (or the first) */ 
    120  
    121         g_mutex_lock (me->model->iterator_lock); 
    122      
    123         prep_iterator (me); 
    124  
    125         if (me->previous) 
    126                 me->current = me->previous; 
    127      
     97        /* Move the iterator to the previous node */ 
     98 
     99        g_mutex_lock (me->model->iterator_lock); 
     100        me->current = g_list_previous (me->current); 
    128101        g_mutex_unlock (me->model->iterator_lock); 
    129102 
     
    136109{ 
    137110        TnyGtkAccountListModelIterator *me = (TnyGtkAccountListModelIterator*) self; 
    138        
     111       
    139112        if (G_UNLIKELY (!me || !me->model)) 
    140113                return TRUE; 
    141114 
    142         return ((!me->has_first) || (!me->has_next)); 
    143 
     115        return me->current == NULL; 
     116
     117 
    144118 
    145119 
     
    149123        TnyGtkAccountListModelIterator *me = (TnyGtkAccountListModelIterator*) self; 
    150124 
    151        if (G_UNLIKELY (!me || !me->model)) 
     125       if (G_UNLIKELY (!me || !me->current || !me->model)) 
    152126                return; 
    153127 
     
    157131 
    158132        g_mutex_lock (me->model->iterator_lock); 
    159      
    160         prep_iterator (me); 
    161      
    162         gtk_tree_model_get_iter_first (GTK_TREE_MODEL (me->model),  
    163                         me->current); 
    164      
     133        me->current = me->model->first; 
    165134        g_mutex_unlock (me->model->iterator_lock); 
    166135 
     
    173142{ 
    174143        TnyGtkAccountListModelIterator *me = (TnyGtkAccountListModelIterator*) self; 
    175         gboolean next = FALSE; 
    176         gint i=0; 
    177  
    178         if (G_UNLIKELY (!me || !me->model)) 
    179                 return; 
    180      
     144 
     145        if (G_UNLIKELY (!me || !me->current || !me->model)) 
     146                return; 
     147 
    181148        /* Move the iterator to the nth node. We'll count from zero, 
    182149           so we start with the first node of which we know the model 
     
    184151 
    185152        g_mutex_lock (me->model->iterator_lock); 
    186         next = gtk_tree_model_get_iter_first (GTK_TREE_MODEL (me->model),  
    187                         me->current); 
    188         while (next && i < nth) 
    189         { 
    190                 next = gtk_tree_model_iter_next (GTK_TREE_MODEL (me->model),  
    191                                 me->current); 
    192                 i++; 
    193         } 
    194      
     153        me->current = g_list_nth (me->model->first, nth); 
    195154        g_mutex_unlock (me->model->iterator_lock); 
    196155 
     
    203162{ 
    204163        TnyGtkAccountListModelIterator *me = (TnyGtkAccountListModelIterator*) self; 
    205         TnyAccount *retval; 
     164        gpointer retval; 
    206165 
    207166        if (G_UNLIKELY (!me || !me->model)) 
     
    211170 
    212171        g_mutex_lock (me->model->iterator_lock); 
    213         /* This indeed adds a reference (which is good) */ 
    214         gtk_tree_model_get (GTK_TREE_MODEL (me->model), me->current, 
    215                 TNY_GTK_ACCOUNT_LIST_MODEL_INSTANCE_COLUMN, retval, -1); 
    216         g_mutex_unlock (me->model->iterator_lock); 
     172        retval = (G_UNLIKELY (me->current)) ? me->current->data : NULL; 
     173        g_mutex_unlock (me->model->iterator_lock); 
     174 
     175        if (retval) 
     176                g_object_ref (G_OBJECT(retval)); 
    217177 
    218178        return (GObject*)retval; 
  • trunk/libtinymailui-gtk/tny-gtk-account-list-model.c

    r941 r949  
    5858} 
    5959 
     60static void  
     61destroy_accs (gpointer item, gpointer user_data) 
     62{ 
     63        if (item && G_IS_OBJECT (item)) 
     64                g_object_unref (G_OBJECT (item)); 
     65        return; 
     66} 
     67 
    6068static void 
    6169tny_gtk_account_list_model_finalize (GObject *object) 
    6270{ 
    6371        TnyGtkAccountListModel *me = (TnyGtkAccountListModel*) object; 
    64  
     72     
     73        g_mutex_lock (me->iterator_lock); 
     74        g_list_foreach (me->first, destroy_accs, NULL); 
     75        g_mutex_unlock (me->iterator_lock); 
     76     
    6577        (*parent_class->finalize) (object); 
    6678} 
     
    8799 
    88100        me->iterator_lock = g_mutex_new (); 
    89  
     101        me->first = NULL; 
     102     
    90103        gtk_list_store_set_column_types (store,  
    91104                TNY_GTK_ACCOUNT_LIST_MODEL_N_COLUMNS, types); 
     
    115128     
    116129        g_mutex_lock (me->iterator_lock); 
     130        g_object_ref (G_OBJECT (item)); 
     131        me->first = g_list_prepend (me->first, item);     
    117132        gtk_list_store_prepend (store, &iter); 
    118133        gtk_list_store_set (store, &iter,  
    119134                TNY_GTK_ACCOUNT_LIST_MODEL_NAME_COLUMN, tny_account_get_name (account), 
    120                 TNY_GTK_ACCOUNT_LIST_MODEL_INSTANCE_COLUMN, account, -1);     
     135                TNY_GTK_ACCOUNT_LIST_MODEL_INSTANCE_COLUMN, account, -1);  
    121136        g_mutex_unlock (me->iterator_lock); 
    122137} 
     
    131146         
    132147        g_mutex_lock (me->iterator_lock); 
     148        g_object_ref (G_OBJECT (item));  
     149        me->first = g_list_append (me->first, item);     
    133150        gtk_list_store_append (store, &iter); 
    134151        gtk_list_store_set (store, &iter,  
     
    146163     
    147164        g_mutex_lock (me->iterator_lock); 
    148         gtk_tree_model_get_iter_first (GTK_TREE_MODEL (me), &iter); 
    149         while (gtk_tree_model_iter_next (GTK_TREE_MODEL (me), &iter)) 
    150                 retval++; 
     165        retval = me->first?g_list_length (me->first):0; 
    151166        g_mutex_unlock (me->iterator_lock); 
    152167 
     
    168183        g_mutex_lock (me->iterator_lock); 
    169184         
     185        me->first = g_list_remove (me->first, (gconstpointer)item); 
     186     
    170187        gtk_tree_model_get_iter_first (model, &iter); 
    171188        while (gtk_tree_model_iter_next (model, &iter)) 
     
    190207} 
    191208 
    192  
    193 typedef struct  
    194 { 
    195         gpointer user_data; 
    196         GFunc func; 
    197 } ForeachHelpr; 
    198  
    199 static gboolean  
    200 tny_gtk_account_list_model_foreach_in_the_list_impl (GtkTreeModel *model, 
    201                 GtkTreePath *path, GtkTreeIter *iter, gpointer data) 
    202 { 
    203         ForeachHelpr *dta = (ForeachHelpr*) data; 
    204         TnyAccount *item; 
    205  
    206         gtk_tree_model_get (model, iter,  
    207                 TNY_GTK_ACCOUNT_LIST_MODEL_INSTANCE_COLUMN, &item, -1); 
    208         dta->func (item, dta->user_data); 
    209      
    210         g_object_unref (G_OBJECT (item)); 
    211         return FALSE; 
    212 } 
    213          
    214209static void  
    215210tny_gtk_account_list_model_foreach_in_the_list (TnyList *self, GFunc func, gpointer user_data) 
    216211{ 
    217212        TnyGtkAccountListModel *me = (TnyGtkAccountListModel*)self; 
    218         ForeachHelpr *dta = g_new0 (ForeachHelpr, 1); 
    219      
    220         dta->user_data = user_data; 
    221         dta->func = func; 
    222      
     213 
    223214        /* Foreach item in the list (without using a slower iterator) */ 
    224215 
    225216        g_mutex_lock (me->iterator_lock); 
    226         gtk_tree_model_foreach (GTK_TREE_MODEL (me),  
    227                 tny_gtk_account_list_model_foreach_in_the_list_impl, dta); 
    228         g_mutex_unlock (me->iterator_lock); 
    229  
    230         g_free (dta); 
     217        g_list_foreach (me->first, func, user_data); 
     218        g_mutex_unlock (me->iterator_lock); 
    231219 
    232220        return; 
     
    239227        TnyGtkAccountListModel *me = (TnyGtkAccountListModel*)self; 
    240228        TnyGtkAccountListModel *copy = g_object_new (TNY_TYPE_GTK_ACCOUNT_LIST_MODEL, NULL); 
    241  
    242         /* This only copies the TnyList pieces. The result is not a 
    243            correct or good TnyHeaderListModel. But it will be a correct 
    244            TnyList instance. It is the only thing the user of this 
    245            method expects. 
    246  
    247            The new list will point to the same instances, of course. It's 
    248            only a copy of the list-nodes of course. */ 
    249  
    250         g_mutex_lock (me->iterator_lock); 
    251         tny_gtk_account_list_model_foreach_in_the_list (TNY_LIST (copy),  
    252                         (GFunc)g_object_ref, NULL); 
    253         g_mutex_unlock (me->iterator_lock); 
     229     
     230        g_mutex_lock (me->iterator_lock); 
     231        GList *list_copy = g_list_copy (me->first); 
     232        g_list_foreach (list_copy, (GFunc)g_object_ref, NULL); 
     233        copy->first = list_copy; 
     234        g_mutex_unlock (me->iterator_lock);     
    254235 
    255236        return TNY_LIST (copy); 
  • trunk/libtinymailui-gtk/tny-gtk-account-list-model.h

    r947 r949  
    5353        GtkListStore parent; 
    5454        GMutex *iterator_lock; 
     55        GList *first; 
    5556}; 
    5657 
  • trunk/libtinymailui-gtk/tny-gtk-account-tree-model.c

    r943 r949  
    3535 
    3636static GObjectClass *parent_class = NULL; 
     37static void recurse_folders_async (TnyGtkAccountTreeModel *self, TnyFolderStore *store, TnyFolderStoreQuery *query, GtkTreeIter *parent_tree_iter); 
    3738 
    3839typedef void (*treeaddfunc) (GtkTreeStore *tree_store, GtkTreeIter *iter, GtkTreeIter *parent); 
    3940 
    4041 
    41  
    42 static void 
    43 recurse_folders (TnyGtkAccountTreeModel *self, TnyFolderStore *store, TnyFolderStoreQuery *query, GtkTreeIter *parent_tree_iter) 
     42typedef struct { 
     43        GtkTreeIter *parent_tree_iter; 
     44        TnyGtkAccountTreeModel *self; 
     45        TnyFolderStoreQuery *query; 
     46} AsyncHelpr; 
     47 
     48static void 
     49recurse_get_folders_callback (TnyFolderStore *self, TnyList *folders, gpointer user_data) 
     50
     51        AsyncHelpr *hlrp = user_data; 
     52        TnyIterator *iter = tny_list_create_iterator (folders); 
     53 
     54        while (!tny_iterator_is_done (iter)) 
     55        { 
     56                GtkTreeStore *model = GTK_TREE_STORE (hlrp->self); 
     57                TnyFolderStore *folder = (TnyFolderStore*) tny_iterator_get_current (iter); 
     58                GtkTreeIter *tree_iter = gtk_tree_iter_copy (hlrp->parent_tree_iter); 
     59             
     60                gtk_tree_store_append (model, tree_iter, hlrp->parent_tree_iter); 
     61 
     62                gtk_tree_store_set (model, tree_iter, 
     63                        TNY_GTK_ACCOUNT_TREE_MODEL_NAME_COLUMN,  
     64                        tny_folder_get_name (TNY_FOLDER (folder)), 
     65                        TNY_GTK_ACCOUNT_TREE_MODEL_UNREAD_COLUMN,  
     66                        tny_folder_get_unread_count (TNY_FOLDER (folder)), 
     67                        TNY_GTK_ACCOUNT_TREE_MODEL_TYPE_COLUMN, 
     68                        tny_folder_get_folder_type (TNY_FOLDER (folder)), 
     69                        TNY_GTK_ACCOUNT_TREE_MODEL_INSTANCE_COLUMN, 
     70                        folder, -1); 
     71             
     72                recurse_folders_async (hlrp->self, folder, hlrp->query, tree_iter); 
     73             
     74                g_object_unref (G_OBJECT (folder)); 
     75 
     76                tny_iterator_next (iter);            
     77        } 
     78 
     79        g_object_unref (G_OBJECT (iter));    
     80        g_object_unref (G_OBJECT (folders)); 
     81     
     82        //gtk_tree_iter_free (hlrp->parent_tree_iter); 
     83        g_free (hlrp); 
     84     
     85
     86 
     87 
     88static void 
     89recurse_folders_async (TnyGtkAccountTreeModel *self, TnyFolderStore *store, TnyFolderStoreQuery *query, GtkTreeIter *parent_tree_iter) 
     90
     91        AsyncHelpr *hlrp = g_new0 (AsyncHelpr, 1); 
     92        TnyList *folders = tny_simple_list_new (); 
     93     
     94        hlrp->self = self; 
     95        hlrp->parent_tree_iter = parent_tree_iter; 
     96        hlrp->query = query; 
     97     
     98        tny_folder_store_get_folders_async (store, folders,  recurse_get_folders_callback, query, hlrp); 
     99
     100 
     101static void 
     102recurse_folders_sync (TnyGtkAccountTreeModel *self, TnyFolderStore *store, TnyFolderStoreQuery *query, GtkTreeIter *parent_tree_iter) 
    44103{ 
    45104        TnyIterator *iter; 
     
    67126                        folder, -1); 
    68127             
    69                 recurse_folders (self, folder, query, &tree_iter); 
     128                recurse_folders_sync (self, folder, query, &tree_iter); 
    70129             
    71130                g_object_unref (G_OBJECT (folder)); 
     
    85144        TnyList *folders = tny_simple_list_new (); 
    86145        GtkTreeIter name_iter; 
    87  
     146     
    88147        func (model, &name_iter, NULL); 
    89148 
     
    96155                account, -1); 
    97156 
    98         recurse_folders (self, TNY_FOLDER_STORE (account), NULL, &name_iter); 
     157        recurse_folders_sync (self, TNY_FOLDER_STORE (account), NULL, &name_iter); 
     158 
     159        g_object_unref (G_OBJECT (folders)); 
     160     
     161        return; 
     162
     163 
     164static void 
     165tny_gtk_account_tree_model_add_async (TnyGtkAccountTreeModel *self, TnyStoreAccount *account, treeaddfunc func) 
     166
     167        GtkTreeStore *model = GTK_TREE_STORE (self); 
     168        TnyList *folders = tny_simple_list_new (); 
     169        GtkTreeIter first, *name_iter; 
     170        gboolean need_add = TRUE; 
     171     
     172        if (!gtk_tree_model_get_iter_first (GTK_TREE_MODEL (self), &first)) 
     173        { 
     174                func (model, &first, NULL); 
     175                need_add = FALSE; 
     176        } 
     177 
     178        name_iter = gtk_tree_iter_copy (&first); 
     179 
     180        if (need_add) 
     181                func (model, name_iter, NULL); 
     182 
     183        gtk_tree_store_set (model, name_iter, 
     184                TNY_GTK_ACCOUNT_TREE_MODEL_NAME_COLUMN,  
     185                tny_account_get_name (TNY_ACCOUNT (account)), 
     186                TNY_GTK_ACCOUNT_TREE_MODEL_UNREAD_COLUMN, 0, 
     187                TNY_GTK_ACCOUNT_TREE_MODEL_TYPE_COLUMN, TNY_FOLDER_TYPE_ROOT, 
     188                TNY_GTK_ACCOUNT_TREE_MODEL_INSTANCE_COLUMN, 
     189                account, -1); 
     190 
     191        recurse_folders_async (self, TNY_FOLDER_STORE (account), NULL, name_iter); 
    99192 
    100193        g_object_unref (G_OBJECT (folders)); 
     
    105198/** 
    106199 * tny_gtk_account_tree_model_new: 
    107  * 
     200 * @async: Whether or not this component should attempt to asynchronously fill the tree 
    108201 * 
    109202 * Return value: a new #GtkTreeModel instance suitable for showing   
     
    111204 **/ 
    112205GtkTreeModel* 
    113 tny_gtk_account_tree_model_new (void
     206tny_gtk_account_tree_model_new (gboolean async
    114207{ 
    115208        TnyGtkAccountTreeModel *self = g_object_new (TNY_TYPE_GTK_ACCOUNT_TREE_MODEL, NULL); 
    116  
     209        self->is_async = async; 
    117210        return GTK_TREE_MODEL (self); 
    118211} 
     
    181274        g_object_ref (G_OBJECT (item)); 
    182275        me->first = g_list_prepend (me->first, item); 
    183         tny_gtk_account_tree_model_add (me, TNY_STORE_ACCOUNT (item),  
    184                 gtk_tree_store_prepend); 
    185  
     276     
     277        if (me->is_async) 
     278                tny_gtk_account_tree_model_add_async (me, TNY_STORE_ACCOUNT (item),  
     279                        gtk_tree_store_prepend); 
     280        else 
     281                tny_gtk_account_tree_model_add (me, TNY_STORE_ACCOUNT (item),  
     282                        gtk_tree_store_prepend); 
     283         
    186284        g_mutex_unlock (me->iterator_lock); 
    187285} 
     
    197295        g_object_ref (G_OBJECT (item)); 
    198296        me->first = g_list_append (me->first, item); 
    199         tny_gtk_account_tree_model_add (me, TNY_STORE_ACCOUNT (item),  
    200                 gtk_tree_store_append); 
    201  
     297     
     298        if (me->is_async) 
     299                tny_gtk_account_tree_model_add_async (me, TNY_STORE_ACCOUNT (item),  
     300                        gtk_tree_store_append); 
     301        else 
     302                tny_gtk_account_tree_model_add (me, TNY_STORE_ACCOUNT (item),  
     303                        gtk_tree_store_append); 
     304     
    202305        g_mutex_unlock (me->iterator_lock); 
    203306} 
  • trunk/libtinymailui-gtk/tny-gtk-account-tree-model.h

    r943 r949  
    5858        GList *first; 
    5959        GMutex *iterator_lock; 
     60        gboolean is_async; 
    6061}; 
    6162 
     
    6768GType tny_gtk_account_tree_model_get_type (void); 
    6869GType tny_gtk_account_tree_model_column_get_type (void); 
    69 GtkTreeModel* tny_gtk_account_tree_model_new (void); 
     70GtkTreeModel* tny_gtk_account_tree_model_new (gboolean async); 
    7071 
    7172G_END_DECLS 
  • trunk/libtinymailui-gtk/tny-gtk-attach-list-model.c

    r921 r949  
    137137        TnyGtkAttachListModel *me = (TnyGtkAttachListModel*) object; 
    138138 
    139  
    140139        g_mutex_lock (me->iterator_lock); 
    141140        g_list_foreach (me->first, destroy_parts, NULL); 
     
    177176        types[0] = GDK_TYPE_PIXBUF; 
    178177        me->iterator_lock = g_mutex_new (); 
    179  
     178        me->first = NULL; 
     179     
    180180        gtk_list_store_set_column_types (store,  
    181181                TNY_GTK_ATTACH_LIST_MODEL_N_COLUMNS, types); 
  • trunk/tests/shared/account-store.c

    r906 r949  
    121121        tny_list_prepend (list, (GObject*)account); 
    122122        g_object_unref (G_OBJECT (account)); 
    123  
    124         tny_session_camel_set_current_accounts (me->session, list); 
    125123     
    126124        return;  
  • trunk/tinymail/tny-demoui-summary-view.c

    r948 r949  
    127127           TnyList and the GtkTreeModel interfaces) */ 
    128128 
    129         GtkTreeModel *mailbox_model = tny_gtk_account_tree_model_new (); 
     129        GtkTreeModel *mailbox_model = tny_gtk_account_tree_model_new (FALSE); 
    130130        TnyList *accounts = TNY_LIST (mailbox_model); 
    131131