e00f133e93a18c8591221cf006baccb762239c7b
[claws.git] / src / summaryview.h
1 /*
2  * Claws Mail -- a GTK+ based, lightweight, and fast e-mail client
3  * Copyright (C) 1999-2015 Hiroyuki Yamamoto and the Claws Mail team
4  *
5  * This program is free software; you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License as published by
7  * the Free Software Foundation; either version 3 of the License, or
8  * (at your option) any later version.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with this program. If not, see <http://www.gnu.org/licenses/>.
17  */
18
19 #ifndef __SUMMARY_H__
20 #define __SUMMARY_H__
21
22 #include <sys/types.h>
23 #include <regex.h>
24
25 #include <glib.h>
26 #include <gdk/gdk.h>
27 #include <gtk/gtk.h>
28
29 #ifdef HAVE_CONFIG_H
30 #include "config.h"
31 #endif
32
33 #include "viewtypes.h"
34 typedef struct _SummaryColumnState      SummaryColumnState;
35
36 #define MAIL_MANUAL_FILTERING_HOOKLIST "mail_manual_filtering_hooklist"
37
38 typedef enum
39 {
40         S_COL_MARK,
41         S_COL_STATUS,
42         S_COL_MIME,
43         S_COL_SUBJECT,
44         S_COL_FROM,
45         S_COL_TO,
46         S_COL_DATE,
47         S_COL_SIZE,
48         S_COL_NUMBER,
49         S_COL_SCORE,
50         S_COL_LOCKED,
51         S_COL_TAGS
52 } SummaryColumnType;
53
54 #define N_SUMMARY_COLS  12
55
56 typedef enum
57 {
58         SUMMARY_NONE,
59         SUMMARY_SELECTED_NONE,
60         SUMMARY_SELECTED_SINGLE,
61         SUMMARY_SELECTED_MULTIPLE
62 } SummarySelection;
63
64 typedef enum
65 {
66         TARGET_MAIL_URI_LIST,
67         TARGET_DUMMY,
68         TARGET_MAIL_CM_PATH_LIST,
69 } TargetInfo;
70
71 #include "mainwindow.h"
72 #include "compose.h"
73 #include "folder.h"
74 #include "gtksctree.h"
75 #include "prefs_filtering.h"
76 #include "quicksearch.h"
77
78 extern GtkTargetEntry summary_drag_types[3];
79
80 struct _SummaryColumnState
81 {
82         SummaryColumnType type;
83         gboolean visible;
84 };
85
86 struct _SummaryView
87 {
88         GtkWidget *vbox;
89         GtkWidget *mainwidget_book;
90         GtkWidget *scrolledwin;
91         GtkWidget *ctree;
92         GtkWidget *hbox;
93         GtkWidget *hbox_l;
94         GtkWidget *hbox_spc;
95         GtkWidget *stat_box;
96         GtkWidget *stat_box2;
97         GtkWidget *folder_pixmap;
98         GtkWidget *folder_pixmap_eventbox;
99         GtkWidget *statlabel_folder;
100         GtkWidget *statlabel_select;
101         GtkWidget *statlabel_msgs;
102         GtkWidget *toggle_eventbox;
103         GtkWidget *toggle_arrow;
104 #ifdef GENERIC_UMPC
105         GtkWidget *multiple_sel_togbtn;
106         GtkWidget *multiple_sel_image;
107 #endif
108         GtkWidget *toggle_search;
109         GtkWidget *quick_search_pixmap;
110         GtkWidget *popupmenu;
111         GtkWidget *colorlabel_menu;
112         GtkWidget *tags_menu;
113         GtkWidget *window;
114
115         GtkCMCTreeNode *selected;
116         GtkCMCTreeNode *displayed;
117
118         gboolean display_msg;
119
120         SummaryColumnState col_state[N_SUMMARY_COLS];
121         gint col_pos[N_SUMMARY_COLS];
122
123         GdkColor color_marked;
124         GdkColor color_dim;
125
126         guint lock_count;
127
128         MainWindow   *mainwin;
129         FolderView   *folderview;
130         HeaderView   *headerview;
131         MessageView  *messageview;
132         MessageView  *ext_messageview;
133         QuickSearch  *quicksearch;
134
135         FolderItem *folder_item;
136
137         /* summaryview prefs */
138         gint important_score;
139         FolderSortKey sort_key;
140         FolderSortType sort_type;
141         guint threaded;
142         guint thread_collapsed;
143
144         /* Extra data for summaryview */
145         regex_t *simplify_subject_preg;
146
147         /* current message status */
148         gint   unreadmarked;
149         goffset total_size;
150         gint   deleted;
151         gint   moved;
152         gint   copied;
153
154 /*
155 private:
156 */
157         /* table for looking up message-id */
158         GHashTable *msgid_table;
159         GHashTable *subject_table;
160
161         /* list for moving/deleting messages */
162         GSList *mlist;
163         int msginfo_update_callback_id;
164
165         /* update folder label when renaming */
166         gint folder_item_update_callback_id;
167         gint folder_update_callback_id;
168
169         GtkTargetList *target_list; /* DnD */
170
171         // folders with matches for recursive quicksearch queries
172         GSList *recursive_matched_folders;
173         FolderItem *search_root_folder;
174
175         guint mark_as_read_timeout_tag;
176
177         GtkActionGroup *action_group;
178         GtkUIManager *ui_manager;
179 };
180
181 SummaryView     *summary_create(MainWindow *mainwin);
182 void summaryview_destroy(SummaryView *summaryview);
183 void summary_init                 (SummaryView          *summaryview);
184 gboolean summary_show             (SummaryView          *summaryview,
185                                    FolderItem           *fitem);
186 void summary_clear_list           (SummaryView          *summaryview);
187 void summary_clear_all            (SummaryView          *summaryview);
188
189 void summary_lock                 (SummaryView          *summaryview);
190 void summary_unlock               (SummaryView          *summaryview);
191 void summary_freeze               (SummaryView          *summaryview);
192 void summary_thaw                 (SummaryView          *summaryview);
193 void summary_thaw_with_status     (SummaryView          *summaryview);
194 void summary_grab_focus           (SummaryView          *summaryview);
195 GtkWidget *summary_get_main_widget(SummaryView          *summaryview);
196 gboolean summary_is_locked        (SummaryView          *summaryview);
197
198 SummarySelection summary_get_selection_type     (SummaryView    *summaryview);
199 MsgInfo *summary_get_selected_msg               (SummaryView *summaryview);
200 GSList *summary_get_selected_msg_list           (SummaryView    *summaryview);
201
202 void summary_select_prev          (SummaryView          *summaryview);
203 void summary_select_next          (SummaryView          *summaryview);
204 void summary_select_prev_unread   (SummaryView          *summaryview);
205 void summary_select_next_unread   (SummaryView          *summaryview);
206 void summary_select_prev_new      (SummaryView          *summaryview);
207 void summary_select_next_new      (SummaryView          *summaryview);
208 void summary_select_prev_marked   (SummaryView          *summaryview);
209 void summary_select_next_marked   (SummaryView          *summaryview);
210 void summary_select_prev_labeled  (SummaryView          *summaryview);
211 void summary_select_next_labeled  (SummaryView          *summaryview);
212 void summary_select_parent        (SummaryView          *summaryview);
213 void summary_select_by_msgnum     (SummaryView          *summaryview,
214                                    guint                 msgnum,
215                                    gboolean              show);
216 void summary_select_by_msg_list   (SummaryView          *summaryview, GSList *msginfos);
217 guint summary_get_current_msgnum  (SummaryView          *summaryview);
218 void summary_select_node          (SummaryView          *summaryview,
219                                    GtkCMCTreeNode       *node,
220                                    gboolean              display_msg);
221
222 void summary_expand_threads       (SummaryView          *summaryview);
223 void summary_collapse_threads     (SummaryView          *summaryview);
224 void summary_toggle_ignore_thread (SummaryView          *summaryview);
225 void summary_toggle_watch_thread  (SummaryView          *summaryview);
226
227 void summary_filter               (SummaryView          *summaryview,
228                                    gboolean              selected_only);
229 void summary_filter_open          (SummaryView *summaryview,
230                                    PrefsFilterType type,
231                                    gint processing_rule);
232 void summary_msginfo_filter_open  (FolderItem * item, MsgInfo *msginfo,
233                                    PrefsFilterType type, gint processing_rule);
234
235 void summary_sort                 (SummaryView          *summaryview,
236                                    FolderSortKey         sort_key,
237                                    FolderSortType        sort_type);
238
239 void summary_delete               (SummaryView          *summaryview);
240 void summary_delete_trash         (SummaryView          *summaryview);
241
242 void summary_cancel               (SummaryView          *summaryview);
243
244 gboolean summary_execute          (SummaryView          *summaryview);
245 gboolean summary_expunge          (SummaryView          *summaryview);
246
247 void summary_attract_by_subject   (SummaryView          *summaryview);
248
249 gint summary_write_cache          (SummaryView          *summaryview);
250
251 gboolean summary_pass_key_press_event (SummaryView              *summaryview,
252                                    GdkEventKey          *event);
253
254 void summary_display_msg_selected (SummaryView          *summaryview,
255                                    gboolean              all_headers);
256 void summary_redisplay_msg        (SummaryView          *summaryview);
257 void summary_open_msg             (SummaryView          *summaryview);
258 void summary_open_row             (GtkSCTree *sctree, SummaryView *summaryview);
259 void summary_view_source          (SummaryView          *summaryview);
260 void summary_reedit               (SummaryView          *summaryview);
261 gboolean summary_step             (SummaryView          *summaryview,
262                                    GtkScrollType         type);
263 void summary_toggle_view          (SummaryView          *summaryview);
264 void summary_set_marks_selected   (SummaryView          *summaryview);
265 guint summary_get_msgnum          (SummaryView          *summaryview,
266                                    GtkCMCTreeNode               *node);
267
268 void summary_move_selected_to     (SummaryView          *summaryview,
269                                    FolderItem           *to_folder);
270 void summary_move_to              (SummaryView          *summaryview);
271 void summary_copy_selected_to     (SummaryView          *summaryview,
272                                    FolderItem           *to_folder);
273 GSList *summary_get_selection     (SummaryView          *summaryview);
274 guint summary_get_selection_count (SummaryView          *summaryview);
275 void summary_copy_to              (SummaryView          *summaryview);
276 void summary_save_as              (SummaryView          *summaryview);
277 void summary_print                (SummaryView          *summaryview);
278 void summary_mark                 (SummaryView          *summaryview);
279 void summary_unmark               (SummaryView          *summaryview);
280 void summary_mark_as_read         (SummaryView          *summaryview);
281 void summary_mark_as_unread       (SummaryView          *summaryview);
282 void summary_msgs_lock            (SummaryView          *summaryview);
283 void summary_msgs_unlock          (SummaryView          *summaryview);
284 void summary_mark_all_read        (SummaryView          *summaryview, gboolean ask_if_needed);
285 void summary_mark_all_unread      (SummaryView          *summaryview, gboolean ask_if_needed);
286 void summary_mark_as_spam         (SummaryView          *summaryview, 
287                                    guint                 action, 
288                                    GtkWidget            *widget);
289 void summary_ignore_thread        (SummaryView          *summaryview);
290 void summary_unignore_thread      (SummaryView          *summaryview);
291 void summary_watch_thread         (SummaryView          *summaryview);
292 void summary_unwatch_thread       (SummaryView          *summaryview);
293
294 void summary_add_address          (SummaryView          *summaryview);
295 void summary_select_all           (SummaryView          *summaryview);
296 void summary_unselect_all         (SummaryView          *summaryview);
297 void summary_select_thread        (SummaryView          *summaryview,
298                                    gboolean              delete_thread,
299                                    gboolean              trash_thread);
300
301 void summary_set_colorlabel       (SummaryView          *summaryview,
302                                    guint                 labelcolor,
303                                    GtkWidget            *widget);
304 void summary_set_tag              (SummaryView          *summaryview,
305                                    gint                  tag_id,
306                                    GtkWidget            *widget);
307
308 void summary_set_column_order     (SummaryView          *summaryview);
309
310 void summary_toggle_show_read_messages
311                                   (SummaryView *summaryview);
312 void summary_toggle_show_read_threads
313                                   (SummaryView *summaryview);
314 void summary_toggle_show_del_messages
315                                   (SummaryView *summaryview);
316
317 void summary_toggle_view_real     (SummaryView  *summaryview);
318
319 void summary_reflect_prefs_pixmap_theme
320                                   (SummaryView *summaryview);
321 void summary_reflect_prefs_custom_colors(SummaryView *summaryview);
322 void summary_reflect_tags_changes(SummaryView *summaryview);
323 void summary_harvest_address      (SummaryView *summaryview);
324 void summary_set_prefs_from_folderitem
325                                   (SummaryView *summaryview, FolderItem *item);
326 void summary_save_prefs_to_folderitem
327                                   (SummaryView *summaryview, FolderItem *item);
328 gint summaryview_export_mbox_list (SummaryView *summaryview);
329 void summaryview_lock(SummaryView *summaryview, FolderItem *item);
330 void summaryview_unlock(SummaryView *summaryview, FolderItem *item);
331 void summary_reflect_prefs(void);
332 void summaryview_activate_quicksearch(SummaryView *summaryview, gboolean show);
333 void summary_set_menu_sensitive (SummaryView            *summaryview);
334 void summary_relayout(SummaryView *summaryview);
335 void summary_update_unread(SummaryView *summaryview, FolderItem *removed_item);
336 gboolean summary_is_list(SummaryView *summaryview);
337 gboolean summaryview_search_root_progress(gpointer data, guint at, guint matched, guint total);
338 gboolean summary_is_opened_message_selected(SummaryView *summaryview);
339 #endif /* __SUMMARY_H__ */