Statistics
| Revision:

root / src / messageview.c @ 710

History | View | Annotate | Download (26.5 kB)

1 1 hiro
/*
2 1 hiro
 * Sylpheed -- a GTK+ based, lightweight, and fast e-mail client
3 154 hiro
 * Copyright (C) 1999-2005 Hiroyuki Yamamoto
4 1 hiro
 *
5 1 hiro
 * This program is free software; you can redistribute it and/or modify
6 1 hiro
 * it under the terms of the GNU General Public License as published by
7 1 hiro
 * the Free Software Foundation; either version 2 of the License, or
8 1 hiro
 * (at your option) any later version.
9 1 hiro
 *
10 1 hiro
 * This program is distributed in the hope that it will be useful,
11 1 hiro
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 1 hiro
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13 1 hiro
 * GNU General Public License for more details.
14 1 hiro
 *
15 1 hiro
 * You should have received a copy of the GNU General Public License
16 1 hiro
 * along with this program; if not, write to the Free Software
17 1 hiro
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18 1 hiro
 */
19 1 hiro
20 1 hiro
#include "defs.h"
21 1 hiro
22 1 hiro
#include <glib.h>
23 92 hiro
#include <glib/gi18n.h>
24 1 hiro
#include <gdk/gdkkeysyms.h>
25 154 hiro
#include <gtk/gtknotebook.h>
26 1 hiro
#include <gtk/gtkvbox.h>
27 1 hiro
#include <gtk/gtkcontainer.h>
28 1 hiro
#include <gtk/gtkwindow.h>
29 1 hiro
#include <gtk/gtktextview.h>
30 1 hiro
#include <gtk/gtkmenu.h>
31 1 hiro
#include <gtk/gtkmenuitem.h>
32 237 hiro
#include <gtk/gtkcheckmenuitem.h>
33 237 hiro
#include <gtk/gtkstatusbar.h>
34 1 hiro
#include <stdio.h>
35 1 hiro
#include <ctype.h>
36 1 hiro
#include <string.h>
37 1 hiro
38 1 hiro
#include "main.h"
39 1 hiro
#include "messageview.h"
40 1 hiro
#include "message_search.h"
41 1 hiro
#include "headerview.h"
42 1 hiro
#include "textview.h"
43 1 hiro
#include "imageview.h"
44 1 hiro
#include "mimeview.h"
45 1 hiro
#include "menu.h"
46 1 hiro
#include "about.h"
47 1 hiro
#include "filesel.h"
48 1 hiro
#include "sourcewindow.h"
49 1 hiro
#include "addressbook.h"
50 1 hiro
#include "alertpanel.h"
51 1 hiro
#include "inputdialog.h"
52 1 hiro
#include "manage_window.h"
53 1 hiro
#include "procmsg.h"
54 1 hiro
#include "procheader.h"
55 1 hiro
#include "procmime.h"
56 1 hiro
#include "account.h"
57 1 hiro
#include "action.h"
58 1 hiro
#include "prefs_common.h"
59 1 hiro
#include "prefs_account.h"
60 1 hiro
#include "prefs_filter.h"
61 547 hiro
#include "filter.h"
62 1 hiro
#include "gtkutils.h"
63 1 hiro
#include "utils.h"
64 1 hiro
#include "rfc2015.h"
65 1 hiro
66 1 hiro
static GList *messageview_list = NULL;
67 1 hiro
68 154 hiro
static void messageview_change_view_type(MessageView                *messageview,
69 154 hiro
                                         MessageType                 type);
70 316 hiro
static gint messageview_delete_cb        (GtkWidget                *widget,
71 316 hiro
                                         GdkEventAny                *event,
72 154 hiro
                                         MessageView                *messageview);
73 154 hiro
static void messageview_size_allocate_cb(GtkWidget                *widget,
74 154 hiro
                                         GtkAllocation                *allocation);
75 154 hiro
static void messageview_switch_page_cb        (GtkNotebook                *notebook,
76 154 hiro
                                         GtkNotebookPage        *page,
77 154 hiro
                                         guint                         page_num,
78 154 hiro
                                         MessageView                *messageview);
79 154 hiro
static gboolean key_pressed                (GtkWidget                *widget,
80 154 hiro
                                         GdkEventKey                *event,
81 154 hiro
                                         MessageView                *messageview);
82 1 hiro
83 1 hiro
static void save_as_cb                        (gpointer         data,
84 1 hiro
                                         guint                 action,
85 1 hiro
                                         GtkWidget        *widget);
86 1 hiro
static void print_cb                        (gpointer         data,
87 1 hiro
                                         guint                 action,
88 1 hiro
                                         GtkWidget        *widget);
89 1 hiro
static void close_cb                        (gpointer         data,
90 1 hiro
                                         guint                 action,
91 1 hiro
                                         GtkWidget        *widget);
92 1 hiro
static void copy_cb                        (gpointer         data,
93 1 hiro
                                         guint                 action,
94 1 hiro
                                         GtkWidget        *widget);
95 1 hiro
static void allsel_cb                        (gpointer         data,
96 1 hiro
                                         guint                 action,
97 1 hiro
                                         GtkWidget        *widget);
98 1 hiro
static void search_cb                        (gpointer         data,
99 1 hiro
                                         guint                 action,
100 1 hiro
                                         GtkWidget        *widget);
101 1 hiro
102 1 hiro
static void set_charset_cb                (gpointer         data,
103 1 hiro
                                         guint                 action,
104 1 hiro
                                         GtkWidget        *widget);
105 1 hiro
static void view_source_cb                (gpointer         data,
106 1 hiro
                                         guint                 action,
107 1 hiro
                                         GtkWidget        *widget);
108 1 hiro
static void show_all_header_cb                (gpointer         data,
109 1 hiro
                                         guint                 action,
110 1 hiro
                                         GtkWidget        *widget);
111 1 hiro
112 1 hiro
static void compose_cb                        (gpointer         data,
113 1 hiro
                                         guint                 action,
114 1 hiro
                                         GtkWidget        *widget);
115 1 hiro
static void reply_cb                        (gpointer         data,
116 1 hiro
                                         guint                 action,
117 1 hiro
                                         GtkWidget        *widget);
118 1 hiro
static void reedit_cb                        (gpointer         data,
119 1 hiro
                                         guint                 action,
120 1 hiro
                                         GtkWidget        *widget);
121 1 hiro
122 1 hiro
static void addressbook_open_cb                (gpointer         data,
123 1 hiro
                                         guint                 action,
124 1 hiro
                                         GtkWidget        *widget);
125 1 hiro
static void add_address_cb                (gpointer         data,
126 1 hiro
                                         guint                 action,
127 1 hiro
                                         GtkWidget        *widget);
