2007-04-23 [colin] 2.9.1cvs17
[claws.git] / src / summaryview.h
1 /*
2  * Sylpheed -- a GTK+ based, lightweight, and fast e-mail client
3  * Copyright (C) 1999-2007 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 2 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, write to the Free Software
17  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
18  */
19
20 #ifndef __SUMMARY_H__
21 #define __SUMMARY_H__
22
23 #include <sys/types.h>
24 #include <regex.h>
25
26 #include <glib.h>
27 #include <gdk/gdk.h>
28 #include <gtk/gtkwidget.h>
29 #include <gtk/gtkitemfactory.h>
30 #include <gtk/gtkctree.h>
31 #include <gtk/gtkdnd.h>
32
33 typedef struct _SummaryView             SummaryView;
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 } SummaryColumnType;
52
53 #define N_SUMMARY_COLS  11
54
55 typedef enum
56 {
57         SUMMARY_NONE,
58         SUMMARY_SELECTED_NONE,
59         SUMMARY_SELECTED_SINGLE,
60         SUMMARY_SELECTED_MULTIPLE
61 } SummarySelection;
62
63 typedef enum
64 {
65         TARGET_MAIL_URI_LIST,
66         TARGET_DUMMY
67 } TargetInfo;
68
69 #include "mainwindow.h"
70 #include "folderview.h"
71 #include "headerview.h"
72 #include "messageview.h"
73 #include "compose.h"
74 #include "folder.h"
75 #include "gtksctree.h"
76 #include "prefs_filtering.h"
77 #include "quicksearch.h"
78
79 extern GtkTargetEntry summary_drag_types[2];
80
81 struct _SummaryColumnState
82 {
83         SummaryColumnType type;
84         gboolean visible;
85 };
86
87 struct _SummaryView
88 {
89         GtkWidget *vbox;
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 MAEMO
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
113         GtkItemFactory *popupfactory;
114
115         GtkWidget *window;
116
117         GtkCTreeNode *selected;
118         GtkCTreeNode *displayed;
119         GtkCTreeNode *last_displayed;
120
121         gboolean display_msg;
122
123         GdkColor color_important;
124         SummaryColumnState col_state[N_SUMMARY_COLS];
125         gint col_pos[N_SUMMARY_COLS];
126
127         GdkColor color_marked;
128         GdkColor color_dim;
129
130         guint lock_count;
131
132         MainWindow   *mainwin;
133         FolderView   *folderview;
134         HeaderView   *headerview;
135         MessageView  *messageview;
136         MessageView  *ext_messageview;
137         QuickSearch  *quicksearch;
138
139         FolderItem *folder_item;
140
141         /* summaryview prefs */
142         gint important_score;
143         FolderSortKey sort_key;
144         FolderSortType sort_type;
145         guint threaded;
146         guint thread_collapsed;
147
148         /* Extra data for summaryview */
149         regex_t *simplify_subject_preg;
150
151         /* current message status */
152         gint   unreadmarked;
153         off_t  total_size;
154         gint   deleted;
155         gint   moved;
156         gint   copied;
157
158 /*
159 private:
160 */
161         /* table for looking up message-id */
162         GHashTable *msgid_table;
163         GHashTable *subject_table;
164
165         /* list for moving/deleting messages */
166         GSList *mlist;
167         int msginfo_update_callback_id;
168
169         /* update folder label when renaming */
170         gint folder_item_update_callback_id;
171         gint folder_update_callback_id;
172
173         GtkTargetList *target_list; /* DnD */
174         
175         GtkTooltips *tips;
176 };
177
178 SummaryView     *summary_create(void);
179
180 void summary_init                 (SummaryView          *summaryview);
181 gboolean summary_show             (SummaryView          *summaryview,
182                                    FolderItem           *fitem);
183 void summary_clear_list           (SummaryView          *summaryview);
184 void summary_clear_all            (SummaryView          *summaryview);
185
186 void summary_lock                 (SummaryView          *summaryview);
187 void summary_unlock               (SummaryView          *summaryview);
188 void summary_freeze               (SummaryView          *summaryview);
189 void summary_thaw                 (SummaryView          *summaryview);
190 void summary_grab_focus           (SummaryView          *summaryview);
191 GtkWidget *summary_get_main_widget(SummaryView          *summaryview);
192 gboolean summary_is_locked        (SummaryView          *summaryview);
193
194 SummarySelection summary_get_selection_type     (SummaryView    *summaryview);
195 MsgInfo *summary_get_selected_msg               (SummaryView *summaryview);
196 GSList *summary_get_selected_msg_list           (SummaryView    *summaryview);
197
198 void summary_select_prev_unread   (SummaryView          *summaryview);
199 void summary_select_next_unread   (SummaryView          *summaryview);
200 void summary_select_prev_new      (SummaryView          *summaryview);
201 void summary_select_next_new      (SummaryView          *summaryview);
202 void summary_select_prev_marked   (SummaryView          *summaryview);
203 void summary_select_next_marked   (SummaryView          *summaryview);
204 void summary_select_prev_labeled  (SummaryView          *summaryview);
205 void summary_select_next_labeled  (SummaryView          *summaryview);
206 void summary_select_last_read     (SummaryView          *summaryview);
207 void summary_select_parent        (SummaryView          *summaryview);
208 void summary_select_by_msgnum     (SummaryView          *summaryview,
209                                    guint                 msgnum);
210 guint summary_get_current_msgnum  (SummaryView          *summaryview);
211 void summary_select_node          (SummaryView          *summaryview,
212                                    GtkCTreeNode         *node,
213                                    gboolean              display_msg,
214                                    gboolean              do_refresh);
215
216 void summary_thread_build         (SummaryView          *summaryview);
217
218 void summary_expand_threads       (SummaryView          *summaryview);
219 void summary_collapse_threads     (SummaryView          *summaryview);
220 void summary_toggle_ignore_thread (SummaryView          *summaryview);
221
222 void summary_filter               (SummaryView          *summaryview,
223                                    gboolean              selected_only);
224 void summary_filter_open          (SummaryView *summaryview,
225                                    PrefsFilterType type,
226                                    gint processing_rule);
227 void summary_msginfo_filter_open  (FolderItem * item, MsgInfo *msginfo,
228                                    PrefsFilterType type, gint processing_rule);
229
230 void summary_sort                 (SummaryView          *summaryview,
231                                    FolderSortKey         sort_key,
232                                    FolderSortType        sort_type);
233
234 void summary_delete               (SummaryView          *summaryview);
235 void summary_delete_trash         (SummaryView          *summaryview);
236
237 void summary_cancel               (SummaryView          *summaryview);
238
239 gboolean summary_execute          (SummaryView          *summaryview);
240
241 void summary_attract_by_subject   (SummaryView          *summaryview);
242
243 gint summary_write_cache          (SummaryView          *summaryview);
244
245 gboolean summary_pass_key_press_event (SummaryView              *summaryview,
246                                    GdkEventKey          *event);
247
248 void summary_display_msg_selected (SummaryView          *summaryview,
249                                    gboolean              all_headers);
250 void summary_redisplay_msg        (SummaryView          *summaryview);
251 void summary_open_msg             (SummaryView          *summaryview);
252 void summary_open_row             (GtkSCTree *sctree, SummaryView *summaryview);
253 void summary_view_source          (SummaryView          *summaryview);
254 void summary_reedit               (SummaryView          *summaryview);
255 gboolean summary_step             (SummaryView          *summaryview,
256                                    GtkScrollType         type);
257 void summary_toggle_view          (SummaryView          *summaryview);
258 void summary_set_marks_selected   (SummaryView          *summaryview);
259 guint summary_get_msgnum          (SummaryView          *summaryview,
260                                    GtkCTreeNode         *node);
261
262 void summary_move_selected_to     (SummaryView          *summaryview,
263                                    FolderItem           *to_folder);
264 void summary_move_to              (SummaryView          *summaryview);
265 void summary_copy_selected_to     (SummaryView          *summaryview,
266                                    FolderItem           *to_folder);
267 GSList *summary_get_selection     (SummaryView          *summaryview);
268 void summary_copy_to              (SummaryView          *summaryview);
269 void summary_save_as              (SummaryView          *summaryview);
270 void summary_print                (SummaryView          *summaryview);
271 void summary_mark                 (SummaryView          *summaryview);
272 void summary_unmark               (SummaryView          *summaryview);
273 void summary_mark_as_unread       (SummaryView          *summaryview);
274 void summary_mark_as_read         (SummaryView          *summaryview);
275 void summary_msgs_lock            (SummaryView          *summaryview);
276 void summary_msgs_unlock          (SummaryView          *summaryview);
277 void summary_mark_all_read        (SummaryView          *summaryview);
278 void summary_mark_as_spam         (SummaryView          *summaryview, 
279                                    guint                 action, 
280                                    GtkWidget            *widget);
281 void summary_ignore_thread        (SummaryView          *summaryview);
282 void summary_unignore_thread      (SummaryView          *summaryview);
283
284 void summary_add_address          (SummaryView          *summaryview);
285 void summary_select_all           (SummaryView          *summaryview);
286 void summary_unselect_all         (SummaryView          *summaryview);
287 void summary_select_thread        (SummaryView          *summaryview,
288                                    gboolean              delete_thread);
289
290 void summary_set_colorlabel       (SummaryView          *summaryview,
291                                    guint                 labelcolor,
292                                    GtkWidget            *widget);
293 void summary_set_colorlabel_color (GtkCTree             *ctree,
294                                    GtkCTreeNode         *node,
295                                    guint                 labelcolor);
296
297 void summary_set_column_order     (SummaryView          *summaryview);
298
299 void summary_toggle_show_read_messages
300                                   (SummaryView *summaryview);
301
302 void summary_toggle_view_real     (SummaryView  *summaryview);
303
304 void summary_reflect_prefs_pixmap_theme
305                                   (SummaryView *summaryview);
306 void summary_reflect_prefs_custom_colors(SummaryView *summaryview);
307 void summary_harvest_address      (SummaryView *summaryview);
308 void summary_set_prefs_from_folderitem
309                                   (SummaryView *summaryview, FolderItem *item);
310 void summary_save_prefs_to_folderitem
311                                   (SummaryView *summaryview, FolderItem *item);
312 gint summaryview_export_mbox_list (SummaryView *summaryview);
313 void summaryview_lock(SummaryView *summaryview, FolderItem *item);
314 void summaryview_unlock(SummaryView *summaryview, FolderItem *item);
315 void summary_reflect_prefs(void);
316 void summaryview_activate_quicksearch(SummaryView *summaryview, gboolean show);
317 void summary_set_menu_sensitive (SummaryView            *summaryview);
318 void summary_relayout(SummaryView *summaryview);
319 void summary_update_unread(SummaryView *summaryview, FolderItem *removed_item);
320 #endif /* __SUMMARY_H__ */