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