Patch that adds some API to the merge folder



Hi all,

I'd like to add two new functions to the TnyMergeFolder API. These two
ones are:

void tny_merge_folder_remove_folder (TnyMergeFolder *self, TnyFolder
folder);
gint tny_merge_folder_get_num_folders (TnyMergeFolder *self);

I guess everybody could understand what they do ;-). See the patch attached.

Br
Index: libtinymail/tny-merge-folder.c
===================================================================
--- libtinymail/tny-merge-folder.c	(revision 2653)
+++ libtinymail/tny-merge-folder.c	(working copy)
@@ -1359,6 +1359,61 @@
 }
 
 /**
+ * tny_merge_folder_remove_folder:
+ * @self: a #TnyMergeFolder object
+ * @folder: a #TnyFolder object 
+ *
+ * Removes @folder from the list of folders that will be merged by
+ * @self.
+ **/
+void 
+tny_merge_folder_remove_folder (TnyMergeFolder *self, TnyFolder *folder)
+{
+	TnyMergeFolderPriv *priv;
+
+	g_return_if_fail (TNY_IS_MERGE_FOLDER (self));
+	g_return_if_fail (TNY_IS_FOLDER (folder));
+
+	priv = TNY_MERGE_FOLDER_GET_PRIVATE (self);
+	
+	g_static_rec_mutex_lock (priv->lock);
+
+	tny_folder_remove_observer (folder, TNY_FOLDER_OBSERVER (self));
+
+	tny_list_remove (priv->mothers, G_OBJECT (folder));
+
+	g_static_rec_mutex_unlock (priv->lock);
+
+	return;
+}
+
+/**
+ * tny_merge_folder_get_num_folders:
+ * @self: a #TnyMergeFolder object
+ *
+ * Returns the number of folders that are merged in the @self merge
+ * folder.
+ **/
+gint 
+tny_merge_folder_get_num_folders (TnyMergeFolder *self)
+{
+	TnyMergeFolderPriv *priv;
+	gint num_folders = 0;
+
+	g_return_val_if_fail (TNY_IS_MERGE_FOLDER (self), -1);
+
+	priv = TNY_MERGE_FOLDER_GET_PRIVATE (self);
+	
+	g_static_rec_mutex_lock (priv->lock);
+
+	num_folders = tny_list_get_length (priv->mothers);
+
+	g_static_rec_mutex_unlock (priv->lock);
+
+	return num_folders;
+}
+
+/**
  * tny_merge_folder_new:
  * @folder_name: the name of the merged folder
  *
Index: libtinymail/tny-merge-folder.h
===================================================================
--- libtinymail/tny-merge-folder.h	(revision 2653)
+++ libtinymail/tny-merge-folder.h	(working copy)
@@ -58,7 +58,9 @@
 
 TnyFolder* tny_merge_folder_new (const gchar *folder_name);
 void tny_merge_folder_add_folder (TnyMergeFolder *self, TnyFolder *folder);
+void tny_merge_folder_remove_folder (TnyMergeFolder *self, TnyFolder *folder);
 void tny_merge_folder_set_folder_type (TnyMergeFolder *self, TnyFolderType folder_type);
+gint tny_merge_folder_get_num_folders (TnyMergeFolder *self);
 
 G_END_DECLS
 


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