Changeset 2944
- Timestamp:
- 11/13/07 23:45:39
- Files:
-
- trunk/libtinymailui-gtk/tny-gtk-account-list-model.c (modified) (4 diffs)
- trunk/libtinymailui-gtk/tny-gtk-account-list-model.h (modified) (1 diff)
- trunk/libtinymailui-gtk/tny-gtk-attach-list-model.c (modified) (7 diffs)
- trunk/libtinymailui-gtk/tny-gtk-attach-list-model.h (modified) (1 diff)
- trunk/libtinymailui-gtk/tny-gtk-folder-store-tree-model.c (modified) (3 diffs)
- trunk/libtinymailui-gtk/tny-gtk-folder-store-tree-model.h (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/libtinymailui-gtk/tny-gtk-account-list-model.c
r2943 r2944 46 46 * tny_gtk_account_list_model_new: 47 47 * 48 * Create a new #GtkTreeModel instance suitable for showing a #TnyMimePart. 49 * 50 * Return value: a new #GtkTreeModel instance suitable for showing a #TnyMimePart 48 * Create a new #GtkTreeModel instance suitable for showing a list of accounts. 49 * Note that when using gtk_combo_box_set_model or gtk_tree_view_set_model, the 50 * view will add its reference to your model instance. If you want the view to 51 * become the owner, you must get rid of your initial reference. 52 * 53 * <informalexample><programlisting> 54 * GtkTreeModel *model = tny_gtk_account_list_model_new (); 55 * GtkTreeView *view = ...; 56 * gtk_tree_view_set_model (view, model); 57 * g_object_unref (model); // this is probably what you want to do 58 * </programlisting></informalexample> 59 * 60 * Return value: a new #GtkTreeModel instance suitable for showing accounts 51 61 **/ 52 62 GtkTreeModel* … … 65 75 66 76 g_mutex_lock (me->iterator_lock); 67 if (me->first) 77 if (me->first) { 78 if (me->first_needs_unref) 79 g_list_foreach (me->first, (GFunc)g_object_unref, NULL); 80 me->first_needs_unref = FALSE; 68 81 g_list_free (me->first); 82 } 69 83 me->first = NULL; 70 84 g_mutex_unlock (me->iterator_lock); … … 97 111 me->iterator_lock = g_mutex_new (); 98 112 me->first = NULL; 113 me->first_needs_unref = FALSE; 99 114 100 115 gtk_list_store_set_column_types (store, … … 225 240 list_copy = g_list_copy (me->first); 226 241 g_list_foreach (list_copy, (GFunc)g_object_ref, NULL); 242 copy->first_needs_unref = TRUE; 227 243 copy->first = list_copy; 228 244 g_mutex_unlock (me->iterator_lock); trunk/libtinymailui-gtk/tny-gtk-account-list-model.h
r2825 r2944 53 53 GMutex *iterator_lock; 54 54 GList *first; 55 gboolean first_needs_unref; 55 56 }; 56 57 trunk/libtinymailui-gtk/tny-gtk-attach-list-model.c
r2825 r2944 123 123 } 124 124 125 static void126 destroy_parts (gpointer item, gpointer user_data)127 {128 if (item && G_IS_OBJECT (item))129 g_object_unref (G_OBJECT (item));130 return;131 }132 133 125 static void 134 126 tny_gtk_attach_list_model_finalize (GObject *object) … … 138 130 139 131 g_mutex_lock (me->iterator_lock); 140 if (me->first) 141 { 142 g_list_foreach (me->first, destroy_parts, NULL); 143 g_list_free (me->first); me->first = NULL; 132 if (me->first) { 133 if (me->first_needs_unref) 134 g_list_foreach (me->first, (GFunc)g_object_unref, NULL); 135 me->first_needs_unref = FALSE; 136 g_list_free (me->first); 144 137 } 138 me->first = NULL; 145 139 g_mutex_unlock (me->iterator_lock); 146 140 … … 177 171 static GType types[] = { G_TYPE_POINTER, G_TYPE_STRING, G_TYPE_OBJECT }; 178 172 173 179 174 priv->theme = NULL; 180 175 types[0] = GDK_TYPE_PIXBUF; 181 176 me->iterator_lock = g_mutex_new (); 182 177 me->first = NULL; 183 178 me->first_needs_unref = FALSE; 179 184 180 gtk_list_store_set_column_types (store, 185 181 TNY_GTK_ATTACH_LIST_MODEL_N_COLUMNS, types); … … 208 204 209 205 /* Prepend something to the list */ 210 g_object_ref (G_OBJECT (item));211 212 me->first = g_list_prepend (me->first, item);213 206 214 207 tny_gtk_attach_list_model_add (me, TNY_MIME_PART (item), 215 208 gtk_list_store_prepend); 216 209 210 me->first = g_list_prepend (me->first, item); 211 217 212 g_mutex_unlock (me->iterator_lock); 218 213 } … … 226 221 227 222 /* Append something to the list */ 228 g_object_ref (G_OBJECT (item)); 229 230 me->first = g_list_append (me->first, item); 223 231 224 tny_gtk_attach_list_model_add (me, TNY_MIME_PART (item), 232 225 gtk_list_store_append); 226 me->first = g_list_append (me->first, item); 233 227 234 228 g_mutex_unlock (me->iterator_lock); … … 278 272 { 279 273 gtk_list_store_remove (GTK_LIST_STORE (me), &iter); 280 g_object_unref (G_OBJECT (item));274 g_object_unref (item); 281 275 break; 282 276 } 283 g_object_unref ( G_OBJECT (citem));277 g_object_unref (citem); 284 278 } 285 279 … … 306 300 list_copy = g_list_copy (me->first); 307 301 g_list_foreach (list_copy, (GFunc)g_object_ref, NULL); 302 copy->first_needs_unref = TRUE; 308 303 copy->first = list_copy; 309 304 g_mutex_unlock (me->iterator_lock); trunk/libtinymailui-gtk/tny-gtk-attach-list-model.h
r2825 r2944 56 56 GList *first; 57 57 GMutex *iterator_lock; 58 gboolean first_needs_unref; 58 59 }; 59 60 trunk/libtinymailui-gtk/tny-gtk-folder-store-tree-model.c
r2943 r2944 520 520 521 521 g_mutex_lock (me->iterator_lock); 522 if (me->first) 522 if (me->first) { 523 if (me->first_needs_unref) 524 g_list_foreach (me->first, (GFunc)g_object_unref, NULL); 525 me->first_needs_unref = FALSE; 523 526 g_list_free (me->first); 527 } 524 528 me->first = NULL; 525 529 g_mutex_unlock (me->iterator_lock); … … 558 562 me->store_obs = NULL; 559 563 me->iterator_lock = g_mutex_new (); 564 me->first_needs_unref = FALSE; 560 565 561 566 gtk_tree_store_set_column_types (store, … … 734 739 list_copy = g_list_copy (me->first); 735 740 g_list_foreach (list_copy, (GFunc)g_object_ref, NULL); 741 copy->first_needs_unref = TRUE; 736 742 copy->first = list_copy; 737 743 g_mutex_unlock (me->iterator_lock); trunk/libtinymailui-gtk/tny-gtk-folder-store-tree-model.h
r2926 r2944 61 61 GMutex *iterator_lock; 62 62 TnyFolderStoreQuery *query; 63 gboolean first_needs_unref; 63 64 }; 64 65
