Changeset 949
- Timestamp:
- 09/13/06 21:05:28
- Files:
-
- trunk/ChangeLog (modified) (2 diffs)
- trunk/docs/devel/reference/tmpl/tny-gtk-account-list-model-iterator-priv.sgml (modified) (1 diff)
- trunk/docs/devel/reference/tmpl/tny-gtk-account-tree-model.sgml (modified) (1 diff)
- trunk/docs/devel/reference/tmpl/tny-gtk-folder-tree-model-iterator-priv.sgml (modified) (1 diff)
- trunk/docs/devel/reference/tmpl/tny-gtk-folder-tree-model.sgml (modified) (1 diff)
- trunk/docs/devel/reference/tmpl/tny-session-camel.sgml (modified) (1 diff)
- trunk/libtinymail-camel/Makefile.am (modified) (1 diff)
- trunk/libtinymail-camel/tny-camel-account.c (modified) (3 diffs)
- trunk/libtinymail-camel/tny-session-camel-priv.h (added)
- trunk/libtinymail-camel/tny-session-camel.c (modified) (5 diffs)
- trunk/libtinymail-camel/tny-session-camel.h (modified) (2 diffs)
- trunk/libtinymail-gnome-desktop/tny-gnome-account-store.c (modified) (1 diff)
- trunk/libtinymail-gpe/tny-gpe-account-store.c (modified) (1 diff)
- trunk/libtinymail-maemo/tny-maemo-account-store.c (modified) (1 diff)
- trunk/libtinymail-olpc/tny-olpc-account-store.c (modified) (1 diff)
- trunk/libtinymailui-gtk/tny-gtk-account-list-model-iterator-priv.h (modified) (1 diff)
- trunk/libtinymailui-gtk/tny-gtk-account-list-model-iterator.c (modified) (13 diffs)
- trunk/libtinymailui-gtk/tny-gtk-account-list-model.c (modified) (8 diffs)
- trunk/libtinymailui-gtk/tny-gtk-account-list-model.h (modified) (1 diff)
- trunk/libtinymailui-gtk/tny-gtk-account-tree-model.c (modified) (8 diffs)
- trunk/libtinymailui-gtk/tny-gtk-account-tree-model.h (modified) (2 diffs)
- trunk/libtinymailui-gtk/tny-gtk-attach-list-model.c (modified) (2 diffs)
- trunk/tests/shared/account-store.c (modified) (1 diff)
- trunk/tinymail/tny-demoui-summary-view.c (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/ChangeLog
r947 r949 1 1 2006-09-13 Philip Van Hoof <pvanhoof@gnome.org> 2 2 3 * Removed silly API in TnySessionCamel, solved the need for the API internally 4 * Bug fixes in TnySessionCamel 3 5 * Introduction of TnyGtkFolderTreeModel (however, it's atm unfinished) 4 6 * Introduction of TnyGtkAccountListModel which could be useful for for … … 15 17 * Added documentation about tinymail enumerations 16 18 19 * This wasa major API change in libtinymail-camel 20 17 21 2006-09-11 Philip Van Hoof <pvanhoof@gnome.org> 18 22 trunk/docs/devel/reference/tmpl/tny-gtk-account-list-model-iterator-priv.sgml
r944 r949 26 26 @model: 27 27 @current: 28 @previous:29 @has_first:30 @has_next:31 28 trunk/docs/devel/reference/tmpl/tny-gtk-account-tree-model.sgml
r944 r949 95 95 </para> 96 96 97 @async: 97 98 @Returns: 98 99 trunk/docs/devel/reference/tmpl/tny-gtk-folder-tree-model-iterator-priv.sgml
r947 r949 10 10 </para> 11 11 12 13 12 <!-- ##### SECTION See_Also ##### --> 14 13 <para> 15 14 16 15 </para> 17 18 16 19 17 <!-- ##### SECTION Stability_Level ##### --> trunk/docs/devel/reference/tmpl/tny-gtk-folder-tree-model.sgml
r947 r949 29 29 </para> 30 30 31 32 33 31 <!-- ##### SECTION See_Also ##### --> 34 32 <para> 35 33 36 34 </para> 37 38 35 39 36 <!-- ##### SECTION Stability_Level ##### --> trunk/docs/devel/reference/tmpl/tny-session-camel.sgml
r911 r949 88 88 89 89 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 26 26 27 27 libtinymail_camel_1_0_la_SOURCES = \ 28 tny-session-camel-priv.h \ 28 29 tny-camel-common.c \ 29 30 tny-camel-common-priv.h \ trunk/libtinymail-camel/tny-camel-account.c
r900 r949 45 45 46 46 #include "tny-camel-account-priv.h" 47 #include "tny-session-camel-priv.h" 47 48 48 49 static GObjectClass *parent_class = NULL; … … 231 232 TNY_CAMEL_ACCOUNT_GET_CLASS (self)->reconnect_func (self); 232 233 234 _tny_session_camel_add_account (session, self); 235 233 236 g_static_rec_mutex_unlock (priv->service_lock); 234 237 … … 545 548 TnyCamelAccountPriv *priv = TNY_CAMEL_ACCOUNT_GET_PRIVATE (self); 546 549 550 _tny_session_camel_forget_account (priv->session, (TnyCamelAccount*) object); 547 551 _tny_camel_account_start_camel_operation (self, NULL, NULL, NULL); 548 552 _tny_camel_account_stop_camel_operation (self); trunk/libtinymail-camel/tny-session-camel.c
r906 r949 30 30 #include <camel/camel-filter-driver.h> 31 31 32 33 32 #include <camel/camel-store.h> 34 33 #include <camel/camel.h> … … 42 41 #include <tny-camel-transport-account.h> 43 42 43 #include "tny-session-camel-priv.h" 44 44 #include "tny-camel-store-account-priv.h" 45 45 #include "tny-camel-transport-account-priv.h" … … 443 443 444 444 void 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 450 void 451 _tny_session_camel_forget_account (TnySessionCamel *self, TnyCamelAccount *account) 452 { 453 self->current_accounts = g_list_remove (self->current_accounts, account); 454 } 455 456 static void 457 foreach_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); 448 462 } 449 463 … … 455 469 camel_session_set_online ((CamelSession *) self, online); 456 470 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 459 472 && self->account_store) 460 473 { 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); 478 476 } 479 477 … … 481 479 g_signal_emit (self->account_store, 482 480 tny_account_store_signals [TNY_ACCOUNT_STORE_ACCOUNTS_RELOADED], 0); 483 484 481 485 482 self->first_switch = FALSE; trunk/libtinymail-camel/tny-session-camel.h
r900 r949 41 41 gboolean interactive, prev_constat, first_switch; 42 42 guint connchanged_signal; 43 TnyList *current_accounts;43 GList *current_accounts; 44 44 }; 45 45 … … 48 48 CamelSessionClass parent_class; 49 49 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); 53 53 54 54 }; 55 55 56 CamelType tny_session_camel_get_type(void);56 CamelType tny_session_camel_get_type (void); 57 57 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); 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 void tny_session_camel_set_account_store (TnySessionCamel *self, TnyAccountStore *account_store); 61 void tny_session_camel_set_device (TnySessionCamel *self, TnyDevice *device); 64 62 65 63 G_END_DECLS trunk/libtinymail-gnome-desktop/tny-gnome-account-store.c
r906 r949 487 487 } 488 488 489 tny_session_camel_set_current_accounts (priv->session, list);490 491 489 return; 492 490 } trunk/libtinymail-gpe/tny-gpe-account-store.c
r906 r949 370 370 } 371 371 372 tny_session_camel_set_current_accounts (priv->session, list);373 374 372 return; 375 373 } trunk/libtinymail-maemo/tny-maemo-account-store.c
r906 r949 372 372 } 373 373 374 tny_session_camel_set_current_accounts (priv->session, list);375 376 374 return; 377 375 } trunk/libtinymail-olpc/tny-olpc-account-store.c
r906 r949 304 304 g_dir_close (dir); 305 305 306 307 tny_session_camel_set_current_accounts (priv->session, list);308 309 306 return; 310 307 } trunk/libtinymailui-gtk/tny-gtk-account-list-model-iterator-priv.h
r941 r949 44 44 GObject parent; 45 45 TnyGtkAccountListModel *model; 46 GtkTreeIter *current, *previous; 47 gboolean has_first, has_next; 46 GList *current; 48 47 }; 49 48 trunk/libtinymailui-gtk/tny-gtk-account-list-model-iterator.c
r941 r949 28 28 GType _tny_gtk_account_list_model_iterator_get_type (void); 29 29 30 static void31 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 }42 30 43 31 void … … 45 33 { 46 34 self->model = model; 47 prep_iterator (self); 35 self->current = model->first; 36 48 37 return; 49 38 } … … 68 57 self->model = NULL; 69 58 self->current = NULL; 70 self->has_first = FALSE; 71 self->has_next = FALSE; 72 self->previous = NULL; 73 59 74 60 return; 75 61 } … … 78 64 tny_gtk_account_list_model_iterator_finalize (GObject *object) 79 65 { 80 TnyGtkAccountListModelIterator *self = (TnyGtkAccountListModelIterator *) object;81 self->has_first = FALSE;82 self->has_next = FALSE;83 84 66 (*parent_class->finalize) (object); 85 67 … … 93 75 TnyGtkAccountListModelIterator *me = (TnyGtkAccountListModelIterator*) self; 94 76 77 if (G_UNLIKELY (!me || !me->current || !me->model)) 78 return; 95 79 96 80 /* Move the iterator to the next node */ 97 81 98 82 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); 106 84 g_mutex_unlock (me->model->iterator_lock); 107 85 … … 117 95 return; 118 96 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); 128 101 g_mutex_unlock (me->model->iterator_lock); 129 102 … … 136 109 { 137 110 TnyGtkAccountListModelIterator *me = (TnyGtkAccountListModelIterator*) self; 138 111 139 112 if (G_UNLIKELY (!me || !me->model)) 140 113 return TRUE; 141 114 142 return ((!me->has_first) || (!me->has_next)); 143 } 115 return me->current == NULL; 116 } 117 144 118 145 119 … … 149 123 TnyGtkAccountListModelIterator *me = (TnyGtkAccountListModelIterator*) self; 150 124 151 if (G_UNLIKELY (!me|| !me->model))125 if (G_UNLIKELY (!me || !me->current || !me->model)) 152 126 return; 153 127 … … 157 131 158 132 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; 165 134 g_mutex_unlock (me->model->iterator_lock); 166 135 … … 173 142 { 174 143 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 181 148 /* Move the iterator to the nth node. We'll count from zero, 182 149 so we start with the first node of which we know the model … … 184 151 185 152 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); 195 154 g_mutex_unlock (me->model->iterator_lock); 196 155 … … 203 162 { 204 163 TnyGtkAccountListModelIterator *me = (TnyGtkAccountListModelIterator*) self; 205 TnyAccount *retval;164 gpointer retval; 206 165 207 166 if (G_UNLIKELY (!me || !me->model)) … … 211 170 212 171 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)); 217 177 218 178 return (GObject*)retval; trunk/libtinymailui-gtk/tny-gtk-account-list-model.c
r941 r949 58 58 } 59 59 60 static void 61 destroy_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 60 68 static void 61 69 tny_gtk_account_list_model_finalize (GObject *object) 62 70 { 63 71 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 65 77 (*parent_class->finalize) (object); 66 78 } … … 87 99 88 100 me->iterator_lock = g_mutex_new (); 89 101 me->first = NULL; 102 90 103 gtk_list_store_set_column_types (store, 91 104 TNY_GTK_ACCOUNT_LIST_MODEL_N_COLUMNS, types); … … 115 128 116 129 g_mutex_lock (me->iterator_lock); 130 g_object_ref (G_OBJECT (item)); 131 me->first = g_list_prepend (me->first, item); 117 132 gtk_list_store_prepend (store, &iter); 118 133 gtk_list_store_set (store, &iter, 119 134 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); 121 136 g_mutex_unlock (me->iterator_lock); 122 137 } … … 131 146 132 147 g_mutex_lock (me->iterator_lock); 148 g_object_ref (G_OBJECT (item)); 149 me->first = g_list_append (me->first, item); 133 150 gtk_list_store_append (store, &iter); 134 151 gtk_list_store_set (store, &iter, … … 146 163 147 164 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; 151 166 g_mutex_unlock (me->iterator_lock); 152 167 … … 168 183 g_mutex_lock (me->iterator_lock); 169 184 185 me->first = g_list_remove (me->first, (gconstpointer)item); 186 170 187 gtk_tree_model_get_iter_first (model, &iter); 171 188 while (gtk_tree_model_iter_next (model, &iter)) … … 190 207 } 191 208 192 193 typedef struct194 {195 gpointer user_data;196 GFunc func;197 } ForeachHelpr;198 199 static gboolean200 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 214 209 static void 215 210 tny_gtk_account_list_model_foreach_in_the_list (TnyList *self, GFunc func, gpointer user_data) 216 211 { 217 212 TnyGtkAccountListModel *me = (TnyGtkAccountListModel*)self; 218 ForeachHelpr *dta = g_new0 (ForeachHelpr, 1); 219 220 dta->user_data = user_data; 221 dta->func = func; 222 213 223 214 /* Foreach item in the list (without using a slower iterator) */ 224 215 225 216 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); 231 219 232 220 return; … … 239 227 TnyGtkAccountListModel *me = (TnyGtkAccountListModel*)self; 240 228 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); 254 235 255 236 return TNY_LIST (copy); trunk/libtinymailui-gtk/tny-gtk-account-list-model.h
r947 r949 53 53 GtkListStore parent; 54 54 GMutex *iterator_lock; 55 GList *first; 55 56 }; 56 57 trunk/libtinymailui-gtk/tny-gtk-account-tree-model.c
r943 r949 35 35 36 36 static GObjectClass *parent_class = NULL; 37 static void recurse_folders_async (TnyGtkAccountTreeModel *self, TnyFolderStore *store, TnyFolderStoreQuery *query, GtkTreeIter *parent_tree_iter); 37 38 38 39 typedef void (*treeaddfunc) (GtkTreeStore *tree_store, GtkTreeIter *iter, GtkTreeIter *parent); 39 40 40 41 41 42 static void 43 recurse_folders (TnyGtkAccountTreeModel *self, TnyFolderStore *store, TnyFolderStoreQuery *query, GtkTreeIter *parent_tree_iter) 42 typedef struct { 43 GtkTreeIter *parent_tree_iter; 44 TnyGtkAccountTreeModel *self; 45 TnyFolderStoreQuery *query; 46 } AsyncHelpr; 47 48 static void 49 recurse_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 88 static void 89 recurse_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 101 static void 102 recurse_folders_sync (TnyGtkAccountTreeModel *self, TnyFolderStore *store, TnyFolderStoreQuery *query, GtkTreeIter *parent_tree_iter) 44 103 { 45 104 TnyIterator *iter; … … 67 126 folder, -1); 68 127 69 recurse_folders (self, folder, query, &tree_iter);128 recurse_folders_sync (self, folder, query, &tree_iter); 70 129 71 130 g_object_unref (G_OBJECT (folder)); … … 85 144 TnyList *folders = tny_simple_list_new (); 86 145 GtkTreeIter name_iter; 87 146 88 147 func (model, &name_iter, NULL); 89 148 … … 96 155 account, -1); 97 156 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 164 static void 165 tny_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); 99 192 100 193 g_object_unref (G_OBJECT (folders)); … … 105 198 /** 106 199 * tny_gtk_account_tree_model_new: 107 * 200 * @async: Whether or not this component should attempt to asynchronously fill the tree 108 201 * 109 202 * Return value: a new #GtkTreeModel instance suitable for showing … … 111 204 **/ 112 205 GtkTreeModel* 113 tny_gtk_account_tree_model_new ( void)206 tny_gtk_account_tree_model_new (gboolean async) 114 207 { 115 208 TnyGtkAccountTreeModel *self = g_object_new (TNY_TYPE_GTK_ACCOUNT_TREE_MODEL, NULL); 116 209 self->is_async = async; 117 210 return GTK_TREE_MODEL (self); 118 211 } … … 181 274 g_object_ref (G_OBJECT (item)); 182 275 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 186 284 g_mutex_unlock (me->iterator_lock); 187 285 } … … 197 295 g_object_ref (G_OBJECT (item)); 198 296 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 202 305 g_mutex_unlock (me->iterator_lock); 203 306 } trunk/libtinymailui-gtk/tny-gtk-account-tree-model.h
r943 r949 58 58 GList *first; 59 59 GMutex *iterator_lock; 60 gboolean is_async; 60 61 }; 61 62 … … 67 68 GType tny_gtk_account_tree_model_get_type (void); 68 69 GType tny_gtk_account_tree_model_column_get_type (void); 69 GtkTreeModel* tny_gtk_account_tree_model_new ( void);70 GtkTreeModel* tny_gtk_account_tree_model_new (gboolean async); 70 71 71 72 G_END_DECLS trunk/libtinymailui-gtk/tny-gtk-attach-list-model.c
r921 r949 137 137 TnyGtkAttachListModel *me = (TnyGtkAttachListModel*) object; 138 138 139 140 139 g_mutex_lock (me->iterator_lock); 141 140 g_list_foreach (me->first, destroy_parts, NULL); … … 177 176 types[0] = GDK_TYPE_PIXBUF; 178 177 me->iterator_lock = g_mutex_new (); 179 178 me->first = NULL; 179 180 180 gtk_list_store_set_column_types (store, 181 181 TNY_GTK_ATTACH_LIST_MODEL_N_COLUMNS, types); trunk/tests/shared/account-store.c
r906 r949 121 121 tny_list_prepend (list, (GObject*)account); 122 122 g_object_unref (G_OBJECT (account)); 123 124 tny_session_camel_set_current_accounts (me->session, list);125 123 126 124 return; trunk/tinymail/tny-demoui-summary-view.c
r948 r949 127 127 TnyList and the GtkTreeModel interfaces) */ 128 128 129 GtkTreeModel *mailbox_model = tny_gtk_account_tree_model_new ( );129 GtkTreeModel *mailbox_model = tny_gtk_account_tree_model_new (FALSE); 130 130 TnyList *accounts = TNY_LIST (mailbox_model); 131 131
