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