1 /*
2  *
3  * This program is free software; you can redistribute it and/or modify it
4  * under the terms of the GNU Lesser General Public License as published by
5  * the Free Software Foundation.
6  *
7  * This program is distributed in the hope that it will be useful, but
8  * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
9  * or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
10  * for more details.
11  *
12  * You should have received a copy of the GNU Lesser General Public License
13  * along with this program; if not, see <http://www.gnu.org/licenses/>.
14  *
15  *
16  * Authors:
17  *		Jeffrey Stedfast <fejj@ximian.com>
18  *
19  * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com)
20  *
21  */
22 
23 #ifndef EM_FOLDER_TREE_H
24 #define EM_FOLDER_TREE_H
25 
26 #include <gtk/gtk.h>
27 #include <e-util/e-util.h>
28 #include <mail/em-folder-tree-model.h>
29 #include <libemail-engine/libemail-engine.h>
30 
31 /* Standard GObject macros */
32 #define EM_TYPE_FOLDER_TREE \
33 	(em_folder_tree_get_type ())
34 #define EM_FOLDER_TREE(obj) \
35 	(G_TYPE_CHECK_INSTANCE_CAST \
36 	((obj), EM_TYPE_FOLDER_TREE, EMFolderTree))
37 #define EM_FOLDER_TREE_CLASS(cls) \
38 	(G_TYPE_CHECK_CLASS_CAST \
39 	((cls), EM_TYPE_FOLDER_TREE, EMFolderTreeClass))
40 #define EM_IS_FOLDER_TREE(obj) \
41 	(G_TYPE_CHECK_INSTANCE_TYPE \
42 	((obj), EM_TYPE_FOLDER_TREE))
43 #define EM_IS_FOLDER_TREE_CLASS(cls) \
44 	(G_TYPE_CHECK_CLASS_TYPE \
45 	((cls), EM_TYPE_FOLDER_TREE))
46 #define EM_FOLDER_TREE_GET_CLASS(obj) \
47 	(G_TYPE_INSTANCE_GET_CLASS \
48 	((obj), EM_TYPE_FOLDER_TREE, EMFolderTreeClass))
49 
50 G_BEGIN_DECLS
51 
52 typedef struct _EMFolderTree EMFolderTree;
53 typedef struct _EMFolderTreeClass EMFolderTreeClass;
54 typedef struct _EMFolderTreePrivate EMFolderTreePrivate;
55 
56 #define STATE_KEY_EXPANDED	"Expanded"
57 
58 /* XXX Not sure this api is the best, but its the easiest
59  *     to implement and will cover what we need. */
60 #define EMFT_EXCLUDE_NOSELECT CAMEL_FOLDER_NOSELECT
61 #define EMFT_EXCLUDE_NOINFERIORS CAMEL_FOLDER_NOINFERIORS
62 #define EMFT_EXCLUDE_VIRTUAL CAMEL_FOLDER_VIRTUAL
63 #define EMFT_EXCLUDE_SYSTEM CAMEL_FOLDER_SYSTEM
64 #define EMFT_EXCLUDE_VTRASH CAMEL_FOLDER_VTRASH
65 
66 typedef gboolean	(*EMFTExcludeFunc)	(EMFolderTree *folder_tree,
67 						 GtkTreeModel *model,
68 						 GtkTreeIter *iter,
69 						 gpointer user_data);
70 
71 struct _EMFolderTree {
72 	GtkTreeView parent;
73 	EMFolderTreePrivate *priv;
74 };
75 
76 struct _EMFolderTreeClass {
77 	GtkTreeViewClass parent_class;
78 
79 	/* signals */
80 	void		(*folder_activated)	(EMFolderTree *folder_tree,
81 						 CamelStore *store,
82 						 const gchar *folder_name);
83 	void		(*folder_selected)	(EMFolderTree *folder_tree,
84 						 CamelStore *store,
85 						 const gchar *folder_name,
86 						 CamelFolderInfoFlags flags);
87 	void		(*popup_event)		(EMFolderTree *folder_tree);
88 	void		(*hidden_key_event)	(EMFolderTree *emft, GdkEvent *event);
89 };
90 
91 GType		em_folder_tree_get_type		(void);
92 GtkWidget *	em_folder_tree_new		(EMailSession *session,
93 						 EAlertSink *alert_sink);
94 GtkWidget *	em_folder_tree_new_with_model	(EMailSession *session,
95 						 EAlertSink *alert_sink,
96 						 EMFolderTreeModel *model);
97 EActivity *	em_folder_tree_new_activity	(EMFolderTree *folder_tree);
98 EAlertSink *	em_folder_tree_get_alert_sink	(EMFolderTree *folder_tree);
99 EMailSession *	em_folder_tree_get_session	(EMFolderTree *folder_tree);
100 void		em_folder_tree_enable_drag_and_drop
101 						(EMFolderTree *folder_tree);
102 void		em_folder_tree_set_excluded	(EMFolderTree *folder_tree,
103 						 guint32 flags);
104 void		em_folder_tree_set_excluded_func
105 						(EMFolderTree *folder_tree,
106 						 EMFTExcludeFunc exclude,
107 						 gpointer data);
108 void		em_folder_tree_set_selected_list
109 						(EMFolderTree *folder_tree,
110 						 GList *list,
111 						 gboolean expand_only);
112 GList *		em_folder_tree_get_selected_uris
113 						(EMFolderTree *folder_tree);
114 GList *		em_folder_tree_get_selected_paths
115 						(EMFolderTree *folder_tree);
116 void		em_folder_tree_set_selected	(EMFolderTree *folder_tree,
117 						 const gchar *uri,
118 						 gboolean expand_only);
119 gboolean	em_folder_tree_select_next_path	(EMFolderTree *folder_tree,
120 						 gboolean skip_read_folders);
121 gboolean	em_folder_tree_select_prev_path	(EMFolderTree *folder_tree,
122 						 gboolean skip_read_folders);
123 void		em_folder_tree_edit_selected	(EMFolderTree *folder_tree);
124 gboolean	em_folder_tree_get_selected	(EMFolderTree *folder_tree,
125 						 CamelStore **out_store,
126 						 gchar **out_folder_name);
127 gboolean	em_folder_tree_store_root_selected
128 						(EMFolderTree *folder_tree,
129 						 CamelStore **out_store);
130 gchar *		em_folder_tree_get_selected_uri	(EMFolderTree *folder_tree);
131 CamelStore *	em_folder_tree_ref_selected_store
132 						(EMFolderTree *folder_tree);
133 gboolean	em_folder_tree_create_folder	(EMFolderTree *folder_tree,
134 						 const gchar *full_name,
135 						 const gchar *uri);
136 void		em_folder_tree_set_skip_double_click
137 						(EMFolderTree *folder_tree,
138 						 gboolean skip);
139 void		em_folder_tree_restore_state	(EMFolderTree *folder_tree,
140 						 GKeyFile *key_file);
141 void		em_folder_tree_set_selectable_widget
142 						(EMFolderTree *folder_tree,
143 						 GtkWidget *selectable);
144 void		em_folder_tree_select_store_when_added
145 						(EMFolderTree *folder_tree,
146 						 const gchar *store_uid);
147 
148 G_END_DECLS
149 
150 #endif /* EM_FOLDER_TREE_H */
151