2007-03-30 [paul] 2.8.1cvs68
[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         GtkWidget *toggle_search;
105         GtkWidget *quick_search_pixmap;
106         GtkWidget *popupmenu;
107         GtkWidget *colorlabel_menu;
108
109         GtkItemFactory *popupfactory;
110
111         GtkWidget *window;
112
113         GtkCTreeNode *selected;
114         GtkCTreeNode *displayed;
115         GtkCTreeNode *last_displayed;
116
117         gboolean display_msg;
118
119         GdkColor color_important;
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         off_t  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         GtkTooltips *tips;
172 };
173
174 SummaryView     *summary_create(void);
175
176 void summary_init                 (SummaryView          *summaryview);
177 gboolean summary_show             (SummaryView          *summaryview,
178                                    FolderItem           *fitem);
179 void summary_clear_list           (SummaryView          *summaryview);
180 void summary_clear_all            (SummaryView          *summaryview);
181
182 void summary_lock                 (SummaryView          *summaryview);
183 void summary_unlock               (SummaryView          *summaryview);
184 void summary_freeze               (SummaryView          *summaryview);
185 void summary_thaw                 (SummaryView          *summaryview);
186 void summary_grab_focus           (SummaryView          *summaryview);
187 GtkWidget *summary_get_main_widget(SummaryView          *summaryview);
188 gboolean summary_is_locked        (SummaryView          *summaryview);
189
190 SummarySelection summary_get_selection_type     (SummaryView    *summaryview);
191 MsgInfo *summary_get_selected_msg               (SummaryView *summaryview);
192 GSList *summary_get_selected_msg_list           (SummaryView    *summaryview);
193
194 void summary_select_prev_unread   (SummaryView          *summaryview);
195 void summary_select_next_unread   (SummaryView          *summaryview);
196 void summary_select_prev_new      (SummaryView          *summaryview);
197 void summary_select_next_new      (SummaryView          *summaryview);
198 void summary_select_prev_marked   (SummaryView          *summaryview);
199 void summary_select_next_marked   (SummaryView          *summaryview);
200 void summary_select_prev_labeled  (SummaryView          *summaryview);
201 void summary_select_next_labeled  (SummaryView          *summaryview);
202 void summary_select_last_read     (SummaryView          *summaryview);
203 void summary_select_parent        (SummaryView          *summaryview);
204 void summary_select_by_msgnum     (SummaryView          *summaryview,
205                                    guint                 msgnum);
206 guint summary_get_current_msgnum  (SummaryView          *summaryview);
207 void summary_select_node          (SummaryView          *summaryview,
208                                    GtkCTreeNode         *node,
209                                    gboolean              display_msg,
210                                    gboolean              do_refresh);
211
212 void summary_thread_build         (SummaryView          *summaryview);
213
214 void summary_expand_threads       (SummaryView          *summaryview);
215 void summary_collapse_threads     (SummaryView          *summaryview);
216 void summary_toggle_ignore_thread (SummaryView          *summaryview);
217
218 void summary_filter               (SummaryView          *summaryview,
219                                    gboolean              selected_only);
220 void summary_filter_open          (SummaryView *summaryview,
221                                    PrefsFilterType type,
222                                    gint processing_rule);
223 void summary_msginfo_filter_open  (FolderItem * item, MsgInfo *msginfo,
224                                    PrefsFilterType type, gint processing_rule);
225
226 void summary_sort                 (SummaryView          *summaryview,
227                                    FolderSortKey         sort_key,
228                                    FolderSortType        sort_type);
229
230 void summary_delete               (SummaryView          *summaryview);
231 void summary_delete_trash         (SummaryView          *summaryview);
232
233 void summary_cancel               (SummaryView          *summaryview);
234
235 gboolean summary_execute          (SummaryView          *summaryview);
236
237 void summary_attract_by_subject   (SummaryView          *summaryview);
238
239 gint summary_write_cache          (SummaryView          *summaryview);
240
241 gboolean summary_pass_key_press_event (SummaryView              *summaryview,
242                                    GdkEventKey          *event);
243
244 void summary_display_msg_selected (SummaryView          *summaryview,
245                                    gboolean              all_headers);
246 void summary_redisplay_msg        (SummaryView          *summaryview);
247 void summary_open_msg             (SummaryView          *summaryview);
248 void summary_open_row             (GtkSCTree *sctree, SummaryView *summaryview);
249 void summary_view_source          (SummaryView          *summaryview);
250 void summary_reedit               (SummaryView          *summaryview);
251 gboolean summary_step             (SummaryView          *summaryview,
252                                    GtkScrollType         type);
253 void summary_toggle_view          (SummaryView          *summaryview);
254 void summary_set_marks_selected   (SummaryView          *summaryview);
255 guint summary_get_msgnum          (SummaryView          *summaryview,
256                                    GtkCTreeNode         *node);
257
258 void summary_move_selected_to     (SummaryView          *summaryview,
259                                    FolderItem           *to_folder);
260 void summary_move_to              (SummaryView          *summaryview);
261 void summary_copy_selected_to     (SummaryView          *summaryview,
262                                    FolderItem           *to_folder);
263 GSList *summary_get_selection     (SummaryView          *summaryview);
264 void summary_copy_to              (SummaryView          *summaryview);
265 void summary_save_as              (SummaryView          *summaryview);
266 void summary_print                (SummaryView          *summaryview);
267 void summary_mark                 (SummaryView          *summaryview);
268 void summary_unmark               (SummaryView          *summaryview);
269 void summary_mark_as_unread       (SummaryView          *summaryview);
270 void summary_mark_as_read         (SummaryView          *summaryview);
271 void summary_msgs_lock            (SummaryView          *summaryview);
272 void summary_msgs_unlock          (SummaryView          *summaryview);
273 void summary_mark_all_read        (SummaryView          *summaryview);
274 void summary_mark_as_spam         (SummaryView          *summaryview, 
275                                    guint                 action, 
276                                    GtkWidget            *widget);
277 void summary_ignore_thread        (SummaryView          *summaryview);
278 void summary_unignore_thread      (SummaryView          *summaryview);
279
280 void summary_add_address          (SummaryView          *summaryview);
281 void summary_select_all           (SummaryView          *summaryview);
282 void summary_unselect_all         (SummaryView          *summaryview);
283 void summary_select_thread        (SummaryView          *summaryview,
284                                    gboolean              delete_thread);
285
286 void summary_set_colorlabel       (SummaryView          *summaryview,
287                                    guint                 labelcolor,
288                                    GtkWidget            *widget);
289 void summary_set_colorlabel_color (GtkCTree             *ctree,
290                                    GtkCTreeNode         *node,
291                                    guint                 labelcolor);
292
293 void summary_set_column_order     (SummaryView          *summaryview);
294
295 void summary_toggle_show_read_messages
296                                   (SummaryView *summaryview);
297
298 void summary_toggle_view_real     (SummaryView  *summaryview);
299
300 void summary_reflect_prefs_pixmap_theme
301                                   (SummaryView *summaryview);
302 void summary_reflect_prefs_custom_colors(SummaryView *summaryview);
303 void summary_harvest_address      (SummaryView *summaryview);
304 void summary_set_prefs_from_folderitem
305                                   (SummaryView *summaryview, FolderItem *item);
306 void summary_save_prefs_to_folderitem
307                                   (SummaryView *summaryview, FolderItem *item);
308 gint summaryview_export_mbox_list (SummaryView *summaryview);
309 void summaryview_lock(SummaryView *summaryview, FolderItem *item);
310 void summaryview_unlock(SummaryView *summaryview, FolderItem *item);
311 void summary_reflect_prefs(void);
312 void summaryview_activate_quicksearch(SummaryView *summaryview, gboolean show);
313 void summary_set_menu_sensitive (SummaryView            *summaryview);
314 void summary_relayout(SummaryView *summaryview);
315 void summary_update_unread(SummaryView *summaryview, FolderItem *removed_item);
316 #endif /* __SUMMARY_H__ */