1 /*
2  * This program is free software; you can redistribute it and/or modify it
3  * under the terms of the GNU Lesser General Public License as published by
4  * the Free Software Foundation.
5  *
6  * This program is distributed in the hope that it will be useful, but
7  * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
8  * or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
9  * for more details.
10  *
11  * You should have received a copy of the GNU Lesser General Public License
12  * along with this program; if not, see <http://www.gnu.org/licenses/>.
13  *
14  *
15  * Authors:
16  *		Jeffrey Stedfast <fejj@ximian.com>
17  *
18  * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com)
19  *
20  */
21 
22 #ifndef EM_FOLDER_TREE_MODEL_H
23 #define EM_FOLDER_TREE_MODEL_H
24 
25 #include <gtk/gtk.h>
26 #include <camel/camel.h>
27 
28 #include <libemail-engine/libemail-engine.h>
29 
30 #include <mail/e-mail-folder-tweaks.h>
31 
32 /* Standard GObject macros */
33 #define EM_TYPE_FOLDER_TREE_MODEL \
34 	(em_folder_tree_model_get_type ())
35 #define EM_FOLDER_TREE_MODEL(obj) \
36 	(G_TYPE_CHECK_INSTANCE_CAST \
37 	((obj), EM_TYPE_FOLDER_TREE_MODEL, EMFolderTreeModel))
38 #define EM_FOLDER_TREE_MODEL_CLASS(cls) \
39 	(G_TYPE_CHECK_CLASS_CAST \
40 	((cls), EM_TYPE_FOLDER_TREE_MODEL, EMFolderTreeModelClass))
41 #define EM_IS_FOLDER_TREE_MODEL(obj) \
42 	(G_TYPE_CHECK_INSTANCE_TYPE \
43 	((obj), EM_TYPE_FOLDER_TREE_MODEL))
44 #define EM_IS_FOLDER_TREE_MODEL_CLASS(cls) \
45 	(G_TYPE_CHECK_CLASS_TYPE \
46 	((cls), EM_TYPE_FOLDER_TREE_MODEL))
47 #define EM_FOLDER_TREE_MODEL_GET_CLASS(obj) \
48 	(G_TYPE_INSTANCE_GET_CLASS \
49 	((obj), EM_TYPE_FOLDER_TREE_MODEL, EMFolderTreeModelClass))
50 
51 G_BEGIN_DECLS
52 
53 typedef struct _EMFolderTreeModel EMFolderTreeModel;
54 typedef struct _EMFolderTreeModelClass EMFolderTreeModelClass;
55 typedef struct _EMFolderTreeModelPrivate EMFolderTreeModelPrivate;
56 
57 enum {
58 	EMFT_STATUS_CODE_UNKNOWN	= 0,
59 	EMFT_STATUS_CODE_DISCONNECTED	= 1,
60 	EMFT_STATUS_CODE_CONNECTED	= 2,
61 	EMFT_STATUS_CODE_NO_ROUTE	= 3,
62 	EMFT_STATUS_CODE_OTHER_ERROR	= 4
63 };
64 
65 enum {
66 	COL_STRING_DISPLAY_NAME,	/* string that appears in the tree */
67 	COL_OBJECT_CAMEL_STORE,		/* CamelStore object */
68 	COL_STRING_FULL_NAME,		/* if node is a folder, the full path
69 					 * name of the folder, no leading / */
70 	COL_STRING_ICON_NAME,		/* icon name for the folder, see COL_GICON_CUSTOM_ICON */
71 	COL_UINT_UNREAD,		/* unread count */
72 	COL_UINT_FLAGS,			/* FolderInfo.flags */
73 
74 	COL_BOOL_IS_STORE,		/* toplevel store node? */
75 	COL_BOOL_IS_FOLDER,		/* folder (not a store) */
76 	COL_BOOL_LOAD_SUBDIRS,		/* %TRUE only if the store/folder
77 					 * has subfolders which have not yet
78 					 * been added to the tree */
79 	COL_UINT_UNREAD_LAST_SEL,	/* last known unread count */
80 	COL_BOOL_IS_DRAFT,		/* %TRUE for a draft folder */
81 
82 	/* Status icon/spinner, only for top-level store rows. */
83 	COL_STATUS_ICON,
84 	COL_STATUS_ICON_VISIBLE,
85 	COL_STATUS_SPINNER_PULSE,
86 	COL_STATUS_SPINNER_VISIBLE,
87 
88 	COL_STRING_FOLDER_URI,		/* folder URI */
89 	COL_GICON_CUSTOM_ICON,		/* a custom icon to use for the folder; NULL to use COL_STRING_ICON_NAME */
90 	COL_RGBA_FOREGROUND_RGBA,	/* GdkRGBA for the foreground color; can be NULL */
91 	COL_UINT_SORT_ORDER,		/* 0 - use default; non-zero - define sort order on its level */
92 
93 	COL_UINT_STATUS_CODE,		/* Status code for the store - one of EMFT_STATUS_CODE_ constancts */
94 
95 	NUM_COLUMNS
96 };
97 
98 struct _EMFolderTreeModel {
99 	GtkTreeStore parent;
100 	EMFolderTreeModelPrivate *priv;
101 };
102 
103 struct _EMFolderTreeModelClass {
104 	GtkTreeStoreClass parent_class;
105 
106 	/* signals */
107 	void		(*loading_row)		(EMFolderTreeModel *model,
108 						 GtkTreePath *path,
109 						 GtkTreeIter *iter);
110 
111 	void		(*loaded_row)		(EMFolderTreeModel *model,
112 						 GtkTreePath *path,
113 						 GtkTreeIter *iter);
114 };
115 
116 GType		em_folder_tree_model_get_type	(void);
117 EMFolderTreeModel *
118 		em_folder_tree_model_new	(void);
119 EMFolderTreeModel *
120 		em_folder_tree_model_get_default (void);
121 void		em_folder_tree_model_free_default (void);
122 EMailFolderTweaks *
123 		em_folder_tree_model_get_folder_tweaks
124 						(EMFolderTreeModel *model);
125 GtkTreeSelection *
126 		em_folder_tree_model_get_selection
127 					(EMFolderTreeModel *model);
128 void		em_folder_tree_model_set_selection
129 					(EMFolderTreeModel *model,
130 					 GtkTreeSelection *selection);
131 EMailSession *	em_folder_tree_model_get_session
132 					(EMFolderTreeModel *model);
133 void		em_folder_tree_model_set_session
134 					(EMFolderTreeModel *model,
135 					 EMailSession *session);
136 gboolean	em_folder_tree_model_set_folder_info
137 					(EMFolderTreeModel *model,
138 					 GtkTreeIter *iter,
139 					 CamelStore *store,
140 					 CamelFolderInfo *fi,
141 					 gint fully_loaded);
142 void		em_folder_tree_model_add_store
143 					(EMFolderTreeModel *model,
144 					 CamelStore *store);
145 void		em_folder_tree_model_remove_store
146 					(EMFolderTreeModel *model,
147 					 CamelStore *store);
148 void		em_folder_tree_model_remove_all_stores
149 					(EMFolderTreeModel *model);
150 GList *		em_folder_tree_model_list_stores
151 					(EMFolderTreeModel *model);
152 void		em_folder_tree_model_mark_store_loaded
153 					(EMFolderTreeModel *model,
154 					 CamelStore *store);
155 gboolean	em_folder_tree_model_is_type_inbox
156 					(EMFolderTreeModel *model,
157 					 CamelStore *store,
158 					 const gchar *full);
159 gchar *		em_folder_tree_model_get_folder_name
160 					(EMFolderTreeModel *model,
161 					 CamelStore *store,
162 					 const gchar *full);
163 GtkTreeRowReference *
164 		em_folder_tree_model_get_row_reference
165 					(EMFolderTreeModel *model,
166 					 CamelStore *store,
167 					 const gchar *folder_name);
168 void		em_folder_tree_model_user_marked_unread
169 					(EMFolderTreeModel *model,
170 					 CamelFolder *folder,
171 					 guint n_marked);
172 void		em_folder_tree_model_update_row_tweaks
173 					(EMFolderTreeModel *model,
174 					 GtkTreeIter *iter);
175 
176 G_END_DECLS
177 
178 #endif /* EM_FOLDER_TREE_MODEL_H */
179