128 1 hiro
static void create_filter_cb                (gpointer         data,
129 1 hiro
                                         guint                 action,
130 1 hiro
                                         GtkWidget        *widget);
131 1 hiro
132 1 hiro
static void about_cb                        (gpointer         data,
133 1 hiro
                                         guint                 action,
134 1 hiro
                                         GtkWidget        *widget);
135 1 hiro
136 1 hiro
static GtkItemFactoryEntry msgview_entries[] =
137 1 hiro
{
138 1 hiro
        {N_("/_File"),                        NULL, NULL, 0, "<Branch>"},
139 1 hiro
        {N_("/_File/_Save as..."),        NULL, save_as_cb, 0, NULL},
140 1 hiro
        {N_("/_File/_Print..."),        NULL, print_cb, 0, NULL},
141 1 hiro
        {N_("/_File/---"),                NULL, NULL, 0, "<Separator>"},
142 1 hiro
        {N_("/_File/_Close"),                NULL, close_cb, 0, NULL},
143 1 hiro
144 1 hiro
        {N_("/_Edit"),                        NULL, NULL, 0, "<Branch>"},
145 1 hiro
        {N_("/_Edit/_Copy"),                NULL, copy_cb, 0, NULL},
146 1 hiro
        {N_("/_Edit/Select _all"),        NULL, allsel_cb, 0, NULL},
147 1 hiro
        {N_("/_Edit/---"),                NULL, NULL, 0, "<Separator>"},
148 1 hiro
        {N_("/_Edit/_Find in current message..."),
149 1 hiro
                                        NULL, search_cb, 0, NULL},
150 1 hiro
151 1 hiro
        {N_("/_View"),                        NULL, NULL, 0, "<Branch>"},
152 1 hiro
153 175 hiro
#define ENC_SEPARATOR \
154 175 hiro
        {N_("/_View/Character _encoding/---"),        NULL, NULL, 0, "<Separator>"}
155 175 hiro
#define ENC_ACTION(action) \
156 175 hiro
        NULL, set_charset_cb, action, "/View/Character encoding/Auto detect"
157 1 hiro
158 175 hiro
        {N_("/_View/Character _encoding"),        NULL, NULL, 0, "<Branch>"},
159 175 hiro
        {N_("/_View/Character _encoding/_Auto detect"),
160 1 hiro
                                        NULL, set_charset_cb, C_AUTO, "<RadioItem>"},
161 175 hiro
        ENC_SEPARATOR,
162 175 hiro
        {N_("/_View/Character _encoding/7bit ascii (US-ASC_II)"),
163 175 hiro
         ENC_ACTION(C_US_ASCII)},
164 1 hiro
165 175 hiro
        {N_("/_View/Character _encoding/Unicode (_UTF-8)"),
166 175 hiro
         ENC_ACTION(C_UTF_8)},
167 175 hiro
        ENC_SEPARATOR,
168 175 hiro
        {N_("/_View/Character _encoding/Western European (ISO-8859-_1)"),
169 175 hiro
         ENC_ACTION(C_ISO_8859_1)},
170 175 hiro
        {N_("/_View/Character _encoding/Western European (ISO-8859-15)"),
171 175 hiro
         ENC_ACTION(C_ISO_8859_15)},
172 175 hiro
        ENC_SEPARATOR,
173 175 hiro
        {N_("/_View/Character _encoding/Central European (ISO-8859-_2)"),
174 175 hiro
         ENC_ACTION(C_ISO_8859_2)},
175 175 hiro
        ENC_SEPARATOR,
176 175 hiro
        {N_("/_View/Character _encoding/_Baltic (ISO-8859-13)"),
177 175 hiro
         ENC_ACTION(C_ISO_8859_13)},
178 175 hiro
        {N_("/_View/Character _encoding/Baltic (ISO-8859-_4)"),
179 175 hiro
         ENC_ACTION(C_ISO_8859_4)},
180 175 hiro
        ENC_SEPARATOR,
181 175 hiro
        {N_("/_View/Character _encoding/Greek (ISO-8859-_7)"),
182 175 hiro
         ENC_ACTION(C_ISO_8859_7)},
183 175 hiro
        ENC_SEPARATOR,
184 312 hiro
        {N_("/_View/Character _encoding/Hebrew (ISO-8859-_8)"),
185 312 hiro
         ENC_ACTION(C_ISO_8859_8)},
186 312 hiro
        {N_("/_View/Character _encoding/Hebrew (Windows-1255)"),
187 312 hiro
         ENC_ACTION(C_CP1255)},
188 312 hiro
        ENC_SEPARATOR,
189 175 hiro
        {N_("/_View/Character _encoding/Turkish (ISO-8859-_9)"),
190 175 hiro
         ENC_ACTION(C_ISO_8859_9)},
191 175 hiro
        ENC_SEPARATOR,
192 175 hiro
        {N_("/_View/Character _encoding/Cyrillic (ISO-8859-_5)"),
193 175 hiro
         ENC_ACTION(C_ISO_8859_5)},
194 175 hiro
        {N_("/_View/Character _encoding/Cyrillic (KOI8-_R)"),
195 175 hiro
         ENC_ACTION(C_KOI8_R)},
196 175 hiro
        {N_("/_View/Character _encoding/Cyrillic (KOI8-U)"),
197 175 hiro
         ENC_ACTION(C_KOI8_U)},
198 175 hiro
        {N_("/_View/Character _encoding/Cyrillic (Windows-1251)"),
199 175 hiro
         ENC_ACTION(C_CP1251)},
200 175 hiro
        ENC_SEPARATOR,
201 175 hiro
        {N_("/_View/Character _encoding/Japanese (ISO-2022-_JP)"),
202 175 hiro
         ENC_ACTION(C_ISO_2022_JP)},
203 175 hiro
        {N_("/_View/Character _encoding/Japanese (ISO-2022-JP-2)"),
204 175 hiro
         ENC_ACTION(C_ISO_2022_JP_2)},
205 175 hiro
        {N_("/_View/Character _encoding/Japanese (_EUC-JP)"),
206 175 hiro
         ENC_ACTION(C_EUC_JP)},
207 175 hiro
        {N_("/_View/Character _encoding/Japanese (_Shift__JIS)"),
208 175 hiro
         ENC_ACTION(C_SHIFT_JIS)},
209 175 hiro
        ENC_SEPARATOR,
210 175 hiro
        {N_("/_View/Character _encoding/Simplified Chinese (_GB2312)"),
211 175 hiro
         ENC_ACTION(C_GB2312)},
212 211 hiro
        {N_("/_View/Character _encoding/Simplified Chinese (GBK)"),
213 211 hiro
         ENC_ACTION(C_GBK)},
214 175 hiro
        {N_("/_View/Character _encoding/Traditional Chinese (_Big5)"),
215 175 hiro
         ENC_ACTION(C_BIG5)},
216 175 hiro
        {N_("/_View/Character _encoding/Traditional Chinese (EUC-_TW)"),
217 175 hiro
         ENC_ACTION(C_EUC_TW)},
218 175 hiro
        {N_("/_View/Character _encoding/Chinese (ISO-2022-_CN)"),
219 175 hiro
         ENC_ACTION(C_ISO_2022_CN)},
220 175 hiro
        ENC_SEPARATOR,
221 175 hiro
        {N_("/_View/Character _encoding/Korean (EUC-_KR)"),
222 175 hiro
         ENC_ACTION(C_EUC_KR)},
223 175 hiro
        {N_("/_View/Character _encoding/Korean (ISO-2022-KR)"),
224 175 hiro
         ENC_ACTION(C_ISO_2022_KR)},
225 175 hiro
        ENC_SEPARATOR,
226 175 hiro
        {N_("/_View/Character _encoding/Thai (TIS-620)"),
227 175 hiro
         ENC_ACTION(C_TIS_620)},
228 175 hiro
        {N_("/_View/Character _encoding/Thai (Windows-874)"),
229 175 hiro
         ENC_ACTION(C_WINDOWS_874)},
230 1 hiro
231 175 hiro
#undef ENC_SEPARATOR
232 175 hiro
#undef ENC_ACTION
233 1 hiro
234 1 hiro
        {N_("/_View/---"),                NULL, NULL, 0, "<Separator>"},
235 1 hiro
        {N_("/_View/Mess_age source"),        NULL, view_source_cb, 0, NULL},
236 1 hiro
        {N_("/_View/Show all _header"),        NULL, show_all_header_cb, 0, "<ToggleItem>"},
237 1 hiro
238 1 hiro
        {N_("/_Message"),                NULL, NULL, 0, "<Branch>"},
239 1 hiro
        {N_("/_Message/Compose _new message"),
240 1 hiro
                                        NULL, compose_cb, 0, NULL},
241 1 hiro
        {N_("/_Message/---"),                NULL, NULL, 0, "<Separator>"},
242 1 hiro
        {N_("/_Message/_Reply"),        NULL, reply_cb, COMPOSE_REPLY, NULL},
243 1 hiro
        {N_("/_Message/Repl_y to/_all"),
244 1 hiro
                                        NULL, reply_cb, COMPOSE_REPLY_TO_ALL, NULL},
245 1 hiro
        {N_("/_Message/Repl_y to/_sender"),
246 1 hiro
                                        NULL, reply_cb, COMPOSE_REPLY_TO_SENDER, NULL},
247 1 hiro
        {N_("/_Message/Repl_y to/mailing _list"),
248 1 hiro
                                        NULL, reply_cb, COMPOSE_REPLY_TO_LIST, NULL},
249 1 hiro
        {N_("/_Message/---"),                NULL, NULL, 0, "<Separator>"},
250 1 hiro
        {N_("/_Message/_Forward"),        NULL, reply_cb, COMPOSE_FORWARD, NULL},
251 1 hiro
        {N_("/_Message/For_ward as attachment"),
252 1 hiro
                                        NULL, reply_cb, COMPOSE_FORWARD_AS_ATTACH, NULL},
253 1 hiro
        {N_("/_Message/Redirec_t"),        NULL, reply_cb, COMPOSE_REDIRECT, NULL},
254 1 hiro
        {N_("/_Message/---"),                NULL, NULL, 0, "<Separator>"},
255 1 hiro
        {N_("/_Message/Re-_edit"),        NULL, reedit_cb, 0, NULL},
256 1 hiro
257 1 hiro
        {N_("/_Tools"),                        NULL, NULL, 0, "<Branch>"},
258 1 hiro
        {N_("/_Tools/_Address book"),        NULL, addressbook_open_cb, 0, NULL},
259 1 hiro
        {N_("/_Tools/Add sender to address boo_k"),
260 1 hiro
                                        NULL, add_address_cb, 0, NULL},
261 1 hiro
        {N_("/_Tools/---"),                NULL, NULL, 0, "<Separator>"},
262 1 hiro
        {N_("/_Tools/_Create filter rule"),
263 1 hiro
                                        NULL, NULL, 0, "<Branch>"},
264 1 hiro
        {N_("/_Tools/_Create filter rule/_Automatically"),
265 547 hiro
                                        NULL, create_filter_cb, FLT_BY_AUTO, NULL},
266 1 hiro
        {N_("/_Tools/_Create filter rule/by _From"),
267 547 hiro
                                        NULL, create_filter_cb, FLT_BY_FROM, NULL},
268 1 hiro
        {N_("/_Tools/_Create filter rule/by _To"),
269 547 hiro
                                        NULL, create_filter_cb, FLT_BY_TO, NULL},
270 1 hiro
        {N_("/_Tools/_Create filter rule/by _Subject"),
271 547 hiro
                                        NULL, create_filter_cb, FLT_BY_SUBJECT, NULL},
272 1 hiro
        {N_("/_Tools/---"),                NULL, NULL, 0, "<Separator>"},
273 1 hiro
        {N_("/_Tools/Actio_ns"),        NULL, NULL, 0, "<Branch>"},
274 1 hiro
275 1 hiro
        {N_("/_Help"),                        NULL, NULL, 0, "<Branch>"},
276 1 hiro
        {N_("/_Help/_About"),                NULL, about_cb, 0, NULL}
277 1 hiro
};
278 1 hiro
279 1 hiro
280 1 hiro
MessageView *messageview_create(void)
281 1 hiro
{
282 1 hiro
        MessageView *messageview;
283 1 hiro
        GtkWidget *vbox;
284 154 hiro
        GtkWidget *notebook;
285 1 hiro
        HeaderView *headerview;
286 1 hiro
        TextView *textview;
287 1 hiro
        MimeView *mimeview;
288 1 hiro
289 1 hiro
        debug_print(_("Creating message view...\n"));
290 1 hiro
        messageview = g_new0(MessageView, 1);
291 1 hiro
292 1 hiro
        messageview->type = MVIEW_TEXT;
293 1 hiro
294 1 hiro
        headerview = headerview_create();
295 1 hiro
296 1 hiro
        textview = textview_create();
297 1 hiro
        textview->messageview = messageview;
298 1 hiro
299 1 hiro
        mimeview = mimeview_create();
300 1 hiro
        mimeview->textview = textview_create();
301 1 hiro
        mimeview->textview->messageview = messageview;
302 1 hiro
        mimeview->imageview = imageview_create();
303 1 hiro
        mimeview->imageview->messageview = messageview;
304 1 hiro
        mimeview->messageview = messageview;
305 1 hiro
306 154 hiro
        notebook = gtk_notebook_new();
307 154 hiro
        gtk_notebook_set_show_border(GTK_NOTEBOOK(notebook), FALSE);
308 154 hiro
        gtk_notebook_set_show_tabs(GTK_NOTEBOOK(notebook), FALSE);
309 154 hiro
        gtk_notebook_set_scrollable(GTK_NOTEBOOK(notebook), TRUE);
310 154 hiro
        gtk_widget_show(notebook);
311 154 hiro
312 154 hiro
        gtk_container_add(GTK_CONTAINER(notebook), GTK_WIDGET_PTR(textview));
313 154 hiro
        gtk_notebook_set_tab_label_text
314 154 hiro
                (GTK_NOTEBOOK(notebook), GTK_WIDGET_PTR(textview), _("Text"));
315 154 hiro
316 154 hiro
        gtk_container_add(GTK_CONTAINER(notebook), GTK_WIDGET_PTR(mimeview));
317 154 hiro
        gtk_notebook_set_tab_label_text(GTK_NOTEBOOK(notebook),
318 154 hiro
                                        GTK_WIDGET_PTR(mimeview),
319 154 hiro
                                        _("Attachments"));
320 154 hiro
321 154 hiro
        gtk_notebook_set_current_page(GTK_NOTEBOOK(notebook), 0);
322 154 hiro
        gtk_widget_show_all(notebook);
323 154 hiro
324 1 hiro
        vbox = gtk_vbox_new(FALSE, 0);
325 1 hiro
        gtk_box_pack_start(GTK_BOX(vbox), GTK_WIDGET_PTR(headerview),
326 1 hiro
                           FALSE, FALSE, 0);
327 154 hiro
        gtk_box_pack_start(GTK_BOX(vbox), notebook, TRUE, TRUE, 0);
328 1 hiro
        gtk_widget_show(vbox);
329 1 hiro
330 1 hiro
        /* to remove without destroyed */
331 1 hiro
        gtk_widget_ref(GTK_WIDGET_PTR(mimeview->textview));
332 1 hiro
        gtk_widget_ref(GTK_WIDGET_PTR(mimeview->imageview));
333 1 hiro
334 154 hiro
        g_signal_connect(G_OBJECT(notebook), "switch_page",
335 154 hiro
                         G_CALLBACK(messageview_switch_page_cb), messageview);
336 154 hiro
337 1 hiro
        messageview->vbox        = vbox;
338 154 hiro
        messageview->notebook    = notebook;
339 154 hiro
340 1 hiro
        messageview->new_window  = FALSE;
341 1 hiro
        messageview->window      = NULL;
342 1 hiro
        messageview->window_vbox = NULL;
343 154 hiro
        messageview->body_vbox   = NULL;
344 154 hiro
345 1 hiro
        messageview->headerview  = headerview;
346 1 hiro
        messageview->textview    = textview;
347 1 hiro
        messageview->mimeview    = mimeview;
348 1 hiro
349 1 hiro
        messageview->statusbar     = NULL;
350 1 hiro
        messageview->statusbar_cid = 0;
351 1 hiro
352 154 hiro
        messageview->current_page = 0;
353 154 hiro
354 1 hiro
        return messageview;
355 1 hiro
}
356 1 hiro
357 1 hiro
MessageView *messageview_create_with_new_window(void)
358 1 hiro
{
359 1 hiro
        MessageView *msgview;
360 1 hiro
        GtkWidget *window;
361 1 hiro
        GtkWidget *window_vbox;
362 1 hiro
        GtkWidget *body_vbox;
363 1 hiro
        GtkWidget *menubar;
364 1 hiro
        GtkItemFactory *ifactory;
365 1 hiro
        GtkWidget *statusbar;
366 1 hiro
        guint n_menu_entries;
367 1 hiro
368 1 hiro
        window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
369 676 hiro
        gtk_window_set_title(GTK_WINDOW(window), _("Message View - Sylpheed"));
370 1 hiro
        gtk_window_set_wmclass(GTK_WINDOW(window), "message_view", "Sylpheed");
371 1 hiro
        gtk_window_set_policy(GTK_WINDOW(window), TRUE, TRUE, FALSE);
372 1 hiro
        gtk_widget_set_size_request(window, prefs_common.msgwin_width,
373 1 hiro
                                    prefs_common.msgwin_height);
374 1 hiro
375 1 hiro
        msgview = messageview_create();
376 1 hiro
377 1 hiro
        window_vbox = gtk_vbox_new(FALSE, 0);
378 1 hiro
        gtk_container_add(GTK_CONTAINER(window), window_vbox);
379 1 hiro
380 1 hiro
        g_signal_connect(G_OBJECT(window), "size_allocate",
381 1 hiro
                         G_CALLBACK(messageview_size_allocate_cb),
382 1 hiro
                         msgview);
383 316 hiro
        g_signal_connect(G_OBJECT(window), "delete_event",
384 316 hiro
                         G_CALLBACK(messageview_delete_cb), msgview);
385 1 hiro
        g_signal_connect(G_OBJECT(window), "key_press_event",
386 1 hiro
                         G_CALLBACK(key_pressed), msgview);
387 1 hiro
        MANAGE_WINDOW_SIGNALS_CONNECT(window);
388 1 hiro
389 1 hiro
        n_menu_entries = sizeof(msgview_entries) / sizeof (msgview_entries[0]);
390 1 hiro
        menubar = menubar_create(window, msgview_entries, n_menu_entries,
391 1 hiro
                                 "<MessageView>", msgview);
392 1 hiro
#if 0
393 1 hiro
        menu_factory_copy_rc("<Main>", "<MessageView>");
394 1 hiro
#endif
395 1 hiro
        gtk_box_pack_start(GTK_BOX(window_vbox), menubar, FALSE, TRUE, 0);
396 1 hiro
397 1 hiro
        body_vbox = gtk_vbox_new(FALSE, BORDER_WIDTH);
398 1 hiro
        gtk_container_set_border_width(GTK_CONTAINER(body_vbox), BORDER_WIDTH);
399 1 hiro
        gtk_box_pack_start(GTK_BOX(window_vbox), body_vbox, TRUE, TRUE, 0);
400 1 hiro
401 1 hiro
        gtk_box_pack_start(GTK_BOX(body_vbox), GTK_WIDGET_PTR(msgview),
402 1 hiro
                           TRUE, TRUE, 0);
403 1 hiro
        gtk_widget_grab_focus(msgview->textview->text);
404 1 hiro
405 1 hiro
        statusbar = gtk_statusbar_new();
406 1 hiro
        gtk_box_pack_end(GTK_BOX(body_vbox), statusbar, FALSE, FALSE, 0);
407 1 hiro
        msgview->statusbar = statusbar;
408 1 hiro
        msgview->statusbar_cid = gtk_statusbar_get_context_id
409 1 hiro
                (GTK_STATUSBAR(statusbar), "Message View");
410 1 hiro
411 1 hiro
        gtk_widget_show_all(window);
412 1 hiro
413 1 hiro
        msgview->new_window = TRUE;
414 1 hiro
        msgview->window = window;
415 1 hiro
        msgview->window_vbox = window_vbox;
416 1 hiro
        msgview->body_vbox = body_vbox;
417 1 hiro
        msgview->visible = TRUE;
418 1 hiro
419 1 hiro
        messageview_init(msgview);
420 1 hiro
421 1 hiro
        ifactory = gtk_item_factory_from_widget(menubar);
422 1 hiro
        action_update_msgview_menu(ifactory, msgview);
423 1 hiro
424 1 hiro
        messageview_list = g_list_append(messageview_list, msgview);
425 1 hiro
426 1 hiro
        return msgview;
427 1 hiro
}
428 1 hiro
429 1 hiro
void messageview_init(MessageView *messageview)
430 1 hiro
{
431 1 hiro
        headerview_init(messageview->headerview);
432 1 hiro
        textview_init(messageview->textview);
433 1 hiro
        mimeview_init(messageview->mimeview);
434 1 hiro
        /* messageview_set_font(messageview); */
435 1 hiro
}
436 1 hiro
437 1 hiro
GList *messageview_get_window_list(void)
438 1 hiro
{
439 1 hiro
        return messageview_list;
440 1 hiro
}
441 1 hiro
442 1 hiro
gint messageview_show(MessageView *messageview, MsgInfo *msginfo,
443 1 hiro
                      gboolean all_headers)
