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