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