[pawel] 3.7.3cvs13
[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         gchar   *replyto;
160         gchar   *cc;
161         gchar   *bcc;
162         gchar   *newsgroups;
163         gchar   *followup_to;
164
165         gchar   *ml_post;
166
167         gchar   *inreplyto;
168         gchar   *references;
169         gchar   *msgid;
170         gchar   *boundary;
171
172         gboolean autowrap;
173         gboolean autoindent;
174
175         gboolean use_to;
176         gboolean use_cc;
177         gboolean use_bcc;
178         gboolean use_replyto;
179         gboolean use_newsgroups;
180         gboolean use_followupto;
181         gboolean use_attach;
182
183         CharSet out_encoding;
184
185         /* privacy settings */
186         gboolean use_signing;
187         gboolean use_encryption;
188         gchar *privacy_system;
189
190         gboolean modified;
191
192         gboolean sending;
193         
194         gboolean return_receipt;
195
196         gboolean batch;
197         
198         GSList *to_list;
199         GSList *newsgroup_list;
200
201         PrefsAccount *account;
202         FolderItem *folder;
203
204         UndoMain *undostruct;
205
206         gchar *sig_str;
207         gboolean sig_inserted;
208
209         /* external editor */
210         gchar      *exteditor_file;
211         pid_t       exteditor_pid;
212         GIOChannel *exteditor_ch;
213         gint        exteditor_tag;
214
215         /* Priority */
216         gint priority;
217
218         gchar *redirect_filename;
219         
220         gboolean remove_references;
221
222         guint draft_timeout_tag;
223         
224         GtkTextTag *no_wrap_tag;
225         GtkTextTag *no_join_tag;
226         GtkTextTag *signature_tag;
227         GtkTextTag *quote0_tag;
228         GtkTextTag *quote1_tag;
229         GtkTextTag *quote2_tag;
230         GtkTextTag *uri_tag;
231
232         gboolean automatic_break;
233         GMutex *mutex;
234         gchar *orig_charset;
235         gint set_cursor_pos;
236         
237         gboolean updating;
238         gboolean deferred_destroy;
239         ComposeMode rmode;
240         GtkWidget *first_combo;
241         GtkWidget *first_entry;
242         
243         GtkUIManager *ui_manager;
244 #if USE_ENCHANT
245         /* GNU/aspell spell checker */
246         GtkAspell *gtkaspell;
247         GtkWidget *aspell_options_menu;
248 #endif
249 };
250
251 struct _AttachInfo
252 {
253         gchar *file;
254         gchar *content_type;
255         EncodingType encoding;
256         gchar *name;
257         goffset size;
258 };
259
260 typedef enum
261 {
262         COMPOSE_QUIT_EDITING,
263         COMPOSE_KEEP_EDITING,
264         COMPOSE_AUTO_SAVE,
265         COMPOSE_DRAFT_FOR_EXIT
266 } ComposeDraftAction;
267
268 /*#warning FIXME_GTK2 */
269 /* attache_files will be locale encode */
270 Compose *compose_new                    (PrefsAccount   *account,
271                                          const gchar    *mailto,
272                                          GPtrArray      *attach_files);
273
274 Compose *compose_new_with_folderitem    (PrefsAccount   *account,
275                                          FolderItem     *item,
276                                          const gchar    *mailto);
277
278 Compose *compose_new_with_list          (PrefsAccount   *account,
279                                          GList          *listAddress);
280
281 Compose *compose_forward                (PrefsAccount *account,
282                                          MsgInfo        *msginfo,
283                                          gboolean        as_attach,
284                                          const gchar    *body,
285                                          gboolean        no_extedit,
286                                          gboolean        batch);
287
288 Compose *compose_redirect               (PrefsAccount   *account,
289                                          MsgInfo        *msginfo,
290                                          gboolean        batch);
291 Compose *compose_reedit                 (MsgInfo        *msginfo,
292                                          gboolean        batch);
293
294 GList *compose_get_compose_list         (void);
295
296 void compose_entry_append               (Compose          *compose,
297                                          const gchar      *address,
298                                          ComposeEntryType  type,
299                                          ComposePrefType   pref_type);
300
301
302 gint compose_send                       (Compose          *compose);
303
304 void compose_update_actions_menu        (Compose        *compose);
305 void compose_reflect_prefs_all                  (void);
306 void compose_reflect_prefs_pixmap_theme (void);
307
308 void compose_destroy_all                (void);
309 gboolean compose_draft                  (gpointer data, guint action);
310 void compose_toolbar_cb                 (gint           action, 
311                                          gpointer       data);
312 void compose_reply_from_messageview     (MessageView    *msgview, 
313                                          GSList         *msginfo_list, 
314                                          guint           action);
315 void compose_action_cb                  (void           *data);
316
317 void compose_set_position                               (Compose        *compose,
318                                                  gint            pos);
319 gboolean compose_search_string                  (Compose        *compose,
320                                                  const gchar    *str,
321                                                  gboolean        case_sens);
322 gboolean compose_search_string_backward (Compose        *compose,
323                                                  const gchar    *str,
324                                                  gboolean        case_sens);
325 gint compose_queue                      (Compose *compose, 
326                                          gint *msgnum, 
327                                          FolderItem **item, 
328                                          gchar **msgpath,
329                                          gboolean remove_reedit_target);
330 gboolean compose_close                  (Compose *compose);
331 void compose_close_toolbar              (Compose *compose);
332 void compose_clear_exit_drafts          (void);
333 void compose_reopen_exit_drafts         (void);
334 void compose_attach_from_list (Compose *compose, GList *file_list, gboolean free_data);
335 #endif /* __COMPOSE_H__ */