2010-02-09 [colin] 3.7.5cvs11
[claws.git] / src / compose.h
1 /*
2  * Sylpheed -- a GTK+ based, lightweight, and fast e-mail client
3  * Copyright (C) 1999-2009 Hiroyuki Yamamoto
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
20 #ifndef __COMPOSE_H__
21 #define __COMPOSE_H__
22
23 typedef struct _Compose         Compose;
24 typedef struct _AttachInfo      AttachInfo;
25
26 #include <glib.h>
27 #include <gtk/gtk.h>
28
29 #include "procmsg.h"
30 #include "procmime.h"
31 #include "addressbook.h"
32 #include "prefs_account.h"
33 #include "undo.h"
34 #include "toolbar.h"
35 #include "messageview.h"
36 #include "codeconv.h"
37 #include "template.h"
38 #include "textview.h"
39 #include "folder.h"
40
41 #ifdef USE_ENCHANT
42 #include "gtkaspell.h"
43 #endif
44
45 #define COMPOSE_CHECK_BEFORE_SEND_HOOKLIST "compose_check_before_send"
46 #define COMPOSE_CREATED_HOOKLIST "compose_created"
47
48 typedef enum
49 {
50         COMPOSE_TO,
51         COMPOSE_CC,
52         COMPOSE_BCC,
53         COMPOSE_REPLYTO,
54         COMPOSE_NEWSGROUPS,
55         COMPOSE_FOLLOWUPTO,
56         COMPOSE_INREPLYTO
57 } ComposeEntryType;
58
59 typedef enum
60 {
61         COMPOSE_REPLY,
62         COMPOSE_REPLY_WITH_QUOTE,
63         COMPOSE_REPLY_WITHOUT_QUOTE,
64         COMPOSE_REPLY_TO_SENDER,
65         COMPOSE_FOLLOWUP_AND_REPLY_TO,
66         COMPOSE_REPLY_TO_SENDER_WITH_QUOTE,
67         COMPOSE_REPLY_TO_SENDER_WITHOUT_QUOTE,
68         COMPOSE_REPLY_TO_ALL,
69         COMPOSE_REPLY_TO_ALL_WITH_QUOTE,
70         COMPOSE_REPLY_TO_ALL_WITHOUT_QUOTE,
71         COMPOSE_REPLY_TO_LIST,
72         COMPOSE_REPLY_TO_LIST_WITH_QUOTE,
73         COMPOSE_REPLY_TO_LIST_WITHOUT_QUOTE,
74         COMPOSE_FORWARD,
75         COMPOSE_FORWARD_AS_ATTACH,
76         COMPOSE_FORWARD_INLINE,
77         COMPOSE_NEW,
78         COMPOSE_REDIRECT,
79         COMPOSE_REEDIT
80 } ComposeMode;
81
82 typedef enum {
83         PREF_ACCOUNT,
84         PREF_FOLDER,
85         PREF_TEMPLATE,
86         PREF_ML,
87         PREF_MAILTO,
88         PREF_NONE
89 } ComposePrefType;
90
91 typedef struct {
92         guint headernum;
93         Compose *compose;
94         GtkWidget *combo;
95         GtkWidget *entry;
96         GtkWidget *button;
97         GtkWidget *hbox;
98         ComposePrefType type;
99 } ComposeHeaderEntry;
100
101 struct _Compose
102 {
103         /* start with window widget don`t change order */
104         GtkWidget *window;
105         GtkWidget *vbox;
106         GtkWidget *menubar;
107
108         /* Toolbar handlebox */
109         GtkWidget *handlebox;
110         Toolbar *toolbar;
111         
112         GtkWidget *vbox2;
113
114         /* Header */
115         GtkWidget *table_vbox;
116         GtkWidget *table;
117         GtkWidget *subject_entry;
118         GtkWidget *paned;
119
120         /* Attachments */
121         GtkWidget *attach_scrwin;
122         GtkWidget *attach_clist;
123         GtkWidget *attach_label;
124
125         /* Others */
126         GtkWidget *savemsg_checkbtn;
127         GtkWidget *savemsg_combo;
128
129         /* Headers notebook */
130         GtkWidget *notebook;
131
132         /* Textedit */
133         GtkWidget *edit_vbox;
134         GtkWidget *ruler_hbox;
135         GtkWidget *ruler;
136         GtkWidget *scrolledwin;
137         GtkWidget *text;
138         GtkWidget *from_name;
139 #if !GTK_CHECK_VERSION(2,12,0)
140         GtkTooltips *tooltips;
141 #endif
142
143         GtkWidget *focused_editable;
144
145         GtkWidget *popupmenu;
146
147         GtkWidget *tmpl_menu;
148
149         ComposeMode mode;
150
151         MsgInfo *targetinfo;
152         MsgInfo *replyinfo;
153         MsgInfo *autosaved_draft;
154         MsgInfo *fwdinfo;
155
156         GtkWidget *header_table;
157         GSList    *header_list;
158         guint      header_nextrow;
159         ComposeHeaderEntry *header_last;
160
161         GHashTable *email_hashtable;
162
163         gchar   *replyto;
164         gchar   *cc;
165         gchar   *bcc;
166         gchar   *newsgroups;
167         gchar   *followup_to;
168
169         gchar   *ml_post;
170
171         gchar   *inreplyto;
172         gchar   *references;
173         gchar   *msgid;
174         gchar   *boundary;
175
176         gboolean autowrap;
177         gboolean autoindent;
178
179         gboolean use_to;
180         gboolean use_cc;
181         gboolean use_bcc;
182         gboolean use_replyto;
183         gboolean use_newsgroups;
184         gboolean use_followupto;
185         gboolean use_attach;
186
187         CharSet out_encoding;
188
189         /* privacy settings */
190         gboolean use_signing;
191         gboolean use_encryption;
192         gchar *privacy_system;
193
194         gboolean modified;
195
196         gboolean sending;
197         
198         gboolean return_receipt;
199
200         gboolean batch;
201         
202         GSList *to_list;
203         GSList *newsgroup_list;
204
205         PrefsAccount *account;
206         FolderItem *folder;
207
208         UndoMain *undostruct;
209
210         gchar *sig_str;
211         gboolean sig_inserted;
212
213         /* external editor */
214         gchar      *exteditor_file;
215         pid_t       exteditor_pid;
216         GIOChannel *exteditor_ch;
217         gint        exteditor_tag;
218
219         /* Priority */
220         gint priority;
221
222         gchar *redirect_filename;
223         
224         gboolean remove_references;
225
226         guint draft_timeout_tag;
227         
228         GtkTextTag *no_wrap_tag;
229         GtkTextTag *no_join_tag;
230         GtkTextTag *signature_tag;
231         GtkTextTag *quote0_tag;
232         GtkTextTag *quote1_tag;
233         GtkTextTag *quote2_tag;
234         GtkTextTag *uri_tag;
235
236         gboolean automatic_break;
237         GMutex *mutex;
238         gchar *orig_charset;
239         gint set_cursor_pos;
240         
241         gboolean updating;
242         gboolean deferred_destroy;
243         ComposeMode rmode;
244         GtkWidget *first_combo;
245         GtkWidget *first_entry;
246         
247         GtkUIManager *ui_manager;
248 #if USE_ENCHANT
249         /* GNU/aspell spell checker */
250         GtkAspell *gtkaspell;
251         GtkWidget *aspell_options_menu;
252 #endif
253 };
254
255 struct _AttachInfo
256 {
257         gchar *file;
258         gchar *content_type;
259         EncodingType encoding;
260         gchar *name;
261         goffset size;
262 };
263
264 typedef enum
265 {
266         COMPOSE_QUIT_EDITING,
267         COMPOSE_KEEP_EDITING,
268         COMPOSE_AUTO_SAVE,
269         COMPOSE_DRAFT_FOR_EXIT
270 } ComposeDraftAction;
271
272 /*#warning FIXME_GTK2 */
273 /* attache_files will be locale encode */
274 Compose *compose_new                    (PrefsAccount   *account,
275                                          const gchar    *mailto,
276                                          GPtrArray      *attach_files);
277
278 Compose *compose_new_with_folderitem    (PrefsAccount   *account,
279                                          FolderItem     *item,
280                                          const gchar    *mailto);
281
282 Compose *compose_new_with_list          (PrefsAccount   *account,
283                                          GList          *listAddress);
284
285 Compose *compose_forward                (PrefsAccount *account,
286                                          MsgInfo        *msginfo,
287                                          gboolean        as_attach,
288                                          const gchar    *body,
289                                          gboolean        no_extedit,
290                                          gboolean        batch);
291
292 Compose *compose_redirect               (PrefsAccount   *account,
293                                          MsgInfo        *msginfo,
294                                          gboolean        batch);
295 Compose *compose_reedit                 (MsgInfo        *msginfo,
296                                          gboolean        batch);
297
298 GList *compose_get_compose_list         (void);
299
300 void compose_entry_append               (Compose          *compose,
301                                          const gchar      *address,
302                                          ComposeEntryType  type,
303                                          ComposePrefType   pref_type);
304
305
306 gint compose_send                       (Compose          *compose);
307
308 void compose_update_actions_menu        (Compose        *compose);
309 void compose_reflect_prefs_all                  (void);
310 void compose_reflect_prefs_pixmap_theme (void);
311
312 void compose_destroy_all                (void);
313 gboolean compose_draft                  (gpointer data, guint action);
314 void compose_toolbar_cb                 (gint           action, 
315                                          gpointer       data);
316 void compose_reply_from_messageview     (MessageView    *msgview, 
317                                          GSList         *msginfo_list, 
318                                          guint           action);
319 void compose_action_cb                  (void           *data);
320
321 void compose_set_position                               (Compose        *compose,
322                                                  gint            pos);
323 gboolean compose_search_string                  (Compose        *compose,
324                                                  const gchar    *str,
325                                                  gboolean        case_sens);
326 gboolean compose_search_string_backward (Compose        *compose,
327                                                  const gchar    *str,
328                                                  gboolean        case_sens);
329 gint compose_queue                      (Compose *compose, 
330                                          gint *msgnum, 
331                                          FolderItem **item, 
332                                          gchar **msgpath,
333                                          gboolean remove_reedit_target);
334 gboolean compose_close                  (Compose *compose);
335 void compose_close_toolbar              (Compose *compose);
336 void compose_clear_exit_drafts          (void);
337 void compose_reopen_exit_drafts         (void);
338 void compose_attach_from_list (Compose *compose, GList *file_list, gboolean free_data);
339 #endif /* __COMPOSE_H__ */