Re: About folder subscriptions



Philip Van Hoof wrote:
> It should be possible to get a list of unsubscribed folders, a list of
> subscribed folders, a list of both and it should be possible to
> subscribe and unsubscribe folders. And when it happens, a signal should
> be emitted that tells the observers to reload their folder-list.
> 
> For getting these lists, I added the query thingy. That should already
> be possible atm.

Yes, and it works nice. I have a proposal, why not add a query to the
TnyGtkAccountTreeModel. Currently the model does not use the queries
despite the support is implemented.

See my proposal attached. I have modified also the demo UI but not its
behaviour, I mean, it lists still all the folders because it's not using
any query.

Br
Index: libtinymailui-gtk/tny-gtk-account-tree-model.c
===================================================================
--- libtinymailui-gtk/tny-gtk-account-tree-model.c	(revision 1197)
+++ libtinymailui-gtk/tny-gtk-account-tree-model.c	(working copy)
@@ -34,7 +34,7 @@
 #include "tny-gtk-account-tree-model-iterator-priv.h"
 
 static GObjectClass *parent_class = NULL;
-static void recurse_folders_async (TnyGtkAccountTreeModel *self, TnyFolderStore *store, TnyFolderStoreQuery *query, GtkTreeIter *parent_tree_iter);
+static void recurse_folders_async (TnyGtkAccountTreeModel *self, TnyFolderStore *store, GtkTreeIter *parent_tree_iter);
 
 typedef void (*treeaddfunc) (GtkTreeStore *tree_store, GtkTreeIter *iter, GtkTreeIter *parent);
 
@@ -42,7 +42,6 @@
 typedef struct {
 	GtkTreeIter *parent_tree_iter;
 	TnyGtkAccountTreeModel *self;
-	TnyFolderStoreQuery *query;
 } AsyncHelpr;
 
 static void
@@ -69,7 +68,7 @@
 			TNY_GTK_ACCOUNT_TREE_MODEL_INSTANCE_COLUMN,
 			folder, -1);
 
-		recurse_folders_async (hlrp->self, folder, hlrp->query, tree_iter);
+		recurse_folders_async (hlrp->self, folder, tree_iter);
 
 		g_object_unref (G_OBJECT (folder));
 
@@ -86,25 +85,24 @@
 
 
 static void
-recurse_folders_async (TnyGtkAccountTreeModel *self, TnyFolderStore *store, TnyFolderStoreQuery *query, GtkTreeIter *parent_tree_iter)
+recurse_folders_async (TnyGtkAccountTreeModel *self, TnyFolderStore *store, GtkTreeIter *parent_tree_iter)
 {
 	AsyncHelpr *hlrp = g_slice_new0 (AsyncHelpr);
 	TnyList *folders = tny_simple_list_new ();
 
 	hlrp->self = self;
 	hlrp->parent_tree_iter = parent_tree_iter;
-	hlrp->query = query;
 
-	tny_folder_store_get_folders_async (store, folders,  recurse_get_folders_callback, query, hlrp);
+	tny_folder_store_get_folders_async (store, folders, recurse_get_folders_callback, self->query, hlrp);
 }
 
 static void
-recurse_folders_sync (TnyGtkAccountTreeModel *self, TnyFolderStore *store, TnyFolderStoreQuery *query, GtkTreeIter *parent_tree_iter)
+recurse_folders_sync (TnyGtkAccountTreeModel *self, TnyFolderStore *store, GtkTreeIter *parent_tree_iter)
 {
 	TnyIterator *iter;
 	TnyList *folders = tny_simple_list_new ();
 
-	tny_folder_store_get_folders (store, folders, query);
+	tny_folder_store_get_folders (store, folders, self->query);
 	iter = tny_list_create_iterator (folders);
 
 	while (!tny_iterator_is_done (iter))
@@ -125,7 +123,7 @@
 			TNY_GTK_ACCOUNT_TREE_MODEL_INSTANCE_COLUMN,
 			folder, -1);
 	    