444 1 hiro
{
445 1 hiro
        gchar *file;
446 1 hiro
        MimeInfo *mimeinfo;
447 1 hiro
448 1 hiro
        g_return_val_if_fail(msginfo != NULL, -1);
449 1 hiro
450 1 hiro
        mimeinfo = procmime_scan_message(msginfo);
451 1 hiro
        if (!mimeinfo) {
452 1 hiro
                messageview_change_view_type(messageview, MVIEW_TEXT);
453 1 hiro
                textview_show_error(messageview->textview);
454 1 hiro
                return -1;
455 1 hiro
        }
456 1 hiro
457 1 hiro
        file = procmsg_get_message_file_path(msginfo);
458 1 hiro
        if (!file) {
459 1 hiro
                g_warning("can't get message file path.\n");
460 1 hiro
                procmime_mimeinfo_free_all(mimeinfo);
461 1 hiro
                messageview_change_view_type(messageview, MVIEW_TEXT);
462 1 hiro
                textview_show_error(messageview->textview);
463 1 hiro
                return -1;
464 1 hiro
        }
465 1 hiro
466 1 hiro
        if (messageview->msginfo != msginfo) {
467 1 hiro
                procmsg_msginfo_free(messageview->msginfo);
468 1 hiro
                messageview->msginfo = procmsg_msginfo_get_full_info(msginfo);
469 20 hiro
                if (!messageview->msginfo)
470 20 hiro
                        messageview->msginfo = procmsg_msginfo_copy(msginfo);
471 1 hiro
        }
472 676 hiro
473 676 hiro
        if (messageview->window && msginfo->subject) {
474 676 hiro
                gchar *title;
475 676 hiro
476 676 hiro
                title = g_strconcat(msginfo->subject, " - Sylpheed", NULL);
477 676 hiro
                gtk_window_set_title(GTK_WINDOW(messageview->window), title);
478 676 hiro
                g_free(title);
479 676 hiro
        }
480 1 hiro
        headerview_show(messageview->headerview, messageview->msginfo);
481 1 hiro
482 1 hiro
        textview_set_all_headers(messageview->textview, all_headers);
483 1 hiro
        textview_set_all_headers(messageview->mimeview->textview, all_headers);
484 1 hiro
485 1 hiro
        if (mimeinfo->mime_type != MIME_TEXT &&
486 1 hiro
            mimeinfo->mime_type != MIME_TEXT_HTML) {
487 1 hiro
                messageview_change_view_type(messageview, MVIEW_MIME);
488 1 hiro
                mimeview_show_message(messageview->mimeview, mimeinfo, file);
489 1 hiro
        } else {
490 1 hiro
                messageview_change_view_type(messageview, MVIEW_TEXT);
491 1 hiro
                textview_show_message(messageview->textview, mimeinfo, file);
492 1 hiro
                procmime_mimeinfo_free_all(mimeinfo);
493 1 hiro
        }
494 1 hiro
495 1 hiro
        g_free(file);
496 1 hiro
497 1 hiro
        return 0;
498 1 hiro
}
499 1 hiro
500 1 hiro
static void messageview_change_view_type(MessageView *messageview,
501 1 hiro
                                         MessageType type)
