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 _MESSAGE_LIST_H_
23 #define _MESSAGE_LIST_H_
24 
25 #include <gtk/gtk.h>
26 #include <camel/camel.h>
27 
28 #include <e-util/e-util.h>
29 #include <libemail-engine/libemail-engine.h>
30 
31 /* Standard GObject macros */
32 #define MESSAGE_LIST_TYPE \
33 	(message_list_get_type ())
34 #define MESSAGE_LIST(obj) \
35 	(G_TYPE_CHECK_INSTANCE_CAST \
36 	((obj), MESSAGE_LIST_TYPE, MessageList))
37 #define MESSAGE_LIST_CLASS(cls) \
38 	(G_TYPE_CHECK_CLASS_CAST \
39 	((cls), MESSAGE_LIST_TYPE, MessageListClass))
40 #define IS_MESSAGE_LIST(obj) \
41 	(G_TYPE_CHECK_INSTANCE_TYPE \
42 	((obj), MESSAGE_LIST_TYPE))
43 #define IS_MESSAGE_LIST_CLASS(cls) \
44 	(G_TYPE_CHECK_CLASS_TYPE \
45 	((cls), MESSAGE_LIST_TYPE))
46 #define MESSAGE_LIST_GET_CLASS(obj) \
47 	(G_TYPE_INSTANCE_GET_CLASS \
48 	((obj), MESSAGE_LIST_TYPE, MessageListClass))
49 
50 G_BEGIN_DECLS
51 
52 enum {
53 	COL_MESSAGE_STATUS,
54 	COL_FLAGGED,
55 	COL_SCORE,
56 	COL_ATTACHMENT,
57 	COL_FROM,
58 	COL_SUBJECT,
59 	COL_SENT,
60 	COL_RECEIVED,
61 	COL_TO,
62 	COL_SIZE,
63 	COL_FOLLOWUP_FLAG_STATUS,
64 	COL_FOLLOWUP_FLAG,
65 	COL_FOLLOWUP_DUE_BY,
66 	COL_LOCATION,		/* vfolder location? */
67 	COL_SENDER,
68 	COL_RECIPIENTS,
69 	COL_MIXED_SENDER,
70 	COL_MIXED_RECIPIENTS,
71 	COL_LABELS,
72 
73 	/* subject with junk removed */
74 	COL_SUBJECT_TRIMMED,
75 
76 	/* normalised strings */
77 	COL_FROM_NORM,
78 	COL_SUBJECT_NORM,
79 	COL_TO_NORM,
80 
81 	COL_UID,
82 	COL_SENDER_MAIL,
83 	COL_RECIPIENTS_MAIL,
84 	COL_USER_HEADER_1,
85 	COL_USER_HEADER_2,
86 	COL_USER_HEADER_3,
87 
88 	COL_LAST,
89 
90 	/* Invisible columns */
91 	COL_DELETED,
92 	COL_DELETED_OR_JUNK,
93 	COL_JUNK,
94 	COL_JUNK_STRIKEOUT_COLOR,
95 	COL_UNREAD,
96 	COL_COLOUR,
97 	COL_ITALIC
98 };
99 
100 #define MESSAGE_LIST_COLUMN_IS_ACTIVE(col) (col == COL_MESSAGE_STATUS || \
101 					    col == COL_FLAGGED)
102 
103 typedef struct _MessageList MessageList;
104 typedef struct _MessageListClass MessageListClass;
105 typedef struct _MessageListPrivate MessageListPrivate;
106 
107 struct _MessageList {
108 	ETree parent;
109 
110 	MessageListPrivate *priv;
111 
112 	/* The table */
113 	ETableExtras *extras;
114 
115 	GHashTable *uid_nodemap; /* uid (from info) -> tree node mapping */
116 
117 	GHashTable *normalised_hash;
118 
119 	/* Current search string, or %NULL */
120 	gchar *search;
121 
122 	/* are we regenerating the message_list because set_folder
123 	 * was just called? */
124 	guint just_set_folder : 1;
125 
126 	guint expand_all :1;
127 	guint collapse_all :1;
128 
129 	/* frozen count */
130 	guint frozen : 16;
131 
132 	/* Where the ETree cursor is. */
133 	gchar *cursor_uid;
134 
135 	/* whether the last selection was on a single row or none/multi */
136 	gboolean last_sel_single;
137 
138 	/* Row-selection and seen-marking timers */
139 	guint idle_id, seen_id;
140 
141 	gchar *frozen_search;	/* to save search took place while we were frozen */
142 };
143 
144 struct _MessageListClass {
145 	ETreeClass parent_class;
146 
147 	/* signals - select a message */
148 	void (*message_selected) (MessageList *message_list, const gchar *uid);
149 	void (*message_list_built) (MessageList *message_list);
150 	void (*message_list_scrolled) (MessageList *message_list);
151 };
152 
153 typedef enum {
154 	MESSAGE_LIST_SELECT_NEXT = 0,
155 	MESSAGE_LIST_SELECT_PREVIOUS = 1,
156 	MESSAGE_LIST_SELECT_DIRECTION = 1, /* direction mask */
157 	MESSAGE_LIST_SELECT_WRAP = 1 << 1, /* option bit */
158 	MESSAGE_LIST_SELECT_INCLUDE_COLLAPSED = 1 << 2 /* whether to search collapsed nodes as well */
159 } MessageListSelectDirection;
160 
161 GType		message_list_get_type		(void);
162 GtkWidget *	message_list_new		(EMailSession *session);
163 EMailSession *	message_list_get_session	(MessageList *message_list);
164 CamelFolder *	message_list_ref_folder		(MessageList *message_list);
165 void		message_list_set_folder		(MessageList *message_list,
166 						 CamelFolder *folder);
167 GtkTargetList *	message_list_get_copy_target_list
168 						(MessageList *message_list);
169 GtkTargetList *	message_list_get_paste_target_list
170 						(MessageList *message_list);
171 void		message_list_set_expanded_default
172 						(MessageList *message_list,
173 						 gboolean expanded_default);
174 gboolean	message_list_get_group_by_threads
175 						(MessageList *message_list);
176 void		message_list_set_group_by_threads
177 						(MessageList *message_list,
178 						 gboolean group_by_threads);
179 gboolean	message_list_get_show_deleted	(MessageList *message_list);
180 void		message_list_set_show_deleted	(MessageList *message_list,
181 						 gboolean show_deleted);
182 gboolean	message_list_get_show_junk	(MessageList *message_list);
183 void		message_list_set_show_junk	(MessageList *message_list,
184 						 gboolean show_junk);
185 gboolean	message_list_get_show_subject_above_sender
186 						(MessageList *message_list);
187 void		message_list_set_show_subject_above_sender
188 						(MessageList *message_list,
189 						 gboolean show_subject_above_sender);
190 gboolean	message_list_get_thread_latest	(MessageList *message_list);
191 void		message_list_set_thread_latest	(MessageList *message_list,
192 						 gboolean thread_latest);
193 gboolean	message_list_get_thread_subject	(MessageList *message_list);
194 void		message_list_set_thread_subject	(MessageList *message_list,
195 						 gboolean thread_subject);
196 gboolean	message_list_get_thread_compress(MessageList *message_list);
197 void		message_list_set_thread_compress(MessageList *message_list,
198 						 gboolean thread_compress);
199 gboolean	message_list_get_regen_selects_unread
200 						(MessageList *message_list);
201 void		message_list_set_regen_selects_unread
202 						(MessageList *message_list,
203 						 gboolean regen_selects_unread);
204 void		message_list_freeze		(MessageList *message_list);
205 void		message_list_thaw		(MessageList *message_list);
206 GPtrArray *	message_list_get_selected	(MessageList *message_list);
207 GPtrArray *	message_list_get_selected_with_collapsed_threads
208 						(MessageList *message_list);
209 void		message_list_set_selected	(MessageList *message_list,
210 						 GPtrArray *uids);
211 gboolean	message_list_select		(MessageList *message_list,
212 						 MessageListSelectDirection direction,
213 						 guint32 flags,
214 						 guint32 mask);
215 gboolean	message_list_can_select		(MessageList *message_list,
216 						 MessageListSelectDirection direction,
217 						 guint32 flags,
218 						 guint32 mask);
219 void		message_list_select_uid		(MessageList *message_list,
220 						 const gchar *uid,
221 						 gboolean with_fallback);
222 void		message_list_select_next_thread	(MessageList *message_list);
223 void		message_list_select_prev_thread	(MessageList *message_list);
224 void		message_list_select_all		(MessageList *message_list);
225 void		message_list_select_thread	(MessageList *message_list);
226 void		message_list_select_subthread	(MessageList *message_list);
227 void		message_list_copy		(MessageList *message_list,
228 						 gboolean cut);
229 void		message_list_paste		(MessageList *message_list);
230 guint		message_list_count		(MessageList *message_list);
231 guint		message_list_selected_count	(MessageList *message_list);
232 void		message_list_set_threaded_expand_all
233 						(MessageList *message_list);
234 void		message_list_set_threaded_collapse_all
235 						(MessageList *message_list);
236 void		message_list_set_search		(MessageList *message_list,
237 						 const gchar *search);
238 void		message_list_save_state		(MessageList *message_list);
239 
240 void		message_list_sort_uids		(MessageList *message_list,
241 						 GPtrArray *uids);
242 gboolean	message_list_contains_uid	(MessageList *message_list,
243 						 const gchar *uid);
244 void		message_list_inc_setting_up_search_folder
245 						(MessageList *message_list);
246 void		message_list_dec_setting_up_search_folder
247 						(MessageList *message_list);
248 gboolean	message_list_is_setting_up_search_folder
249 						(MessageList *message_list);
250 
251 G_END_DECLS
252 
253 #endif /* _MESSAGE_LIST_H_ */
254