-		recurse_folders_sync (self, folder, query, &tree_iter);
+		recurse_folders_sync (self, folder, &tree_iter);
 	    
  		g_object_unref (G_OBJECT (folder));
 
@@ -154,7 +152,7 @@
 		TNY_GTK_ACCOUNT_TREE_MODEL_INSTANCE_COLUMN,
 		account, -1);
 
-	recurse_folders_sync (self, TNY_FOLDER_STORE (account), NULL, &name_iter);
+	recurse_folders_sync (self, TNY_FOLDER_STORE (account), &name_iter);
 
     	g_object_unref (G_OBJECT (folders));
     
@@ -187,7 +185,7 @@
 		TNY_GTK_ACCOUNT_TREE_MODEL_INSTANCE_COLUMN,
 		account, -1);
 
-	recurse_folders_async (self, TNY_FOLDER_STORE (account), NULL, name_iter);
+	recurse_folders_async (self, TNY_FOLDER_STORE (account), name_iter);
     
 	return;
 }
@@ -200,10 +198,11 @@
  * #TnyAccount instances
  **/
 GtkTreeModel*
-tny_gtk_account_tree_model_new (gboolean async)
+tny_gtk_account_tree_model_new (gboolean async, TnyFolderStoreQuery *query)
 {
 	TnyGtkAccountTreeModel *self = g_object_new (TNY_TYPE_GTK_ACCOUNT_TREE_MODEL, NULL);
 	self->is_async = async;
+	if (query) self->query = g_object_ref (G_OBJECT (query));
 	return GTK_TREE_MODEL (self);
 }
 
@@ -231,6 +230,9 @@
 	g_mutex_free (me->iterator_lock);
 	me->iterator_lock = NULL;
 
+	if (me->query)
+		g_object_unref (G_OBJECT (me->query));
+
 	(*parent_class->finalize) (object);
 }
 
Index: libtinymailui-gtk/tny-gtk-account-tree-model.h
===================================================================
--- libtinymailui-gtk/tny-gtk-account-tree-model.h	(revision 1197)
+++ libtinymailui-gtk/tny-gtk-account-tree-model.h	(working copy)
@@ -23,6 +23,7 @@
 #include <glib.h>
 #include <gtk/gtk.h>
 #include <tny-store-account.h>
+#include <tny-folder-store-query.h>
 #include <tny-list.h>
 
 G_BEGIN_DECLS
@@ -58,6 +59,7 @@
 	GList *first;
 	GMutex *iterator_lock;
 	gboolean is_async;
+	TnyFolderStoreQuery *query;
 };
 
 struct _TnyGtkAccountTreeModelClass
@@ -67,7 +69,7 @@
 
 GType tny_gtk_account_tree_model_get_type (void);
 GType tny_gtk_account_tree_model_column_get_type (void);
-GtkTreeModel* tny_gtk_account_tree_model_new (gboolean async);
+GtkTreeModel* tny_gtk_account_tree_model_new (gboolean async, TnyFolderStoreQuery *query);
 
 G_END_DECLS
 
Index: tinymail/tny-demoui-summary-view.c
===================================================================
--- tinymail/tny-demoui-summary-view.c	(revision 1197)
+++ tinymail/tny-demoui-summary-view.c	(working copy)
@@ -126,9 +126,9 @@
 	   TnyList and the GtkTreeModel interfaces) */
 
 #if PLATFORM==1
-	GtkTreeModel *mailbox_model = tny_gtk_account_tree_model_new (TRUE);
+	GtkTreeModel *mailbox_model = tny_gtk_account_tree_model_new (TRUE, NULL);
 #else
-	GtkTreeModel *mailbox_model = tny_gtk_account_tree_model_new (FALSE);
+	GtkTreeModel *mailbox_model = tny_gtk_account_tree_model_new (FALSE, NULL);
 #endif
 
 	TnyList *accounts = TNY_LIST (mailbox_model);


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]