502 1 hiro
{
503 154 hiro
        GtkWidget *notebook = messageview->notebook;
504 1 hiro
505 1 hiro
        if (messageview->type == type) return;
506 1 hiro
507 1 hiro
        if (type == MVIEW_MIME) {
508 154 hiro
                gtk_notebook_set_show_tabs(GTK_NOTEBOOK(notebook), TRUE);
509 154 hiro
                gtk_notebook_set_current_page(GTK_NOTEBOOK(notebook),
510 154 hiro
                                              messageview->current_page);
511 1 hiro
        } else if (type == MVIEW_TEXT) {
512 154 hiro
                gint current_page = messageview->current_page;
513 1 hiro
514 154 hiro
                gtk_notebook_set_show_tabs(GTK_NOTEBOOK(notebook), FALSE);
515 154 hiro
                gtk_notebook_set_current_page(GTK_NOTEBOOK(notebook), 0);
516 154 hiro
                messageview->current_page = current_page;
517 154 hiro
                mimeview_clear(messageview->mimeview);
518 1 hiro
        } else
519 1 hiro
                return;
520 1 hiro
521 1 hiro
        messageview->type = type;
522 1 hiro
}
523 1 hiro
524 1 hiro
void messageview_clear(MessageView *messageview)
525 1 hiro
{
526 1 hiro
        procmsg_msginfo_free(messageview->msginfo);
527 1 hiro
        messageview->msginfo = NULL;
528 1 hiro
        messageview_change_view_type(messageview, MVIEW_TEXT);
529 1 hiro
        headerview_clear(messageview->headerview);
530 1 hiro
        textview_clear(messageview->textview);
531 1 hiro
        mimeview_clear(messageview->mimeview);
532 1 hiro
}
533 1 hiro
534 1 hiro
void messageview_destroy(MessageView *messageview)
535 1 hiro
{
536 154 hiro
        GtkWidget *textview  = GTK_WIDGET_PTR(messageview->mimeview->textview);
537 1 hiro
        GtkWidget *imageview = GTK_WIDGET_PTR(messageview->mimeview->imageview);
538 1 hiro
539 1 hiro
        messageview_list = g_list_remove(messageview_list, messageview);
540 1 hiro
541 1 hiro
        headerview_destroy(messageview->headerview);
542 1 hiro
        textview_destroy(messageview->textview);
543 1 hiro
        mimeview_destroy(messageview->mimeview);
544 1 hiro
545 1 hiro
        procmsg_msginfo_free(messageview->msginfo);
546 1 hiro
547 316 hiro
        if (messageview->window)
548 316 hiro
                gtk_widget_destroy(messageview->window);
549 316 hiro
550 1 hiro
        g_free(messageview);
551 1 hiro
552 1 hiro
        gtk_widget_unref(textview);
553 1 hiro
        gtk_widget_unref(imageview);
554 1 hiro
}
555 1 hiro
556 1 hiro
void messageview_quote_color_set(void)
557 1 hiro
{
558 1 hiro
}
559 1 hiro
560 1 hiro
void messageview_set_font(MessageView *messageview)
561 1 hiro
{
562 1 hiro
        textview_set_font(messageview->textview, NULL);
563 1 hiro
}
564 1 hiro
565 1 hiro
TextView *messageview_get_current_textview(MessageView *messageview)
566 1 hiro
{
567 1 hiro
        TextView *text = NULL;
568 1 hiro
569 1 hiro
        if (messageview->type == MVIEW_TEXT)
570 1 hiro
                text = messageview->textview;
571 1 hiro
        else if (messageview->type == MVIEW_MIME) {
572 1 hiro
                if (gtk_notebook_get_current_page
573 154 hiro
                        (GTK_NOTEBOOK(messageview->notebook)) == 0)
574 1 hiro
                        text = messageview->textview;
575 1 hiro
                else if (messageview->mimeview->type == MIMEVIEW_TEXT)
576 1 hiro
                        text = messageview->mimeview->textview;
577 1 hiro
        }
578 1 hiro
579 1 hiro
        return text;
580 1 hiro
}
581 1 hiro
582 1 hiro
MimeInfo *messageview_get_selected_mime_part(MessageView *messageview)
583 1 hiro
{
584 1 hiro
        if (messageview->type == MVIEW_MIME)
585 1 hiro
                return mimeview_get_selected_part(messageview->mimeview);
586 1 hiro
587 1 hiro
        return NULL;
588 1 hiro
}
589 1 hiro
590 1 hiro
void messageview_copy_clipboard(MessageView *messageview)
591 1 hiro
{
592 1 hiro
        TextView *text;
593 1 hiro
594 1 hiro
        text = messageview_get_current_textview(messageview);
595 1 hiro
        if (text) {
596 1 hiro
                GtkTextView *textview = GTK_TEXT_VIEW(text->text);
597 1 hiro
                GtkTextBuffer *buffer;
598 1 hiro
                GtkClipboard *clipboard;
599 1 hiro
600 1 hiro
                buffer = gtk_text_view_get_buffer(textview);
601 1 hiro
                clipboard = gtk_clipboard_get(GDK_SELECTION_CLIPBOARD);
602 1 hiro
                gtk_text_buffer_copy_clipboard(buffer, clipboard);
603 1 hiro
        }
604 1 hiro
}
605 1 hiro
606 1 hiro
void messageview_select_all(MessageView *messageview)
607 1 hiro
{
608 1 hiro
        TextView *text;
609 1 hiro
610 1 hiro
        text = messageview_get_current_textview(messageview);
611 130 hiro
        if (text) {
612 130 hiro
                GtkTextView *textview = GTK_TEXT_VIEW(text->text);
613 130 hiro
                GtkTextBuffer *buffer;
614 130 hiro
                GtkTextIter start, end;
615 130 hiro
616 130 hiro
                buffer = gtk_text_view_get_buffer(textview);
617 130 hiro
                gtk_text_buffer_get_bounds(buffer, &start, &end);
618 130 hiro
                gtk_text_buffer_select_range(buffer, &start, &end);
619 130 hiro
        }
620 1 hiro
}
621 1 hiro
622 1 hiro
void messageview_set_position(MessageView *messageview, gint pos)
623 1 hiro
{
624 1 hiro
        textview_set_position(messageview->textview, pos);
625 1 hiro
}
626 1 hiro
627 1 hiro
gboolean messageview_search_string(MessageView *messageview, const gchar *str,
628 1 hiro
                                   gboolean case_sens)
