Changeset 1935
- Timestamp:
- 05/09/07 21:56:11
- Files:
-
- trunk/ChangeLog (modified) (1 diff)
- trunk/libtinymailui-gtk/tny-gtk-header-list-iterator-priv.h (modified) (1 diff)
- trunk/libtinymailui-gtk/tny-gtk-header-list-iterator.c (modified) (12 diffs)
- trunk/libtinymailui-gtk/tny-gtk-header-list-model.c (modified) (55 diffs)
- trunk/libtinymailui-gtk/tny-gtk-header-list-model.h (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/ChangeLog
r1934 r1935 1 2007-05-09 Philip Van Hoof <pvanhoof@gnome.org> 2 3 * libtinymailui-gtk/tny-gtk-header-list-model.c: Moved the private API 4 to a private type 5 6 * This was a minor API change 7 1 8 2007-05-09 Jose Dapena Paz <jdapena@igalia.com> 2 9 trunk/libtinymailui-gtk/tny-gtk-header-list-iterator-priv.h
r1708 r1935 62 62 63 63 64 65 #define TNY_GTK_HEADER_LIST_MODEL_GET_PRIVATE(o) \ 66 (G_TYPE_INSTANCE_GET_PRIVATE ((o), TNY_TYPE_GTK_HEADER_LIST_MODEL, TnyGtkHeaderListModelPriv)) 67 68 typedef struct _TnyGtkHeaderListModelPriv TnyGtkHeaderListModelPriv; 69 70 struct _TnyGtkHeaderListModelPriv 71 { 72 GStaticRecMutex *iterator_lock; 73 TnyFolder *folder; 74 gint stamp, registered; 75 gint updating_views; 76 GMutex *ra_lock, *to_lock; 77 gint cur_len; 78 guint add_timeout; 79 80 guint timeout_span; 81 GPtrArray *items; 82 GArray *del_timeouts; 83 TnyIterator *iterator; 84 }; 85 64 86 G_END_DECLS 65 87 trunk/libtinymailui-gtk/tny-gtk-header-list-iterator.c
r1708 r1935 90 90 { 91 91 TnyGtkHeaderListIterator *me = (TnyGtkHeaderListIterator*) self; 92 TnyGtkHeaderListModelPriv *mpriv; 92 93 93 94 if (G_UNLIKELY (!me || !me->model)) 94 95 return; 95 96 97 mpriv = TNY_GTK_HEADER_LIST_MODEL_GET_PRIVATE (me->model); 98 96 99 /* Move the iterator to the next node */ 97 100 98 g_static_rec_mutex_lock (m e->model->iterator_lock);101 g_static_rec_mutex_lock (mpriv->iterator_lock); 99 102 me->current++; 100 g_static_rec_mutex_unlock (m e->model->iterator_lock);103 g_static_rec_mutex_unlock (mpriv->iterator_lock); 101 104 102 105 return; … … 114 117 { 115 118 TnyGtkHeaderListIterator *me = (TnyGtkHeaderListIterator*) self; 119 TnyGtkHeaderListModelPriv *mpriv; 116 120 117 121 if (G_UNLIKELY (!me || !me->model)) … … 120 124 /* Move the iterator to the previous node */ 121 125 122 g_static_rec_mutex_lock (me->model->iterator_lock); 126 mpriv = TNY_GTK_HEADER_LIST_MODEL_GET_PRIVATE (me->model); 127 128 g_static_rec_mutex_lock (mpriv->iterator_lock); 123 129 me->current--; 124 g_static_rec_mutex_unlock (m e->model->iterator_lock);130 g_static_rec_mutex_unlock (mpriv->iterator_lock); 125 131 126 132 return; … … 130 136 _tny_gtk_header_list_iterator_is_done_nl (TnyGtkHeaderListIterator *me) 131 137 { 138 TnyGtkHeaderListModelPriv *mpriv; 139 132 140 if (G_UNLIKELY (!me || !me->model)) 133 141 return TRUE; 134 142 135 return (me->current < 0 || me->current >= me->model->items->len); 143 mpriv = TNY_GTK_HEADER_LIST_MODEL_GET_PRIVATE (me->model); 144 145 return (me->current < 0 || me->current >= mpriv->items->len); 136 146 } 137 147 … … 140 150 { 141 151 TnyGtkHeaderListIterator *me = (TnyGtkHeaderListIterator*) self; 152 TnyGtkHeaderListModelPriv *mpriv; 142 153 gboolean retval = FALSE; 143 154 … … 145 156 return FALSE; 146 157 147 g_static_rec_mutex_lock (me->model->iterator_lock); 148 retval = (me->current < 0 || me->current >= me->model->items->len); 149 g_static_rec_mutex_unlock (me->model->iterator_lock); 158 mpriv = TNY_GTK_HEADER_LIST_MODEL_GET_PRIVATE (me->model); 159 g_static_rec_mutex_lock (mpriv->iterator_lock); 160 retval = (me->current < 0 || me->current >= mpriv->items->len); 161 g_static_rec_mutex_unlock (mpriv->iterator_lock); 150 162 151 163 return retval; … … 165 177 { 166 178 TnyGtkHeaderListIterator *me = (TnyGtkHeaderListIterator*) self; 179 TnyGtkHeaderListModelPriv *mpriv; 167 180 168 181 if (G_UNLIKELY (!me || !me->current || !me->model)) 169 182 return; 170 183 171 g_static_rec_mutex_lock (me->model->iterator_lock); 184 mpriv = TNY_GTK_HEADER_LIST_MODEL_GET_PRIVATE (me->model); 185 186 g_static_rec_mutex_lock (mpriv->iterator_lock); 172 187 me->current = 0; 173 g_static_rec_mutex_unlock (m e->model->iterator_lock);188 g_static_rec_mutex_unlock (mpriv->iterator_lock); 174 189 175 190 return; … … 188 203 { 189 204 TnyGtkHeaderListIterator *me = (TnyGtkHeaderListIterator*) self; 205 TnyGtkHeaderListModelPriv *mpriv; 190 206 191 207 if (G_UNLIKELY (!me || !me->current || !me->model)) 192 208 return; 193 209 194 g_static_rec_mutex_lock (me->model->iterator_lock); 210 mpriv = TNY_GTK_HEADER_LIST_MODEL_GET_PRIVATE (me->model); 211 212 g_static_rec_mutex_lock (mpriv->iterator_lock); 195 213 me->current = nth; 196 g_static_rec_mutex_unlock (m e->model->iterator_lock);214 g_static_rec_mutex_unlock (mpriv->iterator_lock); 197 215 198 216 return; … … 203 221 _tny_gtk_header_list_iterator_get_current_nl (TnyGtkHeaderListIterator *me) 204 222 { 205 return me->model->items->pdata[me->current]; 223 TnyGtkHeaderListModelPriv *mpriv = TNY_GTK_HEADER_LIST_MODEL_GET_PRIVATE (me->model); 224 return mpriv->items->pdata[me->current]; 206 225 } 207 226 … … 210 229 { 211 230 TnyGtkHeaderListIterator *me = (TnyGtkHeaderListIterator*) self; 231 TnyGtkHeaderListModelPriv *mpriv; 212 232 gpointer retval; 213 233 … … 217 237 /* Give the data of the current node */ 218 238 219 g_static_rec_mutex_lock (me->model->iterator_lock);220 retval = me->model->items->pdata[me->current]; 221 g_static_rec_mutex_ unlock (me->model->iterator_lock);222 239 mpriv = TNY_GTK_HEADER_LIST_MODEL_GET_PRIVATE (me->model); 240 241 g_static_rec_mutex_lock (mpriv->iterator_lock); 242 retval = mpriv->items->pdata[me->current]; 223 243 if (retval) 224 g_object_ref (G_OBJECT(retval)); 225 226 return (GObject*)retval; 244 g_object_ref (retval); 245 g_static_rec_mutex_unlock (mpriv->iterator_lock); 246 247 248 return (GObject*) retval; 227 249 } 228 250 … … 238 260 return NULL; 239 261 240 g_object_ref ( G_OBJECT (me->model));262 g_object_ref (me->model); 241 263 242 264 return TNY_LIST (me->model); trunk/libtinymailui-gtk/tny-gtk-header-list-model.c
r1923 r1935 40 40 #include "tny-gtk-header-list-iterator-priv.h" 41 41 42 42 43 static gint 43 44 add_del_timeout (TnyGtkHeaderListModel *me, guint num) 44 45 { 46 TnyGtkHeaderListModelPriv *priv = TNY_GTK_HEADER_LIST_MODEL_GET_PRIVATE (me); 47 45 48 gint retval = 0; 46 g_mutex_lock (me->to_lock); 47 if (!me->del_timeouts) 48 me->del_timeouts = g_array_new (FALSE, FALSE, sizeof (guint)); 49 g_array_append_val (me->del_timeouts, num); 50 retval = me->del_timeouts->len-1; 51 g_mutex_unlock (me->to_lock); 49 g_mutex_lock (priv->to_lock); 50 if (!priv->del_timeouts) 51 priv->del_timeouts = g_array_new (FALSE, FALSE, sizeof (guint)); 52 g_array_append_val (priv->del_timeouts, num); 53 retval = priv->del_timeouts->len-1; 54 g_mutex_unlock (priv->to_lock); 55 52 56 return retval; 53 57 } … … 56 60 remove_del_timeouts (TnyGtkHeaderListModel *me) 57 61 { 62 TnyGtkHeaderListModelPriv *priv = TNY_GTK_HEADER_LIST_MODEL_GET_PRIVATE (me); 63 58 64 gint i; 59 65 guint src; 60 66 61 g_mutex_lock ( me->to_lock);62 63 if (! me->del_timeouts)67 g_mutex_lock (priv->to_lock); 68 69 if (!priv->del_timeouts) 64 70 { 65 g_mutex_unlock ( me->to_lock);71 g_mutex_unlock (priv->to_lock); 66 72 return; 67 73 } 68 74 69 for (i = 0; i < me->del_timeouts->len; i++)75 for (i = 0; i < priv->del_timeouts->len; i++) 70 76 { 71 src = g_array_index ( me->del_timeouts, guint, i);77 src = g_array_index (priv->del_timeouts, guint, i); 72 78 if (src > 0) 73 79 g_source_remove (src); 74 g_array_index ( me->del_timeouts, guint, i) = 0;75 } 76 g_array_free ( me->del_timeouts, TRUE);77 me->del_timeouts = NULL;78 g_mutex_unlock ( me->to_lock);80 g_array_index (priv->del_timeouts, guint, i) = 0; 81 } 82 g_array_free (priv->del_timeouts, TRUE); 83 priv->del_timeouts = NULL; 84 g_mutex_unlock (priv->to_lock); 79 85 } 80 86 … … 128 134 tny_gtk_header_list_model_get_iter (GtkTreeModel *self, GtkTreeIter *iter, GtkTreePath *path) 129 135 { 130 TnyGtkHeaderListModel *list_model = TNY_GTK_HEADER_LIST_MODEL (self); 131 gint i, tlen; gboolean retval=FALSE; 136 TnyGtkHeaderListModelPriv *priv = TNY_GTK_HEADER_LIST_MODEL_GET_PRIVATE (self); 137 138 gint i, tlen; 139 gboolean retval=FALSE; 132 140 133 141 g_return_val_if_fail (gtk_tree_path_get_depth (path) > 0, FALSE); 134 142 135 g_static_rec_mutex_lock ( list_model->iterator_lock);143 g_static_rec_mutex_lock (priv->iterator_lock); 136 144 137 145 i = gtk_tree_path_get_indices (path)[0]; 138 146 139 g_mutex_lock ( list_model->ra_lock);140 tlen = list_model->cur_len;141 g_mutex_unlock ( list_model->ra_lock);147 g_mutex_lock (priv->ra_lock); 148 tlen = priv->cur_len; 149 g_mutex_unlock (priv->ra_lock); 142 150 143 151 if (i >= tlen) … … 145 153 else { 146 154 if (i >= 0 && i < tlen) { 147 iter->stamp = list_model->stamp;155 iter->stamp = priv->stamp; 148 156 iter->user_data = (gpointer) i; 149 157 retval = TRUE; … … 151 159 } 152 160 153 g_static_rec_mutex_unlock ( list_model->iterator_lock);161 g_static_rec_mutex_unlock (priv->iterator_lock); 154 162 155 163 return retval; … … 159 167 tny_gtk_header_list_model_get_path (GtkTreeModel *self, GtkTreeIter *iter) 160 168 { 169 TnyGtkHeaderListModelPriv *priv = TNY_GTK_HEADER_LIST_MODEL_GET_PRIVATE (self); 161 170 GtkTreePath *tree_path; 162 171 gint i = 0, tlen; 163 TnyGtkHeaderListModel *list_model = TNY_GTK_HEADER_LIST_MODEL (self);164 172 165 173 /* Return the path of an existing GtkTreeIter */ 166 if (!(iter->stamp == TNY_GTK_HEADER_LIST_MODEL (self)->stamp))174 if (!(iter->stamp == priv->stamp)) 167 175 return NULL; 168 176 169 g_static_rec_mutex_lock ( list_model->iterator_lock);177 g_static_rec_mutex_lock (priv->iterator_lock); 170 178 171 179 i = (gint) iter->user_data; 172 180 173 g_mutex_lock ( list_model->ra_lock);174 tlen = list_model->cur_len;175 g_mutex_unlock ( list_model->ra_lock);181 g_mutex_lock (priv->ra_lock); 182 tlen = priv->cur_len; 183 g_mutex_unlock (priv->ra_lock); 176 184 177 185 if (i < 0 || i >= tlen) { 178 g_static_rec_mutex_unlock ( list_model->iterator_lock);186 g_static_rec_mutex_unlock (priv->iterator_lock); 179 187 return NULL; 180 188 } … … 183 191 gtk_tree_path_append_index (tree_path, i); 184 192 185 g_static_rec_mutex_unlock ( list_model->iterator_lock);193 g_static_rec_mutex_unlock (priv->iterator_lock); 186 194 187 195 return tree_path; … … 220 228 tny_gtk_header_list_model_received_date_sort_func (GtkTreeModel *model, GtkTreeIter *a, GtkTreeIter *b, gpointer user_data) 221 229 { 222 TnyGtkHeaderListModel *list_model = TNY_GTK_HEADER_LIST_MODEL(model);230 TnyGtkHeaderListModelPriv *priv = TNY_GTK_HEADER_LIST_MODEL_GET_PRIVATE (model); 223 231 224 232 TnyHeader *hdr_a, *hdr_b; … … 229 237 * of times while you are sorting things. */ 230 238 231 hdr_a = list_model->items->pdata[(gint)a->user_data];232 hdr_b = list_model->items->pdata[(gint)b->user_data];239 hdr_a = priv->items->pdata[(gint)a->user_data]; 240 hdr_b = priv->items->pdata[(gint)b->user_data]; 233 241 234 242 recv_a = tny_header_get_date_received (hdr_a); … … 252 260 tny_gtk_header_list_model_sent_date_sort_func (GtkTreeModel *model, GtkTreeIter *a, GtkTreeIter *b, gpointer user_data) 253 261 { 254 TnyGtkHeaderListModel *list_model = TNY_GTK_HEADER_LIST_MODEL(model);262 TnyGtkHeaderListModelPriv *priv = TNY_GTK_HEADER_LIST_MODEL_GET_PRIVATE (model); 255 263 256 264 TnyHeader *hdr_a, *hdr_b; … … 261 269 * of times while you are sorting things. */ 262 270 263 hdr_a = list_model->items->pdata[(gint)a->user_data];264 hdr_b = list_model->items->pdata[(gint)b->user_data];271 hdr_a = priv->items->pdata[(gint)a->user_data]; 272 hdr_b = priv->items->pdata[(gint)b->user_data]; 265 273 266 274 recv_a = tny_header_get_date_sent (hdr_a); … … 273 281 tny_gtk_header_list_model_get_value (GtkTreeModel *self, GtkTreeIter *iter, gint column, GValue *value) 274 282 { 275 TnyGtkHeaderListModel *list_model = TNY_GTK_HEADER_LIST_MODEL (self); 283 TnyGtkHeaderListModelPriv *priv = TNY_GTK_HEADER_LIST_MODEL_GET_PRIVATE (self); 284 276 285 const gchar *str; 277 286 gchar *rdate = NULL; 278 287 gint i; 279 288 280 if (iter->stamp != list_model->stamp)289 if (iter->stamp != priv->stamp) 281 290 return; 282 291 283 g_static_rec_mutex_lock ( list_model->iterator_lock);292 g_static_rec_mutex_lock (priv->iterator_lock); 284 293 285 294 /* Get the index out of the iter, and use the item by looking it up in … … 292 301 * length of the available data in the array, not only the registered 293 302 * length, although in 99.999999% of the cases it's the same) */ 294 if (i < 0 || i >= list_model->items->len)303 if (i < 0 || i >= priv->items->len) 295 304 { 296 305 g_warning ("GtkTreeModel in invalid state\n"); 297 g_static_rec_mutex_unlock ( list_model->iterator_lock);306 g_static_rec_mutex_unlock (priv->iterator_lock); 298 307 return; 299 308 } … … 303 312 case TNY_GTK_HEADER_LIST_MODEL_CC_COLUMN: 304 313 g_value_init (value, G_TYPE_STRING); 305 str = tny_header_get_cc ((TnyHeader*) list_model->items->pdata[i]);314 str = tny_header_get_cc ((TnyHeader*) priv->items->pdata[i]); 306 315 if (str) 307 316 g_value_set_string (value, str); … … 309 318 case TNY_GTK_HEADER_LIST_MODEL_DATE_SENT_COLUMN: 310 319 g_value_init (value, G_TYPE_STRING); 311 rdate = _get_readable_date (tny_header_get_date_sent ((TnyHeader*) list_model->items->pdata[i]));320 rdate = _get_readable_date (tny_header_get_date_sent ((TnyHeader*) priv->items->pdata[i])); 312 321 if (rdate) 313 322 g_value_set_string (value, rdate); … … 317 326 case TNY_GTK_HEADER_LIST_MODEL_DATE_RECEIVED_COLUMN: 318 327 g_value_init (value, G_TYPE_STRING); 319 rdate = _get_readable_date (tny_header_get_date_received ((TnyHeader*) list_model->items->pdata[i]));328 rdate = _get_readable_date (tny_header_get_date_received ((TnyHeader*) priv->items->pdata[i])); 320 329 if (rdate) 321 330 g_value_set_string (value, rdate); … … 326 335 g_value_init (value, G_TYPE_INT); 327 336 g_value_set_int (value, 328 tny_header_get_date_sent ((TnyHeader*) list_model->items->pdata[i]));337 tny_header_get_date_sent ((TnyHeader*) priv->items->pdata[i])); 329 338 break; 330 339 case TNY_GTK_HEADER_LIST_MODEL_DATE_RECEIVED_TIME_T_COLUMN: 331 340 g_value_init (value, G_TYPE_INT); 332 341 g_value_set_int (value, 333 tny_header_get_date_received ((TnyHeader*) list_model->items->pdata[i]));342 tny_header_get_date_received ((TnyHeader*) priv->items->pdata[i])); 334 343 break; 335 344 336 345 case TNY_GTK_HEADER_LIST_MODEL_MESSAGE_SIZE_COLUMN: 337 346 g_value_init (value, G_TYPE_INT); 338 g_value_set_int (value, tny_header_get_message_size((TnyHeader*) list_model->items->pdata[i]));347 g_value_set_int (value, tny_header_get_message_size((TnyHeader*) priv->items->pdata[i])); 339 348 break; 340 349 case TNY_GTK_HEADER_LIST_MODEL_INSTANCE_COLUMN: 341 350 g_value_init (value, G_TYPE_OBJECT); 342 g_value_set_object (value, (TnyHeader*) list_model->items->pdata[i]);351 g_value_set_object (value, (TnyHeader*) priv->items->pdata[i]); 343 352 break; 344 353 case TNY_GTK_HEADER_LIST_MODEL_TO_COLUMN: 345 354 g_value_init (value, G_TYPE_STRING); 346 str = tny_header_get_to ((TnyHeader*) list_model->items->pdata[i]);355 str = tny_header_get_to ((TnyHeader*) priv->items->pdata[i]); 347 356 if (str) 348 357 g_value_set_string (value, str); … … 350 359 case TNY_GTK_HEADER_LIST_MODEL_SUBJECT_COLUMN: 351 360 g_value_init (value, G_TYPE_STRING); 352 str = tny_header_get_subject ((TnyHeader*) list_model->items->pdata[i]);361 str = tny_header_get_subject ((TnyHeader*) priv->items->pdata[i]); 353 362 if (str) 354 363 g_value_set_string (value, str); … … 356 365 case TNY_GTK_HEADER_LIST_MODEL_FROM_COLUMN: 357 366 g_value_init (value, G_TYPE_STRING); 358 str = tny_header_get_from ((TnyHeader*) list_model->items->pdata[i]);367 str = tny_header_get_from ((TnyHeader*) priv->items->pdata[i]); 359 368 if (str) 360 369 g_value_set_string (value, str); … … 362 371 case TNY_GTK_HEADER_LIST_MODEL_FLAGS_COLUMN: 363 372 g_value_init (value, G_TYPE_INT); 364 g_value_set_int (value, tny_header_get_flags ((TnyHeader*) list_model->items->pdata[i]));373 g_value_set_int (value, tny_header_get_flags ((TnyHeader*) priv->items->pdata[i])); 365 374 break; 366 375 default: … … 368 377 } 369 378 370 g_static_rec_mutex_unlock ( list_model->iterator_lock);379 g_static_rec_mutex_unlock (priv->iterator_lock); 371 380 372 381 return; … … 376 385 tny_gtk_header_list_model_iter_next (GtkTreeModel *self, GtkTreeIter *iter) 377 386 { 387 TnyGtkHeaderListModelPriv *priv = TNY_GTK_HEADER_LIST_MODEL_GET_PRIVATE (self); 378 388 gboolean retval; 379 TnyGtkHeaderListModel *list_model = TNY_GTK_HEADER_LIST_MODEL (self);380 389 gint newv; 381 390 382 if (iter->stamp != TNY_GTK_HEADER_LIST_MODEL (self)->stamp)391 if (iter->stamp != priv->stamp) 383 392 return FALSE; 384 393 385 g_static_rec_mutex_lock ( list_model->iterator_lock);394 g_static_rec_mutex_lock (priv->iterator_lock); 386 395 387 396 /* The next will simply be the current plus one: That's because we are … … 390 399 * can't be part of the GPtrArray instance (would be devastating). */ 391 400 392 newv = ((gint) iter->user_data);401 newv = ((gint) iter->user_data); 393 402 newv++; 394 403 iter->user_data = (gpointer) newv; 395 404 396 g_mutex_lock ( list_model->ra_lock);397 retval = (newv >= 0 && newv < list_model->cur_len);398 g_mutex_unlock ( list_model->ra_lock);405 g_mutex_lock (priv->ra_lock); 406 retval = (newv >= 0 && newv < priv->cur_len); 407 g_mutex_unlock (priv->ra_lock); 399 408 400 409 if (!retval) { … … 403 412 } 404 413 405 g_static_rec_mutex_unlock ( list_model->iterator_lock);414 g_static_rec_mutex_unlock (priv->iterator_lock); 406 415 407 416 return retval; … … 420 429 tny_gtk_header_list_model_iter_n_children (GtkTreeModel *self, GtkTreeIter *iter) 421 430 { 431 TnyGtkHeaderListModelPriv *priv = TNY_GTK_HEADER_LIST_MODEL_GET_PRIVATE (self); 422 432 gint retval = -1; 423 TnyGtkHeaderListModel *list_model = TNY_GTK_HEADER_LIST_MODEL (self);424 433 425 434 /* Return the amount of children for this GtkTreeIter. Because this … … 427 436 return the full length. */ 428 437 429 g_static_rec_mutex_lock ( list_model->iterator_lock);438 g_static_rec_mutex_lock (priv->iterator_lock); 430 439 431 440 if (G_LIKELY (!iter)) 432 retval = list_model->cur_len;433 434 g_static_rec_mutex_unlock ( list_model->iterator_lock);441 retval = priv->cur_len; 442 443 g_static_rec_mutex_unlock (priv->iterator_lock); 435 444 436 445 return retval; … … 440 449 tny_gtk_header_list_model_iter_nth_child (GtkTreeModel *self, GtkTreeIter *iter, GtkTreeIter *parent, gint n) 441 450 { 442 TnyGtkHeaderListModel *list_model = TNY_GTK_HEADER_LIST_MODEL(self);451 TnyGtkHeaderListModelPriv *priv = TNY_GTK_HEADER_LIST_MODEL_GET_PRIVATE (self); 443 452 gboolean retval = FALSE; 444 453 gint tlen; … … 447 456 return FALSE; 448 457 449 g_static_rec_mutex_lock ( list_model->iterator_lock);450 451 g_mutex_lock ( list_model->ra_lock);452 tlen = list_model->cur_len;453 g_mutex_unlock ( list_model->ra_lock);458 g_static_rec_mutex_lock (priv->iterator_lock); 459 460 g_mutex_lock (priv->ra_lock); 461 tlen = priv->cur_len; 462 g_mutex_unlock (priv->ra_lock); 454 463 455 464 if (n >= 0 && n < tlen) 456 465 { 457 iter->stamp = TNY_GTK_HEADER_LIST_MODEL (self)->stamp;466 iter->stamp = priv->stamp; 458 467 iter->user_data = (gpointer) n; 459 468 retval = TRUE; … … 463 472 } 464 473 465 g_static_rec_mutex_unlock ( list_model->iterator_lock);474 g_static_rec_mutex_unlock (priv->iterator_lock); 466 475 467 476 return retval; … … 490 499 notify_views_add_destroy (gpointer data) 491 500 { 492 TnyGtkHeaderListModel *me = (TnyGtkHeaderListModel*) data;493 494 g_mutex_lock ( me->ra_lock);495 me->updating_views = -1;496 g_mutex_unlock ( me->ra_lock);497 498 if ( me->timeout_span < 5000)499 me->timeout_span += 300;500 me->add_timeout = 0;501 g_object_unref ( me);501 TnyGtkHeaderListModelPriv *priv = TNY_GTK_HEADER_LIST_MODEL_GET_PRIVATE (data); 502 503 g_mutex_lock (priv->ra_lock); 504 priv->updating_views = -1; 505 g_mutex_unlock (priv->ra_lock); 506 507 if (priv->timeout_span < 5000) 508 priv->timeout_span += 300; 509 priv->add_timeout = 0; 510 g_object_unref (data); 502 511 503 512 return; … … 507 516 notify_views_add (gpointer data) 508 517 { 509 TnyGtkHeaderListModel *me = (TnyGtkHeaderListModel*) data;518 TnyGtkHeaderListModelPriv *priv = TNY_GTK_HEADER_LIST_MODEL_GET_PRIVATE (data); 510 519 gint already_registered, going_tb_registered, i; 511 520 … … 514 523 GtkTreeIter iter; 515 524 516 g_mutex_lock ( me->ra_lock);517 me->updating_views++;518 if ( me->registered >= me->items->len) {519 g_mutex_unlock ( me->ra_lock);525 g_mutex_lock (priv->ra_lock); 526 priv->updating_views++; 527 if (priv->registered >= priv->items->len) { 528 g_mutex_unlock (priv->ra_lock); 520 529 return FALSE; 521 530 } 522 531 523 already_registered = me->registered;524 525 if ( me->items->len - already_registered > 1000)532 already_registered = priv->registered; 533 534 if (priv->items->len - already_registered > 1000) 526 535 { 527 536 going_tb_registered = already_registered + 1000; 528 537 needmore = TRUE; 529 538 } else 530 going_tb_registered = me->items->len;531 532 me->registered = going_tb_registered;533 534 if ( me->updating_views < 2)539 going_tb_registered = priv->items->len; 540 541 priv->registered = going_tb_registered; 542 543 if (priv->updating_views < 2) 535 544 needmore = TRUE; 536 545 537 g_mutex_unlock ( me->ra_lock);546 g_mutex_unlock (priv->ra_lock); 538 547 539 548 gdk_threads_enter(); … … 541 550 for (i = already_registered; i < going_tb_registered; i++) 542 551 { 543 iter.stamp = me->stamp;552 iter.stamp = priv->stamp; 544 553 iter.user_data = (gpointer) i; 545 554 path = gtk_tree_path_new (); … … 547 556 if (G_LIKELY (path)) 548 557 { 549 me->cur_len = i+1;550 gtk_tree_model_row_inserted ((GtkTreeModel *) me, path, &iter);558 priv->cur_len = i+1; 559 gtk_tree_model_row_inserted ((GtkTreeModel *) data, path, &iter); 551 560 gtk_tree_path_free (path); 552 561 } … … 565 574 tny_gtk_header_list_model_prepend (TnyList *self, GObject* item) 566 575 { 567 TnyGtkHeaderListModel *me = (TnyGtkHeaderListModel*)self; 568 g_static_rec_mutex_lock (me->iterator_lock); 576 TnyGtkHeaderListModelPriv *priv = TNY_GTK_HEADER_LIST_MODEL_GET_PRIVATE (self); 577 578 g_static_rec_mutex_lock (priv->iterator_lock); 569 579 570 580 /* Prepend something to the list itself. The get_length will auto update … … 574 584 g_object_ref (item); 575 585 576 g_mutex_lock ( me->ra_lock);577 578 g_ptr_array_add ( me->items, item);586 g_mutex_lock (priv->ra_lock); 587 588 g_ptr_array_add (priv->items, item); 579 589 580 590 /* This prepend will happen very often, the notificating of the view is, 581 591 * however, quite slow and gdk wants us to do this from the mainloop */ 582 592 583 if ( me->updating_views == -1)593 if (priv->updating_views == -1) 584 594 { 585 me->updating_views = 0;586 g_object_ref ( me);587 588 if ( me->add_timeout > 0) {589 g_source_remove ( me->add_timeout);590 me->add_timeout = 0;595 priv->updating_views = 0; 596 g_object_ref (self); 597 598 if (priv->add_timeout > 0) { 599 g_source_remove (priv->add_timeout); 600 priv->add_timeout = 0; 591 601 } 592 602 593 me->add_timeout = g_timeout_add_full (G_PRIORITY_DEFAULT_IDLE,594 me->timeout_span, notify_views_add, me,603 priv->add_timeout = g_timeout_add_full (G_PRIORITY_DEFAULT_IDLE, 604 priv->timeout_span, notify_views_add, self, 595 605 notify_views_add_destroy); 596 606 } 597 607 598 g_mutex_unlock ( me->ra_lock);599 600 g_static_rec_mutex_unlock ( me->iterator_lock);608 g_mutex_unlock (priv->ra_lock); 609 610 g_static_rec_mutex_unlock (priv->iterator_lock); 601 611 602 612 return; … … 624 634 { 625 635 notify_views_data_t *stuff = data; 626 TnyGtkHeaderListModel *me = (TnyGtkHeaderListModel*) stuff->self;627 628 g_mutex_lock ( me->to_lock);629 if (stuff->src != -1 && stuff->src < me->del_timeouts->len)630 g_array_index ( me->del_timeouts, guint, (guint) stuff->src) = 0;631 g_mutex_unlock ( me->to_lock);636 TnyGtkHeaderListModelPriv *priv = TNY_GTK_HEADER_LIST_MODEL_GET_PRIVATE (stuff->self); 637 638 g_mutex_lock (priv->to_lock); 639 if (stuff->src != -1 && stuff->src < priv->del_timeouts->len) 640 g_array_index (priv->del_timeouts, guint, (guint) stuff->src) = 0; 641 g_mutex_unlock (priv->to_lock); 632 642 633 643 g_object_unref (stuff->item); … … 644 654 { 645 655 notify_views_data_t *stuff = data; 646 TnyGtkHeaderListModel *me = (TnyGtkHeaderListModel*) stuff->self; 656 TnyGtkHeaderListModelPriv *priv = TNY_GTK_HEADER_LIST_MODEL_GET_PRIVATE (stuff->self); 657 647 658 GtkTreePath *path; 648 659 GtkTreeIter iter; … … 650 661 GObject *mitem, *item = stuff->item; 651 662 652 g_static_rec_mutex_lock ( me->iterator_lock);653 654 for (i=0; i < me->items->len; i++)655 if ( me->items->pdata[i] == item)663 g_static_rec_mutex_lock (priv->iterator_lock); 664 665 for (i=0; i < priv->items->len; i++) 666 if (priv->items->pdata[i] == item) 656 667 { 657 668 found = TRUE; … … 661 672 if (found) 662 673 { 663 iter.stamp = me->stamp;674 iter.stamp = priv->stamp; 664 675 iter.user_data = (gpointer) i; 665 676 path = gtk_tree_path_new (); 666 677 gtk_tree_path_append_index (path, i); 667 gtk_tree_model_row_deleted ( GTK_TREE_MODEL (me), path);668 g_mutex_lock ( me->ra_lock);669 me->cur_len--;670 me->registered--;671 g_mutex_unlock ( me->ra_lock);678 gtk_tree_model_row_deleted ((GtkTreeModel *) stuff->self, path); 679 g_mutex_lock (priv->ra_lock); 680 priv->cur_len--; 681 priv->registered--; 682 g_mutex_unlock (priv->ra_lock); 672 683 gtk_tree_path_free (path); 673 684 674 mitem = g_ptr_array_remove_index ( me->items, i);685 mitem = g_ptr_array_remove_index (priv->items, i); 675 686 if (mitem) 676 687 g_object_unref (mitem); 677 688 } 678 689 679 g_static_rec_mutex_unlock ( me->iterator_lock);690 g_static_rec_mutex_unlock (priv->iterator_lock); 680 691 681 692 if (g_main_loop_is_running (stuff->loop)) … … 689 700 tny_gtk_header_list_model_remove (TnyList *self, GObject* item) 690 701 { 691 TnyGtkHeaderListModel *me = (TnyGtkHeaderListModel*) self;702 TnyGtkHeaderListModelPriv *priv = TNY_GTK_HEADER_LIST_MODEL_GET_PRIVATE (self); 692 703 notify_views_data_t *stuff; 693 704 guint src; … … 702 713 src = g_timeout_add_full (G_PRIORITY_HIGH_IDLE, 0, 703 714 notify_views_delete, stuff, notify_views_delete_destroy); 704 stuff->src = (gint) add_del_timeout ( me, src);715 stuff->src = (gint) add_del_timeout ((TnyGtkHeaderListModel *) self, src); 705 716 706 717 /* This truly sucks :-( */ … … 713 724 tny_gtk_header_list_model_get_length (TnyList *self) 714 725 { 715 TnyGtkHeaderListModel *me = (TnyGtkHeaderListModel*)self;726 TnyGtkHeaderListModelPriv *priv = TNY_GTK_HEADER_LIST_MODEL_GET_PRIVATE (self); 716 727 guint retval = 0; 717 728 718 g_static_rec_mutex_lock ( me->iterator_lock);719 retval = me->items->len;720 g_static_rec_mutex_unlock ( me->iterator_lock);729 g_static_rec_mutex_lock (priv->iterator_lock); 730 retval = priv->items->len; 731 g_static_rec_mutex_unlock (priv->iterator_lock); 721 732 722 733 return retval; … … 726 737 tny_gtk_header_list_model_create_iterator (TnyList *self) 727 738 { 728 TnyGtkHeaderListModel *me = (TnyGtkHeaderListModel*)self; 729 730 /* Return a new iterator */ 731 732 return _tny_gtk_header_list_iterator_new (me); 739 return _tny_gtk_header_list_iterator_new ((TnyGtkHeaderListModel *) self); 733 740 } 734 741 … … 737 744 { 738 745 GPtrArray *items = user_data; 739 g_ptr_array_add (items, g_object_ref ( G_OBJECT (data)));746 g_ptr_array_add (items, g_object_ref (data)); 740 747 return; 741 748 } … … 744 751 tny_gtk_header_list_model_copy_the_list (TnyList *self) 745 752 { 746 TnyGtkHeaderListModel *me = (TnyGtkHeaderListModel*)self;753 TnyGtkHeaderListModelPriv *priv = TNY_GTK_HEADER_LIST_MODEL_GET_PRIVATE (self); 747 754 TnyGtkHeaderListModel *copy = g_object_new (TNY_TYPE_GTK_HEADER_LIST_MODEL, NULL); 755 TnyGtkHeaderListModelPriv *cpriv = TNY_GTK_HEADER_LIST_MODEL_GET_PRIVATE (copy); 748 756 749 757 /* This only copies the TnyList pieces. The result is not a … … 755 763 only a copy of the list-nodes of course. */ 756 764 757 g_static_rec_mutex_lock (me->iterator_lock); 758 759 GPtrArray *items_copy = g_ptr_array_sized_new (me->items->len); 760 g_ptr_array_foreach (me->items, copy_it, items_copy); 761 copy->items = items_copy; 762 763 g_static_rec_mutex_unlock (me->iterator_lock); 765 g_static_rec_mutex_lock (priv->iterator_lock); 766 767 GPtrArray *items_copy = g_ptr_array_sized_new (priv->items->len); 768 g_ptr_array_foreach (priv->items, copy_it, items_copy); 769 cpriv->items = items_copy; 770 g_static_rec_mutex_unlock (priv->iterator_lock); 764 771 765 772 return TNY_LIST (copy); … … 769 776 tny_gtk_header_list_model_foreach_in_the_list (TnyList *self, GFunc func, gpointer user_data) 770 777 { 771 TnyGtkHeaderListModel *me = (TnyGtkHeaderListModel*)self; 772 773 /* Foreach item in the list (without using a slower iterator) */ 774 775 g_static_rec_mutex_lock (me->iterator_lock); 776 777 g_ptr_array_foreach (me->items, func, user_data); 778 779 g_static_rec_mutex_unlock (me->iterator_lock); 778 TnyGtkHeaderListModelPriv *priv = TNY_GTK_HEADER_LIST_MODEL_GET_PRIVATE (self); 779 780 g_static_rec_mutex_lock (priv->iterator_lock); 781 g_ptr_array_foreach (priv->items, func, user_data); 782 g_static_rec_mutex_unlock (priv->iterator_lock); 780 783 781 784 return; … … 800 803 tny_gtk_header_list_model_finalize (GObject *object) 801 804 { 802 TnyGtkHeaderListModel *self = (TnyGtkHeaderListModel *)object; 803 804 g_static_rec_mutex_lock (self->iterator_lock); 805 806 if (self->add_timeout > 0) { 807 g_source_remove (self->add_timeout); 808 self->add_timeout = 0; 805 TnyGtkHeaderListModel *self = (TnyGtkHeaderListModel *) object; 806 TnyGtkHeaderListModelPriv *priv = TNY_GTK_HEADER_LIST_MODEL_GET_PRIVATE (self); 807 808 g_static_rec_mutex_lock (priv->iterator_lock); 809
