2007-01-21 [colin] 2.7.1cvs43
[claws.git] / src / compose.h
1 /*
2  * Sylpheed -- a GTK+ based, lightweight, and fast e-mail client
3  * Copyright (C) 1999-2007 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 2 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, write to the Free Software
17  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
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/gtkwidget.h>
28 #include <gtk/gtkitemfactory.h>
29
30 #include "procmsg.h"
31 #include "procmime.h"
32 #include "addressbook.h"
33 #include "prefs_account.h"
34 #include "undo.h"
35 #include "toolbar.h"
36 #include "messageview.h"
37 #include "codeconv.h"
38 #include "template.h"
39 #include "textview.h"
40
41 #ifdef USE_ASPELL
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 } ComposeHeaderEntry;
86
87 struct _Compose
88 {
89         /* start with window widget don`t change order */
90         GtkWidget *window;
91         GtkWidget *vbox;
92         GtkWidget *menubar;
93
94         /* Toolbar handlebox */
95         GtkWidget *handlebox;
96         Toolbar *toolbar;
97         
98         GtkWidget *vbox2;
99
100         /* Header */
101         GtkWidget *table_vbox;
102         GtkWidget *table;
103         GtkWidget *subject_entry;
104         GtkWidget *paned;
105
106         /* Attachments */
107         GtkWidget *attach_scrwin;
108         GtkWidget *attach_clist;
109
110         /* Others */
111         GtkWidget *savemsg_checkbtn;
112         GtkWidget *savemsg_entry;
113
114         /* Textedit */
115         GtkWidget *edit_vbox;
116         GtkWidget *ruler_hbox;
117         GtkWidget *ruler;
118         GtkWidget *scrolledwin;
119         GtkWidget *text;
120         GtkWidget *from_name;
121         GtkTooltips *tooltips;
122
123         GtkWidget *focused_editable;
124
125         GtkWidget *popupmenu;
126
127         GtkItemFactory *popupfactory;
128
129         GtkWidget *tmpl_menu;
130
131         ComposeMode mode;
132
133         MsgInfo *targetinfo;
134         MsgInfo *replyinfo;
135         MsgInfo *autosaved_draft;
136         MsgInfo *fwdinfo;
137
138         GtkWidget *header_table;
139         GSList    *header_list;
140         guint      header_nextrow;
141         ComposeHeaderEntry *header_last;
142
143         gchar   *replyto;
144         gchar   *cc;
145         gchar   *bcc;
146         gchar   *newsgroups;
147         gchar   *followup_to;
148
149         gchar   *ml_post;
150
151         gchar   *inreplyto;
152         gchar   *references;
153         gchar   *msgid;
154         gchar   *boundary;
155
156         gboolean autowrap;
157
158         gboolean use_to;
159         gboolean use_cc;
160         gboolean use_bcc;
161         gboolean use_replyto;
162         gboolean use_newsgroups;
163         gboolean use_followupto;
164         gboolean use_attach;
165
166         CharSet out_encoding;
167
168         /* privacy settings */
169         gboolean use_signing;
170         gboolean use_encryption;
171         gchar *privacy_system;
172
173         gboolean modified;
174
175         gboolean sending;
176         
177         gboolean return_receipt;
178
179         gboolean batch;
180         
181         GSList *to_list;
182         GSList *newsgroup_list;
183
184         PrefsAccount *account;
185
186         UndoMain *undostruct;
187
188         gchar *sig_str;
189
190         /* external editor */
191         gchar      *exteditor_file;
192         pid_t       exteditor_pid;
193         GIOChannel *exteditor_ch;
194         gint        exteditor_tag;
195
196 #if USE_ASPELL
197         /* GNU/aspell spell checker */
198         GtkAspell *gtkaspell;
199         GtkWidget *aspell_options_menu;
200 #endif
201
202         /* Priority */
203         gint priority;
204
205         gchar *redirect_filename;
206         
207         gboolean remove_references;
208
209         guint draft_timeout_tag;
210         
211         GtkTextTag *no_wrap_tag;
212         GtkTextTag *no_join_tag;
213         GMutex *mutex;
214         gchar *orig_charset;
215         gint set_cursor_pos;
216         
217         gboolean updating;
218         gboolean deferred_destroy;
219         ComposeMode rmode;
220 };
221
222 struct _AttachInfo
223 {
224         gchar *file;
225         gchar *content_type;
226         EncodingType encoding;
227         gchar *name;
228         off_t size;
229 };
230
231 /*#warning FIXME_GTK2 */
232 /* attache_files will be locale encode */
233 Compose *compose_new                    (PrefsAccount   *account,
234                                          const gchar    *mailto,
235                                          GPtrArray      *attach_files);
236
237 Compose *compose_new_with_folderitem    (PrefsAccount   *account,
238                                          FolderItem     *item,
239                                          const gchar    *mailto);
240
241 Compose *compose_new_with_list          (PrefsAccount   *account,
242                                          GList          *listAddress);
243
244 Compose *compose_forward                (PrefsAccount *account,
245                                          MsgInfo        *msginfo,
246                                          gboolean        as_attach,
247                                          const gchar    *body,
248                                          gboolean        no_extedit,
249                                          gboolean        batch);
250
251 Compose *compose_redirect               (PrefsAccount   *account,
252                                          MsgInfo        *msginfo,
253                                          gboolean        batch);
254 Compose *compose_reedit                 (MsgInfo        *msginfo,
255                                          gboolean        batch);
256
257 GList *compose_get_compose_list         (void);
258
259 void compose_entry_append               (Compose          *compose,
260                                          const gchar      *address,
261                                          ComposeEntryType  type);
262
263
264 gint compose_send                       (Compose          *compose);
265
266 void compose_update_actions_menu        (Compose        *compose);
267 void compose_reflect_prefs_all                  (void);
268 void compose_reflect_prefs_pixmap_theme (void);
269
270 void compose_destroy_all                (void);
271 void compose_draft                      (gpointer data);
272 void compose_toolbar_cb                 (gint           action, 
273                                          gpointer       data);
274 void compose_reply_from_messageview     (MessageView    *msgview, 
275                                          GSList         *msginfo_list, 
276                                          guint           action);
277 void compose_action_cb                  (void           *data);
278
279 void compose_set_position                               (Compose        *compose,
280                                                  gint            pos);
281 gboolean compose_search_string                  (Compose        *compose,
282                                                  const gchar    *str,
283                                                  gboolean        case_sens);
284 gboolean compose_search_string_backward (Compose        *compose,
285                                                  const gchar    *str,
286                                                  gboolean        case_sens);
287 gint compose_queue                      (Compose *compose, 
288                                          gint *msgnum, 
289                                          FolderItem **item, 
290                                          gchar **msgpath,
291                                          gboolean remove_reedit_target);
292 gboolean compose_close                  (Compose *compose);
293 #endif /* __COMPOSE_H__ */