629 1 hiro
{
630 1 hiro
        return textview_search_string(messageview->textview, str, case_sens);
631 1 hiro
        return FALSE;
632 1 hiro
}
633 1 hiro
634 1 hiro
gboolean messageview_search_string_backward(MessageView *messageview,
635 1 hiro
                                            const gchar *str,
636 1 hiro
                                            gboolean case_sens)
637 1 hiro
{
638 1 hiro
        return textview_search_string_backward(messageview->textview,
639 1 hiro
                                               str, case_sens);
640 1 hiro
        return FALSE;
641 1 hiro
}
642 1 hiro
643 1 hiro
gboolean messageview_is_visible(MessageView *messageview)
644 1 hiro
{
645 1 hiro
        return messageview->visible;
646 1 hiro
}
647 1 hiro
648 1 hiro
void messageview_save_as(MessageView *messageview)
649 1 hiro
{
650 1 hiro
        gchar *filename = NULL;
651 1 hiro
        MsgInfo *msginfo;
652 1 hiro
        gchar *src, *dest;
653 1 hiro
654 1 hiro
        if (!messageview->msginfo) return;
655 1 hiro
        msginfo = messageview->msginfo;
656 1 hiro
657 1 hiro
        if (msginfo->subject) {
658 1 hiro
                Xstrdup_a(filename, msginfo->subject, return);
659 1 hiro
                subst_for_filename(filename);
660 1 hiro
        }
661 128 hiro
662 128 hiro
        dest = filesel_save_as(filename);
663 1 hiro
        if (!dest) return;
664 1 hiro
665 1 hiro
        src = procmsg_get_message_file(msginfo);
666 1 hiro
        if (copy_file(src, dest, TRUE) < 0) {
667 1 hiro
                alertpanel_error(_("Can't save the file `%s'."),
668 1 hiro
                                 g_basename(dest));
669 1 hiro
        }
670 1 hiro
        g_free(src);
671 128 hiro
672 128 hiro
        g_free(dest);
673 1 hiro
}
674 1 hiro
675 316 hiro
static gint messageview_delete_cb(GtkWidget *widget, GdkEventAny *event,
676 316 hiro
                                  MessageView *messageview)
