initial message templates support
[claws.git] / src / mainwindow.c
blob4891cce2d5f0aabab11325ede05dc6d343c5a905
1 /*
2 * Sylpheed -- a GTK+ based, lightweight, and fast e-mail client
3 * Copyright (C) 1999-2001 Hiroyuki Yamamoto
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.
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.
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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
20 #include "defs.h"
22 #include <glib.h>
23 #include <gtk/gtkmain.h>
24 #include <gtk/gtkwindow.h>
25 #include <gtk/gtkwidget.h>
26 #include <gtk/gtksignal.h>
27 #include <gtk/gtkvbox.h>
28 #include <gtk/gtkcontainer.h>
29 #include <gtk/gtkstatusbar.h>
30 #include <gtk/gtkhpaned.h>
31 #include <gtk/gtkvpaned.h>
32 #include <gtk/gtkcheckmenuitem.h>
33 #include <gtk/gtkitemfactory.h>
34 #include <gtk/gtkeditable.h>
35 #include <gtk/gtkmenu.h>
36 #include <gtk/gtkmenuitem.h>
37 #include <gtk/gtkhandlebox.h>
38 #include <gtk/gtktoolbar.h>
39 #include <gtk/gtkbutton.h>
40 #include <string.h>
42 #include "intl.h"
43 #include "main.h"
44 #include "mainwindow.h"
45 #include "folderview.h"
46 #include "foldersel.h"
47 #include "summaryview.h"
48 #include "summary_search.h"
49 #include "messageview.h"
50 #include "headerview.h"
51 #include "menu.h"
52 #include "folder.h"
53 #include "inc.h"
54 #include "compose.h"
55 #include "procmsg.h"
56 #include "import.h"
57 #include "export.h"
58 #include "prefs_common.h"
59 #include "prefs_filter.h"
60 #include "prefs_filtering.h"
61 #include "prefs_scoring.h"
62 #include "prefs_account.h"
63 #include "prefs_folder_item.h"
64 #include "account.h"
65 #include "addressbook.h"
66 #include "headerwindow.h"
67 #include "logwindow.h"
68 #include "manage_window.h"
69 #include "alertpanel.h"
70 #include "statusbar.h"
71 #include "inputdialog.h"
72 #include "utils.h"
73 #include "gtkutils.h"
74 #include "codeconv.h"
75 #include "about.h"
76 #include "manual.h"
77 #include "prefs_templates.h"
79 #define AC_LABEL_WIDTH 240
81 #define STATUSBAR_PUSH(mainwin, str) \
82 { \
83 gtk_statusbar_push(GTK_STATUSBAR(mainwin->statusbar), \
84 mainwin->mainwin_cid, str); \
85 gtkut_widget_wait_for_draw(mainwin->hbox_stat); \
88 #define STATUSBAR_POP(mainwin) \
89 { \
90 gtk_statusbar_pop(GTK_STATUSBAR(mainwin->statusbar), \
91 mainwin->mainwin_cid); \
94 /* list of all instantiated MainWindow */
95 static GList *mainwin_list = NULL;
97 static GdkCursor *watch_cursor;
99 static void main_window_show_cur_account (MainWindow *mainwin);
101 static void main_window_set_widgets (MainWindow *mainwin,
102 SeparateType type);
103 static void main_window_toolbar_create (MainWindow *mainwin,
104 GtkWidget *container);
106 /* callback functions */
107 static void toolbar_inc_cb (GtkWidget *widget,
108 gpointer data);
109 static void toolbar_inc_all_cb (GtkWidget *widget,
110 gpointer data);
111 static void toolbar_send_cb (GtkWidget *widget,
112 gpointer data);
114 static void toolbar_compose_cb (GtkWidget *widget,
115 gpointer data);
116 static void toolbar_popup_compose_type_cb(GtkWidget *widget,
117 gpointer data);
118 static void toolbar_popup_compose_type_set(GtkWidget *widget,
119 gpointer data);
120 static void toolbar_compose_news_cb (GtkWidget *widget,
121 gpointer data);
122 static void toolbar_compose_mail_cb (GtkWidget *widget,
123 gpointer data);
124 static void toolbar_reply_cb (GtkWidget *widget,
125 gpointer data);
126 static void toolbar_reply_to_all_cb (GtkWidget *widget,
127 gpointer data);
128 static void toolbar_reply_to_sender_cb (GtkWidget *widget,
129 gpointer data);
130 static void toolbar_forward_cb (GtkWidget *widget,
131 gpointer data);
133 static void toolbar_delete_cb (GtkWidget *widget,
134 gpointer data);
135 static void toolbar_exec_cb (GtkWidget *widget,
136 gpointer data);
138 static void toolbar_next_unread_cb (GtkWidget *widget,
139 gpointer data);
141 static void toolbar_prefs_cb (GtkWidget *widget,
142 gpointer data);
143 static void toolbar_account_cb (GtkWidget *widget,
144 gpointer data);
146 static void toolbar_account_button_pressed (GtkWidget *widget,
147 GdkEventButton *event,
148 gpointer data);
149 static void ac_label_button_pressed (GtkWidget *widget,
150 GdkEventButton *event,
151 gpointer data);
152 static void ac_menu_popup_closed (GtkMenuShell *menu_shell,
153 gpointer data);
155 static gint main_window_close_cb (GtkWidget *widget,
156 GdkEventAny *event,
157 gpointer data);
159 static void add_mailbox_cb (MainWindow *mainwin,
160 guint action,
161 GtkWidget *widget);
162 static void add_mbox_cb (MainWindow *mainwin,
163 guint action,
164 GtkWidget *widget);
165 static void update_folderview_cb (MainWindow *mainwin,
166 guint action,
167 GtkWidget *widget);
168 static void new_folder_cb (MainWindow *mainwin,
169 guint action,
170 GtkWidget *widget);
171 static void rename_folder_cb (MainWindow *mainwin,
172 guint action,
173 GtkWidget *widget);
174 static void delete_folder_cb (MainWindow *mainwin,
175 guint action,
176 GtkWidget *widget);
177 static void import_mbox_cb (MainWindow *mainwin,
178 guint action,
179 GtkWidget *widget);
180 static void export_mbox_cb (MainWindow *mainwin,
181 guint action,
182 GtkWidget *widget);
183 static void empty_trash_cb (MainWindow *mainwin,
184 guint action,
185 GtkWidget *widget);
187 static void save_as_cb (MainWindow *mainwin,
188 guint action,
189 GtkWidget *widget);
190 static void print_cb (MainWindow *mainwin,
191 guint action,
192 GtkWidget *widget);
193 static void app_exit_cb (MainWindow *mainwin,
194 guint action,
195 GtkWidget *widget);
197 static void toggle_folder_cb (MainWindow *mainwin,
198 guint action,
199 GtkWidget *widget);
200 static void toggle_message_cb (MainWindow *mainwin,
201 guint action,
202 GtkWidget *widget);
203 static void toggle_toolbar_cb (MainWindow *mainwin,
204 guint action,
205 GtkWidget *widget);
206 static void toggle_statusbar_cb (MainWindow *mainwin,
207 guint action,
208 GtkWidget *widget);
209 static void separate_widget_cb (GtkCheckMenuItem *checkitem,
210 guint action,
211 GtkWidget *widget);
213 static void addressbook_open_cb (MainWindow *mainwin,
214 guint action,
215 GtkWidget *widget);
216 static void log_window_show_cb (MainWindow *mainwin,
217 guint action,
218 GtkWidget *widget);
220 static void inc_mail_cb (MainWindow *mainwin,
221 guint action,
222 GtkWidget *widget);
223 static void inc_all_account_mail_cb (MainWindow *mainwin,
224 guint action,
225 GtkWidget *widget);
227 static void send_queue_cb (MainWindow *mainwin,
228 guint action,
229 GtkWidget *widget);
231 static void compose_cb (MainWindow *mainwin,
232 guint action,
233 GtkWidget *widget);
234 static void compose_mail_cb(MainWindow *mainwin, guint action,
235 GtkWidget *widget);
236 static void compose_news_cb(MainWindow *mainwin, guint action,
237 GtkWidget *widget);
238 static void reply_cb (MainWindow *mainwin,
239 guint action,
240 GtkWidget *widget);
242 static void open_msg_cb (MainWindow *mainwin,
243 guint action,
244 GtkWidget *widget);
246 static void view_source_cb (MainWindow *mainwin,
247 guint action,
248 GtkWidget *widget);
250 static void reedit_cb (MainWindow *mainwin,
251 guint action,
252 GtkWidget *widget);
254 static void move_to_cb (MainWindow *mainwin,
255 guint action,
256 GtkWidget *widget);
257 static void copy_to_cb (MainWindow *mainwin,
258 guint action,
259 GtkWidget *widget);
260 static void delete_cb (MainWindow *mainwin,
261 guint action,
262 GtkWidget *widget);
264 static void mark_cb (MainWindow *mainwin,
265 guint action,
266 GtkWidget *widget);
267 static void unmark_cb (MainWindow *mainwin,
268 guint action,
269 GtkWidget *widget);
271 static void mark_as_unread_cb (MainWindow *mainwin,
272 guint action,
273 GtkWidget *widget);
274 static void mark_as_read_cb (MainWindow *mainwin,
275 guint action,
276 GtkWidget *widget);
278 static void set_charset_cb (MainWindow *mainwin,
279 guint action,
280 GtkWidget *widget);
282 static void thread_cb (MainWindow *mainwin,
283 guint action,
284 GtkWidget *widget);
285 static void set_display_item_cb (MainWindow *mainwin,
286 guint action,
287 GtkWidget *widget);
288 static void sort_summary_cb (MainWindow *mainwin,
289 guint action,
290 GtkWidget *widget);
291 static void attract_by_subject_cb(MainWindow *mainwin,
292 guint action,
293 GtkWidget *widget);
295 static void delete_duplicated_cb (MainWindow *mainwin,
296 guint action,
297 GtkWidget *widget);
298 static void filter_cb (MainWindow *mainwin,
299 guint action,
300 GtkWidget *widget);
301 static void execute_summary_cb (MainWindow *mainwin,
302 guint action,
303 GtkWidget *widget);
304 static void update_summary_cb (MainWindow *mainwin,
305 guint action,
306 GtkWidget *widget);
308 static void prev_cb (MainWindow *mainwin,
309 guint action,
310 GtkWidget *widget);
311 static void next_cb (MainWindow *mainwin,
312 guint action,
313 GtkWidget *widget);
315 static void next_unread_cb (MainWindow *mainwin,
316 guint action,
317 GtkWidget *widget);
319 static void next_marked_cb (MainWindow *mainwin,
320 guint action,
321 GtkWidget *widget);
323 static void prev_marked_cb (MainWindow *mainwin,
324 guint action,
325 GtkWidget *widget);
327 static void goto_folder_cb (MainWindow *mainwin,
328 guint action,
329 GtkWidget *widget);
331 static void copy_cb (MainWindow *mainwin,
332 guint action,
333 GtkWidget *widget);
334 static void allsel_cb (MainWindow *mainwin,
335 guint action,
336 GtkWidget *widget);
338 static void prefs_common_open_cb (MainWindow *mainwin,
339 guint action,
340 GtkWidget *widget);
341 static void prefs_filter_open_cb (MainWindow *mainwin,
342 guint action,
343 GtkWidget *widget);
344 static void prefs_scoring_open_cb (MainWindow *mainwin,
345 guint action,
346 GtkWidget *widget);
347 static void prefs_filtering_open_cb (MainWindow *mainwin,
348 guint action,
349 GtkWidget *widget);
350 static void prefs_account_open_cb(MainWindow *mainwin,
351 guint action,
352 GtkWidget *widget);
353 static void new_account_cb (MainWindow *mainwin,
354 guint action,
355 GtkWidget *widget);
357 static void account_menu_cb (GtkMenuItem *menuitem,
358 gpointer data);
360 static void manual_open_cb (MainWindow *mainwin,
361 guint action,
362 GtkWidget *widget);
364 static void scan_tree_func (Folder *folder,
365 FolderItem *item,
366 gpointer data);
368 static void activate_compose_button (MainWindow *mainwin,
369 ToolbarStyle style,
370 ComposeButtonType type);
372 static void prefs_templates_open_cb(MainWindow *mainwin,
373 guint action,
374 GtkWidget *widget);
376 #define SEPARATE_ACTION 667
378 static GtkItemFactoryEntry mainwin_entries[] =
380 {N_("/_File"), NULL, NULL, 0, "<Branch>"},
381 {N_("/_File/_Add mailbox..."), NULL, add_mailbox_cb, 0, NULL},
382 {N_("/_File/_Add mbox mailbox..."), NULL, add_mbox_cb, 0, NULL},
383 {N_("/_File/_Update folder tree"), NULL, update_folderview_cb, 0, NULL},
384 {N_("/_File/_Folder"), NULL, NULL, 0, "<Branch>"},
385 {N_("/_File/_Folder/Create _new folder..."),
386 NULL, new_folder_cb, 0, NULL},
387 {N_("/_File/_Folder/_Rename folder..."),NULL, rename_folder_cb, 0, NULL},
388 {N_("/_File/_Folder/_Delete folder"), NULL, delete_folder_cb, 0, NULL},
389 {N_("/_File/_Import mbox file..."), NULL, import_mbox_cb, 0, NULL},
390 {N_("/_File/_Export to mbox file..."), NULL, export_mbox_cb, 0, NULL},
391 {N_("/_File/Empty _trash"), NULL, empty_trash_cb, 0, NULL},
392 {N_("/_File/---"), NULL, NULL, 0, "<Separator>"},
393 {N_("/_File/_Save as..."), NULL, save_as_cb, 0, NULL},
394 {N_("/_File/_Print..."), "<alt>P", print_cb, 0, NULL},
395 {N_("/_File/---"), NULL, NULL, 0, "<Separator>"},
396 {N_("/_File/_Close"), "<alt>W", app_exit_cb, 0, NULL},
397 {N_("/_File/E_xit"), "<alt>Q", app_exit_cb, 0, NULL},
399 {N_("/_Edit"), NULL, NULL, 0, "<Branch>"},
400 {N_("/_Edit/_Copy"), "<control>C", copy_cb, 0, NULL},
401 {N_("/_Edit/Select _all"), "<control>A", allsel_cb, 0, NULL},
402 {N_("/_Edit/---"), NULL, NULL, 0, "<Separator>"},
403 {N_("/_Edit/_Search"), "<control>S", summary_search_cb, 0, NULL},
405 {N_("/_View"), NULL, NULL, 0, "<Branch>"},
406 {N_("/_View/_Folder tree"), NULL, toggle_folder_cb, 0, "<ToggleItem>"},
407 {N_("/_View/_Message view"), NULL, toggle_message_cb, 0, "<ToggleItem>"},
408 {N_("/_View/_Toolbar"), NULL, NULL, 0, "<Branch>"},
409 {N_("/_View/_Toolbar/Icon _and text"), NULL, toggle_toolbar_cb, TOOLBAR_BOTH, "<RadioItem>"},
410 {N_("/_View/_Toolbar/_Icon"), NULL, toggle_toolbar_cb, TOOLBAR_ICON, "/View/Toolbar/Icon and text"},
411 {N_("/_View/_Toolbar/_Text"), NULL, toggle_toolbar_cb, TOOLBAR_TEXT, "/View/Toolbar/Icon and text"},
412 {N_("/_View/_Toolbar/_None"), NULL, toggle_toolbar_cb, TOOLBAR_NONE, "/View/Toolbar/Icon and text"},
413 {N_("/_View/_Status bar"), NULL, toggle_statusbar_cb, 0, "<ToggleItem>"},
414 {N_("/_View/---"), NULL, NULL, 0, "<Separator>"},
415 {N_("/_View/Separate f_older tree"), NULL, NULL, SEPARATE_ACTION + SEPARATE_FOLDER, "<ToggleItem>"},
416 {N_("/_View/Separate m_essage view"), NULL, NULL, SEPARATE_ACTION + SEPARATE_MESSAGE, "<ToggleItem>"},
417 {N_("/_View/---"), NULL, NULL, 0, "<Separator>"},
418 {N_("/_View/_Code set"), NULL, NULL, 0, "<Branch>"},
419 {N_("/_View/_Code set/_Auto detect"),
420 NULL, set_charset_cb, C_AUTO, "<RadioItem>"},
422 #define CODESET_SEPARATOR \
423 {N_("/_View/_Code set/---"), NULL, NULL, 0, "<Separator>"}
424 #define CODESET_ACTION(action) \
425 NULL, set_charset_cb, action, "/View/Code set/Auto detect"
427 {N_("/_View/_Code set/---"), NULL, NULL, 0, "<Separator>"},
428 {N_("/_View/_Code set/7bit ascii (US-ASC_II)"),
429 CODESET_ACTION(C_US_ASCII)},
431 #if HAVE_LIBJCONV
432 {N_("/_View/_Code set/Unicode (_UTF-8)"),
433 CODESET_ACTION(C_UTF_8)},
434 CODESET_SEPARATOR,
435 #endif
436 {N_("/_View/_Code set/Western European (ISO-8859-_1)"),
437 CODESET_ACTION(C_ISO_8859_1)},
438 CODESET_SEPARATOR,
439 #if HAVE_LIBJCONV
440 {N_("/_View/_Code set/Central European (ISO-8859-_2)"),
441 CODESET_ACTION(C_ISO_8859_2)},
442 CODESET_SEPARATOR,
443 {N_("/_View/_Code set/_Baltic (ISO-8859-13)"),
444 CODESET_ACTION(C_ISO_8859_13)},
445 {N_("/_View/_Code set/Baltic (ISO-8859-_4)"),
446 CODESET_ACTION(C_ISO_8859_4)},
447 CODESET_SEPARATOR,
448 {N_("/_View/_Code set/Greek (ISO-8859-_7)"),
449 CODESET_ACTION(C_ISO_8859_7)},
450 CODESET_SEPARATOR,
451 {N_("/_View/_Code set/Turkish (ISO-8859-_9)"),
452 CODESET_ACTION(C_ISO_8859_9)},
453 CODESET_SEPARATOR,
454 {N_("/_View/_Code set/Cyrillic (ISO-8859-_5)"),
455 CODESET_ACTION(C_ISO_8859_5)},
456 {N_("/_View/_Code set/Cyrillic (KOI8-_R)"),
457 CODESET_ACTION(C_KOI8_R)},
458 {N_("/_View/_Code set/Cyrillic (Windows-1251)"),
459 CODESET_ACTION(C_CP1251)},
460 CODESET_SEPARATOR,
461 #endif
462 {N_("/_View/_Code set/Japanese (ISO-2022-_JP)"),
463 CODESET_ACTION(C_ISO_2022_JP)},
464 #if HAVE_LIBJCONV
465 {N_("/_View/_Code set/Japanese (ISO-2022-JP-2)"),
466 CODESET_ACTION(C_ISO_2022_JP_2)},
467 #endif
468 {N_("/_View/_Code set/Japanese (_EUC-JP)"),
469 CODESET_ACTION(C_EUC_JP)},
470 {N_("/_View/_Code set/Japanese (_Shift__JIS)"),
471 CODESET_ACTION(C_SHIFT_JIS)},
472 #if HAVE_LIBJCONV
473 CODESET_SEPARATOR,
474 {N_("/_View/_Code set/Simplified Chinese (_GB2312)"),
475 CODESET_ACTION(C_GB2312)},
476 {N_("/_View/_Code set/Traditional Chinese (_Big5)"),
477 CODESET_ACTION(C_BIG5)},
478 {N_("/_View/_Code set/Traditional Chinese (EUC-_TW)"),
479 CODESET_ACTION(C_EUC_TW)},
480 {N_("/_View/_Code set/Chinese (ISO-2022-_CN)"),
481 CODESET_ACTION(C_ISO_2022_CN)},
482 CODESET_SEPARATOR,
483 {N_("/_View/_Code set/Korean (EUC-_KR)"),
484 CODESET_ACTION(C_EUC_KR)},
485 {N_("/_View/_Code set/Korean (ISO-2022-KR)"),
486 CODESET_ACTION(C_ISO_2022_KR)},
487 #endif
489 #undef CODESET_SEPARATOR
490 #undef CODESET_ACTION
492 {N_("/_Message"), NULL, NULL, 0, "<Branch>"},
493 {N_("/_Message/Get new ma_il"), "<alt>I", inc_mail_cb, 0, NULL},
494 {N_("/_Message/Get from _all accounts"),
495 "<shift><alt>I", inc_all_account_mail_cb, 0, NULL},
496 {N_("/_Message/---"), NULL, NULL, 0, "<Separator>"},
497 {N_("/_Message/Send queued messa_ges"),
498 NULL, send_queue_cb, 0, NULL},
499 {N_("/_Message/---"), NULL, NULL, 0, "<Separator>"},
500 {N_("/_Message/Compose a_n email message"), "<alt>N", compose_mail_cb, 0, NULL},
501 {N_("/_Message/Compose a news message"), NULL, compose_news_cb, 0, NULL},
502 {N_("/_Message/_Reply"), "<alt>R", reply_cb, COMPOSE_REPLY, NULL},
503 {N_("/_Message/Repl_y to sender"), "<control><alt>R", reply_cb, COMPOSE_REPLY_TO_SENDER, NULL},
504 {N_("/_Message/Follow-up and reply to"), NULL, reply_cb, COMPOSE_FOLLOWUP_AND_REPLY_TO, NULL},
505 {N_("/_Message/Reply to a_ll"), "<shift><alt>R", reply_cb, COMPOSE_REPLY_TO_ALL, NULL},
506 {N_("/_Message/_Forward"), "<control>F", reply_cb, COMPOSE_FORWARD, NULL},
507 {N_("/_Message/Forward as a_ttachment"),
508 "<shift><control>F", reply_cb, COMPOSE_FORWARD_AS_ATTACH, NULL},
509 {N_("/_Message/---"), NULL, NULL, 0, "<Separator>"},
510 {N_("/_Message/M_ove..."), "<alt>O", move_to_cb, 0, NULL},
511 {N_("/_Message/_Copy..."), NULL, copy_to_cb, 0, NULL},
512 {N_("/_Message/_Delete"), "<alt>D", delete_cb, 0, NULL},
513 {N_("/_Message/_Mark"), NULL, NULL, 0, "<Branch>"},
514 {N_("/_Message/_Mark/_Mark"), NULL, mark_cb, 0, NULL},
515 {N_("/_Message/_Mark/_Unmark"), NULL, unmark_cb, 0, NULL},
516 {N_("/_Message/_Mark/---"), NULL, NULL, 0, "<Separator>"},
517 {N_("/_Message/_Mark/Mark as unr_ead"), NULL, mark_as_unread_cb, 0, NULL},
518 {N_("/_Message/_Mark/Mark as rea_d"),
519 NULL, mark_as_read_cb, 0, NULL},
520 {N_("/_Message/---"), NULL, NULL, 0, "<Separator>"},
521 {N_("/_Message/Open in new _window"), "<shift><control>N", open_msg_cb, 0, NULL},
522 {N_("/_Message/View _source"), "<control>U", view_source_cb, 0, NULL},
523 {N_("/_Message/Show all _header"), "<control>H", header_window_show_cb, 0, NULL},
524 {N_("/_Message/Re-_edit"), NULL, reedit_cb, 0, NULL},
526 {N_("/_Summary"), NULL, NULL, 0, "<Branch>"},
527 {N_("/_Summary/_Delete duplicated messages"),
528 NULL, delete_duplicated_cb, 0, NULL},
529 {N_("/_Summary/_Filter messages"), NULL, filter_cb, 0, NULL},
530 {N_("/_Summary/E_xecute"), "<alt>X", execute_summary_cb, 0, NULL},
531 {N_("/_Summary/_Update"), "<alt>U", update_summary_cb, 0, NULL},
532 {N_("/_Summary/---"), NULL, NULL, 0, "<Separator>"},
533 {N_("/_Summary/_Prev message"), NULL, prev_cb, 0, NULL},
534 {N_("/_Summary/_Next message"), NULL, next_cb, 0, NULL},
535 {N_("/_Summary/N_ext unread message"), NULL, next_unread_cb, 0, NULL},
536 {N_("/_Summary/Prev marked message"), NULL, prev_marked_cb, 0, NULL},
537 {N_("/_Summary/Next marked message"), NULL, next_marked_cb, 0, NULL},
538 {N_("/_Summary/---"), NULL, NULL, 0, "<Separator>"},
539 {N_("/_Summary/_Go to other folder"), "<alt>G", goto_folder_cb, 0, NULL},
540 {N_("/_Summary/---"), NULL, NULL, 0, "<Separator>"},
541 {N_("/_Summary/_Sort"), NULL, NULL, 0, "<Branch>"},
542 {N_("/_Summary/_Sort/Sort by _number"), NULL, sort_summary_cb, SORT_BY_NUMBER, NULL},
543 {N_("/_Summary/_Sort/Sort by s_ize"), NULL, sort_summary_cb, SORT_BY_SIZE, NULL},
544 {N_("/_Summary/_Sort/Sort by _date"), NULL, sort_summary_cb, SORT_BY_DATE, NULL},
545 {N_("/_Summary/_Sort/Sort by _from"), NULL, sort_summary_cb, SORT_BY_FROM, NULL},
546 {N_("/_Summary/_Sort/Sort by _subject"),NULL, sort_summary_cb, SORT_BY_SUBJECT, NULL},
547 {N_("/_Summary/_Sort/Sort by sco_re"), NULL, sort_summary_cb, SORT_BY_SCORE, NULL},
548 {N_("/_Summary/_Sort/Sort by _label"), NULL, sort_summary_cb, SORT_BY_LABEL, NULL},
549 {N_("/_Summary/_Sort/---"), NULL, NULL, 0, "<Separator>"},
550 {N_("/_Summary/_Sort/_Attract by subject"),
551 NULL, attract_by_subject_cb, 0, NULL},
552 {N_("/_Summary/_Thread view"), "<control>T", thread_cb, 0, NULL},
553 {N_("/_Summary/Unt_hread view"), "<shift><control>T", thread_cb, 1, NULL},
554 {N_("/_Summary/Set display _item..."), NULL, set_display_item_cb, 0, NULL},
556 {N_("/_Tool"), NULL, NULL, 0, "<Branch>"},
557 {N_("/_Tool/_Address book"), "<alt>A", addressbook_open_cb, 0, NULL},
558 {N_("/_Tool/_Log window"), "<alt>L", log_window_show_cb, 0, NULL},
560 {N_("/_Configuration"), NULL, NULL, 0, "<Branch>"},
561 {N_("/_Configuration/_Common preferences..."),
562 NULL, prefs_common_open_cb, 0, NULL},
563 {N_("/_Configuration/_Filter setting..."),
564 NULL, prefs_filter_open_cb, 0, NULL},
565 {N_("/_Configuration/_Scoring ..."),
566 NULL, prefs_scoring_open_cb, 0, NULL},
567 {N_("/_Configuration/_Filtering ..."),
568 NULL, prefs_filtering_open_cb, 0, NULL},
569 {N_("/_Configuration/_Templates ..."),
570 NULL, prefs_templates_open_cb, 0, NULL},
571 {N_("/_Configuration/_Preferences per account..."),
572 NULL, prefs_account_open_cb, 0, NULL},
573 {N_("/_Configuration/---"), NULL, NULL, 0, "<Separator>"},
574 {N_("/_Configuration/Create _new account..."),
575 NULL, new_account_cb, 0, NULL},
576 {N_("/_Configuration/_Edit accounts..."),
577 NULL, account_edit_open, 0, NULL},
578 {N_("/_Configuration/C_hange current account"),
579 NULL, NULL, 0, "<Branch>"},
581 {N_("/_Help"), NULL, NULL, 0, "<LastBranch>"},
582 {N_("/_Help/_Manual"), NULL, NULL, 0, "<Branch>"},
583 {N_("/_Help/_Manual/_English"), NULL, manual_open_cb, MANUAL_LANG_EN, NULL},
584 {N_("/_Help/_Manual/_Japanese"), NULL, manual_open_cb, MANUAL_LANG_JA, NULL},
585 {N_("/_Help/---"), NULL, NULL, 0, "<Separator>"},
586 {N_("/_Help/_About"), NULL, about_show, 0, NULL}
589 MainWindow *main_window_create(SeparateType type)
591 MainWindow *mainwin;
592 GtkWidget *window;
593 GtkWidget *vbox;
594 GtkWidget *menubar;
595 GtkWidget *handlebox;
596 GtkWidget *vbox_body;
597 GtkWidget *hbox_stat;
598 GtkWidget *statusbar;
599 GtkWidget *ac_button;
600 GtkWidget *ac_label;
602 FolderView *folderview;
603 SummaryView *summaryview;
604 MessageView *messageview;
605 GdkColormap *colormap;
606 GdkColor color[4];
607 gboolean success[4];
608 guint n_menu_entries;
609 GtkItemFactory *ifactory;
610 GtkWidget *ac_menu;
611 GtkWidget *menuitem;
612 gint i;
614 debug_print(_("Creating main window...\n"));
615 mainwin = g_new0(MainWindow, 1);
617 /* main window */
618 window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
619 gtk_window_set_title(GTK_WINDOW(window), PROG_VERSION);
620 gtk_window_set_policy(GTK_WINDOW(window), TRUE, TRUE, FALSE);
621 gtk_signal_connect(GTK_OBJECT(window), "delete_event",
622 GTK_SIGNAL_FUNC(main_window_close_cb), mainwin);
623 gtk_signal_connect(GTK_OBJECT(window), "focus_in_event",
624 GTK_SIGNAL_FUNC(manage_window_focus_in), NULL);
625 gtk_signal_connect(GTK_OBJECT(window), "focus_out_event",
626 GTK_SIGNAL_FUNC(manage_window_focus_out), NULL);
627 gtk_widget_realize(window);
629 vbox = gtk_vbox_new(FALSE, 0);
630 gtk_widget_show(vbox);
631 gtk_container_add(GTK_CONTAINER(window), vbox);
633 /* menu bar */
634 n_menu_entries = sizeof(mainwin_entries) / sizeof(mainwin_entries[0]);
635 menubar = menubar_create(window, mainwin_entries,
636 n_menu_entries, "<Main>", mainwin);
637 gtk_widget_show(menubar);
638 gtk_box_pack_start(GTK_BOX(vbox), menubar, FALSE, TRUE, 0);
640 handlebox = gtk_handle_box_new();
641 gtk_widget_show(handlebox);
642 gtk_box_pack_start(GTK_BOX(vbox), handlebox, FALSE, FALSE, 0);
644 main_window_toolbar_create(mainwin, handlebox);
646 /* vbox that contains body */
647 vbox_body = gtk_vbox_new(FALSE, BORDER_WIDTH);
648 gtk_widget_show(vbox_body);
649 gtk_container_set_border_width(GTK_CONTAINER(vbox_body), BORDER_WIDTH);
650 gtk_box_pack_start(GTK_BOX(vbox), vbox_body, TRUE, TRUE, 0);
652 hbox_stat = gtk_hbox_new(FALSE, 2);
653 gtk_box_pack_end(GTK_BOX(vbox_body), hbox_stat, FALSE, FALSE, 0);
655 statusbar = statusbar_create();
656 gtk_box_pack_start(GTK_BOX(hbox_stat), statusbar, TRUE, TRUE, 0);
658 ac_button = gtk_button_new();
659 gtk_button_set_relief(GTK_BUTTON(ac_button), GTK_RELIEF_NONE);
660 GTK_WIDGET_UNSET_FLAGS(ac_button, GTK_CAN_FOCUS);
661 gtk_widget_set_usize(ac_button, -1, 1);
662 gtk_box_pack_end(GTK_BOX(hbox_stat), ac_button, FALSE, FALSE, 0);
663 gtk_signal_connect(GTK_OBJECT(ac_button), "button_press_event",
664 GTK_SIGNAL_FUNC(ac_label_button_pressed), mainwin);
666 ac_label = gtk_label_new("");
667 gtk_container_add(GTK_CONTAINER(ac_button), ac_label);
669 gtk_widget_show_all(hbox_stat);
671 /* create views */
672 mainwin->folderview = folderview = folderview_create();
673 mainwin->summaryview = summaryview = summary_create();
674 mainwin->messageview = messageview = messageview_create();
675 mainwin->headerwin = header_window_create();
676 mainwin->logwin = log_window_create();
678 folderview->mainwin = mainwin;
679 folderview->summaryview = summaryview;
681 summaryview->mainwin = mainwin;
682 summaryview->folderview = folderview;
683 summaryview->messageview = messageview;
684 summaryview->headerwin = mainwin->headerwin;
685 summaryview->window = window;
687 messageview->mainwin = mainwin;
689 mainwin->window = window;
690 mainwin->vbox = vbox;
691 mainwin->menubar = menubar;
692 mainwin->handlebox = handlebox;
693 mainwin->vbox_body = vbox_body;
694 mainwin->hbox_stat = hbox_stat;
695 mainwin->statusbar = statusbar;
696 mainwin->ac_button = ac_button;
697 mainwin->ac_label = ac_label;
699 /* set context IDs for status bar */
700 mainwin->mainwin_cid = gtk_statusbar_get_context_id
701 (GTK_STATUSBAR(statusbar), "Main Window");
702 mainwin->folderview_cid = gtk_statusbar_get_context_id
703 (GTK_STATUSBAR(statusbar), "Folder View");
704 mainwin->summaryview_cid = gtk_statusbar_get_context_id
705 (GTK_STATUSBAR(statusbar), "Summary View");
707 /* allocate colors for summary view and folder view */
708 summaryview->color_marked.red = summaryview->color_marked.green = 0;
709 summaryview->color_marked.blue = (guint16)65535;
711 summaryview->color_dim.red = summaryview->color_dim.green =
712 summaryview->color_dim.blue = COLOR_DIM;
714 folderview->color_new.red = (guint16)55000;
715 folderview->color_new.green = folderview->color_new.blue = 15000;
717 gtkut_convert_int_to_gdk_color(prefs_common.tgt_folder_col,
718 &folderview->color_op);
720 summaryview->color_important.red = 0;
721 summaryview->color_marked.green = 0;
722 summaryview->color_important.blue = (guint16)65535;
724 color[0] = summaryview->color_marked;
725 color[1] = summaryview->color_dim;
726 color[2] = folderview->color_new;
727 color[3] = folderview->color_op;
729 colormap = gdk_window_get_colormap(window->window);
730 gdk_colormap_alloc_colors(colormap, color, 4, FALSE, TRUE, success);
731 for (i = 0; i < 4; i++) {
732 if (success[i] == FALSE)
733 g_warning(_("MainWindow: color allocation %d failed\n"), i);
736 debug_print(_("done.\n"));
738 main_window_set_widgets(mainwin, type);
740 /* set menu items */
741 ifactory = gtk_item_factory_from_widget(menubar);
742 menuitem = gtk_item_factory_get_item
743 (ifactory, "/View/Code set/Auto detect");
744 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), TRUE);
746 switch (prefs_common.toolbar_style) {
747 case TOOLBAR_NONE:
748 menuitem = gtk_item_factory_get_item
749 (ifactory, "/View/Toolbar/None");
750 break;
751 case TOOLBAR_ICON:
752 menuitem = gtk_item_factory_get_item
753 (ifactory, "/View/Toolbar/Icon");
754 break;
755 case TOOLBAR_TEXT:
756 menuitem = gtk_item_factory_get_item
757 (ifactory, "/View/Toolbar/Text");
758 break;
759 case TOOLBAR_BOTH:
760 menuitem = gtk_item_factory_get_item
761 (ifactory, "/View/Toolbar/Icon and text");
763 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), TRUE);
765 gtk_widget_hide(mainwin->hbox_stat);
766 menuitem = gtk_item_factory_get_item(ifactory, "/View/Status bar");
767 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem),
768 prefs_common.show_statusbar);
770 /* set the check of the SEPARATE_xxx menu items. we also need the main window
771 * as a property and pass the action type to the callback */
772 menuitem = gtk_item_factory_get_widget_by_action(ifactory, SEPARATE_ACTION + SEPARATE_FOLDER);
773 g_assert(menuitem);
774 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), type & SEPARATE_FOLDER);
775 gtk_object_set_data(GTK_OBJECT(menuitem), "mainwindow", mainwin);
776 gtk_signal_connect(GTK_OBJECT(menuitem), "toggled", GTK_SIGNAL_FUNC(separate_widget_cb),
777 GUINT_TO_POINTER(SEPARATE_FOLDER));
779 menuitem = gtk_item_factory_get_widget_by_action(ifactory, SEPARATE_ACTION + SEPARATE_MESSAGE);
780 g_assert(menuitem);
781 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), type & SEPARATE_MESSAGE);
782 gtk_object_set_data(GTK_OBJECT(menuitem), "mainwindow", mainwin);
783 gtk_signal_connect(GTK_OBJECT(menuitem), "toggled", GTK_SIGNAL_FUNC(separate_widget_cb),
784 GUINT_TO_POINTER(SEPARATE_MESSAGE));
787 menu_set_sensitive(ifactory, "/Summary/Thread view",
788 prefs_common.enable_thread ? FALSE : TRUE);
789 menu_set_sensitive(ifactory, "/Summary/Unthread view",
790 prefs_common.enable_thread ? TRUE : FALSE);
792 /*main_window_set_thread_option(mainwin);*/
795 /* set account selection menu */
796 ac_menu = gtk_item_factory_get_widget
797 (ifactory, "/Configuration/Change current account");
798 gtk_signal_connect(GTK_OBJECT(ac_menu), "selection_done",
799 GTK_SIGNAL_FUNC(ac_menu_popup_closed), mainwin);
800 mainwin->ac_menu = ac_menu;
802 main_window_set_toolbar_sensitive(mainwin, FALSE);
804 /* show main window */
805 gtk_widget_set_uposition(mainwin->window,
806 prefs_common.mainwin_x,
807 prefs_common.mainwin_y);
808 gtk_widget_set_usize(window, prefs_common.mainwin_width,
809 prefs_common.mainwin_height);
810 gtk_widget_show(mainwin->window);
812 /* initialize views */
813 folderview_init(folderview);
814 summary_init(summaryview);
815 messageview_init(messageview);
816 header_window_init(mainwin->headerwin);
817 log_window_init(mainwin->logwin);
819 mainwin->lock_count = 0;
820 mainwin->cursor_count = 0;
822 if (!watch_cursor)
823 watch_cursor = gdk_cursor_new(GDK_WATCH);
825 mainwin_list = g_list_append(mainwin_list, mainwin);
827 return mainwin;
830 void main_window_cursor_wait(MainWindow *mainwin)
833 if (mainwin->cursor_count == 0)
834 gdk_window_set_cursor(mainwin->window->window, watch_cursor);
836 mainwin->cursor_count++;
838 gdk_flush();
841 void main_window_cursor_normal(MainWindow *mainwin)
843 if (mainwin->cursor_count)
844 mainwin->cursor_count--;
846 if (mainwin->cursor_count == 0)
847 gdk_window_set_cursor(mainwin->window->window, NULL);
849 gdk_flush();
852 /* lock / unlock the user-interface */
853 void main_window_lock(MainWindow *mainwin)
855 if (mainwin->lock_count == 0) {
856 gtk_widget_set_sensitive(mainwin->toolbar, FALSE);
857 gtk_widget_set_sensitive(mainwin->ac_button, FALSE);
860 mainwin->lock_count++;
862 main_window_set_menu_sensitive(mainwin);
865 void main_window_unlock(MainWindow *mainwin)
867 if (mainwin->lock_count)
868 mainwin->lock_count--;
870 main_window_set_menu_sensitive(mainwin);
872 if (mainwin->lock_count == 0) {
873 gtk_widget_set_sensitive(mainwin->toolbar, TRUE);
874 gtk_widget_set_sensitive(mainwin->ac_button, TRUE);
878 void main_window_reflect_prefs_all(void)
880 GList *cur;
881 MainWindow *mainwin;
883 for (cur = mainwin_list; cur != NULL; cur = cur->next) {
884 mainwin = (MainWindow *)cur->data;
886 main_window_show_cur_account(mainwin);
887 if (cur_account) {
888 gtk_widget_set_sensitive(mainwin->get_btn, TRUE);
889 gtk_widget_set_sensitive(mainwin->getall_btn, TRUE);
890 } else {
891 gtk_widget_set_sensitive(mainwin->get_btn, FALSE);
892 gtk_widget_set_sensitive(mainwin->getall_btn, FALSE);
895 if (prefs_common.immediate_exec)
896 gtk_widget_hide(mainwin->exec_btn);
897 else
898 gtk_widget_show(mainwin->exec_btn);
900 summary_change_display_item(mainwin->summaryview);
901 summary_redisplay_msg(mainwin->summaryview);
902 headerview_set_visibility(mainwin->messageview->headerview,
903 prefs_common.display_header_pane);
907 void main_window_set_account_menu(GList *account_list)
909 GList *cur, *cur_ac, *cur_item;
910 GtkWidget *menuitem;
911 MainWindow *mainwin;
912 PrefsAccount *ac_prefs;
914 for (cur = mainwin_list; cur != NULL; cur = cur->next) {
915 mainwin = (MainWindow *)cur->data;
917 /* destroy all previous menu item */
918 cur_item = GTK_MENU_SHELL(mainwin->ac_menu)->children;
919 while (cur_item != NULL) {
920 GList *next = cur_item->next;
921 gtk_widget_destroy(GTK_WIDGET(cur_item->data));
922 cur_item = next;
925 for (cur_ac = account_list; cur_ac != NULL;
926 cur_ac = cur_ac->next) {
927 ac_prefs = (PrefsAccount *)cur_ac->data;
929 menuitem = gtk_menu_item_new_with_label
930 (ac_prefs->account_name
931 ? ac_prefs->account_name : _("Untitled"));
932 gtk_widget_show(menuitem);
933 gtk_menu_append(GTK_MENU(mainwin->ac_menu), menuitem);
934 gtk_signal_connect(GTK_OBJECT(menuitem), "activate",
935 GTK_SIGNAL_FUNC(account_menu_cb),
936 ac_prefs);
941 static void main_window_show_cur_account(MainWindow *mainwin)
943 gchar *buf;
944 gchar *ac_name;
946 ac_name = g_strdup(cur_account
947 ? (cur_account->account_name
948 ? cur_account->account_name : _("Untitled"))
949 : _("none"));
951 if (cur_account)
952 buf = g_strdup_printf("%s - %s", ac_name, PROG_VERSION);
953 else
954 buf = g_strdup(PROG_VERSION);
955 gtk_window_set_title(GTK_WINDOW(mainwin->window), buf);
956 g_free(buf);
958 buf = g_strdup_printf(_("Current account: %s"), ac_name);
959 gtk_label_set_text(GTK_LABEL(mainwin->ac_label), buf);
960 gtk_widget_queue_resize(mainwin->ac_button);
961 g_free(buf);
963 g_free(ac_name);
966 void main_window_separation_change(MainWindow *mainwin, SeparateType type)
968 GtkWidget *folder_wid = GTK_WIDGET_PTR(mainwin->folderview);
969 GtkWidget *summary_wid = GTK_WIDGET_PTR(mainwin->summaryview);
970 GtkWidget *message_wid = GTK_WIDGET_PTR(mainwin->messageview);
972 if (mainwin->type == type) return;
974 /* remove widgets from those containers */
975 gtk_widget_ref(folder_wid);
976 gtk_widget_ref(summary_wid);
977 gtk_widget_ref(message_wid);
978 gtk_container_remove
979 (GTK_CONTAINER(folder_wid->parent), folder_wid);
980 gtk_container_remove
981 (GTK_CONTAINER(summary_wid->parent), summary_wid);
982 gtk_container_remove
983 (GTK_CONTAINER(message_wid->parent), message_wid);
985 /* clean containers */
986 switch (mainwin->type) {
987 case SEPARATE_NONE:
988 gtk_widget_destroy(mainwin->win.sep_none.hpaned);
989 break;
990 case SEPARATE_FOLDER:
991 gtk_widget_destroy(mainwin->win.sep_folder.vpaned);
992 gtk_widget_destroy(mainwin->win.sep_folder.folderwin);
993 break;
994 case SEPARATE_MESSAGE:
995 gtk_widget_destroy(mainwin->win.sep_message.hpaned);
996 gtk_widget_destroy(mainwin->win.sep_message.messagewin);
997 break;
998 case SEPARATE_BOTH:
999 gtk_widget_destroy(mainwin->win.sep_both.messagewin);
1000 gtk_widget_destroy(mainwin->win.sep_both.folderwin);
1001 break;
1004 gtk_widget_hide(mainwin->window);
1005 main_window_set_widgets(mainwin, type);
1006 gtk_widget_show(mainwin->window);
1008 gtk_widget_unref(folder_wid);
1009 gtk_widget_unref(summary_wid);
1010 gtk_widget_unref(message_wid);
1013 void main_window_get_size(MainWindow *mainwin)
1015 GtkAllocation *allocation;
1017 allocation = &(GTK_WIDGET_PTR(mainwin->summaryview)->allocation);
1019 prefs_common.summaryview_width = allocation->width;
1021 if (mainwin->summaryview->msg_is_toggled_on)
1022 prefs_common.summaryview_height = allocation->height;
1024 prefs_common.mainview_width = allocation->width;
1026 allocation = &mainwin->window->allocation;
1028 prefs_common.mainview_height = allocation->height;
1029 prefs_common.mainwin_width = allocation->width;
1030 prefs_common.mainwin_height = allocation->height;
1032 allocation = &(GTK_WIDGET_PTR(mainwin->folderview)->allocation);
1034 prefs_common.folderview_width = allocation->width;
1035 prefs_common.folderview_height = allocation->height;
1038 void main_window_get_position(MainWindow *mainwin)
1040 gint x, y;
1042 gtkut_widget_get_uposition(mainwin->window, &x, &y);
1044 prefs_common.mainview_x = x;
1045 prefs_common.mainview_y = y;
1046 prefs_common.mainwin_x = x;
1047 prefs_common.mainwin_y = y;
1049 debug_print(_("window position: x = %d, y = %d\n"), x, y);
1052 void main_window_empty_trash(MainWindow *mainwin, gboolean confirm)
1054 GList *list;
1056 if (confirm) {
1057 if (alertpanel(_("Empty trash"),
1058 _("Empty all messages in trash?"),
1059 _("Yes"), _("No"), NULL) != G_ALERTDEFAULT)
1060 return;
1061 manage_window_focus_in(mainwin->window, NULL, NULL);
1064 procmsg_empty_trash();
1066 for (list = folder_get_list(); list != NULL; list = list->next) {
1067 Folder *folder;
1069 folder = list->data;
1070 if (folder->trash) {
1071 folder_item_scan(folder->trash);
1072 folderview_update_item(folder->trash, TRUE);
1076 if (mainwin->summaryview->folder_item &&
1077 mainwin->summaryview->folder_item->stype == F_TRASH)
1078 gtk_widget_grab_focus(mainwin->folderview->ctree);
1081 void main_window_add_mailbox(MainWindow *mainwin)
1083 gchar *path;
1084 Folder *folder;
1086 path = input_dialog(_("Add mailbox"),
1087 _("Input the location of mailbox.\n"
1088 "If the existing mailbox is specified, it will be\n"
1089 "scanned automatically."),
1090 "Mail");
1091 if (!path) return;
1092 if (folder_find_from_path(path)) {
1093 alertpanel_error(_("The mailbox `%s' already exists."), path);
1094 g_free(path);
1095 return;
1097 if (!strcmp(path, "Mail"))
1098 folder = folder_new(F_MH, _("Mailbox"), path);
1099 else
1100 folder = folder_new(F_MH, g_basename(path), path);
1101 g_free(path);
1103 if (folder->create_tree(folder) < 0) {
1104 alertpanel_error(_("Creation of the mailbox failed.\n"
1105 "Maybe some files already exist, or you don't have the permission to write there."));
1106 folder_destroy(folder);
1107 return;
1110 folder_add(folder);
1111 folder_set_ui_func(folder, scan_tree_func, mainwin);
1112 folder->scan_tree(folder);
1113 folder_set_ui_func(folder, NULL, NULL);
1115 folderview_set(mainwin->folderview);
1118 void main_window_add_mbox(MainWindow *mainwin)
1120 gchar *path;
1121 Folder *folder;
1122 FolderItem * item;
1124 path = input_dialog(_("Add mbox mailbox"),
1125 _("Input the location of mailbox."),
1126 "mail");
1128 if (!path) return;
1130 if (folder_find_from_path(path)) {
1131 alertpanel_error(_("The mailbox `%s' already exists."), path);
1132 g_free(path);
1133 return;
1137 if (!strcmp(path, "Mail"))
1138 folder = folder_new(F_MBOX, _("Mailbox"), path);
1139 else
1142 folder = folder_new(F_MBOX, g_basename(path), path);
1143 g_free(path);
1145 if (folder->create_tree(folder) < 0) {
1146 alertpanel_error(_("Creation of the mailbox failed."));
1147 folder_destroy(folder);
1148 return;
1151 folder_add(folder);
1153 item = folder_item_new(folder->name, NULL);
1154 item->folder = folder;
1155 folder->node = g_node_new(item);
1157 folder->create_folder(folder, item, "inbox");
1158 folder->create_folder(folder, item, "outbox");
1159 folder->create_folder(folder, item, "queue");
1160 folder->create_folder(folder, item, "draft");
1161 folder->create_folder(folder, item, "trash");
1163 folderview_set(mainwin->folderview);
1166 void main_window_set_toolbar_sensitive(MainWindow *mainwin, gboolean sensitive)
1168 gtk_widget_set_sensitive(mainwin->reply_btn, sensitive);
1169 gtk_widget_set_sensitive(mainwin->replyall_btn, sensitive);
1170 gtk_widget_set_sensitive(mainwin->replysender_btn, sensitive);
1171 gtk_widget_set_sensitive(mainwin->fwd_btn, sensitive);
1172 gtk_widget_set_sensitive(mainwin->exec_btn, sensitive);
1173 gtk_widget_set_sensitive(mainwin->next_btn, sensitive);
1175 if (!mainwin->summaryview->folder_item ||
1176 mainwin->summaryview->folder_item->folder->type == F_NEWS)
1177 gtk_widget_set_sensitive(mainwin->delete_btn, FALSE);
1178 else
1179 gtk_widget_set_sensitive(mainwin->delete_btn, sensitive);
1182 typedef enum
1184 M_UNLOCKED = 1 << 0,
1185 M_MSG_EXIST = 1 << 1,
1186 M_TARGET_EXIST = 1 << 2,
1187 M_SINGLE_TARGET_EXIST = 1 << 3,
1188 M_EXEC = 1 << 4,
1189 M_ALLOW_REEDIT = 1 << 5
1190 } MenuItemSensitiveCond;
1192 void main_window_set_menu_sensitive(MainWindow *mainwin)
1194 GtkItemFactory *ifactory;
1195 SummarySelection selection;
1196 MenuItemSensitiveCond state = 0;
1197 gboolean sensitive;
1198 gint i;
1200 static const struct {
1201 gchar *const entry;
1202 MenuItemSensitiveCond cond;
1203 } entry[] = {
1204 {"/File/Add mailbox..." , M_UNLOCKED},
1205 {"/File/Update folder tree" , M_UNLOCKED},
1206 {"/File/Folder" , M_UNLOCKED},
1207 {"/File/Import mbox file..." , M_UNLOCKED},
1208 {"/File/Export to mbox file...", M_UNLOCKED},
1209 {"/File/Empty trash" , M_UNLOCKED},
1210 {"/File/Save as...", M_SINGLE_TARGET_EXIST|M_UNLOCKED},
1211 {"/File/Print..." , M_TARGET_EXIST|M_UNLOCKED},
1212 {"/File/Close", M_UNLOCKED},
1213 {"/File/Exit" , M_UNLOCKED},
1215 {"/Message/Get new mail" , M_UNLOCKED},
1216 {"/Message/Get from all accounts", M_UNLOCKED},
1217 {"/Message/Reply" , M_SINGLE_TARGET_EXIST},
1218 {"/Message/Reply to sender" , M_SINGLE_TARGET_EXIST},
1219 {"/Message/Reply to all" , M_SINGLE_TARGET_EXIST},
1220 {"/Message/Forward" , M_SINGLE_TARGET_EXIST},
1221 {"/Message/Forward as attachment", M_SINGLE_TARGET_EXIST},
1222 {"/Message/Open in new window" , M_SINGLE_TARGET_EXIST},
1223 {"/Message/Show all header" , M_SINGLE_TARGET_EXIST},
1224 {"/Message/View source" , M_SINGLE_TARGET_EXIST},
1225 {"/Message/Move...", M_TARGET_EXIST|M_EXEC|M_UNLOCKED},
1226 {"/Message/Copy...", M_TARGET_EXIST|M_EXEC|M_UNLOCKED},
1227 {"/Message/Delete" , M_TARGET_EXIST|M_EXEC|M_UNLOCKED},
1228 {"/Message/Mark" , M_TARGET_EXIST},
1229 {"/Message/Re-edit", M_ALLOW_REEDIT},
1231 {"/Summary/Delete duplicated messages", M_MSG_EXIST|M_EXEC|M_UNLOCKED},
1232 {"/Summary/Filter messages", M_MSG_EXIST|M_EXEC|M_UNLOCKED},
1233 {"/Summary/Execute" , M_MSG_EXIST|M_UNLOCKED},
1234 {"/Summary/Prev message" , M_MSG_EXIST},
1235 {"/Summary/Next message" , M_MSG_EXIST},
1236 {"/Summary/Next unread message", M_MSG_EXIST},
1237 {"/Summary/Sort" , M_MSG_EXIST},
1239 {"/Configuration", M_UNLOCKED},
1241 {NULL, 0}
1244 ifactory = gtk_item_factory_from_widget(mainwin->menubar);
1245 selection = summary_get_selection_type(mainwin->summaryview);
1247 if (mainwin->lock_count == 0)
1248 state |= M_UNLOCKED;
1249 if (selection != SUMMARY_NONE)
1250 state |= M_MSG_EXIST;
1251 if (selection == SUMMARY_SELECTED_SINGLE ||
1252 selection == SUMMARY_SELECTED_MULTIPLE)
1253 state |= M_TARGET_EXIST;
1254 if (selection == SUMMARY_SELECTED_SINGLE)
1255 state |= M_SINGLE_TARGET_EXIST;
1256 if (mainwin->summaryview->folder_item &&
1257 mainwin->summaryview->folder_item->folder->type != F_NEWS)
1258 state |= M_EXEC;
1259 if (selection == SUMMARY_SELECTED_SINGLE &&
1260 (mainwin->summaryview->folder_item &&
1261 mainwin->summaryview->folder_item->stype == F_DRAFT))
1262 state |= M_ALLOW_REEDIT;
1264 for (i = 0; entry[i].entry != NULL; i++) {
1265 sensitive = ((entry[i].cond & state) == entry[i].cond);
1266 menu_set_sensitive(ifactory, entry[i].entry, sensitive);
1270 void main_window_popup(MainWindow *mainwin)
1272 gint x, y;
1273 gint sx, sy;
1274 GtkWidget *widget;
1276 gdk_window_get_origin(mainwin->window->window, &x, &y);
1277 sx = gdk_screen_width();
1278 sy = gdk_screen_height();
1279 x %= sx; if (x < 0) x += sx;
1280 y %= sy; if (y < 0) y += sy;
1281 gdk_window_move(mainwin->window->window, x, y);
1282 gdk_window_raise(mainwin->window->window);
1283 gdk_window_show(mainwin->window->window);
1285 debug_print("window position: x = %d, y = %d\n", x, y);
1287 switch (mainwin->type) {
1288 case SEPARATE_FOLDER:
1289 widget = mainwin->win.sep_folder.folderwin;
1290 gdk_window_get_origin(widget->window, &x, &y);
1291 x %= sx; if (x < 0) x += sx;
1292 y %= sy; if (y < 0) y += sy;
1293 gdk_window_move(widget->window, x, y);
1294 gdk_window_raise(widget->window);
1295 break;
1296 case SEPARATE_MESSAGE:
1297 widget = mainwin->win.sep_message.messagewin;
1298 gdk_window_get_origin(widget->window, &x, &y);
1299 x %= sx; if (x < 0) x += sx;
1300 y %= sy; if (y < 0) y += sy;
1301 gdk_window_move(widget->window, x, y);
1302 gdk_window_raise(widget->window);
1303 break;
1304 case SEPARATE_BOTH:
1305 widget = mainwin->win.sep_both.folderwin;
1306 gdk_window_get_origin(widget->window, &x, &y);
1307 x %= sx; if (x < 0) x += sx;
1308 y %= sy; if (y < 0) y += sy;
1309 gdk_window_move(widget->window, x, y);
1310 gdk_window_raise(widget->window);
1311 widget = mainwin->win.sep_both.messagewin;
1312 gdk_window_get_origin(widget->window, &x, &y);
1313 x %= sx; if (x < 0) x += sx;
1314 y %= sy; if (y < 0) y += sy;
1315 gdk_window_move(widget->window, x, y);
1316 gdk_window_raise(widget->window);
1317 break;
1318 default:
1319 break;
1323 static void main_window_set_widgets(MainWindow *mainwin, SeparateType type)
1325 GtkWidget *folderwin = NULL;
1326 GtkWidget *messagewin = NULL;
1327 GtkWidget *hpaned;
1328 GtkWidget *vpaned;
1329 GtkWidget *vbox_body = mainwin->vbox_body;
1331 debug_print(_("Setting widgets..."));
1333 /* create separated window(s) if needed */
1334 if (type & SEPARATE_FOLDER) {
1335 folderwin = gtk_window_new(GTK_WINDOW_TOPLEVEL);
1336 gtk_window_set_policy(GTK_WINDOW(folderwin),
1337 TRUE, TRUE, FALSE);
1338 gtk_widget_set_usize(folderwin, -1,
1339 prefs_common.mainview_height);
1340 gtk_container_set_border_width(GTK_CONTAINER(folderwin),
1341 BORDER_WIDTH);
1342 gtk_signal_connect(GTK_OBJECT(folderwin), "delete_event",
1343 GTK_SIGNAL_FUNC(gtk_widget_hide_on_delete),
1344 NULL);
1346 if (type & SEPARATE_MESSAGE) {
1347 messagewin = gtk_window_new(GTK_WINDOW_TOPLEVEL);
1348 gtk_window_set_policy(GTK_WINDOW(messagewin),
1349 TRUE, TRUE, FALSE);
1350 gtk_widget_set_usize
1351 (messagewin, prefs_common.mainview_width,
1352 prefs_common.mainview_height
1353 - prefs_common.summaryview_height
1354 + DEFAULT_HEADERVIEW_HEIGHT);
1355 gtk_container_set_border_width(GTK_CONTAINER(messagewin),
1356 BORDER_WIDTH);
1357 gtk_signal_connect(GTK_OBJECT(messagewin), "delete_event",
1358 GTK_SIGNAL_FUNC(gtk_widget_hide_on_delete),
1359 NULL);
1362 switch (type) {
1363 case SEPARATE_NONE:
1364 hpaned = gtk_hpaned_new();
1365 gtk_widget_show(hpaned);
1366 gtk_box_pack_start(GTK_BOX(vbox_body), hpaned, TRUE, TRUE, 0);
1367 gtk_paned_add1(GTK_PANED(hpaned),
1368 GTK_WIDGET_PTR(mainwin->folderview));
1370 vpaned = gtk_vpaned_new();
1371 if (mainwin->summaryview->msg_is_toggled_on) {
1372 gtk_paned_add2(GTK_PANED(hpaned), vpaned);
1373 gtk_paned_add1(GTK_PANED(vpaned),
1374 GTK_WIDGET_PTR(mainwin->summaryview));
1375 } else {
1376 gtk_paned_add2(GTK_PANED(hpaned),
1377 GTK_WIDGET_PTR(mainwin->summaryview));
1378 gtk_widget_ref(vpaned);
1380 gtk_widget_set_usize(GTK_WIDGET_PTR(mainwin->summaryview),
1381 prefs_common.summaryview_width,
1382 prefs_common.summaryview_height);
1383 gtk_paned_add2(GTK_PANED(vpaned),
1384 GTK_WIDGET_PTR(mainwin->messageview));
1385 gtk_widget_set_usize(GTK_WIDGET_PTR(mainwin->messageview),
1386 prefs_common.mainview_width, -1);
1387 gtk_widget_set_usize(mainwin->window,
1388 prefs_common.folderview_width +
1389 prefs_common.mainview_width,
1390 prefs_common.mainwin_height);
1391 gtk_widget_show_all(vpaned);
1393 mainwin->win.sep_none.hpaned = hpaned;
1394 mainwin->win.sep_none.vpaned = vpaned;
1395 break;
1396 case SEPARATE_FOLDER:
1397 vpaned = gtk_vpaned_new();
1398 if (mainwin->summaryview->msg_is_toggled_on) {
1399 gtk_box_pack_start(GTK_BOX(vbox_body), vpaned,
1400 TRUE, TRUE, 0);
1401 gtk_paned_add1(GTK_PANED(vpaned),
1402 GTK_WIDGET_PTR(mainwin->summaryview));
1403 } else {
1404 gtk_box_pack_start(GTK_BOX(vbox_body),
1405 GTK_WIDGET_PTR(mainwin->summaryview),
1406 TRUE, TRUE, 0);
1407 gtk_widget_ref(vpaned);
1409 gtk_paned_add2(GTK_PANED(vpaned),
1410 GTK_WIDGET_PTR(mainwin->messageview));
1411 gtk_widget_show_all(vpaned);
1412 gtk_widget_set_usize(GTK_WIDGET_PTR(mainwin->summaryview),
1413 prefs_common.summaryview_width,
1414 prefs_common.summaryview_height);
1415 gtk_widget_set_usize(GTK_WIDGET_PTR(mainwin->messageview),
1416 prefs_common.mainview_width, -1);
1417 gtk_widget_set_usize(mainwin->window,
1418 prefs_common.mainview_width,
1419 prefs_common.mainview_height);
1421 gtk_container_add(GTK_CONTAINER(folderwin),
1422 GTK_WIDGET_PTR(mainwin->folderview));
1424 mainwin->win.sep_folder.folderwin = folderwin;
1425 mainwin->win.sep_folder.vpaned = vpaned;
1427 gtk_widget_show_all(folderwin);
1428 break;
1429 case SEPARATE_MESSAGE:
1430 hpaned = gtk_hpaned_new();
1431 gtk_box_pack_start(GTK_BOX(vbox_body), hpaned, TRUE, TRUE, 0);
1433 gtk_paned_add1(GTK_PANED(hpaned),
1434 GTK_WIDGET_PTR(mainwin->folderview));
1435 gtk_paned_add2(GTK_PANED(hpaned),
1436 GTK_WIDGET_PTR(mainwin->summaryview));
1437 gtk_widget_set_usize(GTK_WIDGET_PTR(mainwin->summaryview),
1438 prefs_common.summaryview_width,
1439 prefs_common.summaryview_height);
1440 gtk_widget_set_usize(mainwin->window,
1441 prefs_common.folderview_width +
1442 prefs_common.mainview_width,
1443 prefs_common.mainwin_height);
1444 gtk_widget_show_all(hpaned);
1445 gtk_container_add(GTK_CONTAINER(messagewin),
1446 GTK_WIDGET_PTR(mainwin->messageview));
1448 mainwin->win.sep_message.messagewin = messagewin;
1449 mainwin->win.sep_message.hpaned = hpaned;
1451 gtk_widget_show_all(messagewin);
1452 break;
1453 case SEPARATE_BOTH:
1454 gtk_box_pack_start(GTK_BOX(vbox_body),
1455 GTK_WIDGET_PTR(mainwin->summaryview),
1456 TRUE, TRUE, 0);
1457 gtk_widget_set_usize(GTK_WIDGET_PTR(mainwin->summaryview),
1458 prefs_common.summaryview_width,
1459 prefs_common.summaryview_height);
1460 gtk_widget_set_usize(mainwin->window,
1461 prefs_common.mainview_width,
1462 prefs_common.mainwin_height);
1463 gtk_container_add(GTK_CONTAINER(folderwin),
1464 GTK_WIDGET_PTR(mainwin->folderview));
1465 gtk_container_add(GTK_CONTAINER(messagewin),
1466 GTK_WIDGET_PTR(mainwin->messageview));
1468 mainwin->win.sep_both.folderwin = folderwin;
1469 mainwin->win.sep_both.messagewin = messagewin;
1471 gtk_widget_show_all(folderwin);
1472 gtk_widget_show_all(messagewin);
1473 break;
1476 mainwin->type = type;
1478 debug_print(_("done.\n"));
1481 #include "pixmaps/stock_mail_receive.xpm"
1482 #include "pixmaps/stock_mail_receive_all.xpm"
1483 #include "pixmaps/stock_mail_compose.xpm"
1484 #include "pixmaps/stock_news_compose.xpm"
1485 #include "pixmaps/stock_mail_reply.xpm"
1486 #include "pixmaps/stock_mail_reply_to_all.xpm"
1487 #include "pixmaps/stock_mail_reply_to_author.xpm"
1488 #include "pixmaps/stock_mail_forward.xpm"
1489 #include "pixmaps/stock_mail_send.xpm"
1490 #include "pixmaps/stock_preferences.xpm"
1491 #include "pixmaps/stock_properties.xpm"
1492 #include "pixmaps/stock_down_arrow.xpm"
1493 #include "pixmaps/stock_close.xpm"
1494 #include "pixmaps/stock_exec.xpm"
1496 #define CREATE_TOOLBAR_ICON(xpm_d) \
1498 icon = gdk_pixmap_create_from_xpm_d(container->window, &mask, \
1499 &container->style->white, \
1500 xpm_d); \
1501 icon_wid = gtk_pixmap_new(icon, mask); \
1504 static void main_window_toolbar_create(MainWindow *mainwin,
1505 GtkWidget *container)
1507 GtkWidget *toolbar;
1508 GdkPixmap *icon;
1509 GdkBitmap *mask;
1510 GtkWidget *icon_wid;
1511 GtkWidget *get_btn;
1512 GtkWidget *getall_btn;
1513 GtkWidget *compose_mail_btn;
1514 GtkWidget *compose_news_btn;
1515 GtkWidget *compose_mail_btn_plain;
1516 GtkWidget *compose_news_btn_plain;
1517 GtkWidget *reply_btn;
1518 GtkWidget *replyall_btn;
1519 GtkWidget *replysender_btn;
1520 GtkWidget *fwd_btn;
1521 GtkWidget *send_btn;
1523 GtkWidget *prefs_btn;
1524 GtkWidget *account_btn;
1526 GtkWidget *next_btn;
1527 GtkWidget *delete_btn;
1528 GtkWidget *exec_btn;
1529 GtkWidget *compose_type_btn;
1530 GtkWidget *compose_type_arrow;
1531 GtkWidget *compose_box;
1532 GtkWidget *compose_label;
1533 GtkTooltips *tooltips;
1535 toolbar = gtk_toolbar_new(GTK_ORIENTATION_HORIZONTAL,
1536 GTK_TOOLBAR_BOTH);
1537 gtk_container_add(GTK_CONTAINER(container), toolbar);
1538 gtk_container_set_border_width(GTK_CONTAINER(container), 2);
1539 gtk_toolbar_set_button_relief(GTK_TOOLBAR(toolbar), GTK_RELIEF_NONE);
1540 gtk_toolbar_set_space_style(GTK_TOOLBAR(toolbar),
1541 GTK_TOOLBAR_SPACE_LINE);
1543 CREATE_TOOLBAR_ICON(stock_mail_receive_xpm);
1544 get_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
1545 _("Get"),
1546 _("Get new mail from current account"),
1547 "Get",
1548 icon_wid, toolbar_inc_cb, mainwin);
1549 CREATE_TOOLBAR_ICON(stock_mail_receive_all_xpm);
1550 getall_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
1551 _("Get all"),
1552 _("Get new mail from all accounts"),
1553 "Get all",
1554 icon_wid,
1555 toolbar_inc_all_cb,
1556 mainwin);
1558 gtk_toolbar_append_space(GTK_TOOLBAR(toolbar));
1560 CREATE_TOOLBAR_ICON(stock_mail_send_xpm);
1561 send_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
1562 _("Send"),
1563 _("Send queued message(s)"),
1564 "Send",
1565 icon_wid,
1566 toolbar_send_cb,
1567 mainwin);
1569 /* to implement Leandro's "combined" compose buttons, we create
1570 * two sets of compose buttons, one for normal (text + icon)
1571 * toolbar, and one for both text-only and icon-only toolbar;
1572 * we switch between those sets. */
1574 /* insert compose mail button widget */
1576 compose_mail_btn = gtk_button_new();
1577 gtk_widget_show(compose_mail_btn);
1578 tooltips = gtk_tooltips_new();
1579 gtk_tooltips_set_tip(tooltips, compose_mail_btn,
1580 _("Compose email message"),
1581 _("email"));
1582 compose_box = gtk_vbox_new(0, 0);
1583 gtk_widget_show(compose_box);
1585 gtk_container_add(GTK_CONTAINER(compose_mail_btn), compose_box);
1586 CREATE_TOOLBAR_ICON(stock_mail_compose_xpm);
1587 gtk_box_pack_start(GTK_BOX(compose_box), icon_wid, FALSE, FALSE, 0);
1589 compose_label = gtk_label_new(_("Email"));
1590 gtk_widget_show(compose_label);
1591 gtk_box_pack_start(GTK_BOX(compose_box), compose_label, FALSE, FALSE, 0);
1593 GTK_WIDGET_UNSET_FLAGS(GTK_WIDGET(compose_mail_btn), GTK_CAN_FOCUS);
1594 gtk_button_set_relief(GTK_BUTTON(compose_mail_btn), GTK_RELIEF_NONE);
1595 gtk_toolbar_append_widget(GTK_TOOLBAR(toolbar), compose_mail_btn,
1596 NULL, NULL);
1598 /* insert compose news button widget */
1600 compose_news_btn = gtk_button_new();
1601 gtk_widget_show(compose_news_btn);
1602 tooltips = gtk_tooltips_new();
1603 gtk_tooltips_set_tip(tooltips, compose_news_btn,
1604 _("Compose news article"),
1605 _("news"));
1606 compose_box = gtk_vbox_new(0, 0);
1607 gtk_widget_show(compose_box);
1609 gtk_container_add(GTK_CONTAINER(compose_news_btn), compose_box);
1610 CREATE_TOOLBAR_ICON(stock_news_compose_xpm);
1611 gtk_box_pack_start(GTK_BOX(compose_box), icon_wid, FALSE, FALSE, 0);
1613 compose_label = gtk_label_new(_("News"));
1614 gtk_widget_show(compose_label);
1615 gtk_box_pack_start(GTK_BOX(compose_box), compose_label, FALSE, FALSE, 0);
1617 GTK_WIDGET_UNSET_FLAGS(GTK_WIDGET(compose_news_btn), GTK_CAN_FOCUS);
1618 gtk_button_set_relief(GTK_BUTTON(compose_news_btn), GTK_RELIEF_NONE);
1619 gtk_toolbar_append_widget(GTK_TOOLBAR(toolbar), compose_news_btn,
1620 NULL, NULL);
1622 /* insert compose btn plain */
1624 CREATE_TOOLBAR_ICON(stock_mail_compose_xpm);
1625 compose_mail_btn_plain = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
1626 _("Email"),
1627 _("Compose an email message"),
1628 "New",
1629 icon_wid,
1630 toolbar_compose_mail_cb,
1631 mainwin);
1633 /* insert compose btn plain */
1635 CREATE_TOOLBAR_ICON(stock_news_compose_xpm);
1636 compose_news_btn_plain = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
1637 _("News"),
1638 _("Compose a news message"),
1639 "New",
1640 icon_wid,
1641 toolbar_compose_news_cb,
1642 mainwin);
1644 /* insert compose button type widget */
1646 compose_type_btn = gtk_button_new();
1647 gtk_widget_show(compose_type_btn);
1649 compose_type_arrow = gtk_arrow_new(GTK_ARROW_DOWN, GTK_SHADOW_OUT);
1650 gtk_widget_show(compose_type_arrow);
1652 gtk_container_add(GTK_CONTAINER(compose_type_btn), compose_type_arrow);
1654 GTK_WIDGET_UNSET_FLAGS(GTK_WIDGET(compose_type_btn), GTK_CAN_FOCUS);
1655 gtk_button_set_relief(GTK_BUTTON(compose_type_btn), GTK_RELIEF_NONE);
1657 gtk_toolbar_append_widget(GTK_TOOLBAR(toolbar), compose_type_btn,
1658 NULL, NULL);
1660 gtk_toolbar_append_space(GTK_TOOLBAR(toolbar));
1662 CREATE_TOOLBAR_ICON(stock_mail_reply_xpm);
1663 reply_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
1664 _("Reply"),
1665 _("Reply to the message"),
1666 "Reply",
1667 icon_wid,
1668 toolbar_reply_cb,
1669 mainwin);
1670 CREATE_TOOLBAR_ICON(stock_mail_reply_to_all_xpm);
1671 replyall_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
1672 _("All"),
1673 _("Reply to all"),
1674 "Reply to all",
1675 icon_wid,
1676 toolbar_reply_to_all_cb,
1677 mainwin);
1678 CREATE_TOOLBAR_ICON(stock_mail_reply_to_author_xpm);
1679 replysender_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
1680 _("Sender"),
1681 _("Reply to sender"),
1682 "Reply to sender",
1683 icon_wid,
1684 toolbar_reply_to_sender_cb,
1685 mainwin);
1686 CREATE_TOOLBAR_ICON(stock_mail_forward_xpm);
1687 fwd_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
1688 _("Forward"),
1689 _("Forward the message"),
1690 "Fwd",
1691 icon_wid,
1692 toolbar_forward_cb,
1693 mainwin);
1695 gtk_toolbar_append_space(GTK_TOOLBAR(toolbar));
1697 CREATE_TOOLBAR_ICON(stock_close_xpm);
1698 delete_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
1699 _("Delete"),
1700 _("Delete the message"),
1701 "Delete",
1702 icon_wid,
1703 toolbar_delete_cb,
1704 mainwin);
1706 CREATE_TOOLBAR_ICON(stock_exec_xpm);
1707 exec_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
1708 _("Execute"),
1709 _("Execute marked process"),
1710 "Execute",
1711 icon_wid,
1712 toolbar_exec_cb,
1713 mainwin);
1715 CREATE_TOOLBAR_ICON(stock_down_arrow_xpm);
1716 next_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
1717 _("Next"),
1718 _("Next unread message"),
1719 "Next unread",
1720 icon_wid,
1721 toolbar_next_unread_cb,
1722 mainwin);
1725 gtk_toolbar_append_space(GTK_TOOLBAR(toolbar));
1727 CREATE_TOOLBAR_ICON(stock_preferences_xpm);
1728 prefs_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
1729 _("Prefs"),
1730 _("Common preference"),
1731 "Prefs",
1732 icon_wid,
1733 toolbar_prefs_cb,
1734 mainwin);
1735 CREATE_TOOLBAR_ICON(stock_properties_xpm);
1736 account_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
1737 _("Account"),
1738 _("Account setting"),
1739 "Account",
1740 icon_wid,
1741 toolbar_account_cb,
1742 mainwin);
1743 gtk_signal_connect(GTK_OBJECT(account_btn), "button_press_event",
1744 GTK_SIGNAL_FUNC(toolbar_account_button_pressed),
1745 mainwin);
1748 gtk_signal_connect(GTK_OBJECT(compose_type_btn), "clicked",
1749 GTK_SIGNAL_FUNC(toolbar_popup_compose_type_cb),
1750 mainwin);
1752 gtk_signal_connect(GTK_OBJECT(compose_mail_btn), "clicked",
1753 GTK_SIGNAL_FUNC(toolbar_compose_mail_cb),
1754 mainwin);
1756 gtk_signal_connect(GTK_OBJECT(compose_news_btn), "clicked",
1757 GTK_SIGNAL_FUNC(toolbar_compose_news_cb),
1758 mainwin);
1760 mainwin->toolbar = toolbar;
1761 mainwin->get_btn = get_btn;
1762 mainwin->getall_btn = getall_btn;
1763 mainwin->compose_mail_btn = compose_mail_btn;
1764 mainwin->compose_news_btn = compose_news_btn;
1765 mainwin->compose_mail_btn_plain = compose_mail_btn_plain;
1766 mainwin->compose_news_btn_plain = compose_news_btn_plain;
1767 mainwin->reply_btn = reply_btn;
1768 mainwin->replyall_btn = replyall_btn;
1769 mainwin->replysender_btn = replysender_btn;
1770 mainwin->fwd_btn = fwd_btn;
1771 mainwin->send_btn = send_btn;
1773 mainwin->prefs_btn = prefs_btn;
1774 mainwin->account_btn = account_btn;
1776 mainwin->next_btn = next_btn;
1777 mainwin->delete_btn = delete_btn;
1778 mainwin->exec_btn = exec_btn;
1780 gtk_widget_show_all(toolbar);
1782 /* activate Leandro menu system */
1783 activate_compose_button(mainwin,
1784 prefs_common.toolbar_style,
1785 mainwin->compose_btn_type);
1788 /* callback functions */
1790 static void toolbar_popup_compose_type_cb (GtkWidget *widget,
1791 gpointer data)
1793 MainWindow *mainwindow = (MainWindow *) data;
1794 GtkWidget *compose_menu, *compose_item;
1796 g_return_if_fail(mainwindow != NULL);
1798 compose_menu = gtk_menu_new();
1800 compose_item = gtk_menu_item_new_with_label(_("Email message"));
1801 gtk_widget_show(compose_item);
1802 gtk_menu_append(GTK_MENU(compose_menu), compose_item);
1803 gtk_signal_connect(GTK_OBJECT(compose_item), "activate",
1804 GTK_SIGNAL_FUNC(toolbar_popup_compose_type_set),
1805 mainwindow);
1806 gtk_object_set_data(GTK_OBJECT(compose_item), "entry", GINT_TO_POINTER(COMPOSEBUTTON_MAIL));
1808 compose_item = gtk_menu_item_new_with_label(_("News article"));
1809 gtk_widget_show(compose_item);
1810 gtk_menu_append(GTK_MENU(compose_menu), compose_item);
1811 gtk_signal_connect(GTK_OBJECT(compose_item), "activate",
1812 GTK_SIGNAL_FUNC(toolbar_popup_compose_type_set),
1813 mainwindow);
1814 gtk_object_set_data(GTK_OBJECT(compose_item), "entry", GINT_TO_POINTER(COMPOSEBUTTON_NEWS));
1816 gtk_menu_popup(GTK_MENU(compose_menu), NULL, NULL, NULL,
1817 NULL, 1, 0);
1820 static void toolbar_popup_compose_type_set(GtkWidget *widget, gpointer data)
1822 ComposeButtonType compose_type = GPOINTER_TO_INT( gtk_object_get_data(GTK_OBJECT(widget), "entry") );
1823 MainWindow *mainwindow = (MainWindow *) data;
1825 mainwindow->compose_btn_type = compose_type;
1827 activate_compose_button(mainwindow, prefs_common.toolbar_style, mainwindow->compose_btn_type);
1830 static void toolbar_inc_cb (GtkWidget *widget,
1831 gpointer data)
1833 MainWindow *mainwin = (MainWindow *)data;
1835 inc_mail_cb(mainwin, 0, NULL);
1838 static void toolbar_inc_all_cb (GtkWidget *widget,
1839 gpointer data)
1841 MainWindow *mainwin = (MainWindow *)data;
1843 inc_all_account_mail_cb(mainwin, 0, NULL);
1846 static void toolbar_send_cb (GtkWidget *widget,
1847 gpointer data)
1849 MainWindow *mainwin = (MainWindow *)data;
1851 send_queue_cb(mainwin, 0, NULL);
1854 static void toolbar_compose_cb (GtkWidget *widget,
1855 gpointer data)
1857 MainWindow *mainwin = (MainWindow *)data;
1859 if (mainwin->compose_btn_type == COMPOSEBUTTON_MAIL)
1860 compose_cb(mainwin, 0, NULL);
1861 else
1862 compose_news_cb(mainwin, 0, NULL);
1865 static void toolbar_compose_news_cb (GtkWidget *widget,
1866 gpointer data)
1868 MainWindow *mainwin = (MainWindow *)data;
1870 compose_news_cb(mainwin, 0, NULL);
1873 static void toolbar_compose_mail_cb (GtkWidget *widget,
1874 gpointer data)
1876 MainWindow *mainwin = (MainWindow *)data;
1878 compose_mail_cb(mainwin, 0, NULL);
1881 static void toolbar_reply_cb (GtkWidget *widget,
1882 gpointer data)
1884 MainWindow *mainwin = (MainWindow *)data;
1886 reply_cb(mainwin, COMPOSE_REPLY, NULL);
1889 static void toolbar_reply_to_all_cb (GtkWidget *widget,
1890 gpointer data)
1892 MainWindow *mainwin = (MainWindow *)data;
1894 reply_cb(mainwin, COMPOSE_REPLY_TO_ALL, NULL);
1897 static void toolbar_reply_to_sender_cb (GtkWidget *widget,
1898 gpointer data)
1900 MainWindow *mainwin = (MainWindow *)data;
1902 reply_cb(mainwin, COMPOSE_REPLY_TO_SENDER, NULL);
1905 static void toolbar_forward_cb (GtkWidget *widget,
1906 gpointer data)
1908 MainWindow *mainwin = (MainWindow *)data;
1910 if (prefs_common.forward_as_attachment)
1911 reply_cb(mainwin, COMPOSE_FORWARD_AS_ATTACH, NULL);
1912 else
1913 reply_cb(mainwin, COMPOSE_FORWARD, NULL);
1916 static void toolbar_delete_cb (GtkWidget *widget,
1917 gpointer data)
1919 MainWindow *mainwin = (MainWindow *)data;
1921 summary_delete(mainwin->summaryview);
1924 static void toolbar_exec_cb (GtkWidget *widget,
1925 gpointer data)
1927 MainWindow *mainwin = (MainWindow *)data;
1929 summary_execute(mainwin->summaryview);
1932 static void toolbar_next_unread_cb (GtkWidget *widget,
1933 gpointer data)
1935 MainWindow *mainwin = (MainWindow *)data;
1937 next_unread_cb(mainwin, 0, NULL);
1940 static void toolbar_prefs_cb (GtkWidget *widget,
1941 gpointer data)
1943 prefs_common_open();
1946 static void toolbar_account_cb (GtkWidget *widget,
1947 gpointer data)
1949 MainWindow *mainwin = (MainWindow *)data;
1951 prefs_account_open_cb(mainwin, 0, NULL);
1954 static void toolbar_account_button_pressed(GtkWidget *widget,
1955 GdkEventButton *event,
1956 gpointer data)
1958 MainWindow *mainwin = (MainWindow *)data;
1960 if (!event) return;
1961 if (event->button != 3) return;
1963 gtk_button_set_relief(GTK_BUTTON(widget), GTK_RELIEF_NORMAL);
1964 gtk_object_set_data(GTK_OBJECT(mainwin->ac_menu), "menu_button",
1965 widget);
1967 gtk_menu_popup(GTK_MENU(mainwin->ac_menu), NULL, NULL,
1968 menu_button_position, widget,
1969 event->button, event->time);
1972 static void ac_label_button_pressed(GtkWidget *widget, GdkEventButton *event,
1973 gpointer data)
1975 MainWindow *mainwin = (MainWindow *)data;
1977 if (!event) return;
1979 gtk_button_set_relief(GTK_BUTTON(widget), GTK_RELIEF_NORMAL);
1980 gtk_object_set_data(GTK_OBJECT(mainwin->ac_menu), "menu_button",
1981 widget);
1983 gtk_menu_popup(GTK_MENU(mainwin->ac_menu), NULL, NULL,
1984 menu_button_position, widget,
1985 event->button, event->time);
1988 static void ac_menu_popup_closed(GtkMenuShell *menu_shell, gpointer data)
1990 MainWindow *mainwin = (MainWindow *)data;
1991 GtkWidget *button;
1993 button = gtk_object_get_data(GTK_OBJECT(menu_shell), "menu_button");
1994 gtk_button_set_relief(GTK_BUTTON(button), GTK_RELIEF_NONE);
1995 gtk_object_remove_data(GTK_OBJECT(mainwin->ac_menu), "menu_button");
1998 static gint main_window_close_cb(GtkWidget *widget, GdkEventAny *event,
1999 gpointer data)
2001 app_exit_cb(data, 0, widget);
2003 return TRUE;
2006 static void add_mailbox_cb(MainWindow *mainwin, guint action,
2007 GtkWidget *widget)
2009 main_window_add_mailbox(mainwin);
2012 static void add_mbox_cb(MainWindow *mainwin, guint action,
2013 GtkWidget *widget)
2015 main_window_add_mbox(mainwin);
2018 static void update_folderview_cb(MainWindow *mainwin, guint action,
2019 GtkWidget *widget)
2021 summary_show(mainwin->summaryview, NULL, FALSE);
2022 folderview_update_all();
2025 static void new_folder_cb(MainWindow *mainwin, guint action,
2026 GtkWidget *widget)
2028 folderview_new_folder(mainwin->folderview);
2031 static void rename_folder_cb(MainWindow *mainwin, guint action,
2032 GtkWidget *widget)
2034 folderview_rename_folder(mainwin->folderview);
2037 static void delete_folder_cb(MainWindow *mainwin, guint action,
2038 GtkWidget *widget)
2040 folderview_delete_folder(mainwin->folderview);
2043 static void import_mbox_cb(MainWindow *mainwin, guint action,
2044 GtkWidget *widget)
2046 import_mbox(mainwin->summaryview->folder_item);
2049 static void export_mbox_cb(MainWindow *mainwin, guint action,
2050 GtkWidget *widget)
2052 export_mbox(mainwin->summaryview->folder_item);
2055 static void empty_trash_cb(MainWindow *mainwin, guint action,
2056 GtkWidget *widget)
2058 main_window_empty_trash(mainwin, TRUE);
2061 static void save_as_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2063 summary_save_as(mainwin->summaryview);
2066 static void print_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2068 summary_print(mainwin->summaryview);
2071 static void app_exit_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2073 if (prefs_common.confirm_on_exit) {
2074 if (alertpanel(_("Exit"), _("Exit this program?"),
2075 _("OK"), _("Cancel"), NULL) != G_ALERTDEFAULT)
2076 return;
2077 manage_window_focus_in(mainwin->window, NULL, NULL);
2080 app_will_exit(widget, mainwin);
2083 static void toggle_folder_cb(MainWindow *mainwin, guint action,
2084 GtkWidget *widget)
2086 switch (mainwin->type) {
2087 case SEPARATE_NONE:
2088 case SEPARATE_MESSAGE:
2089 break;
2090 case SEPARATE_FOLDER:
2091 if (GTK_CHECK_MENU_ITEM(widget)->active)
2092 gtk_widget_show(mainwin->win.sep_folder.folderwin);
2093 else
2094 gtk_widget_hide(mainwin->win.sep_folder.folderwin);
2095 break;
2096 case SEPARATE_BOTH:
2097 if (GTK_CHECK_MENU_ITEM(widget)->active)
2098 gtk_widget_show(mainwin->win.sep_both.folderwin);
2099 else
2100 gtk_widget_hide(mainwin->win.sep_both.folderwin);
2101 break;
2105 static void toggle_message_cb(MainWindow *mainwin, guint action,
2106 GtkWidget *widget)
2108 switch (mainwin->type) {
2109 case SEPARATE_NONE:
2110 case SEPARATE_FOLDER:
2111 break;
2112 case SEPARATE_MESSAGE:
2113 if (GTK_CHECK_MENU_ITEM(widget)->active)
2114 gtk_widget_show(mainwin->win.sep_message.messagewin);
2115 else
2116 gtk_widget_hide(mainwin->win.sep_message.messagewin);
2117 break;
2118 case SEPARATE_BOTH:
2119 if (GTK_CHECK_MENU_ITEM(widget)->active)
2120 gtk_widget_show(mainwin->win.sep_both.messagewin);
2121 else
2122 gtk_widget_hide(mainwin->win.sep_both.messagewin);
2123 break;
2127 static void toggle_toolbar_cb(MainWindow *mainwin, guint action,
2128 GtkWidget *widget)
2130 activate_compose_button(mainwin, (ToolbarStyle)action,
2131 mainwin->compose_btn_type);
2133 switch ((ToolbarStyle)action) {
2134 case TOOLBAR_NONE:
2135 gtk_widget_hide(mainwin->handlebox);
2136 case TOOLBAR_ICON:
2137 gtk_toolbar_set_style(GTK_TOOLBAR(mainwin->toolbar),
2138 GTK_TOOLBAR_ICONS);
2139 break;
2140 case TOOLBAR_TEXT:
2141 gtk_toolbar_set_style(GTK_TOOLBAR(mainwin->toolbar),
2142 GTK_TOOLBAR_TEXT);
2143 break;
2144 case TOOLBAR_BOTH:
2145 gtk_toolbar_set_style(GTK_TOOLBAR(mainwin->toolbar),
2146 GTK_TOOLBAR_BOTH);
2147 break;
2150 if (action != TOOLBAR_NONE) {
2151 gtk_widget_show(mainwin->handlebox);
2152 gtk_widget_queue_resize(mainwin->handlebox);
2155 mainwin->toolbar_style = (ToolbarStyle)action;
2156 prefs_common.toolbar_style = (ToolbarStyle)action;
2159 static void toggle_statusbar_cb(MainWindow *mainwin, guint action,
2160 GtkWidget *widget)
2162 if (GTK_CHECK_MENU_ITEM(widget)->active) {
2163 gtk_widget_show(mainwin->hbox_stat);
2164 prefs_common.show_statusbar = TRUE;
2165 } else {
2166 gtk_widget_hide(mainwin->hbox_stat);
2167 prefs_common.show_statusbar = FALSE;
2171 static void separate_widget_cb(GtkCheckMenuItem *checkitem, guint action, GtkWidget *widget)
2174 MainWindow *mainwin;
2175 SeparateType type;
2177 mainwin = (MainWindow *) gtk_object_get_data(GTK_OBJECT(checkitem), "mainwindow");
2178 g_return_if_fail(mainwin != NULL);
2180 type = mainwin->type ^ action;
2181 main_window_separation_change(mainwin, type);
2183 prefs_common.sep_folder = (type & SEPARATE_FOLDER) != 0;
2184 prefs_common.sep_msg = (type & SEPARATE_MESSAGE) != 0;
2187 static void addressbook_open_cb(MainWindow *mainwin, guint action,
2188 GtkWidget *widget)
2190 addressbook_open(NULL);
2193 static void log_window_show_cb(MainWindow *mainwin, guint action,
2194 GtkWidget *widget)
2196 log_window_show(mainwin->logwin);
2199 static void inc_mail_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2201 inc_mail(mainwin);
2204 static void inc_all_account_mail_cb(MainWindow *mainwin, guint action,
2205 GtkWidget *widget)
2207 inc_all_account_mail(mainwin);
2210 static void send_queue_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2212 GList *list;
2214 if (procmsg_send_queue() < 0)
2215 alertpanel_error(_("Sending queued message failed."));
2217 statusbar_pop_all();
2219 for (list = folder_get_list(); list != NULL; list = list->next) {
2220 Folder *folder;
2222 folder = list->data;
2223 if (folder->queue) {
2224 folder_item_scan(folder->queue);
2225 folderview_update_item(folder->queue, TRUE);
2230 static void compose_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2232 if (mainwin->summaryview->folder_item) {
2233 if (mainwin->summaryview->folder_item->folder->account != NULL
2234 && mainwin->summaryview->folder_item->folder->account->protocol == A_NNTP)
2235 compose_new_with_recipient(mainwin->summaryview->folder_item->folder->account, mainwin->summaryview->folder_item->path);
2236 else
2237 compose_new_with_folderitem(mainwin->summaryview->folder_item->folder->account, mainwin->summaryview->folder_item);
2239 else
2240 compose_new(NULL);
2243 static void compose_mail_cb(MainWindow *mainwin, guint action,
2244 GtkWidget *widget)
2246 PrefsAccount * ac;
2247 GList * list;
2248 GList * cur;
2250 if (mainwin->summaryview->folder_item) {
2251 ac = mainwin->summaryview->folder_item->folder->account;
2252 if (ac && ac->protocol != A_NNTP) {
2253 compose_new_with_folderitem(ac, mainwin->summaryview->folder_item);
2254 return;
2258 if(cur_account && (cur_account->protocol != A_NNTP)) {
2259 compose_new_with_folderitem(cur_account, mainwin->summaryview->folder_item);
2260 return;
2263 list = account_get_list();
2264 for(cur = list ; cur != NULL ; cur = g_list_next(cur)) {
2265 ac = (PrefsAccount *) cur->data;
2266 if (ac->protocol != A_NNTP) {
2267 compose_new_with_folderitem(ac, mainwin->summaryview->folder_item);
2268 return;
2273 static void compose_news_cb(MainWindow *mainwin, guint action,
2274 GtkWidget *widget)
2276 PrefsAccount * ac = NULL;
2277 GList * list;
2278 GList * cur;
2280 if (mainwin->summaryview->folder_item) {
2281 ac = mainwin->summaryview->folder_item->folder->account;
2282 if (ac && ac->protocol == A_NNTP) {
2283 compose_new_with_recipient
2284 (ac, mainwin->summaryview->folder_item->path);
2285 return;
2289 list = account_get_list();
2290 for(cur = list ; cur != NULL ; cur = g_list_next(cur)) {
2291 ac = (PrefsAccount *) cur->data;
2292 if (ac->protocol == A_NNTP) {
2293 compose_new(ac);
2294 return;
2299 static void reply_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2301 GList *sel = GTK_CLIST(mainwin->summaryview->ctree)->selection;
2302 MsgInfo *msginfo;
2304 msginfo = gtk_ctree_node_get_row_data
2305 (GTK_CTREE(mainwin->summaryview->ctree),
2306 mainwin->summaryview->selected);
2308 if (!msginfo) return;
2310 switch (action) {
2311 case COMPOSE_REPLY:
2312 compose_reply(msginfo, prefs_common.reply_with_quote,
2313 FALSE, FALSE);
2314 break;
2315 case COMPOSE_REPLY_TO_SENDER:
2316 compose_reply(msginfo, prefs_common.reply_with_quote,
2317 FALSE, TRUE);
2318 break;
2319 case COMPOSE_FOLLOWUP_AND_REPLY_TO:
2320 compose_followup_and_reply_to(msginfo,
2321 prefs_common.reply_with_quote,
2322 FALSE, TRUE);
2323 break;
2324 case COMPOSE_REPLY_TO_ALL:
2325 compose_reply(msginfo, prefs_common.reply_with_quote,
2326 TRUE, FALSE);
2327 break;
2328 case COMPOSE_FORWARD:
2329 if (!sel->next) {
2330 compose_forward(NULL, msginfo, FALSE);
2331 break;
2333 /* if (sel->next) FALL_THROUGH */
2334 case COMPOSE_FORWARD_AS_ATTACH:
2336 GSList *msginfo_list = NULL;
2337 for ( ; sel != NULL; sel = sel->next)
2338 msginfo_list = g_slist_append(msginfo_list,
2339 gtk_ctree_node_get_row_data(GTK_CTREE(mainwin->summaryview->ctree),
2340 GTK_CTREE_NODE(sel->data)));
2341 compose_forward_multiple(NULL, msginfo_list);
2342 g_slist_free(msginfo_list);
2344 break;
2345 default:
2346 g_warning("reply_cb(): invalid action type: %d\n", action);
2349 summary_set_marks_selected(mainwin->summaryview);
2352 static void move_to_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2354 summary_move_to(mainwin->summaryview);
2357 static void copy_to_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2359 summary_copy_to(mainwin->summaryview);
2362 static void delete_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2364 summary_delete(mainwin->summaryview);
2367 static void open_msg_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2369 summary_open_msg(mainwin->summaryview);
2372 static void view_source_cb(MainWindow *mainwin, guint action,
2373 GtkWidget *widget)
2375 summary_view_source(mainwin->summaryview);
2378 static void reedit_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2380 summary_reedit(mainwin->summaryview);
2383 static void mark_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2385 summary_mark(mainwin->summaryview);
2388 static void unmark_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2390 summary_unmark(mainwin->summaryview);
2393 static void mark_as_unread_cb(MainWindow *mainwin, guint action,
2394 GtkWidget *widget)
2396 summary_mark_as_unread(mainwin->summaryview);
2399 static void mark_as_read_cb(MainWindow *mainwin, guint action,
2400 GtkWidget *widget)
2402 summary_mark_as_read(mainwin->summaryview);
2405 static void set_charset_cb(MainWindow *mainwin, guint action,
2406 GtkWidget *widget)
2408 const gchar *str;
2410 str = conv_get_charset_str((CharSet)action);
2411 g_free(prefs_common.force_charset);
2412 prefs_common.force_charset = str ? g_strdup(str) : NULL;
2414 summary_redisplay_msg(mainwin->summaryview);
2416 debug_print(_("forced charset: %s\n"), str ? str : "Auto-Detect");
2419 /*void main_window_set_thread_option(MainWindow *mainwin)
2421 GtkItemFactory *ifactory;
2422 gboolean no_item = FALSE;
2424 ifactory = gtk_item_factory_from_widget(mainwin->menubar);
2426 if (mainwin->summaryview == NULL)
2427 no_item = TRUE;
2428 else if (mainwin->summaryview->folder_item == NULL)
2429 no_item = TRUE;
2431 if (no_item) {
2432 menu_set_sensitive(ifactory, "/Summary/Thread view", FALSE);
2433 menu_set_sensitive(ifactory, "/Summary/Unthread view", FALSE);
2435 else {
2436 if (mainwin->summaryview->folder_item->prefs->enable_thread) {
2437 menu_set_sensitive(ifactory,
2438 "/Summary/Thread view", FALSE);
2439 menu_set_sensitive(ifactory,
2440 "/Summary/Unthread view", TRUE);
2441 summary_thread_build(mainwin->summaryview, TRUE);
2443 else {
2444 menu_set_sensitive(ifactory,
2445 "/Summary/Thread view", TRUE);
2446 menu_set_sensitive(ifactory,
2447 "/Summary/Unthread view", FALSE);
2448 summary_unthread(mainwin->summaryview);
2450 prefs_folder_item_save_config(mainwin->summaryview->folder_item);
2454 static void thread_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2456 /*mainwin->summaryview->folder_item->prefs->enable_thread =
2457 !mainwin->summaryview->folder_item->prefs->enable_thread;
2458 main_window_set_thread_option(mainwin);
2461 GtkItemFactory *ifactory;
2463 ifactory = gtk_item_factory_from_widget(widget);
2465 if (0 == action) {
2466 summary_thread_build(mainwin->summaryview, FALSE);
2467 prefs_common.enable_thread = TRUE;
2468 menu_set_sensitive(ifactory, "/Summary/Thread view", FALSE);
2469 menu_set_sensitive(ifactory, "/Summary/Unthread view", TRUE);
2470 } else {
2471 summary_unthread(mainwin->summaryview);
2472 prefs_common.enable_thread = FALSE;
2473 menu_set_sensitive(ifactory, "/Summary/Thread view", TRUE);
2474 menu_set_sensitive(ifactory, "/Summary/Unthread view", FALSE);
2478 static void set_display_item_cb(MainWindow *mainwin, guint action,
2479 GtkWidget *widget)
2481 prefs_summary_display_item_set();
2484 static void sort_summary_cb(MainWindow *mainwin, guint action,
2485 GtkWidget *widget)
2487 summary_sort(mainwin->summaryview, (SummarySortType)action);
2490 static void attract_by_subject_cb(MainWindow *mainwin, guint action,
2491 GtkWidget *widget)
2493 summary_attract_by_subject(mainwin->summaryview);
2496 static void delete_duplicated_cb(MainWindow *mainwin, guint action,
2497 GtkWidget *widget)
2499 summary_delete_duplicated(mainwin->summaryview);
2502 static void filter_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2504 summary_filter(mainwin->summaryview);
2507 static void execute_summary_cb(MainWindow *mainwin, guint action,
2508 GtkWidget *widget)
2510 summary_execute(mainwin->summaryview);
2513 static void update_summary_cb(MainWindow *mainwin, guint action,
2514 GtkWidget *widget)
2516 FolderItem *fitem;
2517 FolderView *folderview = mainwin->folderview;
2519 if (!mainwin->summaryview->folder_item) return;
2520 if (!folderview->opened) return;
2522 folder_update_op_count();
2524 fitem = gtk_ctree_node_get_row_data(GTK_CTREE(folderview->ctree),
2525 folderview->opened);
2526 if (!fitem) return;
2528 summary_show(mainwin->summaryview, fitem, TRUE);
2531 static void prev_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2533 summary_step(mainwin->summaryview, GTK_SCROLL_STEP_BACKWARD);
2536 static void next_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2538 summary_step(mainwin->summaryview, GTK_SCROLL_STEP_FORWARD);
2541 static void next_unread_cb(MainWindow *mainwin, guint action,
2542 GtkWidget *widget)
2544 summary_select_next_unread(mainwin->summaryview);
2547 static void next_marked_cb(MainWindow *mainwin, guint action,
2548 GtkWidget *widget)
2550 summary_select_next_marked(mainwin->summaryview);
2553 static void prev_marked_cb(MainWindow *mainwin, guint action,
2554 GtkWidget *widget)
2556 summary_select_prev_marked(mainwin->summaryview);
2559 static void goto_folder_cb(MainWindow *mainwin, guint action,
2560 GtkWidget *widget)
2562 FolderItem *to_folder;
2564 to_folder = foldersel_folder_sel(NULL, NULL);
2566 if (to_folder)
2567 folderview_select(mainwin->folderview, to_folder);
2570 static void copy_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2572 messageview_copy_clipboard(mainwin->messageview);
2575 static void allsel_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2577 if (GTK_WIDGET_HAS_FOCUS(mainwin->summaryview->ctree))
2578 summary_select_all(mainwin->summaryview);
2579 else if (mainwin->summaryview->msg_is_toggled_on &&
2580 GTK_WIDGET_HAS_FOCUS(mainwin->messageview->textview->text))
2581 messageview_select_all(mainwin->messageview);
2584 static void prefs_common_open_cb(MainWindow *mainwin, guint action,
2585 GtkWidget *widget)
2587 prefs_common_open();
2590 static void prefs_filter_open_cb(MainWindow *mainwin, guint action,
2591 GtkWidget *widget)
2593 prefs_filter_open();
2596 static void prefs_scoring_open_cb(MainWindow *mainwin, guint action,
2597 GtkWidget *widget)
2599 prefs_scoring_open(NULL);
2602 static void prefs_filtering_open_cb(MainWindow *mainwin, guint action,
2603 GtkWidget *widget)
2605 prefs_filtering_open();
2608 static void prefs_account_open_cb(MainWindow *mainwin, guint action,
2609 GtkWidget *widget)
2611 if (!cur_account) {
2612 new_account_cb(mainwin, 0, widget);
2613 } else {
2614 gboolean prev_default = cur_account->is_default;
2616 prefs_account_open(cur_account);
2617 if (!prev_default && cur_account->is_default)
2618 account_set_as_default(cur_account);
2619 account_save_config_all();
2620 account_set_menu();
2621 main_window_reflect_prefs_all();
2625 static void new_account_cb(MainWindow *mainwin, guint action,
2626 GtkWidget *widget)
2628 account_edit_open();
2629 if (!compose_get_compose_list()) account_add();
2632 static void account_menu_cb(GtkMenuItem *menuitem, gpointer data)
2634 cur_account = (PrefsAccount *)data;
2635 main_window_reflect_prefs_all();
2638 static void manual_open_cb(MainWindow *mainwin, guint action,
2639 GtkWidget *widget)
2641 manual_open((ManualLang)action);
2644 static void scan_tree_func(Folder *folder, FolderItem *item, gpointer data)
2646 MainWindow *mainwin = (MainWindow *)data;
2647 gchar *str;
2649 if (item->path)
2650 str = g_strdup_printf(_("Scanning folder %s%c%s ..."),
2651 LOCAL_FOLDER(folder)->rootpath,
2652 G_DIR_SEPARATOR,
2653 item->path);
2654 else
2655 str = g_strdup_printf(_("Scanning folder %s ..."),
2656 LOCAL_FOLDER(folder)->rootpath);
2658 STATUSBAR_PUSH(mainwin, str);
2659 STATUSBAR_POP(mainwin);
2660 g_free(str);
2663 static void activate_compose_button (MainWindow *mainwin,
2664 ToolbarStyle style,
2665 ComposeButtonType type)
2667 if (style == TOOLBAR_NONE)
2668 return;
2670 if (style == TOOLBAR_BOTH) {
2671 gtk_widget_hide(mainwin->compose_mail_btn_plain);
2672 gtk_widget_hide(mainwin->compose_news_btn_plain);
2673 gtk_widget_hide(type == COMPOSEBUTTON_NEWS ? mainwin->compose_mail_btn
2674 : mainwin->compose_news_btn);
2675 gtk_widget_show(type == COMPOSEBUTTON_NEWS ? mainwin->compose_news_btn
2676 : mainwin->compose_mail_btn);
2677 mainwin->compose_btn_type = type;
2679 else {
2680 gtk_widget_hide(mainwin->compose_news_btn);
2681 gtk_widget_hide(mainwin->compose_mail_btn);
2682 gtk_widget_hide(type == COMPOSEBUTTON_NEWS ? mainwin->compose_mail_btn_plain
2683 : mainwin->compose_news_btn_plain);
2684 gtk_widget_show(type == COMPOSEBUTTON_NEWS ? mainwin->compose_news_btn_plain
2685 : mainwin->compose_mail_btn_plain);
2686 mainwin->compose_btn_type = type;
2690 static void prefs_templates_open_cb(MainWindow *mainwin, guint action,
2691 GtkWidget *widget)
2693 prefs_templates_open();