677 1 hiro
{
678 1 hiro
        messageview_destroy(messageview);
679 316 hiro
        return TRUE;
680 1 hiro
}
681 1 hiro
682 1 hiro
static void messageview_size_allocate_cb(GtkWidget *widget,
683 1 hiro
                                         GtkAllocation *allocation)
684 1 hiro
{
685 1 hiro
        g_return_if_fail(allocation != NULL);
686 1 hiro
687 1 hiro
        prefs_common.msgwin_width  = allocation->width;
688 1 hiro
        prefs_common.msgwin_height = allocation->height;
689 1 hiro
}
690 1 hiro
691 154 hiro
static void messageview_switch_page_cb(GtkNotebook *notebook,
692 154 hiro
                                       GtkNotebookPage *page, guint page_num,
693 154 hiro
                                       MessageView *messageview)
694 154 hiro
{
695 154 hiro
        messageview->current_page = page_num;
696 154 hiro
}
697 154 hiro
698 1 hiro
static gboolean key_pressed(GtkWidget *widget, GdkEventKey *event,
699 1 hiro
                            MessageView *messageview)
700 1 hiro
{
701 316 hiro
        if (event && event->keyval == GDK_Escape && messageview->window) {
702 316 hiro
                messageview_destroy(messageview);
703 316 hiro
                return TRUE;
704 316 hiro
        }
705 1 hiro
        return FALSE;
706 1 hiro
}
707 1 hiro
708 1 hiro
static void save_as_cb(gpointer data, guint action, GtkWidget *widget)
709 1 hiro
{
710 1 hiro
        MessageView *messageview = (MessageView *)data;
711 1 hiro
        messageview_save_as(messageview);
712 1 hiro
}
713 1 hiro
714 1 hiro
static void print_cb(gpointer data, guint action, GtkWidget *widget)
715 1 hiro
{
716 1 hiro
        MessageView *messageview = (MessageView *)data;
717 684 hiro
        const gchar *cmdline;
718 684 hiro
        gchar *msg;
719 1 hiro
        gchar *p;
720 1 hiro
721 1 hiro
        if (!messageview->msginfo) return;
722 1 hiro
723 684 hiro
        cmdline = prefs_common.print_cmd;
724 684 hiro
725 684 hiro
        msg = g_strconcat
726 684 hiro
                (_("The message will be printed with the following command:"),
727 684 hiro
                 "\n\n", cmdline ? cmdline : _("(Default print command)"),
728 684 hiro
                 NULL);
729 684 hiro
        if (alertpanel(_("Print"), msg, GTK_STOCK_OK, GTK_STOCK_CANCEL, NULL)
730 684 hiro
            != G_ALERTDEFAULT) {
731 684 hiro
                g_free(msg);
732 684 hiro
                return;
733 684 hiro
        }
734 684 hiro
        g_free(msg);
735 684 hiro
736 684 hiro
        if (cmdline && (!(p = strchr(cmdline, '%')) || *(p + 1) != 's' ||
737 684 hiro
                        strchr(p + 2, '%'))) {
738 1 hiro
                alertpanel_error(_("Print command line is invalid:\n`%s'"),
739 1 hiro
                                 cmdline);
740 1 hiro
                return;
741 1 hiro
        }
742 1 hiro
743 1 hiro
        procmsg_print_message(messageview->msginfo, cmdline);
744 1 hiro
}
745 1 hiro
746 1 hiro
static void close_cb(gpointer data, guint action, GtkWidget *widget)
747 1 hiro
{
748 1 hiro
        MessageView *messageview = (MessageView *)data;
749 316 hiro
        messageview_destroy(messageview);
750 1 hiro
}
751 1 hiro
752 1 hiro
static void copy_cb(gpointer data, guint action, GtkWidget *widget)
753 1 hiro
{
754 1 hiro
        MessageView *messageview = (MessageView *)data;
755 1 hiro
        messageview_copy_clipboard(messageview);
756 1 hiro
}
757 1 hiro
758 1 hiro
static void allsel_cb(gpointer data, guint action, GtkWidget *widget)
759 1 hiro
{
760 1 hiro
        MessageView *messageview = (MessageView *)data;
761 1 hiro
        messageview_select_all(messageview);
762 1 hiro
}
763 1 hiro
764 1 hiro
static void search_cb(gpointer data, guint action, GtkWidget *widget)
765 1 hiro
{
766 1 hiro
        MessageView *messageview = (MessageView *)data;
767 1 hiro
        message_search(messageview);
768 1 hiro
}
769 1 hiro
770 1 hiro
static void set_charset_cb(gpointer data, guint action, GtkWidget *widget)
771 1 hiro
{
772 1 hiro
        MessageView *messageview = (MessageView *)data;
773 1 hiro
        const gchar *charset;
774 1 hiro
775 1 hiro
        if (GTK_CHECK_MENU_ITEM(widget)->active) {
776 1 hiro
                charset = conv_get_charset_str((CharSet)action);
777 1 hiro
                g_free(messageview->forced_charset);
778 1 hiro
                messageview->forced_charset = g_strdup(charset);
779 1 hiro
                messageview_show(messageview, messageview->msginfo, FALSE);
780 1 hiro
        }
781 1 hiro
}
782 1 hiro
783 1 hiro
static void view_source_cb(gpointer data, guint action, GtkWidget *widget)
784 1 hiro
{
785 1 hiro
        MessageView *messageview = (MessageView *)data;
786 1 hiro
        SourceWindow *srcwin;
787 1 hiro
788 1 hiro
        if (!messageview->msginfo) return;
789 1 hiro
790 1 hiro
        srcwin = source_window_create();
791 1 hiro
        source_window_show_msg(srcwin, messageview->msginfo);
792 1 hiro
        source_window_show(srcwin);
793 1 hiro
}
794 1 hiro
795 1 hiro
static void show_all_header_cb(gpointer data, guint action, GtkWidget *widget)
796 1 hiro
{
797 1 hiro
        MessageView *messageview = (MessageView *)data;
798 1 hiro
        MsgInfo *msginfo = messageview->msginfo;
799 1 hiro
800 1 hiro
        if (!msginfo) return;
801 1 hiro
        messageview->msginfo = NULL;
802 1 hiro
        messageview_show(messageview, msginfo,
803 1 hiro
                         GTK_CHECK_MENU_ITEM(widget)->active);
804 1 hiro
        procmsg_msginfo_free(msginfo);
805 1 hiro
}
806 1 hiro
807 1 hiro
static void compose_cb(gpointer data, guint action, GtkWidget *widget)
808 1 hiro
{
809 1 hiro
        MessageView *messageview = (MessageView *)data;
810 1 hiro
        PrefsAccount *ac = NULL;
811 1 hiro
        FolderItem *item = NULL;
812 1 hiro
813 1 hiro
        if (messageview->msginfo)
814 1 hiro
                item = messageview->msginfo->folder;
815 1 hiro
816 1 hiro
        if (item) {
817 1 hiro
                ac = account_find_from_item(item);
818 1 hiro
                if (ac && ac->protocol == A_NNTP &&
819 1 hiro
                    FOLDER_TYPE(item->folder) == F_NEWS) {
820 1 hiro
                        compose_new(ac, item, item->path, NULL);
821 1 hiro
                        return;
822 1 hiro
                }
823 1 hiro
        }
824 1 hiro
825 1 hiro
        compose_new(ac, item, NULL, NULL);
826 1 hiro
}
827 1 hiro
828 1 hiro
static void reply_cb(gpointer data, guint action, GtkWidget *widget)
829 1 hiro
{
830 1 hiro
        MessageView *messageview = (MessageView *)data;
831 1 hiro
        GSList *mlist = NULL;
832 1 hiro
        MsgInfo *msginfo;
833 1 hiro
        gchar *text = NULL;
834 1 hiro
        ComposeMode mode = (ComposeMode)action;
835 1 hiro
836 1 hiro
        msginfo = messageview->msginfo;
837 1 hiro
        mlist = g_slist_append(NULL, msginfo);
838 1 hiro
839 130 hiro
        text = gtkut_text_view_get_selection
840 130 hiro
                (GTK_TEXT_VIEW(messageview->textview->text));
841 1 hiro
        if (text && *text == '\0') {
842 1 hiro
                g_free(text);
843 1 hiro
                text = NULL;
844 1 hiro
        }
845 1 hiro
846 1 hiro
        if (!COMPOSE_QUOTE_MODE(mode))
847 1 hiro
                mode |= prefs_common.reply_with_quote
848 1 hiro
                        ? COMPOSE_WITH_QUOTE : COMPOSE_WITHOUT_QUOTE;
849 1 hiro
850 1 hiro
        switch (COMPOSE_MODE(mode)) {
851 1 hiro
        case COMPOSE_REPLY:
852 1 hiro
        case COMPOSE_REPLY_TO_SENDER:
853 1 hiro
        case COMPOSE_REPLY_TO_ALL:
854 1 hiro
        case COMPOSE_REPLY_TO_LIST:
855 1 hiro
                compose_reply(msginfo, msginfo->folder, mode, text);
856 1 hiro
                break;
857 1 hiro
        case COMPOSE_FORWARD:
858 1 hiro
                compose_forward(mlist, msginfo->folder, FALSE, text);
859 1 hiro
                break;
860 1 hiro
        case COMPOSE_FORWARD_AS_ATTACH:
861 1 hiro
                compose_forward(mlist, msginfo->folder, TRUE, NULL);
862 1 hiro
                break;
863 1 hiro
        case COMPOSE_REDIRECT:
864 1 hiro
                compose_redirect(msginfo, msginfo->folder);
865 1 hiro
                break;
866 1 hiro
        default:
867 1 hiro
                g_warning("messageview.c: reply_cb(): invalid mode: %d\n",
868 1 hiro
                          mode);
869 1 hiro
        }
870 1 hiro
871 1 hiro
        /* summary_set_marks_selected(summaryview); */
872 1 hiro
        g_free(text);
873 1 hiro
        g_slist_free(mlist);
874 1 hiro
}
875 1 hiro
876 1 hiro
static void reedit_cb(gpointer data, guint action, GtkWidget *widget)
877 1 hiro
{
878 1 hiro
        MessageView *messageview = (MessageView *)data;
879 1 hiro
        MsgInfo *msginfo;
880 1 hiro
881 1 hiro
        if (!messageview->msginfo) return;
882 1 hiro
        msginfo = messageview->msginfo;
883 1 hiro
        if (!msginfo->folder) return;
884 1 hiro
        if (msginfo->folder->stype != F_OUTBOX &&
885 1 hiro
            msginfo->folder->stype != F_DRAFT &&
886 1 hiro
            msginfo->folder->stype != F_QUEUE) return;
887 1 hiro
888 1 hiro
        compose_reedit(msginfo);
889 1 hiro
}
890 1 hiro
891 1 hiro
static void addressbook_open_cb(gpointer data, guint action, GtkWidget *widget)
892 1 hiro
{
893 1 hiro
        addressbook_open(NULL);
894 1 hiro
}
895 1 hiro
896 1 hiro
static void add_address_cb(gpointer data, guint action, GtkWidget *widget)
897 1 hiro
{
898 1 hiro
        MessageView *messageview = (MessageView *)data;
899 1 hiro
        MsgInfo *msginfo;
900 1 hiro
        gchar *from;
901 1 hiro
902 1 hiro
        if (!messageview->msginfo) return;
903 1 hiro
        msginfo = messageview->msginfo;
904 1 hiro
        Xstrdup_a(from, msginfo->from, return);
905 1 hiro
        eliminate_address_comment(from);
906 1 hiro
        extract_address(from);
907 1 hiro
        addressbook_add_contact(msginfo->fromname, from, NULL);
908 1 hiro
}
909 1 hiro
910 1 hiro
static void create_filter_cb(gpointer data, guint action, GtkWidget *widget)
911 1 hiro
{
912 1 hiro
        MessageView *messageview = (MessageView *)data;
913 1 hiro
        gchar *header = NULL;
914 1 hiro
        gchar *key = NULL;
915 1 hiro
916 1 hiro
        if (!messageview->msginfo) return;
917 1 hiro
918 547 hiro
        filter_get_keyword_from_msg(messageview->msginfo, &header, &key,
919 547 hiro
                                    (FilterCreateType)action);
920 1 hiro
        prefs_filter_open(messageview->msginfo, header);
921 1 hiro
922 1 hiro
        g_free(header);
923 1 hiro
        g_free(key);
924 1 hiro
}
925 1 hiro
926 1 hiro
static void about_cb(gpointer data, guint action, GtkWidget *widget)
927 1 hiro
{
928 1 hiro
        about_show();
929 1 hiro
}