2007-03-22 [colin] 2.8.1cvs37
[claws.git] / src / mainwindow.c
blobb8a3b4eeb0c0f577e695fbcfd9151e211262d1ab
1 /*
2 * Sylpheed -- a GTK+ based, lightweight, and fast e-mail client
3 * Copyright (C) 1999-2007 Hiroyuki Yamamoto and the Claws Mail team
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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
20 #include "defs.h"
22 #include <glib.h>
23 #include <glib/gi18n.h>
24 #include <gdk/gdkkeysyms.h>
25 #include <gtk/gtkmain.h>
26 #include <gtk/gtkwindow.h>
27 #include <gtk/gtkwidget.h>
28 #include <gtk/gtksignal.h>
29 #include <gtk/gtkvbox.h>
30 #include <gtk/gtkcontainer.h>
31 #include <gtk/gtkstatusbar.h>
32 #include <gtk/gtkprogressbar.h>
33 #include <gtk/gtkhpaned.h>
34 #include <gtk/gtkvpaned.h>
35 #include <gtk/gtkcheckmenuitem.h>
36 #include <gtk/gtkitemfactory.h>
37 #include <gtk/gtkeditable.h>
38 #include <gtk/gtkmenu.h>
39 #include <gtk/gtkmenuitem.h>
40 #include <gtk/gtkhandlebox.h>
41 #include <gtk/gtktoolbar.h>
42 #include <gtk/gtkbutton.h>
43 #include <gtk/gtktooltips.h>
44 #include <string.h>
46 #include "main.h"
47 #include "mainwindow.h"
48 #include "folderview.h"
49 #include "foldersel.h"
50 #include "summaryview.h"
51 #include "summary_search.h"
52 #include "messageview.h"
53 #include "message_search.h"
54 #include "headerview.h"
55 #include "menu.h"
56 #include "stock_pixmap.h"
57 #include "folder.h"
58 #include "inc.h"
59 #include "log.h"
60 #include "compose.h"
61 #include "procmsg.h"
62 #include "import.h"
63 #include "export.h"
64 #include "prefs_common.h"
65 #include "prefs_actions.h"
66 #include "prefs_filtering.h"
67 #include "prefs_account.h"
68 #include "prefs_summary_column.h"
69 #include "prefs_folder_column.h"
70 #include "prefs_template.h"
71 #include "action.h"
72 #include "account.h"
73 #include "addressbook.h"
74 #include "logwindow.h"
75 #include "manage_window.h"
76 #include "alertpanel.h"
77 #include "statusbar.h"
78 #include "inputdialog.h"
79 #include "utils.h"
80 #include "gtkutils.h"
81 #include "codeconv.h"
82 #include "about.h"
83 #include "manual.h"
84 #include "version.h"
85 #include "ssl_manager.h"
86 #include "sslcertwindow.h"
87 #include "prefs_gtk.h"
88 #include "pluginwindow.h"
89 #include "hooks.h"
90 #include "progressindicator.h"
91 #include "localfolder.h"
92 #include "filtering.h"
93 #include "folderutils.h"
94 #include "foldersort.h"
95 #include "icon_legend.h"
96 #include "colorlabel.h"
97 #include "textview.h"
98 #include "imap.h"
99 #include "socket.h"
101 #define AC_LABEL_WIDTH 240
103 /* list of all instantiated MainWindow */
104 static GList *mainwin_list = NULL;
106 static GdkCursor *watch_cursor = NULL;
107 static GdkCursor *hand_cursor = NULL;
109 static gint iconified_count = 0;
111 static void main_window_menu_callback_block (MainWindow *mainwin);
112 static void main_window_menu_callback_unblock (MainWindow *mainwin);
114 static void main_window_show_cur_account (MainWindow *mainwin);
116 static void main_window_separation_change (MainWindow *mainwin,
117 LayoutType layout_mode);
119 static void main_window_set_widgets (MainWindow *mainwin,
120 LayoutType layout_mode);
122 static void toolbar_child_attached (GtkWidget *widget,
123 GtkWidget *child,
124 gpointer data);
125 static void toolbar_child_detached (GtkWidget *widget,
126 GtkWidget *child,
127 gpointer data);
129 static gboolean ac_label_button_pressed (GtkWidget *widget,
130 GdkEventButton *event,
131 gpointer data);
133 static gint main_window_close_cb (GtkWidget *widget,
134 GdkEventAny *event,
135 gpointer data);
137 static void main_window_size_allocate_cb (GtkWidget *widget,
138 GtkAllocation *allocation,
139 gpointer data);
140 static void folder_window_size_allocate_cb (GtkWidget *widget,
141 GtkAllocation *allocation,
142 gpointer data);
143 static void message_window_size_allocate_cb (GtkWidget *widget,
144 GtkAllocation *allocation,
145 gpointer data);
147 static void update_folderview_cb (MainWindow *mainwin,
148 guint action,
149 GtkWidget *widget);
150 static void add_mailbox_cb (MainWindow *mainwin,
151 guint action,
152 GtkWidget *widget);
153 static void foldersort_cb (MainWindow *mainwin,
154 guint action,
155 GtkWidget *widget);
156 static void import_mbox_cb (MainWindow *mainwin,
157 guint action,
158 GtkWidget *widget);
159 static void export_mbox_cb (MainWindow *mainwin,
160 guint action,
161 GtkWidget *widget);
162 static void export_list_mbox_cb (MainWindow *mainwin,
163 guint action,
164 GtkWidget *widget);
165 static void empty_trash_cb (MainWindow *mainwin,
166 guint action,
167 GtkWidget *widget);
169 static void save_as_cb (MainWindow *mainwin,
170 guint action,
171 GtkWidget *widget);
172 static void print_cb (MainWindow *mainwin,
173 guint action,
174 GtkWidget *widget);
175 static void app_exit_cb (MainWindow *mainwin,
176 guint action,
177 GtkWidget *widget);
179 static void search_cb (MainWindow *mainwin,
180 guint action,
181 GtkWidget *widget);
183 static void toggle_message_cb (MainWindow *mainwin,
184 guint action,
185 GtkWidget *widget);
186 static void toggle_toolbar_cb (MainWindow *mainwin,
187 guint action,
188 GtkWidget *widget);
189 static void toggle_statusbar_cb (MainWindow *mainwin,
190 guint action,
191 GtkWidget *widget);
192 static void set_layout_cb (MainWindow *mainwin,
193 guint action,
194 GtkWidget *widget);
196 static void addressbook_open_cb (MainWindow *mainwin,
197 guint action,
198 GtkWidget *widget);
199 static void log_window_show_cb (MainWindow *mainwin,
200 guint action,
201 GtkWidget *widget);
202 static void filtering_debug_window_show_cb (MainWindow *mainwin,
203 guint action,
204 GtkWidget *widget);
206 static void inc_cancel_cb (MainWindow *mainwin,
207 guint action,
208 GtkWidget *widget);
210 static void open_msg_cb (MainWindow *mainwin,
211 guint action,
212 GtkWidget *widget);
214 static void view_source_cb (MainWindow *mainwin,
215 guint action,
216 GtkWidget *widget);
218 static void show_all_header_cb (MainWindow *mainwin,
219 guint action,
220 GtkWidget *widget);
222 static void hide_quotes_cb(MainWindow *mainwin,
223 guint action,
224 GtkWidget *widget);
226 static void move_to_cb (MainWindow *mainwin,
227 guint action,
228 GtkWidget *widget);
229 static void copy_to_cb (MainWindow *mainwin,
230 guint action,
231 GtkWidget *widget);
232 static void delete_cb (MainWindow *mainwin,
233 guint action,
234 GtkWidget *widget);
235 static void delete_trash_cb (MainWindow *mainwin,
236 guint action,
237 GtkWidget *widget);
239 static void cancel_cb (MainWindow *mainwin,
240 guint action,
241 GtkWidget *widget);
243 static void mark_cb (MainWindow *mainwin,
244 guint action,
245 GtkWidget *widget);
246 static void unmark_cb (MainWindow *mainwin,
247 guint action,
248 GtkWidget *widget);
250 static void mark_as_unread_cb (MainWindow *mainwin,
251 guint action,
252 GtkWidget *widget);
253 static void mark_as_read_cb (MainWindow *mainwin,
254 guint action,
255 GtkWidget *widget);
256 static void mark_all_read_cb (MainWindow *mainwin,
257 guint action,
258 GtkWidget *widget);
259 static void mark_as_spam_cb (MainWindow *mainwin,
260 guint action,
261 GtkWidget *widget);
263 static void ignore_thread_cb (MainWindow *mainwin,
264 guint action,
265 GtkWidget *widget);
266 static void unignore_thread_cb (MainWindow *mainwin,
267 guint action,
268 GtkWidget *widget);
269 static void lock_msgs_cb (MainWindow *mainwin,
270 guint action,
271 GtkWidget *widget);
272 static void unlock_msgs_cb (MainWindow *mainwin,
273 guint action,
274 GtkWidget *widget);
276 static void reedit_cb (MainWindow *mainwin,
277 guint action,
278 GtkWidget *widget);
280 static void add_address_cb (MainWindow *mainwin,
281 guint action,
282 GtkWidget *widget);
284 static void set_charset_cb (MainWindow *mainwin,
285 guint action,
286 GtkWidget *widget);
288 static void set_decode_cb (MainWindow *mainwin,
289 guint action,
290 GtkWidget *widget);
292 static void hide_read_messages (MainWindow *mainwin,
293 guint action,
294 GtkWidget *widget);
296 static void thread_cb (MainWindow *mainwin,
297 guint action,
298 GtkWidget *widget);
299 static void expand_threads_cb (MainWindow *mainwin,
300 guint action,
301 GtkWidget *widget);
302 static void collapse_threads_cb (MainWindow *mainwin,
303 guint action,
304 GtkWidget *widget);
306 static void set_summary_display_item_cb (MainWindow *mainwin,
307 guint action,
308 GtkWidget *widget);
309 static void set_folder_display_item_cb (MainWindow *mainwin,
310 guint action,
311 GtkWidget *widget);
312 static void sort_summary_cb (MainWindow *mainwin,
313 guint action,
314 GtkWidget *widget);
315 static void sort_summary_type_cb (MainWindow *mainwin,
316 guint action,
317 GtkWidget *widget);
318 static void attract_by_subject_cb(MainWindow *mainwin,
319 guint action,
320 GtkWidget *widget);
322 static void delete_duplicated_cb (MainWindow *mainwin,
323 guint action,
324 GtkWidget *widget);
325 static void delete_duplicated_all_cb (MainWindow *mainwin,
326 guint action,
327 GtkWidget *widget);
328 static void filter_cb (MainWindow *mainwin,
329 guint action,
330 GtkWidget *widget);
331 static void execute_summary_cb (MainWindow *mainwin,
332 guint action,
333 GtkWidget *widget);
334 static void update_summary_cb (MainWindow *mainwin,
335 guint action,
336 GtkWidget *widget);
338 static void prev_cb (MainWindow *mainwin,
339 guint action,
340 GtkWidget *widget);
341 static void next_cb (MainWindow *mainwin,
342 guint action,
343 GtkWidget *widget);
344 static void next_unread_cb (MainWindow *mainwin,
345 guint action,
346 GtkWidget *widget);
347 static void prev_unread_cb (MainWindow *mainwin,
348 guint action,
349 GtkWidget *widget);
351 static void prev_new_cb (MainWindow *mainwin,
352 guint action,
353 GtkWidget *widget);
354 static void next_new_cb (MainWindow *mainwin,
355 guint action,
356 GtkWidget *widget);
357 static void prev_marked_cb (MainWindow *mainwin,
358 guint action,
359 GtkWidget *widget);
360 static void next_marked_cb (MainWindow *mainwin,
361 guint action,
362 GtkWidget *widget);
363 static void prev_labeled_cb (MainWindow *mainwin,
364 guint action,
365 GtkWidget *widget);
366 static void next_labeled_cb (MainWindow *mainwin,
367 guint action,
368 GtkWidget *widget);
369 static void last_read_cb (MainWindow *mainwin,
370 guint action,
371 GtkWidget *widget);
372 static void parent_cb (MainWindow *mainwin,
373 guint action,
374 GtkWidget *widget);
376 static void goto_folder_cb (MainWindow *mainwin,
377 guint action,
378 GtkWidget *widget);
379 static void goto_unread_folder_cb(MainWindow *mainwin,
380 guint action,
381 GtkWidget *widget);
383 static void copy_cb (MainWindow *mainwin,
384 guint action,
385 GtkWidget *widget);
386 static void allsel_cb (MainWindow *mainwin,
387 guint action,
388 GtkWidget *widget);
389 static void select_thread_cb (MainWindow *mainwin,
390 guint action,
391 GtkWidget *widget);
392 static void delete_thread_cb (MainWindow *mainwin,
393 guint action,
394 GtkWidget *widget);
396 static void create_filter_cb (MainWindow *mainwin,
397 guint action,
398 GtkWidget *widget);
399 static void create_processing_cb (MainWindow *mainwin,
400 guint action,
401 GtkWidget *widget);
402 static void open_urls_cb (MainWindow *mainwin,
403 guint action,
404 GtkWidget *widget);
406 static void prefs_template_open_cb (MainWindow *mainwin,
407 guint action,
408 GtkWidget *widget);
409 static void prefs_actions_open_cb (MainWindow *mainwin,
410 guint action,
411 GtkWidget *widget);
412 static void prefs_account_open_cb (MainWindow *mainwin,
413 guint action,
414 GtkWidget *widget);
416 static void prefs_pre_processing_open_cb (MainWindow *mainwin,
417 guint action,
418 GtkWidget *widget);
420 static void prefs_post_processing_open_cb (MainWindow *mainwin,
421 guint action,
422 GtkWidget *widget);
424 static void prefs_filtering_open_cb (MainWindow *mainwin,
425 guint action,
426 GtkWidget *widget);
427 #ifdef USE_OPENSSL
428 static void ssl_manager_open_cb (MainWindow *mainwin,
429 guint action,
430 GtkWidget *widget);
431 #endif
432 static void new_account_cb (MainWindow *mainwin,
433 guint action,
434 GtkWidget *widget);
436 static void account_selector_menu_cb (GtkMenuItem *menuitem,
437 gpointer data);
438 static void account_receive_menu_cb (GtkMenuItem *menuitem,
439 gpointer data);
440 static void account_compose_menu_cb (GtkMenuItem *menuitem,
441 gpointer data);
443 static void prefs_open_cb (GtkMenuItem *menuitem,
444 gpointer data);
445 static void plugins_open_cb (GtkMenuItem *menuitem,
446 gpointer data);
448 static void online_switch_clicked(GtkButton *btn,
449 gpointer data);
451 static void manual_open_cb (MainWindow *mainwin,
452 guint action,
453 GtkWidget *widget);
455 static void legend_open_cb (GtkMenuItem *menuitem,
456 gpointer data);
458 static void scan_tree_func (Folder *folder,
459 FolderItem *item,
460 gpointer data);
462 static void toggle_work_offline_cb(MainWindow *mainwin, guint action, GtkWidget *widget);
464 static void addr_harvest_cb ( MainWindow *mainwin,
465 guint action,
466 GtkWidget *widget );
468 static void addr_harvest_msg_cb ( MainWindow *mainwin,
469 guint action,
470 GtkWidget *widget );
471 static void sync_cb ( MainWindow *mainwin,
472 guint action,
473 GtkWidget *widget );
475 static gboolean mainwindow_focus_in_event (GtkWidget *widget,
476 GdkEventFocus *focus,
477 gpointer data);
478 static gboolean mainwindow_visibility_event_cb (GtkWidget *widget,
479 GdkEventVisibility *state,
480 gpointer data);
481 static gboolean mainwindow_state_event_cb (GtkWidget *widget,
482 GdkEventWindowState *state,
483 gpointer data);
484 static void main_window_reply_cb (MainWindow *mainwin,
485 guint action,
486 GtkWidget *widget);
487 static gboolean mainwindow_progressindicator_hook (gpointer source,
488 gpointer userdata);
490 static gint mailing_list_create_submenu(GtkItemFactory *ifactory,
491 MsgInfo *msginfo);
493 static gint mailing_list_populate_submenu(GtkWidget *menu, const gchar * list_header);
495 static void get_url_part(const gchar **buf, gchar *url_decoded, gint maxlen);
497 static void mailing_list_compose(GtkWidget *w, gpointer *data);
499 static void mailing_list_open_uri(GtkWidget *w, gpointer *data);
500 #define SEPARATE_ACTION 500
501 static void mainwindow_quicksearch (MainWindow *mainwin,
502 guint action,
503 GtkWidget *widget);
504 static gboolean any_folder_want_synchronise(void);
506 static GtkItemFactoryEntry mainwin_entries[] =
508 {N_("/_File"), NULL, NULL, 0, "<Branch>"},
509 {N_("/_File/_Add mailbox"), NULL, NULL, 0, "<Branch>"},
510 {N_("/_File/_Add mailbox/MH..."), NULL, add_mailbox_cb, 0, NULL},
511 {N_("/_File/---"), NULL, NULL, 0, "<Separator>"},
512 {N_("/_File/Change folder order..."), NULL, foldersort_cb, 0, NULL},
513 {N_("/_File/---"), NULL, NULL, 0, "<Separator>"},
514 {N_("/_File/_Import mbox file..."), NULL, import_mbox_cb, 0, NULL},
515 {N_("/_File/_Export to mbox file..."), NULL, export_mbox_cb, 0, NULL},
516 {N_("/_File/Exp_ort selected to mbox file..."),
517 NULL, export_list_mbox_cb, 0, NULL},
518 {N_("/_File/---"), NULL, NULL, 0, "<Separator>"},
519 {N_("/_File/Empty all _Trash folders"), "<shift>D", empty_trash_cb, 0, NULL},
520 {N_("/_File/---"), NULL, NULL, 0, "<Separator>"},
521 {N_("/_File/_Save as..."), "<control>S", save_as_cb, 0, NULL},
522 {N_("/_File/_Print..."), "<control>P", print_cb, 0, NULL},
523 {N_("/_File/---"), NULL, NULL, 0, "<Separator>"},
524 {N_("/_File/_Work offline"), "<control>W", toggle_work_offline_cb, 0, "<ToggleItem>"},
525 {N_("/_File/Synchronise folders"), "<control><shift>S", sync_cb, 0, NULL},
526 {N_("/_File/---"), NULL, NULL, 0, "<Separator>"},
527 /* {N_("/_File/_Close"), "<alt>W", app_exit_cb, 0, NULL}, */
528 {N_("/_File/E_xit"), "<control>Q", app_exit_cb, 0, NULL},
530 {N_("/_Edit"), NULL, NULL, 0, "<Branch>"},
531 {N_("/_Edit/_Copy"), "<control>C", copy_cb, 0, NULL},
532 {N_("/_Edit/Select _all"), "<control>A", allsel_cb, 0, NULL},
533 {N_("/_Edit/Select _thread"), NULL, select_thread_cb, 0, NULL},
534 {N_("/_Edit/_Delete thread"), NULL, delete_thread_cb, 0, NULL},
535 {N_("/_Edit/---"), NULL, NULL, 0, "<Separator>"},
536 {N_("/_Edit/_Find in current message..."),
537 "<control>F", search_cb, 0, NULL},
538 {N_("/_Edit/_Search folder..."), "<shift><control>F", search_cb, 1, NULL},
539 {N_("/_Edit/_Quick search"), "slash", mainwindow_quicksearch, 0, NULL},
540 {N_("/_View"), NULL, NULL, 0, "<Branch>"},
541 {N_("/_View/Show or hi_de"), NULL, NULL, 0, "<Branch>"},
542 {N_("/_View/Show or hi_de/_Message view"),
543 "V", toggle_message_cb, 0, "<ToggleItem>"},
544 {N_("/_View/Show or hi_de/_Toolbar"),
545 NULL, NULL, 0, "<Branch>"},
546 {N_("/_View/Show or hi_de/_Toolbar/Text _below icons"),
547 NULL, toggle_toolbar_cb, TOOLBAR_BOTH, "<RadioItem>"},
548 {N_("/_View/Show or hi_de/_Toolbar/Text be_side icons"),
549 NULL, toggle_toolbar_cb, TOOLBAR_BOTH_HORIZ, "/View/Show or hide/Toolbar/Text below icons"},
550 {N_("/_View/Show or hi_de/_Toolbar/_Icons only"),
551 NULL, toggle_toolbar_cb, TOOLBAR_ICON, "/View/Show or hide/Toolbar/Text below icons"},
552 {N_("/_View/Show or hi_de/_Toolbar/_Text only"),
553 NULL, toggle_toolbar_cb, TOOLBAR_TEXT, "/View/Show or hide/Toolbar/Text below icons"},
554 {N_("/_View/Show or hi_de/_Toolbar/_Hide"),
555 NULL, toggle_toolbar_cb, TOOLBAR_NONE, "/View/Show or hide/Toolbar/Text below icons"},
556 {N_("/_View/Show or hi_de/Status _bar"),
557 NULL, toggle_statusbar_cb, 0, "<ToggleItem>"},
558 {N_("/_View/Set displayed _columns"), NULL, NULL, 0, "<Branch>"},
559 {N_("/_View/Set displayed _columns/in _Folder list..."), NULL, set_folder_display_item_cb, 0, NULL},
560 {N_("/_View/Set displayed _columns/in _Message list..."),NULL, set_summary_display_item_cb, 0, NULL},
562 {N_("/_View/---"), NULL, NULL, 0, "<Separator>"},
563 {N_("/_View/La_yout"), NULL, NULL, 0, "<Branch>"},
564 {N_("/_View/Layout/_Standard"), NULL, set_layout_cb, NORMAL_LAYOUT, "<RadioItem>"},
565 {N_("/_View/Layout/_Three columns"), NULL, set_layout_cb, VERTICAL_LAYOUT, "/View/Layout/Standard"},
566 {N_("/_View/Layout/_Wide message"), NULL, set_layout_cb, WIDE_LAYOUT, "/View/Layout/Standard"},
567 {N_("/_View/Layout/W_ide message list"),NULL, set_layout_cb, WIDE_MSGLIST_LAYOUT, "/View/Layout/Standard"},
568 {N_("/_View/Layout/S_mall screen"), NULL, set_layout_cb, SMALL_LAYOUT, "/View/Layout/Standard"},
569 {N_("/_View/---"), NULL, NULL, 0, "<Separator>"},
570 {N_("/_View/_Sort"), NULL, NULL, 0, "<Branch>"},
571 {N_("/_View/_Sort/by _number"), NULL, sort_summary_cb, SORT_BY_NUMBER, "<RadioItem>"},
572 {N_("/_View/_Sort/by S_ize"), NULL, sort_summary_cb, SORT_BY_SIZE, "/View/Sort/by number"},
573 {N_("/_View/_Sort/by _Date"), NULL, sort_summary_cb, SORT_BY_DATE, "/View/Sort/by number"},
574 {N_("/_View/_Sort/by _From"), NULL, sort_summary_cb, SORT_BY_FROM, "/View/Sort/by number"},
575 {N_("/_View/_Sort/by _To"), NULL, sort_summary_cb, SORT_BY_TO, "/View/Sort/by number"},
576 {N_("/_View/_Sort/by S_ubject"), NULL, sort_summary_cb, SORT_BY_SUBJECT, "/View/Sort/by number"},
577 {N_("/_View/_Sort/by _color label"),
578 NULL, sort_summary_cb, SORT_BY_LABEL, "/View/Sort/by number"},
579 {N_("/_View/_Sort/by _mark"), NULL, sort_summary_cb, SORT_BY_MARK, "/View/Sort/by number"},
580 {N_("/_View/_Sort/by _status"), NULL, sort_summary_cb, SORT_BY_STATUS, "/View/Sort/by number"},
581 {N_("/_View/_Sort/by a_ttachment"),
582 NULL, sort_summary_cb, SORT_BY_MIME, "/View/Sort/by number"},
583 {N_("/_View/_Sort/by score"), NULL, sort_summary_cb, SORT_BY_SCORE, "/View/Sort/by number"},
584 {N_("/_View/_Sort/by locked"), NULL, sort_summary_cb, SORT_BY_LOCKED, "/View/Sort/by number"},
585 {N_("/_View/_Sort/D_on't sort"), NULL, sort_summary_cb, SORT_BY_NONE, "/View/Sort/by number"},
586 {N_("/_View/_Sort/---"), NULL, NULL, 0, "<Separator>"},
587 {N_("/_View/_Sort/Ascending"), NULL, sort_summary_type_cb, SORT_ASCENDING, "<RadioItem>"},
588 {N_("/_View/_Sort/Descending"), NULL, sort_summary_type_cb, SORT_DESCENDING, "/View/Sort/Ascending"},
589 {N_("/_View/_Sort/---"), NULL, NULL, 0, "<Separator>"},
590 {N_("/_View/_Sort/_Attract by subject"),
591 NULL, attract_by_subject_cb, 0, NULL},
592 {N_("/_View/Th_read view"), "<control>T", thread_cb, 0, "<ToggleItem>"},
593 {N_("/_View/E_xpand all threads"), NULL, expand_threads_cb, 0, NULL},
594 {N_("/_View/Co_llapse all threads"), NULL, collapse_threads_cb, 0, NULL},
595 {N_("/_View/_Hide read messages"), NULL, hide_read_messages, 0, "<ToggleItem>"},
597 {N_("/_View/---"), NULL, NULL, 0, "<Separator>"},
598 {N_("/_View/_Go to"), NULL, NULL, 0, "<Branch>"},
599 {N_("/_View/_Go to/_Previous message"), "P", prev_cb, 0, NULL},
600 {N_("/_View/_Go to/_Next message"), "N", next_cb, 0, NULL},
601 {N_("/_View/_Go to/---"), NULL, NULL, 0, "<Separator>"},
602 {N_("/_View/_Go to/P_revious unread message"),
603 "<shift>P", prev_unread_cb, 0, NULL},
604 {N_("/_View/_Go to/N_ext unread message"),
605 "<shift>N", next_unread_cb, 0, NULL},
606 {N_("/_View/_Go to/---"), NULL, NULL, 0, "<Separator>"},
607 {N_("/_View/_Go to/Previous ne_w message"), NULL, prev_new_cb, 0, NULL},
608 {N_("/_View/_Go to/Ne_xt new message"), NULL, next_new_cb, 0, NULL},
609 {N_("/_View/_Go to/---"), NULL, NULL, 0, "<Separator>"},
610 {N_("/_View/_Go to/Previous _marked message"),
611 NULL, prev_marked_cb, 0, NULL},
612 {N_("/_View/_Go to/Next m_arked message"),
613 NULL, next_marked_cb, 0, NULL},
614 {N_("/_View/_Go to/---"), NULL, NULL, 0, "<Separator>"},
615 {N_("/_View/_Go to/Previous _labeled message"),
616 NULL, prev_labeled_cb, 0, NULL},
617 {N_("/_View/_Go to/Next la_beled message"),
618 NULL, next_labeled_cb, 0, NULL},
619 {N_("/_View/_Go to/---"), NULL, NULL, 0, "<Separator>"},
620 {N_("/_View/_Go to/Last read message"),
621 NULL, last_read_cb, 0, NULL},
622 {N_("/_View/_Go to/Parent message"),
623 "<control>Up", parent_cb, 0, NULL},
624 {N_("/_View/_Go to/---"), NULL, NULL, 0, "<Separator>"},
625 {N_("/_View/_Go to/Next unread _folder"), "<shift>G", goto_unread_folder_cb, 0, NULL},
626 {N_("/_View/_Go to/_Other folder..."), "G", goto_folder_cb, 0, NULL},
627 {N_("/_View/---"), NULL, NULL, 0, "<Separator>"},
629 #define ENC_SEPARATOR \
630 {N_("/_View/Character _encoding/---"), NULL, NULL, 0, "<Separator>"}
631 #define ENC_ACTION(action) \
632 NULL, set_charset_cb, action, "/View/Character encoding/Auto detect"
634 {N_("/_View/Character _encoding"), NULL, NULL, 0, "<Branch>"},
635 {N_("/_View/Character _encoding/_Auto detect"),
636 NULL, set_charset_cb, C_AUTO, "<RadioItem>"},
637 {N_("/_View/Character _encoding/---"), NULL, NULL, 0, "<Separator>"},
638 {N_("/_View/Character _encoding/7bit ascii (US-ASC_II)"),
639 ENC_ACTION(C_US_ASCII)},
640 {N_("/_View/Character _encoding/Unicode (_UTF-8)"),
641 ENC_ACTION(C_UTF_8)},
642 ENC_SEPARATOR,
644 {N_("/_View/Character _encoding/Western European (ISO-8859-_1)"),
645 ENC_ACTION(C_ISO_8859_1)},
646 {N_("/_View/Character _encoding/Western European (ISO-8859-15)"),
647 ENC_ACTION(C_ISO_8859_15)},
648 {N_("/_View/Character _encoding/Western European (Windows-1252)"),
649 ENC_ACTION(C_WINDOWS_1252)},
650 ENC_SEPARATOR,
652 {N_("/_View/Character _encoding/Central European (ISO-8859-_2)"),
653 ENC_ACTION(C_ISO_8859_2)},
654 ENC_SEPARATOR,
656 {N_("/_View/Character _encoding/_Baltic (ISO-8859-13)"),
657 ENC_ACTION(C_ISO_8859_13)},
658 {N_("/_View/Character _encoding/Baltic (ISO-8859-_4)"),
659 ENC_ACTION(C_ISO_8859_4)},
660 ENC_SEPARATOR,
662 {N_("/_View/Character _encoding/Greek (ISO-8859-_7)"),
663 ENC_ACTION(C_ISO_8859_7)},
664 ENC_SEPARATOR,
666 {N_("/_View/Character _encoding/Hebrew (ISO-8859-_8)"),
667 ENC_ACTION(C_ISO_8859_8)},
668 {N_("/_View/Character _encoding/Hebrew (Windows-1255)"),
669 ENC_ACTION(C_CP1255)},
670 ENC_SEPARATOR,
672 {N_("/_View/Character _encoding/Arabic (ISO-8859-_6)"),
673 ENC_ACTION(C_ISO_8859_6)},
674 {N_("/_View/Character _encoding/Arabic (Windows-1256)"),
675 ENC_ACTION(C_CP1256)},
676 ENC_SEPARATOR,
678 {N_("/_View/Character _encoding/Turkish (ISO-8859-_9)"),
679 ENC_ACTION(C_ISO_8859_9)},
680 ENC_SEPARATOR,
682 {N_("/_View/Character _encoding/Cyrillic (ISO-8859-_5)"),
683 ENC_ACTION(C_ISO_8859_5)},
684 {N_("/_View/Character _encoding/Cyrillic (KOI8-_R)"),
685 ENC_ACTION(C_KOI8_R)},
686 {N_("/_View/Character _encoding/Cyrillic (KOI8-U)"),
687 ENC_ACTION(C_KOI8_U)},
688 {N_("/_View/Character _encoding/Cyrillic (Windows-1251)"),
689 ENC_ACTION(C_CP1251)},
690 ENC_SEPARATOR,
692 {N_("/_View/Character _encoding/Japanese (ISO-2022-_JP)"),
693 ENC_ACTION(C_ISO_2022_JP)},
694 {N_("/_View/Character _encoding/Japanese (ISO-2022-JP-2)"),
695 ENC_ACTION(C_ISO_2022_JP_2)},
696 {N_("/_View/Character _encoding/Japanese (_EUC-JP)"),
697 ENC_ACTION(C_EUC_JP)},
698 {N_("/_View/Character _encoding/Japanese (_Shift__JIS)"),
699 ENC_ACTION(C_SHIFT_JIS)},
700 ENC_SEPARATOR,
702 {N_("/_View/Character _encoding/Simplified Chinese (_GB2312)"),
703 ENC_ACTION(C_GB2312)},
704 {N_("/_View/Character _encoding/Simplified Chinese (GBK)"),
705 ENC_ACTION(C_GBK)},
706 {N_("/_View/Character _encoding/Traditional Chinese (_Big5)"),
707 ENC_ACTION(C_BIG5)},
708 {N_("/_View/Character _encoding/Traditional Chinese (EUC-_TW)"),
709 ENC_ACTION(C_EUC_TW)},
710 {N_("/_View/Character _encoding/Chinese (ISO-2022-_CN)"),
711 ENC_ACTION(C_ISO_2022_CN)},
712 ENC_SEPARATOR,
714 {N_("/_View/Character _encoding/Korean (EUC-_KR)"),
715 ENC_ACTION(C_EUC_KR)},
716 {N_("/_View/Character _encoding/Korean (ISO-2022-KR)"),
717 ENC_ACTION(C_ISO_2022_KR)},
718 ENC_SEPARATOR,
720 {N_("/_View/Character _encoding/Thai (TIS-620)"),
721 ENC_ACTION(C_TIS_620)},
722 {N_("/_View/Character _encoding/Thai (Windows-874)"),
723 ENC_ACTION(C_WINDOWS_874)},
725 #undef ENC_SEPARATOR
726 #undef ENC_ACTION
728 #define DEC_SEPARATOR \
729 {N_("/_View/Decode/---"), NULL, NULL, 0, "<Separator>"}
730 #define DEC_ACTION(action) \
731 NULL, set_decode_cb, action, "/View/Decode/Auto detect"
732 {N_("/_View/Decode"), NULL, NULL, 0, "<Branch>"},
733 {N_("/_View/Decode/_Auto detect"),
734 NULL, set_decode_cb, 0, "<RadioItem>"},
735 {N_("/_View/Decode/---"), NULL, NULL, 0, "<Separator>"},
736 {N_("/_View/Decode/_8bit"), DEC_ACTION(ENC_8BIT)},
737 {N_("/_View/Decode/_Quoted printable"), DEC_ACTION(ENC_QUOTED_PRINTABLE)},
738 {N_("/_View/Decode/_Base64"), DEC_ACTION(ENC_BASE64)},
739 {N_("/_View/Decode/_Uuencode"), DEC_ACTION(ENC_X_UUENCODE)},
741 #undef DEC_SEPARATOR
742 #undef DEC_ACTION
744 {N_("/_View/---"), NULL, NULL, 0, "<Separator>"},
745 {N_("/_View/Open in new _window"), "<control><alt>N", open_msg_cb, 0, NULL},
746 {N_("/_View/Mess_age source"), "<control>U", view_source_cb, 0, NULL},
747 {N_("/_View/All headers"), "<control>H", show_all_header_cb, 0, "<ToggleItem>"},
748 {N_("/_View/Quotes"), NULL, NULL, 0, "<Branch>"},
749 {N_("/_View/Quotes/_Fold all"), "<control><shift>Q", hide_quotes_cb, 1, "<ToggleItem>"},
750 {N_("/_View/Quotes/Fold from level _2"),NULL, hide_quotes_cb, 2, "<ToggleItem>"},
751 {N_("/_View/Quotes/Fold from level _3"),NULL, hide_quotes_cb, 3, "<ToggleItem>"},
752 {N_("/_View/---"), NULL, NULL, 0, "<Separator>"},
753 {N_("/_View/_Update summary"), "<control><alt>U", update_summary_cb, 0, NULL},
755 {N_("/_Message"), NULL, NULL, 0, "<Branch>"},
756 {N_("/_Message/Recei_ve"), NULL, NULL, 0, "<Branch>"},
757 {N_("/_Message/Recei_ve/Get from _current account"),
758 "<control>I", inc_mail_cb, 0, NULL},
759 {N_("/_Message/Recei_ve/Get from _all accounts"),
760 "<shift><control>I", inc_all_account_mail_cb, 0, NULL},
761 {N_("/_Message/Recei_ve/Cancel receivin_g"),
762 NULL, inc_cancel_cb, 0, NULL},
763 {N_("/_Message/Recei_ve/---"), NULL, NULL, 0, "<Separator>"},
764 {N_("/_Message/_Send queued messages"), NULL, send_queue_cb, 0, NULL},
765 {N_("/_Message/---"), NULL, NULL, 0, "<Separator>"},
766 {N_("/_Message/Compose a_n email message"), "<control>M", compose_mail_cb, 0, NULL},
767 {N_("/_Message/Compose a news message"), NULL, compose_news_cb, 0, NULL},
768 {N_("/_Message/_Reply"), "<control>R", main_window_reply_cb, COMPOSE_REPLY, NULL},
769 {N_("/_Message/Repl_y to"), NULL, NULL, 0, "<Branch>"},
770 {N_("/_Message/Repl_y to/_all"), "<shift><control>R", main_window_reply_cb, COMPOSE_REPLY_TO_ALL, NULL},
771 {N_("/_Message/Repl_y to/_sender"), NULL, main_window_reply_cb, COMPOSE_REPLY_TO_SENDER, NULL},
772 {N_("/_Message/Repl_y to/mailing _list"),
773 "<control>L", main_window_reply_cb, COMPOSE_REPLY_TO_LIST, NULL},
774 {N_("/_Message/Follow-up and reply to"),NULL, main_window_reply_cb, COMPOSE_FOLLOWUP_AND_REPLY_TO, NULL},
775 {N_("/_Message/---"), NULL, NULL, 0, "<Separator>"},
776 {N_("/_Message/_Forward"), "<control><alt>F", main_window_reply_cb, COMPOSE_FORWARD_INLINE, NULL},
777 {N_("/_Message/For_ward as attachment"), NULL, main_window_reply_cb, COMPOSE_FORWARD_AS_ATTACH, NULL},
778 {N_("/_Message/Redirect"), NULL, main_window_reply_cb, COMPOSE_REDIRECT, NULL},
780 {N_("/_Message/Mailing-_List"), NULL, NULL, 0, "<Branch>"},
781 {N_("/_Message/Mailing-_List/Post"), NULL, NULL, 0, "<Branch>"},
782 {N_("/_Message/Mailing-_List/Help"), NULL, NULL, 0, "<Branch>"},
783 {N_("/_Message/Mailing-_List/Subscribe"), NULL, NULL, 0, "<Branch>"},
784 {N_("/_Message/Mailing-_List/Unsubscribe"), NULL, NULL, 0, "<Branch>"},
785 {N_("/_Message/Mailing-_List/View archive"), NULL, NULL, 0, "<Branch>"},
786 {N_("/_Message/Mailing-_List/Contact owner"), NULL, NULL, 0, "<Branch>"},
788 {N_("/_Message/---"), NULL, NULL, 0, "<Separator>"},
789 {N_("/_Message/M_ove..."), "<control>O", move_to_cb, 0, NULL},
790 {N_("/_Message/_Copy..."), "<shift><control>O", copy_to_cb, 0, NULL},
791 {N_("/_Message/Move to _trash"), "<control>D", delete_trash_cb, 0, NULL},
792 {N_("/_Message/_Delete..."), NULL, delete_cb, 0, NULL},
793 {N_("/_Message/Cancel a news message"), "", cancel_cb, 0, NULL},
794 {N_("/_Message/---"), NULL, NULL, 0, "<Separator>"},
795 {N_("/_Message/_Mark"), NULL, NULL, 0, "<Branch>"},
796 {N_("/_Message/_Mark/_Mark"), "<shift>asterisk", mark_cb, 0, NULL},
797 {N_("/_Message/_Mark/_Unmark"), "U", unmark_cb, 0, NULL},
798 {N_("/_Message/_Mark/---"), NULL, NULL, 0, "<Separator>"},
799 {N_("/_Message/_Mark/Mark as unr_ead"), "<shift>exclam", mark_as_unread_cb, 0, NULL},
800 {N_("/_Message/_Mark/Mark as rea_d"), NULL, mark_as_read_cb, 0, NULL},
801 {N_("/_Message/_Mark/Mark all _read"), NULL, mark_all_read_cb, 0, NULL},
802 {N_("/_Message/_Mark/Ignore thread"), NULL, ignore_thread_cb, 0, NULL},
803 {N_("/_Message/_Mark/Unignore thread"), NULL, unignore_thread_cb, 0, NULL},
804 {N_("/_Message/_Mark/---"), NULL, NULL, 0, "<Separator>"},
805 {N_("/_Message/_Mark/Mark as _spam"), NULL, mark_as_spam_cb, 1, NULL},
806 {N_("/_Message/_Mark/Mark as _ham"), NULL, mark_as_spam_cb, 0, NULL},
807 {N_("/_Message/_Mark/---"), NULL, NULL, 0, "<Separator>"},
808 {N_("/_Message/_Mark/Lock"), NULL, lock_msgs_cb, 0, NULL},
809 {N_("/_Message/_Mark/Unlock"), NULL, unlock_msgs_cb, 0, NULL},
810 {N_("/_Message/Color la_bel"), NULL, NULL, 0, NULL},
811 {N_("/_Message/---"), NULL, NULL, 0, "<Separator>"},
812 {N_("/_Message/Re-_edit"), NULL, reedit_cb, 0, NULL},
814 {N_("/_Tools"), NULL, NULL, 0, "<Branch>"},
815 {N_("/_Tools/_Address book..."), "<shift><control>A", addressbook_open_cb, 0, NULL},
816 {N_("/_Tools/Add sender to address boo_k"),
817 NULL, add_address_cb, 0, NULL},
818 {N_("/_Tools/_Harvest addresses"), NULL, NULL, 0, "<Branch>"},
819 {N_("/_Tools/_Harvest addresses/from _Folder..."),
820 NULL, addr_harvest_cb, 0, NULL},
821 {N_("/_Tools/_Harvest addresses/from _Messages..."),
822 NULL, addr_harvest_msg_cb, 0, NULL},
823 {N_("/_Tools/---"), NULL, NULL, 0, "<Separator>"},
824 {N_("/_Tools/_Filter all messages in folder"),
825 NULL, filter_cb, 0, NULL},
826 {N_("/_Tools/Filter _selected messages"),
827 NULL, filter_cb, 1, NULL},
828 {N_("/_Tools/_Create filter rule"), NULL, NULL, 0, "<Branch>"},
829 {N_("/_Tools/_Create filter rule/_Automatically"),
830 NULL, create_filter_cb, FILTER_BY_AUTO, NULL},
831 {N_("/_Tools/_Create filter rule/by _From"),
832 NULL, create_filter_cb, FILTER_BY_FROM, NULL},
833 {N_("/_Tools/_Create filter rule/by _To"),
834 NULL, create_filter_cb, FILTER_BY_TO, NULL},
835 {N_("/_Tools/_Create filter rule/by _Subject"),
836 NULL, create_filter_cb, FILTER_BY_SUBJECT, NULL},
837 {N_("/_Tools/C_reate processing rule"), NULL, NULL, 0, "<Branch>"},
838 {N_("/_Tools/C_reate processing rule/_Automatically"),
839 NULL, create_processing_cb, FILTER_BY_AUTO, NULL},
840 {N_("/_Tools/C_reate processing rule/by _From"),
841 NULL, create_processing_cb, FILTER_BY_FROM, NULL},
842 {N_("/_Tools/C_reate processing rule/by _To"),
843 NULL, create_processing_cb, FILTER_BY_TO, NULL},
844 {N_("/_Tools/C_reate processing rule/by _Subject"),
845 NULL, create_processing_cb, FILTER_BY_SUBJECT, NULL},
846 {N_("/_Tools/---"), NULL, NULL, 0, "<Separator>"},
847 {N_("/_Tools/List _URLs..."), "<shift><control>U", open_urls_cb, 0, NULL},
848 {N_("/_Tools/---"), NULL, NULL, 0, "<Separator>"},
849 {N_("/_Tools/Actio_ns"), NULL, NULL, 0, "<Branch>"},
850 {N_("/_Tools/---"), NULL, NULL, 0, "<Separator>"},
851 {N_("/_Tools/Ch_eck for new messages in all folders"),
852 NULL, update_folderview_cb, 0, NULL},
853 {N_("/_Tools/Delete du_plicated messages"),
854 NULL, NULL, 0, "<Branch>"},
855 {N_("/_Tools/Delete du_plicated messages/In selected folder"),
856 NULL, delete_duplicated_cb, 0, NULL},
857 {N_("/_Tools/Delete du_plicated messages/In all folders"),
858 NULL, delete_duplicated_all_cb, 0, NULL},
859 {N_("/_Tools/---"), NULL, NULL, 0, "<Separator>"},
860 {N_("/_Tools/E_xecute"), "X", execute_summary_cb, 0, NULL},
861 #ifdef USE_OPENSSL
862 {N_("/_Tools/---"), NULL, NULL, 0, "<Separator>"},
863 {N_("/_Tools/SSL cer_tificates..."),
864 NULL, ssl_manager_open_cb, 0, NULL},
865 #endif
866 {N_("/_Tools/---"), NULL, NULL, 0, "<Separator>"},
867 {N_("/_Tools/Filtering debug window"), NULL, filtering_debug_window_show_cb, 0, NULL},
868 {N_("/_Tools/_Log window"), "<shift><control>L", log_window_show_cb, 0, NULL},
870 {N_("/_Configuration"), NULL, NULL, 0, "<Branch>"},
871 {N_("/_Configuration/C_hange current account"),
872 NULL, NULL, 0, "<Branch>"},
873 {N_("/_Configuration/_Preferences for current account..."),
874 NULL, prefs_account_open_cb, 0, NULL},
875 {N_("/_Configuration/Create _new account..."),
876 NULL, new_account_cb, 0, NULL},
877 {N_("/_Configuration/_Edit accounts..."),
878 NULL, account_edit_open, 0, NULL},
879 {N_("/_Configuration/---"), NULL, NULL, 0, "<Separator>"},
880 {N_("/_Configuration/P_references..."),
881 NULL, prefs_open_cb, 0, NULL},
882 {N_("/_Configuration/Pre-pr_ocessing..."),
883 NULL, prefs_pre_processing_open_cb, 0, NULL},
884 {N_("/_Configuration/Post-pro_cessing..."),
885 NULL, prefs_post_processing_open_cb, 0, NULL},
886 {N_("/_Configuration/_Filtering..."),
887 NULL, prefs_filtering_open_cb, 0, NULL},
888 {N_("/_Configuration/_Templates..."), NULL, prefs_template_open_cb, 0, NULL},
889 {N_("/_Configuration/_Actions..."), NULL, prefs_actions_open_cb, 0, NULL},
890 {N_("/_Configuration/Plu_gins..."), NULL, plugins_open_cb, 0, NULL},
892 {N_("/_Help"), NULL, NULL, 0, "<Branch>"},
893 {N_("/_Help/_Manual"), NULL, manual_open_cb, MANUAL_MANUAL_LOCAL, NULL},
894 {N_("/_Help/_Online User-contributed FAQ"),
895 NULL, manual_open_cb, MANUAL_FAQ_CLAWS, NULL},
896 {N_("/_Help/Icon _Legend"), NULL, legend_open_cb, 0, NULL},
897 {N_("/_Help/---"), NULL, NULL, 0, "<Separator>"},
898 {N_("/_Help/_About"), NULL, about_show, 0, NULL}
901 static gboolean offline_ask_sync = TRUE;
902 static guint lastkey;
903 static gboolean is_obscured = FALSE;
905 static gboolean main_window_accel_activate (GtkAccelGroup *accelgroup,
906 GObject *arg1,
907 guint value,
908 GdkModifierType mod,
909 gpointer user_data)
911 MainWindow *mainwin = (MainWindow *)user_data;
913 if (mainwin->summaryview &&
914 mainwin->summaryview->quicksearch &&
915 quicksearch_has_focus(mainwin->summaryview->quicksearch) &&
916 (mod == 0 || mod == GDK_SHIFT_MASK)) {
917 quicksearch_pass_key(mainwin->summaryview->quicksearch, lastkey, mod);
918 return TRUE;
920 return FALSE;
923 #define N_COLOR_LABELS colorlabel_get_color_count()
925 static void mainwindow_colorlabel_menu_item_activate_item_cb(GtkMenuItem *menu_item,
926 gpointer data)
928 MainWindow *mainwin;
929 GtkMenuShell *menu;
930 GtkCheckMenuItem **items;
931 gint n;
932 GList *cur;
933 GSList *sel;
935 mainwin = (MainWindow *)data;
936 g_return_if_fail(mainwin != NULL);
938 sel = summary_get_selection(mainwin->summaryview);
939 if (!sel) return;
941 menu = GTK_MENU_SHELL(mainwin->colorlabel_menu);
942 g_return_if_fail(menu != NULL);
944 Xalloca(items, (N_COLOR_LABELS + 1) * sizeof(GtkWidget *), return);
946 /* NOTE: don't return prematurely because we set the "dont_toggle"
947 * state for check menu items */
948 g_object_set_data(G_OBJECT(menu), "dont_toggle",
949 GINT_TO_POINTER(1));
951 /* clear items. get item pointers. */
952 for (n = 0, cur = menu->children; cur != NULL && cur->data != NULL; cur = cur->next) {
953 if (GTK_IS_CHECK_MENU_ITEM(cur->data)) {
954 gtk_check_menu_item_set_active
955 (GTK_CHECK_MENU_ITEM(cur->data), FALSE);
956 items[n] = GTK_CHECK_MENU_ITEM(cur->data);
957 n++;
961 if (n == (N_COLOR_LABELS + 1)) {
962 /* iterate all messages and set the state of the appropriate
963 * items */
964 for (; sel != NULL; sel = sel->next) {
965 MsgInfo *msginfo;
966 gint clabel;
968 msginfo = (MsgInfo *)sel->data;
969 if (msginfo) {
970 clabel = MSG_GET_COLORLABEL_VALUE(msginfo->flags);
971 if (!items[clabel]->active)
972 gtk_check_menu_item_set_active
973 (items[clabel], TRUE);
976 } else
977 g_warning("invalid number of color elements (%d)\n", n);
979 /* reset "dont_toggle" state */
980 g_object_set_data(G_OBJECT(menu), "dont_toggle",
981 GINT_TO_POINTER(0));
984 static void mainwindow_colorlabel_menu_item_activate_cb(GtkWidget *widget,
985 gpointer data)
987 guint color = GPOINTER_TO_UINT(data);
988 MainWindow *mainwin;
990 mainwin = g_object_get_data(G_OBJECT(widget), "mainwin");
991 g_return_if_fail(mainwin != NULL);
993 /* "dont_toggle" state set? */
994 if (g_object_get_data(G_OBJECT(mainwin->colorlabel_menu),
995 "dont_toggle"))
996 return;
998 summary_set_colorlabel(mainwin->summaryview, color, NULL);
1001 static void mainwindow_colorlabel_menu_create(MainWindow *mainwin, gboolean refresh)
1003 GtkWidget *label_menuitem;
1004 GtkWidget *menu;
1005 GtkWidget *item;
1006 gint i;
1008 label_menuitem = gtk_item_factory_get_item(mainwin->menu_factory,
1009 "/Message/Color label");
1010 g_signal_connect(G_OBJECT(label_menuitem), "activate",
1011 G_CALLBACK(mainwindow_colorlabel_menu_item_activate_item_cb),
1012 mainwin);
1013 gtk_widget_show(label_menuitem);
1015 menu = gtk_menu_new();
1017 /* create sub items. for the menu item activation callback we pass the
1018 * index of label_colors[] as data parameter. for the None color we
1019 * pass an invalid (high) value. also we attach a data pointer so we
1020 * can always get back the Mainwindow pointer. */
1022 item = gtk_check_menu_item_new_with_label(_("None"));
1023 gtk_menu_shell_append(GTK_MENU_SHELL(menu), item);
1024 g_signal_connect(G_OBJECT(item), "activate",
1025 G_CALLBACK(mainwindow_colorlabel_menu_item_activate_cb),
1026 GUINT_TO_POINTER(0));
1027 g_object_set_data(G_OBJECT(item), "mainwin", mainwin);
1028 gtk_widget_show(item);
1030 gtk_widget_add_accelerator(item, "activate",
1031 mainwin->menu_factory->accel_group,
1032 GDK_0, GDK_CONTROL_MASK,
1033 GTK_ACCEL_LOCKED | GTK_ACCEL_VISIBLE);
1035 item = gtk_menu_item_new();
1036 gtk_menu_shell_append(GTK_MENU_SHELL(menu), item);
1037 gtk_widget_show(item);
1039 /* create pixmap/label menu items */
1040 for (i = 0; i < N_COLOR_LABELS; i++) {
1041 item = colorlabel_create_check_color_menu_item(
1042 i, refresh, MAINWIN_COLORMENU);
1043 gtk_menu_shell_append(GTK_MENU_SHELL(menu), item);
1044 g_signal_connect(G_OBJECT(item), "activate",
1045 G_CALLBACK(mainwindow_colorlabel_menu_item_activate_cb),
1046 GUINT_TO_POINTER(i + 1));
1047 g_object_set_data(G_OBJECT(item), "mainwin",
1048 mainwin);
1049 gtk_widget_show(item);
1050 if (i < 9)
1051 gtk_widget_add_accelerator(item, "activate",
1052 mainwin->menu_factory->accel_group,
1053 GDK_1+i, GDK_CONTROL_MASK,
1054 GTK_ACCEL_LOCKED | GTK_ACCEL_VISIBLE);
1056 gtk_widget_show(menu);
1057 gtk_menu_item_set_submenu(GTK_MENU_ITEM(label_menuitem), menu);
1058 mainwin->colorlabel_menu = menu;
1061 static gboolean warning_icon_pressed(GtkWidget *widget, GdkEventButton *evt,
1062 MainWindow *mainwindow)
1064 if (evt && evt->button == 1) {
1065 log_window_show_error(mainwindow->logwin);
1066 gtk_widget_hide(mainwindow->warning_btn);
1068 return FALSE;
1071 static gboolean warning_visi_notify(GtkWidget *widget,
1072 GdkEventVisibility *event,
1073 MainWindow *mainwindow)
1075 gdk_window_set_cursor(mainwindow->warning_btn->window, hand_cursor);
1076 return FALSE;
1079 static gboolean warning_leave_notify(GtkWidget *widget,
1080 GdkEventCrossing *event,
1081 MainWindow *mainwindow)
1083 gdk_window_set_cursor(mainwindow->warning_btn->window, NULL);
1084 return FALSE;
1087 static gboolean warning_enter_notify(GtkWidget *widget,
1088 GdkEventCrossing *event,
1089 MainWindow *mainwindow)
1091 gdk_window_set_cursor(mainwindow->warning_btn->window, hand_cursor);
1092 return FALSE;
1095 void mainwindow_show_error(void)
1097 MainWindow *mainwin = mainwindow_get_mainwindow();
1098 gtk_widget_show(mainwin->warning_btn);
1101 void mainwindow_clear_error(MainWindow *mainwin)
1103 gtk_widget_hide(mainwin->warning_btn);
1106 MainWindow *main_window_create()
1108 MainWindow *mainwin;
1109 GtkWidget *window;
1110 GtkWidget *vbox;
1111 GtkWidget *menubar;
1112 GtkWidget *handlebox;
1113 GtkWidget *vbox_body;
1114 GtkWidget *hbox_stat;
1115 GtkWidget *statusbar;
1116 GtkWidget *progressbar;
1117 GtkWidget *statuslabel;
1118 GtkWidget *ac_button;
1119 GtkWidget *ac_label;
1120 GtkWidget *online_pixmap;
1121 GtkWidget *offline_pixmap;
1122 GtkWidget *online_switch;
1123 GtkWidget *offline_switch;
1124 GtkTooltips *tips;
1125 GtkWidget *warning_icon;
1126 GtkWidget *warning_btn;
1128 FolderView *folderview;
1129 SummaryView *summaryview;
1130 MessageView *messageview;
1131 GdkColormap *colormap;
1132 GdkColor color[4];
1133 gboolean success[4];
1134 GtkItemFactory *ifactory;
1135 GtkWidget *ac_menu;
1136 GtkWidget *menuitem;
1137 gint i;
1138 guint n_menu_entries;
1140 static GdkGeometry geometry;
1142 debug_print("Creating main window...\n");
1143 mainwin = g_new0(MainWindow, 1);
1145 /* main window */
1146 window = gtkut_window_new(GTK_WINDOW_TOPLEVEL, "mainwindow");
1147 gtk_window_set_title(GTK_WINDOW(window), PROG_VERSION);
1148 gtk_window_set_resizable(GTK_WINDOW(window), TRUE);
1150 if (!geometry.min_height) {
1151 geometry.min_width = 320;
1152 geometry.min_height = 200;
1154 gtk_window_set_geometry_hints(GTK_WINDOW(window), NULL, &geometry,
1155 GDK_HINT_MIN_SIZE);
1157 g_signal_connect(G_OBJECT(window), "delete_event",
1158 G_CALLBACK(main_window_close_cb), mainwin);
1159 MANAGE_WINDOW_SIGNALS_CONNECT(window);
1160 g_signal_connect(G_OBJECT(window), "focus_in_event",
1161 G_CALLBACK(mainwindow_focus_in_event),
1162 mainwin);
1163 g_signal_connect(G_OBJECT(window), "key_press_event",
1164 G_CALLBACK(mainwindow_key_pressed), mainwin);
1166 gtk_widget_realize(window);
1167 gtk_widget_add_events(window, GDK_KEY_PRESS_MASK|GDK_KEY_RELEASE_MASK);
1170 gtkut_widget_set_app_icon(window);
1172 vbox = gtk_vbox_new(FALSE, 0);
1173 gtk_widget_show(vbox);
1174 gtk_container_add(GTK_CONTAINER(window), vbox);
1176 /* menu bar */
1177 n_menu_entries = sizeof(mainwin_entries) / sizeof(mainwin_entries[0]);
1178 menubar = menubar_create(window, mainwin_entries,
1179 n_menu_entries, "<Main>", mainwin);
1180 gtk_widget_show(menubar);
1181 gtk_box_pack_start(GTK_BOX(vbox), menubar, FALSE, TRUE, 0);
1182 ifactory = gtk_item_factory_from_widget(menubar);
1184 /* gtk_widget_show(gtk_item_factory_get_item(ifactory,"/Message/Mailing-List"));
1185 main_create_mailing_list_menu (mainwin, NULL); */
1187 menu_set_sensitive(ifactory, "/Help/Manual", manual_available(MANUAL_MANUAL_LOCAL));
1189 if (prefs_common.toolbar_detachable) {
1190 handlebox = gtk_handle_box_new();
1191 gtk_widget_show(handlebox);
1192 gtk_box_pack_start(GTK_BOX(vbox), handlebox, FALSE, FALSE, 0);
1193 g_signal_connect(G_OBJECT(handlebox), "child_attached",
1194 G_CALLBACK(toolbar_child_attached), mainwin);
1195 g_signal_connect(G_OBJECT(handlebox), "child_detached",
1196 G_CALLBACK(toolbar_child_detached), mainwin);
1197 } else {
1198 handlebox = gtk_hbox_new(FALSE, 0);
1199 gtk_widget_show(handlebox);
1200 gtk_box_pack_start(GTK_BOX(vbox), handlebox, FALSE, FALSE, 0);
1202 /* link window to mainwin->window to avoid gdk warnings */
1203 mainwin->window = window;
1205 /* create toolbar */
1206 mainwin->toolbar = toolbar_create(TOOLBAR_MAIN,
1207 handlebox,
1208 (gpointer)mainwin);
1209 toolbar_set_learn_button
1210 (mainwin->toolbar,
1211 LEARN_SPAM);
1213 /* vbox that contains body */
1214 vbox_body = gtk_vbox_new(FALSE, BORDER_WIDTH);
1215 gtk_widget_show(vbox_body);
1216 gtk_container_set_border_width(GTK_CONTAINER(vbox_body), BORDER_WIDTH);
1217 gtk_box_pack_start(GTK_BOX(vbox), vbox_body, TRUE, TRUE, 0);
1219 hbox_stat = gtk_hbox_new(FALSE, 2);
1220 gtk_box_pack_end(GTK_BOX(vbox_body), hbox_stat, FALSE, FALSE, 0);
1222 tips = gtk_tooltips_new();
1224 warning_icon = gtk_image_new_from_stock
1225 (GTK_STOCK_DIALOG_WARNING, GTK_ICON_SIZE_SMALL_TOOLBAR);
1226 warning_btn = gtk_event_box_new();
1227 gtk_event_box_set_visible_window(GTK_EVENT_BOX(warning_btn), FALSE);
1229 mainwin->warning_btn = warning_btn;
1231 g_signal_connect(G_OBJECT(warning_btn), "button-press-event",
1232 G_CALLBACK(warning_icon_pressed),
1233 (gpointer) mainwin);
1234 g_signal_connect(G_OBJECT(warning_btn), "visibility-notify-event",
1235 G_CALLBACK(warning_visi_notify), mainwin);
1236 g_signal_connect(G_OBJECT(warning_btn), "motion-notify-event",
1237 G_CALLBACK(warning_visi_notify), mainwin);
1238 g_signal_connect(G_OBJECT(warning_btn), "leave-notify-event",
1239 G_CALLBACK(warning_leave_notify), mainwin);
1240 g_signal_connect(G_OBJECT(warning_btn), "enter-notify-event",
1241 G_CALLBACK(warning_enter_notify), mainwin);
1243 gtk_container_add (GTK_CONTAINER(warning_btn), warning_icon);
1245 gtk_tooltips_set_tip(GTK_TOOLTIPS(tips),warning_btn,
1246 _("Some error(s) happened. Click here to view log."), NULL);
1247 gtk_box_pack_start(GTK_BOX(hbox_stat), warning_btn, FALSE, FALSE, 0);
1249 statusbar = statusbar_create();
1250 gtk_box_pack_start(GTK_BOX(hbox_stat), statusbar, TRUE, TRUE, 0);
1252 progressbar = gtk_progress_bar_new();
1253 gtk_widget_set_size_request(progressbar, 120, 1);
1254 gtk_box_pack_start(GTK_BOX(hbox_stat), progressbar, FALSE, FALSE, 0);
1256 online_pixmap = stock_pixmap_widget(hbox_stat, STOCK_PIXMAP_ONLINE);
1257 offline_pixmap = stock_pixmap_widget(hbox_stat, STOCK_PIXMAP_OFFLINE);
1258 online_switch = gtk_button_new ();
1259 gtk_tooltips_set_tip(GTK_TOOLTIPS(tips),online_switch,
1260 _("You are online. Click the icon to go offline"), NULL);
1261 offline_switch = gtk_button_new ();
1262 gtk_tooltips_set_tip(GTK_TOOLTIPS(tips),offline_switch,
1263 _("You are offline. Click the icon to go online"),
1264 NULL);
1265 gtk_container_add (GTK_CONTAINER(online_switch), online_pixmap);
1266 gtk_button_set_relief (GTK_BUTTON(online_switch), GTK_RELIEF_NONE);
1267 g_signal_connect (G_OBJECT(online_switch), "clicked", G_CALLBACK(online_switch_clicked), mainwin);
1268 gtk_box_pack_start (GTK_BOX(hbox_stat), online_switch, FALSE, FALSE, 0);
1269 gtk_container_add (GTK_CONTAINER(offline_switch), offline_pixmap);
1270 gtk_button_set_relief (GTK_BUTTON(offline_switch), GTK_RELIEF_NONE);
1271 g_signal_connect (G_OBJECT(offline_switch), "clicked", G_CALLBACK(online_switch_clicked), mainwin);
1272 gtk_box_pack_start (GTK_BOX(hbox_stat), offline_switch, FALSE, FALSE, 0);
1274 statuslabel = gtk_label_new("");
1275 gtk_box_pack_start(GTK_BOX(hbox_stat), statuslabel, FALSE, FALSE, 0);
1277 ac_button = gtk_button_new();
1278 gtk_tooltips_set_tip(GTK_TOOLTIPS(tips),
1279 ac_button, _("Select account"), NULL);
1280 GTK_WIDGET_UNSET_FLAGS(ac_button, GTK_CAN_FOCUS);
1281 gtk_widget_set_size_request(ac_button, -1, 0);
1282 gtk_box_pack_end(GTK_BOX(hbox_stat), ac_button, FALSE, FALSE, 0);
1283 g_signal_connect(G_OBJECT(ac_button), "button_press_event",
1284 G_CALLBACK(ac_label_button_pressed), mainwin);
1286 ac_label = gtk_label_new("");
1287 gtk_container_add(GTK_CONTAINER(ac_button), ac_label);
1289 gtk_widget_show_all(hbox_stat);
1291 gtk_widget_hide(offline_switch);
1292 gtk_widget_hide(warning_btn);
1294 /* create views */
1295 mainwin->folderview = folderview = folderview_create();
1296 mainwin->summaryview = summaryview = summary_create();
1297 mainwin->messageview = messageview = messageview_create(mainwin);
1299 /* init log instances data before creating log views */
1300 set_log_title(LOG_PROTOCOL, _("Protocol log"));
1301 set_log_prefs(LOG_PROTOCOL,
1302 &prefs_common.logwin_width,
1303 &prefs_common.logwin_height);
1304 set_log_title(LOG_DEBUG_FILTERING, _("Filtering/processing debug log"));
1305 set_log_prefs(LOG_DEBUG_FILTERING,
1306 &prefs_common.filtering_debugwin_width,
1307 &prefs_common.filtering_debugwin_height);
1309 /* setup log windows */
1310 mainwin->logwin = log_window_create(LOG_PROTOCOL);
1311 log_window_init(mainwin->logwin);
1313 mainwin->filtering_debugwin = log_window_create(LOG_DEBUG_FILTERING);
1314 log_window_set_clipping(mainwin->logwin,
1315 prefs_common.cliplog,
1316 prefs_common.loglength);
1318 log_window_init(mainwin->filtering_debugwin);
1319 log_window_set_clipping(mainwin->filtering_debugwin,
1320 prefs_common.filtering_debug_cliplog,
1321 prefs_common.filtering_debug_loglength);
1322 if (prefs_common.enable_filtering_debug)
1323 log_message(LOG_DEBUG_FILTERING, _("filtering debug enabled\n"));
1324 else
1325 log_message(LOG_DEBUG_FILTERING, _("filtering debug disabled\n"));
1327 folderview->mainwin = mainwin;
1328 folderview->summaryview = summaryview;
1330 summaryview->mainwin = mainwin;
1331 summaryview->folderview = folderview;
1332 summaryview->messageview = messageview;
1333 summaryview->window = window;
1335 messageview->statusbar = statusbar;
1336 mainwin->vbox = vbox;
1337 mainwin->menubar = menubar;
1338 mainwin->menu_factory = ifactory;
1339 mainwin->handlebox = handlebox;
1340 mainwin->vbox_body = vbox_body;
1341 mainwin->hbox_stat = hbox_stat;
1342 mainwin->statusbar = statusbar;
1343 mainwin->progressbar = progressbar;
1344 mainwin->statuslabel = statuslabel;
1345 mainwin->online_switch = online_switch;
1346 mainwin->online_pixmap = online_pixmap;
1347 mainwin->offline_pixmap = offline_pixmap;
1348 mainwin->ac_button = ac_button;
1349 mainwin->ac_label = ac_label;
1350 mainwin->offline_switch = offline_switch;
1352 /* set context IDs for status bar */
1353 mainwin->mainwin_cid = gtk_statusbar_get_context_id
1354 (GTK_STATUSBAR(statusbar), "Main Window");
1355 mainwin->folderview_cid = gtk_statusbar_get_context_id
1356 (GTK_STATUSBAR(statusbar), "Folder View");
1357 mainwin->summaryview_cid = gtk_statusbar_get_context_id
1358 (GTK_STATUSBAR(statusbar), "Summary View");
1359 mainwin->messageview_cid = gtk_statusbar_get_context_id
1360 (GTK_STATUSBAR(statusbar), "Message View");
1362 messageview->statusbar_cid = mainwin->messageview_cid;
1364 /* allocate colors for summary view and folder view */
1365 summaryview->color_marked.red = summaryview->color_marked.green = 0;
1366 summaryview->color_marked.blue = (guint16)65535;
1368 summaryview->color_dim.red = summaryview->color_dim.green =
1369 summaryview->color_dim.blue = COLOR_DIM;
1371 gtkut_convert_int_to_gdk_color(prefs_common.color_new,
1372 &folderview->color_new);
1374 gtkut_convert_int_to_gdk_color(prefs_common.tgt_folder_col,
1375 &folderview->color_op);
1377 summaryview->color_important.red = 0;
1378 summaryview->color_important.green = 0;
1379 summaryview->color_important.blue = (guint16)65535;
1381 color[0] = summaryview->color_marked;
1382 color[1] = summaryview->color_dim;
1383 color[2] = folderview->color_new;
1384 color[3] = folderview->color_op;
1386 colormap = gdk_drawable_get_colormap(window->window);
1387 gdk_colormap_alloc_colors(colormap, color, 4, FALSE, TRUE, success);
1388 for (i = 0; i < 4; i++) {
1389 if (success[i] == FALSE)
1390 g_warning("MainWindow: color allocation %d failed\n", i);
1393 debug_print("done.\n");
1395 messageview->visible = prefs_common.msgview_visible;
1397 main_window_set_widgets(mainwin, prefs_common.layout_mode);
1399 g_signal_connect(G_OBJECT(window), "size_allocate",
1400 G_CALLBACK(main_window_size_allocate_cb),
1401 mainwin);
1403 /* set menu items */
1404 menuitem = gtk_item_factory_get_item
1405 (ifactory, "/View/Character encoding/Auto detect");
1406 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), TRUE);
1408 switch (prefs_common.toolbar_style) {
1409 case TOOLBAR_NONE:
1410 menuitem = gtk_item_factory_get_item
1411 (ifactory, "/View/Show or hide/Toolbar/Hide");
1412 break;
1413 case TOOLBAR_ICON:
1414 menuitem = gtk_item_factory_get_item
1415 (ifactory, "/View/Show or hide/Toolbar/Icons only");
1416 break;
1417 case TOOLBAR_TEXT:
1418 menuitem = gtk_item_factory_get_item
1419 (ifactory, "/View/Show or hide/Toolbar/Text only");
1420 break;
1421 case TOOLBAR_BOTH:
1422 menuitem = gtk_item_factory_get_item
1423 (ifactory, "/View/Show or hide/Toolbar/Text below icons");
1424 break;
1425 case TOOLBAR_BOTH_HORIZ:
1426 menuitem = gtk_item_factory_get_item
1427 (ifactory,
1428 "/View/Show or hide/Toolbar/Text beside icons");
1430 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), TRUE);
1432 gtk_widget_hide(mainwin->hbox_stat);
1433 menuitem = gtk_item_factory_get_item
1434 (ifactory, "/View/Show or hide/Status bar");
1435 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem),
1436 prefs_common.show_statusbar);
1438 /* set account selection menu */
1439 ac_menu = gtk_item_factory_get_widget
1440 (ifactory, "/Configuration/Change current account");
1441 mainwin->ac_menu = ac_menu;
1443 toolbar_main_set_sensitive(mainwin);
1445 /* create actions menu */
1446 main_window_update_actions_menu(mainwin);
1448 main_create_mailing_list_menu (mainwin, NULL);
1450 /* attach accel groups to main window */
1451 #define ADD_MENU_ACCEL_GROUP_TO_WINDOW(menu,win) \
1452 gtk_window_add_accel_group \
1453 (GTK_WINDOW(win), \
1454 gtk_item_factory_from_widget(menu)->accel_group); \
1455 g_signal_connect(G_OBJECT(gtk_item_factory_from_widget(menu)->accel_group), \
1456 "accel_activate", \
1457 G_CALLBACK(main_window_accel_activate), mainwin);
1460 ADD_MENU_ACCEL_GROUP_TO_WINDOW(summaryview->popupmenu, mainwin->window);
1462 /* connect the accelerators for equivalent
1463 menu items in different menus */
1464 menu_connect_identical_items();
1466 gtk_window_iconify(GTK_WINDOW(mainwin->window));
1468 g_signal_connect(G_OBJECT(window), "window_state_event",
1469 G_CALLBACK(mainwindow_state_event_cb), mainwin);
1470 g_signal_connect(G_OBJECT(window), "visibility_notify_event",
1471 G_CALLBACK(mainwindow_visibility_event_cb), mainwin);
1472 gtk_widget_add_events(GTK_WIDGET(window), GDK_VISIBILITY_NOTIFY_MASK);
1474 if (prefs_common.layout_mode == VERTICAL_LAYOUT ||
1475 prefs_common.layout_mode == SMALL_LAYOUT) {
1476 summary_relayout(mainwin->summaryview);
1479 gtk_widget_show(mainwin->window);
1481 /* initialize views */
1482 folderview_init(folderview);
1483 summary_init(summaryview);
1484 messageview_init(messageview);
1485 #ifdef USE_OPENSSL
1486 sslcertwindow_register_hook();
1487 #endif
1488 mainwin->lock_count = 0;
1489 mainwin->menu_lock_count = 0;
1490 mainwin->cursor_count = 0;
1492 mainwin->progressindicator_hook =
1493 hooks_register_hook(PROGRESSINDICATOR_HOOKLIST, mainwindow_progressindicator_hook, mainwin);
1495 if (!watch_cursor)
1496 watch_cursor = gdk_cursor_new(GDK_WATCH);
1497 if (!hand_cursor)
1498 hand_cursor = gdk_cursor_new(GDK_HAND2);
1500 mainwin_list = g_list_append(mainwin_list, mainwin);
1502 /* init work_offline */
1503 if (prefs_common.work_offline)
1504 online_switch_clicked (GTK_BUTTON(online_switch), mainwin);
1506 mainwindow_colorlabel_menu_create(mainwin, FALSE);
1508 return mainwin;
1511 void main_window_destroy(MainWindow *mainwin)
1513 /* TODO : destroy other component */
1514 messageview_destroy(mainwin->messageview);
1515 mainwin->messageview = NULL;
1518 void main_window_update_actions_menu(MainWindow *mainwin)
1520 GtkItemFactory *ifactory;
1522 ifactory = gtk_item_factory_from_widget(mainwin->menubar);
1523 action_update_mainwin_menu(ifactory, "/Tools/Actions", mainwin);
1526 void main_window_cursor_wait(MainWindow *mainwin)
1529 if (mainwin->cursor_count == 0) {
1530 gdk_window_set_cursor(mainwin->window->window, watch_cursor);
1531 textview_cursor_wait(mainwin->messageview->mimeview->textview);
1534 mainwin->cursor_count++;
1536 gdk_flush();
1539 void main_window_cursor_normal(MainWindow *mainwin)
1541 if (mainwin->cursor_count)
1542 mainwin->cursor_count--;
1544 if (mainwin->cursor_count == 0) {
1545 gdk_window_set_cursor(mainwin->window->window, NULL);
1546 textview_cursor_normal(mainwin->messageview->mimeview->textview);
1548 gdk_flush();
1551 /* lock / unlock the user-interface */
1552 void main_window_lock(MainWindow *mainwin)
1554 if (mainwin->lock_count == 0)
1555 gtk_widget_set_sensitive(mainwin->ac_button, FALSE);
1557 mainwin->lock_count++;
1559 main_window_set_menu_sensitive(mainwin);
1560 toolbar_main_set_sensitive(mainwin);
1563 void main_window_unlock(MainWindow *mainwin)
1565 if (mainwin->lock_count)
1566 mainwin->lock_count--;
1568 main_window_set_menu_sensitive(mainwin);
1569 toolbar_main_set_sensitive(mainwin);
1571 if (mainwin->lock_count == 0)
1572 gtk_widget_set_sensitive(mainwin->ac_button, TRUE);
1575 static void main_window_menu_callback_block(MainWindow *mainwin)
1577 mainwin->menu_lock_count++;
1580 static void main_window_menu_callback_unblock(MainWindow *mainwin)
1582 if (mainwin->menu_lock_count)
1583 mainwin->menu_lock_count--;
1586 static guint prefs_tag = 0;
1588 void main_window_reflect_prefs_all(void)
1590 main_window_reflect_prefs_all_real(FALSE);
1593 static gboolean reflect_prefs_timeout_cb(gpointer data)
1595 gboolean pixmap_theme_changed = GPOINTER_TO_INT(data);
1596 GList *cur;
1597 MainWindow *mainwin;
1598 GtkWidget *pixmap;
1600 for (cur = mainwin_list; cur != NULL; cur = cur->next) {
1601 mainwin = (MainWindow *)cur->data;
1603 main_window_show_cur_account(mainwin);
1604 main_window_set_menu_sensitive(mainwin);
1605 toolbar_main_set_sensitive(mainwin);
1607 /* pixmap themes */
1608 if (pixmap_theme_changed) {
1609 toolbar_update(TOOLBAR_MAIN, mainwin);
1610 messageview_reflect_prefs_pixmap_theme();
1611 compose_reflect_prefs_pixmap_theme();
1612 folderview_reflect_prefs_pixmap_theme(mainwin->folderview);
1613 summary_reflect_prefs_pixmap_theme(mainwin->summaryview);
1615 pixmap = stock_pixmap_widget(mainwin->hbox_stat, STOCK_PIXMAP_ONLINE);
1616 gtk_container_remove(GTK_CONTAINER(mainwin->online_switch),
1617 mainwin->online_pixmap);
1618 gtk_container_add (GTK_CONTAINER(mainwin->online_switch), pixmap);
1619 gtk_widget_show(pixmap);
1620 mainwin->online_pixmap = pixmap;
1621 pixmap = stock_pixmap_widget(mainwin->hbox_stat, STOCK_PIXMAP_OFFLINE);
1622 gtk_container_remove(GTK_CONTAINER(mainwin->offline_switch),
1623 mainwin->offline_pixmap);
1624 gtk_container_add (GTK_CONTAINER(mainwin->offline_switch), pixmap);
1625 gtk_widget_show(pixmap);
1626 mainwin->offline_pixmap = pixmap;
1629 headerview_set_font(mainwin->messageview->headerview);
1630 headerview_set_visibility(mainwin->messageview->headerview,
1631 prefs_common.display_header_pane);
1632 textview_reflect_prefs(mainwin->messageview->mimeview->textview);
1633 folderview_reflect_prefs();
1634 summary_reflect_prefs();
1635 summary_redisplay_msg(mainwin->summaryview);
1637 prefs_tag = 0;
1638 return FALSE;
1641 void main_window_reflect_prefs_all_now(void)
1643 reflect_prefs_timeout_cb(GINT_TO_POINTER(FALSE));
1646 void main_window_reflect_prefs_custom_colors(MainWindow *mainwin)
1648 GtkMenuShell *menu;
1649 GList *cur;
1651 /* re-create colorlabel submenu */
1652 menu = GTK_MENU_SHELL(mainwin->colorlabel_menu);
1653 g_return_if_fail(menu != NULL);
1655 /* clear items. get item pointers. */
1656 for (cur = menu->children; cur != NULL && cur->data != NULL; cur = cur->next) {
1657 gtk_menu_item_remove_submenu(GTK_MENU_ITEM(cur->data));
1659 mainwindow_colorlabel_menu_create(mainwin, TRUE);
1660 summary_reflect_prefs_custom_colors(mainwin->summaryview);
1664 void main_window_reflect_prefs_all_real(gboolean pixmap_theme_changed)
1666 if (prefs_tag == 0 || pixmap_theme_changed) {
1667 prefs_tag = g_timeout_add(500, reflect_prefs_timeout_cb,
1668 GINT_TO_POINTER(pixmap_theme_changed));
1672 void main_window_set_summary_column(void)
1674 GList *cur;
1675 MainWindow *mainwin;
1677 for (cur = mainwin_list; cur != NULL; cur = cur->next) {
1678 mainwin = (MainWindow *)cur->data;
1679 summary_set_column_order(mainwin->summaryview);
1683 void main_window_set_folder_column(void)
1685 GList *cur;
1686 MainWindow *mainwin;
1688 for (cur = mainwin_list; cur != NULL; cur = cur->next) {
1689 mainwin = (MainWindow *)cur->data;
1690 folderview_set_column_order(mainwin->folderview);
1694 static void main_window_set_account_selector_menu(MainWindow *mainwin,
1695 GList *account_list)
1697 GList *cur_ac, *cur_item;
1698 GtkWidget *menuitem;
1699 PrefsAccount *ac_prefs;
1701 /* destroy all previous menu item */
1702 cur_item = GTK_MENU_SHELL(mainwin->ac_menu)->children;
1703 while (cur_item != NULL) {
1704 GList *next = cur_item->next;
1705 gtk_widget_destroy(GTK_WIDGET(cur_item->data));
1706 cur_item = next;
1709 for (cur_ac = account_list; cur_ac != NULL; cur_ac = cur_ac->next) {
1710 ac_prefs = (PrefsAccount *)cur_ac->data;
1712 menuitem = gtk_menu_item_new_with_label
1713 (ac_prefs->account_name
1714 ? ac_prefs->account_name : _("Untitled"));
1715 gtk_widget_show(menuitem);
1716 gtk_menu_append(GTK_MENU(mainwin->ac_menu), menuitem);
1717 g_signal_connect(G_OBJECT(menuitem), "activate",
1718 G_CALLBACK(account_selector_menu_cb),
1719 ac_prefs);
1723 static void main_window_set_account_receive_menu(MainWindow *mainwin,
1724 GList *account_list)
1726 GList *cur_ac, *cur_item;
1727 GtkWidget *menu;
1728 GtkWidget *menuitem;
1729 PrefsAccount *ac_prefs;
1731 menu = gtk_item_factory_get_widget(mainwin->menu_factory,
1732 "/Message/Receive");
1734 /* search for separator */
1735 for (cur_item = GTK_MENU_SHELL(menu)->children; cur_item != NULL;
1736 cur_item = cur_item->next) {
1737 if (GTK_BIN(cur_item->data)->child == NULL) {
1738 cur_item = cur_item->next;
1739 break;
1743 /* destroy all previous menu item */
1744 while (cur_item != NULL) {
1745 GList *next = cur_item->next;
1746 gtk_widget_destroy(GTK_WIDGET(cur_item->data));
1747 cur_item = next;
1750 for (cur_ac = account_list; cur_ac != NULL; cur_ac = cur_ac->next) {
1751 ac_prefs = (PrefsAccount *)cur_ac->data;
1753 menuitem = gtk_menu_item_new_with_label
1754 (ac_prefs->account_name ? ac_prefs->account_name
1755 : _("Untitled"));
1756 gtk_widget_show(menuitem);
1757 gtk_menu_append(GTK_MENU(menu), menuitem);
1758 g_signal_connect(G_OBJECT(menuitem), "activate",
1759 G_CALLBACK(account_receive_menu_cb),
1760 ac_prefs);
1764 static void main_window_set_toolbar_combo_receive_menu(MainWindow *mainwin,
1765 GList *account_list)
1767 GList *cur_ac, *cur_item;
1768 GtkWidget *menuitem;
1769 PrefsAccount *ac_prefs;
1770 GtkWidget *menu = NULL;
1772 if (mainwin->toolbar->getall_btn == NULL
1773 || mainwin->toolbar->getall_combo == NULL) /* button doesn't exist */
1774 return;
1776 menu = mainwin->toolbar->getall_combo->menu;
1778 /* destroy all previous menu item */
1779 cur_item = GTK_MENU_SHELL(menu)->children;
1780 while (cur_item != NULL) {
1781 GList *next = cur_item->next;
1782 gtk_widget_destroy(GTK_WIDGET(cur_item->data));
1783 cur_item = next;
1786 for (cur_ac = account_list; cur_ac != NULL; cur_ac = cur_ac->next) {
1787 ac_prefs = (PrefsAccount *)cur_ac->data;
1789 menuitem = gtk_menu_item_new_with_label
1790 (ac_prefs->account_name
1791 ? ac_prefs->account_name : _("Untitled"));
1792 gtk_widget_show(menuitem);
1793 gtk_menu_append(GTK_MENU(menu), menuitem);
1794 g_signal_connect(G_OBJECT(menuitem), "activate",
1795 G_CALLBACK(account_receive_menu_cb),
1796 ac_prefs);
1800 static void main_window_set_toolbar_combo_compose_menu(MainWindow *mainwin,
1801 GList *account_list)
1803 GList *cur_ac, *cur_item;
1804 GtkWidget *menuitem;
1805 PrefsAccount *ac_prefs;
1806 GtkWidget *menu = NULL;
1808 if (mainwin->toolbar->compose_mail_btn == NULL
1809 || mainwin->toolbar->compose_combo == NULL) /* button doesn't exist */
1810 return;
1812 menu = mainwin->toolbar->compose_combo->menu;
1814 /* destroy all previous menu item */
1815 cur_item = GTK_MENU_SHELL(menu)->children;
1816 while (cur_item != NULL) {
1817 GList *next = cur_item->next;
1818 gtk_widget_destroy(GTK_WIDGET(cur_item->data));
1819 cur_item = next;
1822 for (cur_ac = account_list; cur_ac != NULL; cur_ac = cur_ac->next) {
1823 ac_prefs = (PrefsAccount *)cur_ac->data;
1825 menuitem = gtk_menu_item_new_with_label
1826 (ac_prefs->account_name
1827 ? ac_prefs->account_name : _("Untitled"));
1828 gtk_widget_show(menuitem);
1829 gtk_menu_append(GTK_MENU(menu), menuitem);
1830 g_signal_connect(G_OBJECT(menuitem), "activate",
1831 G_CALLBACK(account_compose_menu_cb),
1832 ac_prefs);
1836 void main_window_set_account_menu(GList *account_list)
1838 GList *cur;
1839 MainWindow *mainwin;
1841 for (cur = mainwin_list; cur != NULL; cur = cur->next) {
1842 mainwin = (MainWindow *)cur->data;
1843 main_window_set_account_selector_menu(mainwin, account_list);
1844 main_window_set_account_receive_menu(mainwin, account_list);
1845 main_window_set_toolbar_combo_receive_menu(mainwin, account_list);
1846 main_window_set_toolbar_combo_compose_menu(mainwin, account_list);
1848 hooks_invoke(ACCOUNT_LIST_CHANGED_HOOKLIST, NULL);
1851 void main_window_set_account_menu_only_toolbar(GList *account_list)
1853 GList *cur;
1854 MainWindow *mainwin;
1856 for (cur = mainwin_list; cur != NULL; cur = cur->next) {
1857 mainwin = (MainWindow *)cur->data;
1858 main_window_set_toolbar_combo_receive_menu(mainwin, account_list);
1859 main_window_set_toolbar_combo_compose_menu(mainwin, account_list);
1863 static void main_window_show_cur_account(MainWindow *mainwin)
1865 gchar *buf;
1866 gchar *ac_name;
1868 ac_name = g_strdup(cur_account
1869 ? (cur_account->account_name
1870 ? cur_account->account_name : _("Untitled"))
1871 : _("none"));
1873 if (cur_account)
1874 buf = g_strdup_printf("%s - %s", ac_name, PROG_VERSION);
1875 else
1876 buf = g_strdup(PROG_VERSION);
1877 gtk_window_set_title(GTK_WINDOW(mainwin->window), buf);
1878 g_free(buf);
1880 gtk_label_set_text(GTK_LABEL(mainwin->ac_label), ac_name);
1881 gtk_widget_queue_resize(mainwin->ac_button);
1883 g_free(ac_name);
1886 static void main_window_separation_change(MainWindow *mainwin, LayoutType layout_mode)
1888 GtkWidget *folder_wid = GTK_WIDGET_PTR(mainwin->folderview);
1889 GtkWidget *summary_wid = GTK_WIDGET_PTR(mainwin->summaryview);
1890 GtkWidget *message_wid = mainwin->messageview->vbox;
1892 if (layout_mode == prefs_common.layout_mode)
1893 return;
1895 debug_print("Changing window separation type from %d to %d\n",
1896 prefs_common.layout_mode, layout_mode);
1898 /* remove widgets from those containers */
1899 gtk_widget_ref(folder_wid);
1900 gtk_widget_ref(summary_wid);
1901 gtk_widget_ref(message_wid);
1902 gtkut_container_remove
1903 (GTK_CONTAINER(folder_wid->parent), folder_wid);
1904 gtkut_container_remove
1905 (GTK_CONTAINER(summary_wid->parent), summary_wid);
1906 gtkut_container_remove
1907 (GTK_CONTAINER(message_wid->parent), message_wid);
1909 gtk_widget_hide(mainwin->window);
1910 main_window_set_widgets(mainwin, layout_mode);
1911 gtk_widget_show(mainwin->window);
1913 gtk_widget_unref(folder_wid);
1914 gtk_widget_unref(summary_wid);
1915 gtk_widget_unref(message_wid);
1918 void mainwindow_reset_paned(GtkPaned *paned)
1920 gint min, max, mid;
1922 if (gtk_paned_get_child1(GTK_PANED(paned)))
1923 gtk_widget_show(gtk_paned_get_child1(GTK_PANED(paned)));
1924 if (gtk_paned_get_child2(GTK_PANED(paned)))
1925 gtk_widget_show(gtk_paned_get_child2(GTK_PANED(paned)));
1927 GTK_EVENTS_FLUSH();
1928 g_object_get (G_OBJECT(paned),
1929 "min-position",
1930 &min, NULL);
1931 g_object_get (G_OBJECT(paned),
1932 "max-position",
1933 &max, NULL);
1934 mid = (min+max)/2;
1935 gtk_paned_set_position(GTK_PANED(paned), mid);
1938 static void mainwin_paned_show_first(GtkPaned *paned)
1940 gint max;
1941 g_object_get (G_OBJECT(paned),
1942 "max-position",
1943 &max, NULL);
1945 if (gtk_paned_get_child1(GTK_PANED(paned)))
1946 gtk_widget_show(gtk_paned_get_child1(GTK_PANED(paned)));
1947 if (gtk_paned_get_child2(GTK_PANED(paned)))
1948 gtk_widget_hide(gtk_paned_get_child2(GTK_PANED(paned)));
1949 gtk_paned_set_position(GTK_PANED(paned), max);
1952 static void mainwin_paned_show_last(GtkPaned *paned)
1954 gint min;
1955 g_object_get (G_OBJECT(paned),
1956 "min-position",
1957 &min, NULL);
1959 if (gtk_paned_get_child1(GTK_PANED(paned)))
1960 gtk_widget_hide(gtk_paned_get_child1(GTK_PANED(paned)));
1961 if (gtk_paned_get_child2(GTK_PANED(paned)))
1962 gtk_widget_show(gtk_paned_get_child2(GTK_PANED(paned)));
1963 gtk_paned_set_position(GTK_PANED(paned), min);
1966 void main_window_toggle_message_view(MainWindow *mainwin)
1968 SummaryView *summaryview = mainwin->summaryview;
1969 GtkWidget *ppaned = NULL;
1970 GtkWidget *container = NULL;
1972 switch (prefs_common.layout_mode) {
1973 case NORMAL_LAYOUT:
1974 case VERTICAL_LAYOUT:
1975 case SMALL_LAYOUT:
1976 ppaned = mainwin->vpaned;
1977 container = mainwin->hpaned;
1978 if (ppaned->parent != NULL) {
1979 mainwin->messageview->visible = FALSE;
1980 summaryview->displayed = NULL;
1981 gtk_widget_ref(ppaned);
1982 gtkut_container_remove(GTK_CONTAINER(container), ppaned);
1983 gtk_widget_reparent(GTK_WIDGET_PTR(summaryview), container);
1984 } else {
1985 mainwin->messageview->visible = TRUE;
1986 gtk_widget_reparent(GTK_WIDGET_PTR(summaryview), ppaned);
1987 gtk_container_add(GTK_CONTAINER(container), ppaned);
1988 gtk_widget_unref(ppaned);
1990 break;
1991 case WIDE_LAYOUT:
1992 ppaned = mainwin->hpaned;
1993 container = mainwin->vpaned;
1994 if (mainwin->messageview->vbox->parent != NULL) {
1995 mainwin->messageview->visible = FALSE;
1996 summaryview->displayed = NULL;
1997 gtk_widget_ref(mainwin->messageview->vbox);
1998 gtkut_container_remove(GTK_CONTAINER(container), mainwin->messageview->vbox);
1999 } else {
2000 mainwin->messageview->visible = TRUE;
2001 gtk_container_add(GTK_CONTAINER(container), mainwin->messageview->vbox);
2002 gtk_widget_unref(mainwin->messageview->vbox);
2004 break;
2005 case WIDE_MSGLIST_LAYOUT:
2006 g_warning("can't hide messageview in this wide msglist layout");
2007 break;
2010 if (messageview_is_visible(mainwin->messageview))
2011 gtk_arrow_set(GTK_ARROW(mainwin->summaryview->toggle_arrow),
2012 GTK_ARROW_DOWN, GTK_SHADOW_OUT);
2013 else
2014 gtk_arrow_set(GTK_ARROW(mainwin->summaryview->toggle_arrow),
2015 GTK_ARROW_UP, GTK_SHADOW_OUT);
2017 if (mainwin->messageview->visible == FALSE)
2018 messageview_clear(mainwin->messageview);
2020 main_window_set_menu_sensitive(mainwin);
2022 prefs_common.msgview_visible = mainwin->messageview->visible;
2024 if (messageview_is_visible(mainwin->messageview)) {
2025 gtk_widget_queue_resize(mainwin->hpaned);
2026 gtk_widget_queue_resize(mainwin->vpaned);
2028 summary_grab_focus(summaryview);
2031 void main_window_get_size(MainWindow *mainwin)
2033 GtkAllocation *allocation;
2035 if (mainwin_list == NULL || mainwin->messageview == NULL) {
2036 debug_print("called after messageview "
2037 "has been deallocated!\n");
2038 return;
2041 allocation = &(GTK_WIDGET_PTR(mainwin->summaryview)->allocation);
2043 if (allocation->width > 1 && allocation->height > 1) {
2044 prefs_common.summaryview_width = allocation->width;
2046 if (messageview_is_visible(mainwin->messageview))
2047 prefs_common.summaryview_height = allocation->height;
2049 prefs_common.mainview_width = allocation->width;
2052 allocation = &mainwin->window->allocation;
2053 if (allocation->width > 1 && allocation->height > 1) {
2054 prefs_common.mainview_height = allocation->height;
2055 prefs_common.mainwin_width = allocation->width;
2056 prefs_common.mainwin_height = allocation->height;
2059 allocation = &(GTK_WIDGET_PTR(mainwin->folderview)->allocation);
2060 if (allocation->width > 1 && allocation->height > 1) {
2061 prefs_common.folderview_width = allocation->width;
2062 prefs_common.folderview_height = allocation->height;
2065 allocation = &(GTK_WIDGET_PTR(mainwin->messageview)->allocation);
2066 if (allocation->width > 1 && allocation->height > 1) {
2067 prefs_common.msgview_width = allocation->width;
2068 prefs_common.msgview_height = allocation->height;
2071 /* debug_print("summaryview size: %d x %d\n",
2072 prefs_common.summaryview_width,
2073 prefs_common.summaryview_height);
2074 debug_print("folderview size: %d x %d\n",
2075 prefs_common.folderview_width,
2076 prefs_common.folderview_height);
2077 debug_print("messageview size: %d x %d\n",
2078 prefs_common.msgview_width,
2079 prefs_common.msgview_height); */
2082 void main_window_get_position(MainWindow *mainwin)
2084 gint x, y;
2086 gtkut_widget_get_uposition(mainwin->window, &x, &y);
2088 prefs_common.mainview_x = x;
2089 prefs_common.mainview_y = y;
2090 prefs_common.mainwin_x = x;
2091 prefs_common.mainwin_y = y;
2093 debug_print("main window position: %d, %d\n", x, y);
2096 void main_window_progress_on(MainWindow *mainwin)
2098 gtk_progress_bar_set_text(GTK_PROGRESS_BAR(mainwin->progressbar), "");
2101 void main_window_progress_off(MainWindow *mainwin)
2103 gtk_progress_bar_set_fraction(GTK_PROGRESS_BAR(mainwin->progressbar), 0.0);
2104 gtk_progress_bar_set_text(GTK_PROGRESS_BAR(mainwin->progressbar), "");
2107 void main_window_progress_set(MainWindow *mainwin, gint cur, gint total)
2109 gchar buf[32];
2111 g_snprintf(buf, sizeof(buf), "%d / %d", cur, total);
2112 gtk_progress_bar_set_text(GTK_PROGRESS_BAR(mainwin->progressbar), buf);
2113 gtk_progress_bar_set_fraction(GTK_PROGRESS_BAR(mainwin->progressbar),
2114 (total == 0) ? 0 : (gfloat)cur / (gfloat)total);
2117 void main_window_empty_trash(MainWindow *mainwin, gboolean confirm)
2119 if (confirm && procmsg_have_trashed_mails_fast()) {
2120 if (alertpanel(_("Empty trash"),
2121 _("Delete all messages in trash folders?"),
2122 GTK_STOCK_NO, "+" GTK_STOCK_YES, NULL)
2123 != G_ALERTALTERNATE)
2124 return;
2125 manage_window_focus_in(mainwin->window, NULL, NULL);
2128 procmsg_empty_all_trash();
2130 if (mainwin->summaryview->folder_item &&
2131 mainwin->summaryview->folder_item->stype == F_TRASH)
2132 gtk_widget_grab_focus(mainwin->folderview->ctree);
2135 void main_window_add_mailbox(MainWindow *mainwin)
2137 gchar *path;
2138 Folder *folder;
2140 path = input_dialog(_("Add mailbox"),
2141 _("Input the location of mailbox.\n"
2142 "If the existing mailbox is specified, it will be\n"
2143 "scanned automatically."),
2144 "Mail");
2145 if (!path) return;
2146 if (folder_find_from_path(path)) {
2147 alertpanel_error(_("The mailbox '%s' already exists."), path);
2148 g_free(path);
2149 return;
2151 folder = folder_new(folder_get_class_from_string("mh"),
2152 !strcmp(path, "Mail") ? _("Mailbox") :
2153 g_path_get_basename(path), path);
2154 g_free(path);
2156 if (folder->klass->create_tree(folder) < 0) {
2157 alertpanel_error(_("Creation of the mailbox failed.\n"
2158 "Maybe some files already exist, or you don't have the permission to write there."));
2159 folder_destroy(folder);
2160 return;
2163 folder_add(folder);
2164 folder_set_ui_func(folder, scan_tree_func, mainwin);
2165 folder_scan_tree(folder, TRUE);
2166 folder_set_ui_func(folder, NULL, NULL);
2169 SensitiveCond main_window_get_current_state(MainWindow *mainwin)
2171 SensitiveCond state = 0;
2172 SummarySelection selection;
2173 FolderItem *item = mainwin->summaryview->folder_item;
2174 GList *account_list = account_get_list();
2176 selection = summary_get_selection_type(mainwin->summaryview);
2178 if (mainwin->lock_count == 0)
2179 state |= M_UNLOCKED;
2180 if (selection != SUMMARY_NONE)
2181 state |= M_MSG_EXIST;
2182 if (item && item->path && folder_item_parent(item) && !item->no_select) {
2183 state |= M_EXEC;
2184 /* if (item->folder->type != F_NEWS) */
2185 state |= M_ALLOW_DELETE;
2187 if (prefs_common.immediate_exec == 0
2188 && mainwin->lock_count == 0)
2189 state |= M_DELAY_EXEC;
2191 if ((selection == SUMMARY_NONE && item->hide_read_msgs)
2192 || selection != SUMMARY_NONE)
2193 state |= M_HIDE_READ_MSG;
2195 if (mainwin->summaryview->threaded)
2196 state |= M_THREADED;
2197 else
2198 state |= M_UNTHREADED;
2199 if (selection == SUMMARY_SELECTED_SINGLE ||
2200 selection == SUMMARY_SELECTED_MULTIPLE)
2201 state |= M_TARGET_EXIST;
2202 if (selection == SUMMARY_SELECTED_SINGLE)
2203 state |= M_SINGLE_TARGET_EXIST;
2204 if (mainwin->summaryview->folder_item &&
2205 mainwin->summaryview->folder_item->folder->klass->type == F_NEWS)
2206 state |= M_NEWS;
2207 else
2208 state |= M_NOT_NEWS;
2209 if (prefs_common.actions_list && g_slist_length(prefs_common.actions_list))
2210 state |= M_ACTIONS_EXIST;
2212 if (procmsg_have_queued_mails_fast() && !procmsg_is_sending())
2213 state |= M_HAVE_QUEUED_MAILS;
2215 if (selection == SUMMARY_SELECTED_SINGLE &&
2216 (item &&
2217 (folder_has_parent_of_type(item, F_DRAFT) ||
2218 folder_has_parent_of_type(item, F_OUTBOX) ||
2219 folder_has_parent_of_type(item, F_QUEUE))))
2220 state |= M_ALLOW_REEDIT;
2221 if (cur_account)
2222 state |= M_HAVE_ACCOUNT;
2224 if (any_folder_want_synchronise())
2225 state |= M_WANT_SYNC;
2227 for ( ; account_list != NULL; account_list = account_list->next) {
2228 if (((PrefsAccount*)account_list->data)->protocol == A_NNTP) {
2229 state |= M_HAVE_NEWS_ACCOUNT;
2230 break;
2234 if (procmsg_spam_can_learn() &&
2235 (mainwin->summaryview->folder_item &&
2236 mainwin->summaryview->folder_item->folder->klass->type != F_UNKNOWN &&
2237 mainwin->summaryview->folder_item->folder->klass->type != F_NEWS)) {
2238 state |= M_CAN_LEARN_SPAM;
2241 if (inc_is_active())
2242 state |= M_INC_ACTIVE;
2244 if (mainwin->summaryview->deleted > 0 ||
2245 mainwin->summaryview->moved > 0 ||
2246 mainwin->summaryview->copied > 0)
2247 state |= M_DELAY_EXEC;
2249 return state;
2254 void main_window_set_menu_sensitive(MainWindow *mainwin)
2256 GtkItemFactory *ifactory = mainwin->menu_factory;
2257 SensitiveCond state;
2258 gboolean sensitive;
2259 GtkWidget *menu;
2260 GtkWidget *menuitem;
2261 SummaryView *summaryview;
2262 gchar *menu_path;
2263 gint i;
2264 GList *cur_item;
2266 static const struct {
2267 gchar *const entry;
2268 SensitiveCond cond;
2269 } entry[] = {
2270 {"/File/Save as...", M_TARGET_EXIST},
2271 {"/File/Print..." , M_TARGET_EXIST},
2272 {"/File/Synchronise folders", M_WANT_SYNC},
2273 {"/File/Exit" , M_UNLOCKED},
2275 {"/Edit/Select thread" , M_SINGLE_TARGET_EXIST},
2276 {"/Edit/Delete thread" , M_SINGLE_TARGET_EXIST},
2277 {"/Edit/Find in current message...", M_SINGLE_TARGET_EXIST},
2279 {"/View/Set displayed columns/in Folder list..."
2280 , M_UNLOCKED},
2281 {"/View/Sort" , M_EXEC},
2282 {"/View/Thread view" , M_EXEC},
2283 {"/View/Expand all threads" , M_MSG_EXIST},
2284 {"/View/Collapse all threads" , M_MSG_EXIST},
2285 {"/View/Hide read messages" , M_HIDE_READ_MSG},
2286 {"/View/Go to/Previous message" , M_MSG_EXIST},
2287 {"/View/Go to/Next message" , M_MSG_EXIST},
2288 {"/View/Go to/Previous unread message" , M_MSG_EXIST},
2289 {"/View/Go to/Previous new message" , M_MSG_EXIST},
2290 {"/View/Go to/Previous marked message" , M_MSG_EXIST},
2291 {"/View/Go to/Previous labeled message", M_MSG_EXIST},
2292 {"/View/Go to/Next labeled message", M_MSG_EXIST},
2293 {"/View/Go to/Last read message" , M_SINGLE_TARGET_EXIST},
2294 {"/View/Go to/Parent message" , M_SINGLE_TARGET_EXIST},
2295 {"/View/Open in new window" , M_SINGLE_TARGET_EXIST},
2296 {"/View/Message source" , M_SINGLE_TARGET_EXIST},
2297 {"/View/All headers" , M_SINGLE_TARGET_EXIST},
2298 {"/View/Quotes" , M_SINGLE_TARGET_EXIST},
2300 {"/Message/Receive/Get from current account"
2301 , M_HAVE_ACCOUNT|M_UNLOCKED},
2302 {"/Message/Receive/Get from all accounts"
2303 , M_HAVE_ACCOUNT|M_UNLOCKED},
2304 {"/Message/Receive/Cancel receiving"
2305 , M_INC_ACTIVE},
2306 {"/Message/Send queued messages" , M_HAVE_ACCOUNT|M_HAVE_QUEUED_MAILS},
2307 {"/Message/Compose a news message", M_HAVE_NEWS_ACCOUNT},
2308 {"/Message/Reply" , M_HAVE_ACCOUNT|M_TARGET_EXIST},
2309 {"/Message/Reply to" , M_HAVE_ACCOUNT|M_TARGET_EXIST},
2310 {"/Message/Follow-up and reply to", M_HAVE_ACCOUNT|M_TARGET_EXIST|M_NEWS},
2311 {"/Message/Forward" , M_HAVE_ACCOUNT|M_TARGET_EXIST},
2312 {"/Message/Forward as attachment" , M_HAVE_ACCOUNT|M_TARGET_EXIST},
2313 {"/Message/Redirect" , M_HAVE_ACCOUNT|M_TARGET_EXIST},
2314 {"/Message/Move..." , M_TARGET_EXIST|M_ALLOW_DELETE},
2315 {"/Message/Copy..." , M_TARGET_EXIST|M_EXEC},
2316 {"/Message/Move to trash" , M_TARGET_EXIST|M_ALLOW_DELETE|M_NOT_NEWS},
2317 {"/Message/Delete..." , M_TARGET_EXIST|M_ALLOW_DELETE},
2318 {"/Message/Cancel a news message" , M_TARGET_EXIST|M_ALLOW_DELETE|M_NEWS},
2319 {"/Message/Mark" , M_TARGET_EXIST},
2320 {"/Message/Mark/Mark as spam" , M_TARGET_EXIST|M_CAN_LEARN_SPAM},
2321 {"/Message/Mark/Mark as ham" , M_TARGET_EXIST|M_CAN_LEARN_SPAM},
2322 {"/Message/Mark/Ignore thread" , M_TARGET_EXIST},
2323 {"/Message/Mark/Unignore thread" , M_TARGET_EXIST},
2324 {"/Message/Mark/Lock" , M_TARGET_EXIST},
2325 {"/Message/Mark/Unlock" , M_TARGET_EXIST},
2326 {"/Message/Color label" , M_TARGET_EXIST},
2327 {"/Message/Re-edit" , M_HAVE_ACCOUNT|M_ALLOW_REEDIT},
2329 {"/Tools/Add sender to address book" , M_SINGLE_TARGET_EXIST},
2330 {"/Tools/Harvest addresses" , M_MSG_EXIST},
2331 {"/Tools/Harvest addresses/from Messages..."
2332 , M_TARGET_EXIST},
2333 {"/Tools/Filter all messages in folder", M_MSG_EXIST|M_EXEC},
2334 {"/Tools/Filter selected messages" , M_TARGET_EXIST|M_EXEC},
2335 {"/Tools/Create filter rule" , M_SINGLE_TARGET_EXIST|M_UNLOCKED},
2336 {"/Tools/Create processing rule" , M_SINGLE_TARGET_EXIST|M_UNLOCKED},
2337 {"/Tools/List URLs..." , M_TARGET_EXIST},
2338 {"/Tools/Actions" , M_TARGET_EXIST|M_ACTIONS_EXIST},
2339 {"/Tools/Execute" , M_DELAY_EXEC},
2340 {"/Tools/Delete duplicated messages/In selected folder" , M_MSG_EXIST|M_ALLOW_DELETE},
2342 {"/Configuration", M_UNLOCKED},
2343 {"/Configuration/Preferences for current account...", M_UNLOCKED},
2344 {"/Configuration/Create new account...", M_UNLOCKED},
2345 {"/Configuration/Edit accounts...", M_UNLOCKED},
2347 {NULL, 0}
2350 state = main_window_get_current_state(mainwin);
2352 for (i = 0; entry[i].entry != NULL; i++) {
2353 sensitive = ((entry[i].cond & state) == entry[i].cond);
2354 menu_set_sensitive(ifactory, entry[i].entry, sensitive);
2357 menu = gtk_item_factory_get_widget(ifactory, "/Message/Receive");
2359 /* search for separator */
2360 for (cur_item = GTK_MENU_SHELL(menu)->children; cur_item != NULL;
2361 cur_item = cur_item->next) {
2362 if (GTK_BIN(cur_item->data)->child == NULL) {
2363 cur_item = cur_item->next;
2364 break;
2368 for (; cur_item != NULL; cur_item = cur_item->next) {
2369 gtk_widget_set_sensitive(GTK_WIDGET(cur_item->data),
2370 (M_UNLOCKED & state) != 0);
2373 main_window_menu_callback_block(mainwin);
2375 #define SET_CHECK_MENU_ACTIVE(path, active) \
2377 menuitem = gtk_item_factory_get_widget(ifactory, path); \
2378 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), active); \
2381 SET_CHECK_MENU_ACTIVE("/View/Show or hide/Message view",
2382 messageview_is_visible(mainwin->messageview));
2384 summaryview = mainwin->summaryview;
2385 menu_path = "/View/Sort/Don't sort";
2387 switch (summaryview->sort_key) {
2388 case SORT_BY_NUMBER:
2389 menu_path = "/View/Sort/by number"; break;
2390 case SORT_BY_SIZE:
2391 menu_path = "/View/Sort/by Size"; break;
2392 case SORT_BY_DATE:
2393 menu_path = "/View/Sort/by Date"; break;
2394 case SORT_BY_FROM:
2395 menu_path = "/View/Sort/by From"; break;
2396 case SORT_BY_TO:
2397 menu_path = "/View/Sort/by To"; break;
2398 case SORT_BY_SUBJECT:
2399 menu_path = "/View/Sort/by Subject"; break;
2400 case SORT_BY_LABEL:
2401 menu_path = "/View/Sort/by color label"; break;
2402 case SORT_BY_MARK:
2403 menu_path = "/View/Sort/by mark"; break;
2404 case SORT_BY_STATUS:
2405 menu_path = "/View/Sort/by status"; break;
2406 case SORT_BY_MIME:
2407 menu_path = "/View/Sort/by attachment"; break;
2408 case SORT_BY_SCORE:
2409 menu_path = "/View/Sort/by score"; break;
2410 case SORT_BY_LOCKED:
2411 menu_path = "/View/Sort/by locked"; break;
2412 case SORT_BY_NONE:
2413 default:
2414 menu_path = "/View/Sort/Don't sort"; break;
2416 SET_CHECK_MENU_ACTIVE(menu_path, TRUE);
2418 if (summaryview->sort_type == SORT_ASCENDING) {
2419 SET_CHECK_MENU_ACTIVE("/View/Sort/Ascending", TRUE);
2420 } else {
2421 SET_CHECK_MENU_ACTIVE("/View/Sort/Descending", TRUE);
2424 if (summaryview->sort_key != SORT_BY_NONE) {
2425 menu_set_sensitive(ifactory, "/View/Sort/Ascending", TRUE);
2426 menu_set_sensitive(ifactory, "/View/Sort/Descending", TRUE);
2427 } else {
2428 menu_set_sensitive(ifactory, "/View/Sort/Ascending", FALSE);
2429 menu_set_sensitive(ifactory, "/View/Sort/Descending", FALSE);
2432 if (mainwin->messageview
2433 && mainwin->messageview->mimeview
2434 && mainwin->messageview->mimeview->textview)
2435 SET_CHECK_MENU_ACTIVE("/View/All headers",
2436 mainwin->messageview->mimeview->textview->show_all_headers);
2437 SET_CHECK_MENU_ACTIVE("/View/Thread view", (state & M_THREADED) != 0);
2438 SET_CHECK_MENU_ACTIVE("/View/Quotes/Fold all", FALSE);
2439 SET_CHECK_MENU_ACTIVE("/View/Quotes/Fold from level 2", FALSE);
2440 SET_CHECK_MENU_ACTIVE("/View/Quotes/Fold from level 3", FALSE);
2441 if (prefs_common.hide_quotes == 1)
2442 SET_CHECK_MENU_ACTIVE("/View/Quotes/Fold all", TRUE);
2443 if (prefs_common.hide_quotes == 2)
2444 SET_CHECK_MENU_ACTIVE("/View/Quotes/Fold from level 2", TRUE);
2445 if (prefs_common.hide_quotes == 3)
2446 SET_CHECK_MENU_ACTIVE("/View/Quotes/Fold from level 3", TRUE);
2448 #undef SET_CHECK_MENU_ACTIVE
2450 main_window_menu_callback_unblock(mainwin);
2453 void main_create_mailing_list_menu (MainWindow *mainwin, MsgInfo *msginfo)
2455 GtkItemFactory *ifactory;
2456 gint is_menu = 0;
2457 ifactory = gtk_item_factory_from_widget(mainwin->menubar);
2459 if (msginfo)
2460 is_menu = mailing_list_create_submenu (ifactory, msginfo);
2461 if (is_menu)
2462 gtk_widget_set_sensitive (gtk_item_factory_get_item
2463 (ifactory,"/Message/Mailing-List"), TRUE);
2464 else
2465 gtk_widget_set_sensitive (gtk_item_factory_get_item
2466 (ifactory,"/Message/Mailing-List"), FALSE);
2469 static gint mailing_list_create_submenu (GtkItemFactory *ifactory, MsgInfo *msginfo)
2471 gint menu_nb = 0;
2472 GtkWidget *menuitem;
2474 if (!msginfo || !msginfo->extradata) {
2475 menu_set_sensitive(ifactory, "/Message/Mailing-List/Post", FALSE);
2476 menu_set_sensitive(ifactory, "/Message/Mailing-List/Help", FALSE);
2477 menu_set_sensitive(ifactory, "/Message/Mailing-List/Subscribe", FALSE);
2478 menu_set_sensitive(ifactory, "/Message/Mailing-List/Unsubscribe", FALSE);
2479 menu_set_sensitive(ifactory, "/Message/Mailing-List/View archive", FALSE);
2480 menu_set_sensitive(ifactory, "/Message/Mailing-List/Contact owner", FALSE);
2481 return 0;
2484 /* Mailing list post */
2485 if (!strcmp2 (msginfo->extradata->list_post, "NO")) {
2486 g_free(msginfo->extradata->list_post);
2487 msginfo->extradata->list_post = g_strdup (_("No posting allowed"));
2489 menuitem = gtk_item_factory_get_item (ifactory, "/Message/Mailing-List/Post");
2491 menu_nb += mailing_list_populate_submenu (menuitem, msginfo->extradata->list_post);
2493 /* Mailing list help */
2494 menuitem = gtk_item_factory_get_item (ifactory, "/Message/Mailing-List/Help");
2496 menu_nb += mailing_list_populate_submenu (menuitem, msginfo->extradata->list_help);
2498 /* Mailing list subscribe */
2499 menuitem = gtk_item_factory_get_item (ifactory, "/Message/Mailing-List/Subscribe");
2501 menu_nb += mailing_list_populate_submenu (menuitem, msginfo->extradata->list_subscribe);
2503 /* Mailing list unsubscribe */
2504 menuitem = gtk_item_factory_get_item (ifactory, "/Message/Mailing-List/Unsubscribe");
2506 menu_nb += mailing_list_populate_submenu (menuitem, msginfo->extradata->list_unsubscribe);
2508 /* Mailing list view archive */
2509 menuitem = gtk_item_factory_get_item (ifactory, "/Message/Mailing-List/View archive");
2511 menu_nb += mailing_list_populate_submenu (menuitem, msginfo->extradata->list_archive);
2513 /* Mailing list contact owner */
2514 menuitem = gtk_item_factory_get_item (ifactory, "/Message/Mailing-List/Contact owner");
2516 menu_nb += mailing_list_populate_submenu (menuitem, msginfo->extradata->list_owner);
2518 return menu_nb;
2521 static gint mailing_list_populate_submenu (GtkWidget *menuitem, const gchar * list_header)
2523 GtkWidget *item, *menu;
2524 const gchar *url_pt ;
2525 gchar url_decoded[BUFFSIZE];
2526 GList *amenu, *alist;
2527 gint menu_nb = 0;
2529 menu = GTK_WIDGET(GTK_MENU_ITEM(menuitem)->submenu);
2531 /* First delete old submenu */
2532 /* FIXME: we can optimize this, and only change/add/delete necessary items */
2533 for (amenu = (GTK_MENU_SHELL(menu)->children) ; amenu; ) {
2534 alist = amenu->next;
2535 item = GTK_WIDGET (amenu->data);
2536 gtk_widget_destroy (item);
2537 amenu = alist;
2539 if (list_header) {
2540 for (url_pt = list_header; url_pt && *url_pt;) {
2541 get_url_part (&url_pt, url_decoded, BUFFSIZE);
2542 item = NULL;
2543 if (!g_strncasecmp(url_decoded, "mailto:", 7)) {
2544 item = gtk_menu_item_new_with_label ((url_decoded));
2545 g_signal_connect(G_OBJECT(item), "activate",
2546 G_CALLBACK(mailing_list_compose),
2547 NULL);
2549 else if (!g_strncasecmp (url_decoded, "http:", 5) ||
2550 !g_strncasecmp (url_decoded, "https:",6)) {
2552 item = gtk_menu_item_new_with_label ((url_decoded));
2553 g_signal_connect(G_OBJECT(item), "activate",
2554 G_CALLBACK(mailing_list_open_uri),
2555 NULL);
2557 if (item) {
2558 gtk_menu_append (GTK_MENU(menu), item);
2559 gtk_widget_show (item);
2560 menu_nb++;
2564 if (menu_nb)
2565 gtk_widget_set_sensitive (menuitem, TRUE);
2566 else
2567 gtk_widget_set_sensitive (menuitem, FALSE);
2570 return menu_nb;
2573 static void get_url_part (const gchar **buffer, gchar *url_decoded, gint maxlen)
2575 gchar tmp[BUFFSIZE];
2576 const gchar *buf;
2577 gint i = 0;
2578 buf = *buffer;
2579 gboolean with_plus = TRUE;
2581 if (buf == 0x00) {
2582 *url_decoded = '\0';
2583 *buffer = NULL;
2584 return;
2586 /* Ignore spaces, comments and tabs () */
2587 for (;*buf == ' ' || *buf == '(' || *buf == '\t'; buf++)
2588 if (*buf == '(')
2589 for (;*buf != ')' && *buf != 0x00; buf++);
2591 /* First non space and non comment must be a < */
2592 if (*buf =='<' ) {
2593 buf++;
2594 if (!strncmp(buf, "mailto:", strlen("mailto:")))
2595 with_plus = FALSE;
2596 for (i = 0; *buf != '>' && *buf != 0x00 && i<maxlen; tmp[i++] = *(buf++));
2597 buf++;
2599 else {
2600 *buffer = NULL;
2601 *url_decoded = '\0';
2602 return;
2605 tmp[i] = 0x00;
2606 *url_decoded = '\0';
2607 *buffer = NULL;
2609 if (i == maxlen) {
2610 return;
2612 decode_uri_with_plus (url_decoded, (const gchar *)tmp, with_plus);
2614 /* Prepare the work for the next url in the list */
2615 /* after the closing bracket >, ignore space, comments and tabs */
2616 for (;buf && *buf && (*buf == ' ' || *buf == '(' || *buf == '\t'); buf++)
2617 if (*buf == '(')
2618 for (;*buf != ')' && *buf != 0x00; buf++);
2620 if (!buf || !*buf) {
2621 *buffer = NULL;
2622 return;
2625 /* now first non space, non comment must be a comma */
2626 if (*buf != ',')
2627 for (;*buf != 0x00; buf++);
2628 else
2629 buf++;
2630 *buffer = buf;
2633 static void mailing_list_compose (GtkWidget *w, gpointer *data)
2635 gchar *mailto;
2637 gtk_label_get (GTK_LABEL (GTK_BIN (w)->child), (gchar **) &mailto);
2638 compose_new(NULL, mailto+7, NULL);
2641 static void mailing_list_open_uri (GtkWidget *w, gpointer *data)
2644 gchar *mailto;
2646 gtk_label_get (GTK_LABEL (GTK_BIN (w)->child), (gchar **) &mailto);
2647 open_uri (mailto, prefs_common.uri_cmd);
2650 void main_window_popup(MainWindow *mainwin)
2652 if (!GTK_WIDGET_VISIBLE(GTK_WIDGET(mainwin->window)))
2653 main_window_show(mainwin);
2655 gtkut_window_popup(mainwin->window);
2658 void main_window_show(MainWindow *mainwin)
2660 gtk_widget_show(mainwin->window);
2661 gtk_widget_show(mainwin->vbox_body);
2663 gtk_widget_set_uposition(mainwin->window,
2664 prefs_common.mainwin_x,
2665 prefs_common.mainwin_y);
2667 gtk_widget_set_size_request(GTK_WIDGET_PTR(mainwin->folderview),
2668 prefs_common.folderview_width,
2669 prefs_common.folderview_height);
2670 gtk_widget_set_size_request(GTK_WIDGET_PTR(mainwin->summaryview),
2671 prefs_common.summaryview_width,
2672 prefs_common.summaryview_height);
2673 gtk_widget_set_size_request(GTK_WIDGET_PTR(mainwin->messageview),
2674 prefs_common.msgview_width,
2675 prefs_common.msgview_height);
2678 void main_window_hide(MainWindow *mainwin)
2680 main_window_get_size(mainwin);
2681 main_window_get_position(mainwin);
2683 gtk_widget_hide(mainwin->window);
2684 gtk_widget_hide(mainwin->vbox_body);
2687 static void main_window_set_widgets(MainWindow *mainwin, LayoutType layout_mode)
2689 GtkWidget *folderwin = NULL;
2690 GtkWidget *messagewin = NULL;
2691 GtkWidget *hpaned;
2692 GtkWidget *vpaned;
2693 GtkWidget *vbox_body = mainwin->vbox_body;
2694 GtkItemFactory *ifactory = mainwin->menu_factory;
2695 GtkWidget *menuitem;
2696 gboolean first_set = (mainwin->hpaned == NULL);
2697 debug_print("Setting widgets... ");
2699 if (layout_mode == SMALL_LAYOUT && first_set) {
2700 gtk_widget_set_size_request(GTK_WIDGET_PTR(mainwin->folderview),
2701 prefs_common.folderview_width,
2702 prefs_common.folderview_height);
2703 gtk_widget_set_size_request(GTK_WIDGET_PTR(mainwin->summaryview),
2704 0,0);
2705 gtk_widget_set_size_request(GTK_WIDGET_PTR(mainwin->messageview),
2706 0,0);
2707 } else {
2708 gtk_widget_set_size_request(GTK_WIDGET_PTR(mainwin->folderview),
2709 prefs_common.folderview_width,
2710 prefs_common.folderview_height);
2711 gtk_widget_set_size_request(GTK_WIDGET_PTR(mainwin->summaryview),
2712 prefs_common.summaryview_width,
2713 prefs_common.summaryview_height);
2714 gtk_widget_set_size_request(GTK_WIDGET_PTR(mainwin->messageview),
2715 prefs_common.msgview_width,
2716 prefs_common.msgview_height);
2719 mainwin->messageview->statusbar = mainwin->statusbar;
2720 mainwin->messageview->statusbar_cid = mainwin->messageview_cid;
2722 /* clean top-most container */
2723 if (mainwin->hpaned) {
2724 if (mainwin->hpaned->parent == mainwin->vpaned)
2725 gtk_widget_destroy(mainwin->vpaned);
2726 else
2727 gtk_widget_destroy(mainwin->hpaned);
2730 menu_set_sensitive(ifactory, "/View/Show or hide/Message view",
2731 (layout_mode != WIDE_MSGLIST_LAYOUT && layout_mode != SMALL_LAYOUT));
2732 switch (layout_mode) {
2733 case VERTICAL_LAYOUT:
2734 case NORMAL_LAYOUT:
2735 case SMALL_LAYOUT:
2736 hpaned = gtk_hpaned_new();
2737 if (layout_mode == VERTICAL_LAYOUT)
2738 vpaned = gtk_hpaned_new();
2739 else
2740 vpaned = gtk_vpaned_new();
2741 gtk_box_pack_start(GTK_BOX(vbox_body), hpaned, TRUE, TRUE, 0);
2742 gtk_paned_add1(GTK_PANED(hpaned),
2743 GTK_WIDGET_PTR(mainwin->folderview));
2744 gtk_widget_show(hpaned);
2745 gtk_widget_queue_resize(hpaned);
2747 if (messageview_is_visible(mainwin->messageview)) {
2748 gtk_paned_add2(GTK_PANED(hpaned), vpaned);
2749 gtk_paned_add1(GTK_PANED(vpaned),
2750 GTK_WIDGET_PTR(mainwin->summaryview));
2751 } else {
2752 gtk_paned_add2(GTK_PANED(hpaned),
2753 GTK_WIDGET_PTR(mainwin->summaryview));
2754 gtk_widget_ref(vpaned);
2756 gtk_paned_add2(GTK_PANED(vpaned),
2757 GTK_WIDGET_PTR(mainwin->messageview));
2758 gtk_widget_show(vpaned);
2759 if (layout_mode == SMALL_LAYOUT && first_set) {
2760 mainwin_paned_show_first(GTK_PANED(hpaned));
2762 gtk_widget_queue_resize(vpaned);
2763 break;
2764 case WIDE_LAYOUT:
2765 vpaned = gtk_vpaned_new();
2766 hpaned = gtk_hpaned_new();
2767 gtk_box_pack_start(GTK_BOX(vbox_body), vpaned, TRUE, TRUE, 0);
2768 gtk_paned_add1(GTK_PANED(vpaned), hpaned);
2770 gtk_paned_add1(GTK_PANED(hpaned),
2771 GTK_WIDGET_PTR(mainwin->folderview));
2772 gtk_paned_add2(GTK_PANED(hpaned),
2773 GTK_WIDGET_PTR(mainwin->summaryview));
2775 gtk_widget_show(hpaned);
2776 gtk_widget_queue_resize(hpaned);
2778 if (messageview_is_visible(mainwin->messageview)) {
2779 gtk_paned_add2(GTK_PANED(vpaned),
2780 GTK_WIDGET_PTR(mainwin->messageview));
2781 } else {
2782 gtk_widget_ref(GTK_WIDGET_PTR(mainwin->messageview));
2784 gtk_widget_show(vpaned);
2785 gtk_widget_queue_resize(vpaned);
2786 break;
2787 case WIDE_MSGLIST_LAYOUT:
2788 vpaned = gtk_vpaned_new();
2789 hpaned = gtk_hpaned_new();
2790 gtk_box_pack_start(GTK_BOX(vbox_body), vpaned, TRUE, TRUE, 0);
2792 gtk_paned_add1(GTK_PANED(vpaned),
2793 GTK_WIDGET_PTR(mainwin->summaryview));
2794 gtk_paned_add1(GTK_PANED(hpaned),
2795 GTK_WIDGET_PTR(mainwin->folderview));
2797 gtk_widget_show(hpaned);
2798 gtk_widget_queue_resize(hpaned);
2800 if (messageview_is_visible(mainwin->messageview)) {
2801 gtk_paned_add2(GTK_PANED(hpaned),
2802 GTK_WIDGET_PTR(mainwin->messageview));
2803 } else {
2804 gtk_widget_ref(GTK_WIDGET_PTR(mainwin->messageview));
2806 gtk_paned_add2(GTK_PANED(vpaned), hpaned);
2808 gtk_widget_show(vpaned);
2809 gtk_widget_queue_resize(vpaned);
2810 break;
2811 default:
2812 g_warning("Unknown layout");
2813 return;
2816 mainwin->hpaned = hpaned;
2817 mainwin->vpaned = vpaned;
2819 if (layout_mode == SMALL_LAYOUT) {
2820 if (mainwin->messageview->visible)
2821 main_window_toggle_message_view(mainwin);
2824 if (layout_mode == SMALL_LAYOUT && first_set) {
2825 gtk_widget_realize(mainwin->window);
2826 gtk_widget_realize(mainwin->folderview->ctree);
2827 gtk_widget_realize(mainwin->summaryview->hbox);
2828 gtk_widget_realize(mainwin->summaryview->hbox_l);
2829 gtk_widget_set_size_request(GTK_WIDGET_PTR(mainwin->folderview),
2830 prefs_common.folderview_width,
2831 prefs_common.folderview_height);
2832 gtk_widget_set_size_request(GTK_WIDGET_PTR(mainwin->summaryview),
2833 0,0);
2834 gtk_widget_set_size_request(GTK_WIDGET_PTR(mainwin->messageview),
2835 0,0);
2836 gtk_widget_set_size_request(GTK_WIDGET(mainwin->window),
2837 prefs_common.mainwin_width,
2838 prefs_common.mainwin_height);
2839 gtk_paned_set_position(GTK_PANED(mainwin->hpaned), 800);
2841 /* remove headerview if not in prefs */
2842 headerview_set_visibility(mainwin->messageview->headerview,
2843 prefs_common.display_header_pane);
2845 if (messageview_is_visible(mainwin->messageview))
2846 gtk_arrow_set(GTK_ARROW(mainwin->summaryview->toggle_arrow),
2847 GTK_ARROW_DOWN, GTK_SHADOW_OUT);
2848 else
2849 gtk_arrow_set(GTK_ARROW(mainwin->summaryview->toggle_arrow),
2850 GTK_ARROW_UP, GTK_SHADOW_OUT);
2852 gtk_window_move(GTK_WINDOW(mainwin->window),
2853 prefs_common.mainwin_x,
2854 prefs_common.mainwin_y);
2856 gtk_widget_queue_resize(vbox_body);
2857 gtk_widget_queue_resize(mainwin->vbox);
2858 gtk_widget_queue_resize(mainwin->window);
2859 /* CLAWS: previous "gtk_widget_show_all" makes noticeview
2860 * and mimeview icon list/ctree lose track of their visibility states */
2861 if (!noticeview_is_visible(mainwin->messageview->noticeview))
2862 gtk_widget_hide(GTK_WIDGET_PTR(mainwin->messageview->noticeview));
2863 if (!noticeview_is_visible(mainwin->messageview->mimeview->siginfoview))
2864 gtk_widget_hide(GTK_WIDGET_PTR(mainwin->messageview->mimeview->siginfoview));
2865 if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(mainwin->messageview->mimeview->mime_toggle)))
2866 gtk_widget_hide(mainwin->messageview->mimeview->icon_mainbox);
2867 else
2868 gtk_widget_hide(mainwin->messageview->mimeview->ctree_mainbox);
2870 prefs_common.layout_mode = layout_mode;
2872 menuitem = gtk_item_factory_get_item
2873 (ifactory, "/View/Show or hide/Message view");
2874 gtk_check_menu_item_set_active
2875 (GTK_CHECK_MENU_ITEM(menuitem),
2876 messageview_is_visible(mainwin->messageview));
2878 #define SET_CHECK_MENU_ACTIVE(path, active) \
2880 menuitem = gtk_item_factory_get_widget(ifactory, path); \
2881 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), active); \
2884 switch (prefs_common.layout_mode) {
2885 case NORMAL_LAYOUT:
2886 SET_CHECK_MENU_ACTIVE("/View/Layout/Standard", TRUE);
2887 break;
2888 case VERTICAL_LAYOUT:
2889 SET_CHECK_MENU_ACTIVE("/View/Layout/Three columns", TRUE);
2890 break;
2891 case WIDE_LAYOUT:
2892 SET_CHECK_MENU_ACTIVE("/View/Layout/Wide message", TRUE);
2893 break;
2894 case WIDE_MSGLIST_LAYOUT:
2895 SET_CHECK_MENU_ACTIVE("/View/Layout/Wide message list", TRUE);
2896 break;
2897 case SMALL_LAYOUT:
2898 SET_CHECK_MENU_ACTIVE("/View/Layout/Small screen", TRUE);
2899 break;
2901 #undef SET_CHECK_MENU_ACTIVE
2903 if (folderwin) {
2904 g_signal_connect
2905 (G_OBJECT(folderwin), "size_allocate",
2906 G_CALLBACK(folder_window_size_allocate_cb),
2907 mainwin);
2909 if (messagewin) {
2910 g_signal_connect
2911 (G_OBJECT(messagewin), "size_allocate",
2912 G_CALLBACK(message_window_size_allocate_cb),
2913 mainwin);
2916 debug_print("done.\n");
2919 void main_window_destroy_all(void)
2921 while (mainwin_list != NULL) {
2922 MainWindow *mainwin = (MainWindow*)mainwin_list->data;
2924 /* free toolbar stuff */
2925 toolbar_clear_list(TOOLBAR_MAIN);
2926 TOOLBAR_DESTROY_ACTIONS(mainwin->toolbar->action_list);
2927 TOOLBAR_DESTROY_ITEMS(mainwin->toolbar->item_list);
2929 mainwin->folderview->mainwin = NULL;
2930 mainwin->summaryview->mainwin = NULL;
2931 mainwin->messageview->mainwin = NULL;
2933 g_free(mainwin->toolbar);
2934 g_free(mainwin);
2936 mainwin_list = g_list_remove(mainwin_list, mainwin);
2938 g_list_free(mainwin_list);
2939 mainwin_list = NULL;
2942 static void toolbar_child_attached(GtkWidget *widget, GtkWidget *child,
2943 gpointer data)
2945 gtk_widget_set_size_request(child, 1, -1);
2948 static void toolbar_child_detached(GtkWidget *widget, GtkWidget *child,
2949 gpointer data)
2951 gtk_widget_set_size_request(child, -1, -1);
2954 static gboolean ac_label_button_pressed(GtkWidget *widget, GdkEventButton *event,
2955 gpointer data)
2957 MainWindow *mainwin = (MainWindow *)data;
2959 if (!event) return FALSE;
2961 gtk_button_set_relief(GTK_BUTTON(widget), GTK_RELIEF_NORMAL);
2962 g_object_set_data(G_OBJECT(mainwin->ac_menu), "menu_button",
2963 widget);
2965 gtk_menu_popup(GTK_MENU(mainwin->ac_menu), NULL, NULL,
2966 menu_button_position, widget,
2967 event->button, event->time);
2969 return TRUE;
2972 static gint main_window_close_cb(GtkWidget *widget, GdkEventAny *event,
2973 gpointer data)
2975 MainWindow *mainwin = (MainWindow *)data;
2976 gboolean close_allowed = TRUE;
2978 hooks_invoke(MAIN_WINDOW_CLOSE, &close_allowed);
2980 if (close_allowed && mainwin->lock_count == 0)
2981 app_exit_cb(data, 0, widget);
2983 return TRUE;
2986 static void main_window_size_allocate_cb(GtkWidget *widget,
2987 GtkAllocation *allocation,
2988 gpointer data)
2990 MainWindow *mainwin = (MainWindow *)data;
2991 main_window_get_size(mainwin);
2994 static void folder_window_size_allocate_cb(GtkWidget *widget,
2995 GtkAllocation *allocation,
2996 gpointer data)
2998 MainWindow *mainwin = (MainWindow *)data;
3000 main_window_get_size(mainwin);
3003 static void message_window_size_allocate_cb(GtkWidget *widget,
3004 GtkAllocation *allocation,
3005 gpointer data)
3007 MainWindow *mainwin = (MainWindow *)data;
3009 main_window_get_size(mainwin);
3012 static void add_mailbox_cb(MainWindow *mainwin, guint action,
3013 GtkWidget *widget)
3015 main_window_add_mailbox(mainwin);
3018 static void update_folderview_cb(MainWindow *mainwin, guint action,
3019 GtkWidget *widget)
3021 summary_show(mainwin->summaryview, NULL);
3022 folderview_check_new_all();
3025 static void foldersort_cb(MainWindow *mainwin, guint action,
3026 GtkWidget *widget)
3028 foldersort_open();
3031 static void import_mbox_cb(MainWindow *mainwin, guint action,
3032 GtkWidget *widget)
3034 /* only notify if import has failed */
3035 if (import_mbox(mainwin->summaryview->folder_item) == -1) {
3036 alertpanel_error(_("Mbox import has failed."));
3040 static void export_mbox_cb(MainWindow *mainwin, guint action,
3041 GtkWidget *widget)
3043 /* only notify if export has failed */
3044 if (export_mbox(mainwin->summaryview->folder_item) == -1) {
3045 alertpanel_error(_("Export to mbox has failed."));
3049 static void export_list_mbox_cb(MainWindow *mainwin, guint action,
3050 GtkWidget *widget)
3052 /* only notify if export has failed */
3053 if (summaryview_export_mbox_list(mainwin->summaryview) == -1) {
3054 alertpanel_error(_("Export to mbox has failed."));
3058 static void empty_trash_cb(MainWindow *mainwin, guint action,
3059 GtkWidget *widget)
3061 main_window_empty_trash(mainwin, TRUE);
3064 static void save_as_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
3066 summary_save_as(mainwin->summaryview);
3069 static void print_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
3071 summary_print(mainwin->summaryview);
3074 static void app_exit_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
3076 if (prefs_common.confirm_on_exit) {
3077 if (alertpanel(_("Exit"), _("Exit Claws Mail?"),
3078 GTK_STOCK_CANCEL, GTK_STOCK_QUIT, NULL)
3079 != G_ALERTALTERNATE)
3080 return;
3081 manage_window_focus_in(mainwin->window, NULL, NULL);
3084 app_will_exit(widget, mainwin);
3087 static void search_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
3089 if (action == 1)
3090 summary_search(mainwin->summaryview);
3091 else
3092 message_search(mainwin->messageview);
3095 static void mainwindow_quicksearch(MainWindow *mainwin, guint action, GtkWidget *widget)
3097 summaryview_activate_quicksearch(mainwin->summaryview, TRUE);
3100 static void toggle_message_cb(MainWindow *mainwin, guint action,
3101 GtkWidget *widget)
3103 gboolean active;
3105 active = GTK_CHECK_MENU_ITEM(widget)->active;
3107 if (active != messageview_is_visible(mainwin->messageview))
3108 summary_toggle_view(mainwin->summaryview);
3111 static void toggle_toolbar_cb(MainWindow *mainwin, guint action,
3112 GtkWidget *widget)
3114 toolbar_toggle(action, mainwin);
3117 static void main_window_reply_cb(MainWindow *mainwin, guint action,
3118 GtkWidget *widget)
3120 MessageView *msgview = (MessageView*)mainwin->messageview;
3121 GSList *msginfo_list = NULL;
3123 g_return_if_fail(msgview != NULL);
3125 msginfo_list = summary_get_selection(mainwin->summaryview);
3126 g_return_if_fail(msginfo_list != NULL);
3127 compose_reply_from_messageview(msgview, msginfo_list, action);
3128 g_slist_free(msginfo_list);
3132 static void toggle_statusbar_cb(MainWindow *mainwin, guint action,
3133 GtkWidget *widget)
3135 if (GTK_CHECK_MENU_ITEM(widget)->active) {
3136 gtk_widget_show(mainwin->hbox_stat);
3137 prefs_common.show_statusbar = TRUE;
3138 } else {
3139 gtk_widget_hide(mainwin->hbox_stat);
3140 prefs_common.show_statusbar = FALSE;
3144 static void set_layout_cb(MainWindow *mainwin, guint action,
3145 GtkWidget *widget)
3147 LayoutType layout_mode = action;
3148 LayoutType old_layout_mode = prefs_common.layout_mode;
3149 if (mainwin->menu_lock_count) {
3150 return;
3152 if (!GTK_CHECK_MENU_ITEM(widget)->active) {
3153 return;
3156 if (layout_mode == prefs_common.layout_mode) {
3157 return;
3160 if (!mainwin->messageview->visible && layout_mode != SMALL_LAYOUT)
3161 main_window_toggle_message_view(mainwin);
3162 else if (mainwin->messageview->visible && layout_mode == SMALL_LAYOUT)
3163 main_window_toggle_message_view(mainwin);
3165 main_window_separation_change(mainwin, layout_mode);
3166 mainwindow_reset_paned(GTK_PANED(mainwin->vpaned));
3167 if (old_layout_mode == SMALL_LAYOUT && layout_mode != SMALL_LAYOUT) {
3168 mainwindow_reset_paned(GTK_PANED(mainwin->hpaned));
3170 if (old_layout_mode != SMALL_LAYOUT && layout_mode == SMALL_LAYOUT) {
3171 mainwin_paned_show_first(GTK_PANED(mainwin->hpaned));
3172 mainwindow_exit_folder(mainwin);
3174 summary_relayout(mainwin->summaryview);
3177 void main_window_toggle_work_offline (MainWindow *mainwin, gboolean offline,
3178 gboolean ask_sync)
3180 offline_ask_sync = ask_sync;
3181 if (offline)
3182 online_switch_clicked (GTK_BUTTON(mainwin->online_switch), mainwin);
3183 else
3184 online_switch_clicked (GTK_BUTTON(mainwin->offline_switch), mainwin);
3185 offline_ask_sync = TRUE;
3188 static void toggle_work_offline_cb (MainWindow *mainwin, guint action, GtkWidget *widget)
3190 main_window_toggle_work_offline(mainwin, GTK_CHECK_MENU_ITEM(widget)->active, TRUE);
3193 static gboolean any_folder_want_synchronise(void)
3195 GList *folderlist = folder_get_list();
3197 /* see if there are synchronised folders */
3198 for (; folderlist; folderlist = folderlist->next) {
3199 Folder *folder = (Folder *)folderlist->data;
3200 if (folder_want_synchronise(folder)) {
3201 return TRUE;
3205 return FALSE;
3208 static void mainwindow_check_synchronise(MainWindow *mainwin, gboolean ask)
3211 if (!any_folder_want_synchronise())
3212 return;
3214 if (offline_ask_sync && ask && alertpanel(_("Folder synchronisation"),
3215 _("Do you want to synchronise your folders now?"),
3216 GTK_STOCK_CANCEL, _("+_Synchronise"), NULL) != G_ALERTALTERNATE)
3217 return;
3219 folder_synchronise(NULL);
3222 static void online_switch_clicked (GtkButton *btn, gpointer data)
3224 MainWindow *mainwin;
3225 GtkItemFactory *ifactory;
3226 GtkCheckMenuItem *menuitem;
3228 mainwin = (MainWindow *) data;
3230 ifactory = gtk_item_factory_from_widget(mainwin->menubar);
3231 menuitem = GTK_CHECK_MENU_ITEM (gtk_item_factory_get_widget(ifactory, "/File/Work offline"));
3233 g_return_if_fail(mainwin != NULL);
3234 g_return_if_fail(menuitem != NULL);
3236 if (btn == GTK_BUTTON(mainwin->online_switch)) {
3237 gtk_widget_hide (mainwin->online_switch);
3238 gtk_widget_show (mainwin->offline_switch);
3239 menuitem->active = TRUE;
3240 inc_autocheck_timer_remove();
3242 /* go offline */
3243 if (prefs_common.work_offline)
3244 return;
3245 mainwindow_check_synchronise(mainwin, TRUE);
3246 prefs_common.work_offline = TRUE;
3247 imap_disconnect_all();
3248 hooks_invoke(OFFLINE_SWITCH_HOOKLIST, NULL);
3249 } else {
3250 /*go online */
3251 if (!prefs_common.work_offline)
3252 return;
3253 gtk_widget_hide (mainwin->offline_switch);
3254 gtk_widget_show (mainwin->online_switch);
3255 menuitem->active = FALSE;
3256 prefs_common.work_offline = FALSE;
3257 inc_autocheck_timer_set();
3258 refresh_resolvers();
3259 hooks_invoke(OFFLINE_SWITCH_HOOKLIST, NULL);
3263 static void addressbook_open_cb(MainWindow *mainwin, guint action,
3264 GtkWidget *widget)
3266 addressbook_open(NULL);
3269 static void log_window_show_cb(MainWindow *mainwin, guint action,
3270 GtkWidget *widget)
3272 log_window_show(mainwin->logwin);
3275 static void filtering_debug_window_show_cb(MainWindow *mainwin, guint action,
3276 GtkWidget *widget)
3278 log_window_show(mainwin->filtering_debugwin);
3281 static void inc_cancel_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
3283 inc_cancel_all();
3286 static void move_to_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
3288 summary_move_to(mainwin->summaryview);
3291 static void copy_to_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
3293 summary_copy_to(mainwin->summaryview);
3296 static void delete_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
3298 summary_delete(mainwin->summaryview);
3301 static void delete_trash_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
3303 summary_delete_trash(mainwin->summaryview);
3306 static void cancel_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
3308 summary_cancel(mainwin->summaryview);
3311 static void open_msg_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
3313 summary_open_msg(mainwin->summaryview);
3316 static void view_source_cb(MainWindow *mainwin, guint action,
3317 GtkWidget *widget)
3319 summary_view_source(mainwin->summaryview);
3322 static void show_all_header_cb(MainWindow *mainwin, guint action,
3323 GtkWidget *widget)
3325 if (mainwin->menu_lock_count) return;
3326 mainwin->summaryview->messageview->all_headers =
3327 GTK_CHECK_MENU_ITEM(widget)->active;
3328 summary_display_msg_selected(mainwin->summaryview,
3329 GTK_CHECK_MENU_ITEM(widget)->active);
3332 #define SET_CHECK_MENU_ACTIVE(path, active) \
3334 menuitem = gtk_item_factory_get_widget(ifactory, path); \
3335 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), active); \
3338 static void hide_quotes_cb(MainWindow *mainwin, guint action,
3339 GtkWidget *widget)
3341 GtkWidget *menuitem;
3342 GtkItemFactory *ifactory = mainwin->menu_factory;
3344 if (mainwin->menu_lock_count) return;
3346 prefs_common.hide_quotes =
3347 GTK_CHECK_MENU_ITEM(widget)->active ? action : 0;
3349 mainwin->menu_lock_count++;
3350 SET_CHECK_MENU_ACTIVE("/View/Quotes/Fold all", FALSE);
3351 SET_CHECK_MENU_ACTIVE("/View/Quotes/Fold from level 2", FALSE);
3352 SET_CHECK_MENU_ACTIVE("/View/Quotes/Fold from level 3", FALSE);
3353 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(widget), prefs_common.hide_quotes > 0);
3354 mainwin->menu_lock_count--;
3356 summary_redisplay_msg(mainwin->summaryview);
3359 #undef SET_CHECK_MENU_ACTIVE
3360 static void mark_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
3362 summary_mark(mainwin->summaryview);
3365 static void unmark_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
3367 summary_unmark(mainwin->summaryview);
3370 static void mark_as_unread_cb(MainWindow *mainwin, guint action,
3371 GtkWidget *widget)
3373 summary_mark_as_unread(mainwin->summaryview);
3376 static void mark_as_read_cb(MainWindow *mainwin, guint action,
3377 GtkWidget *widget)
3379 summary_mark_as_read(mainwin->summaryview);
3382 static void mark_all_read_cb(MainWindow *mainwin, guint action,
3383 GtkWidget *widget)
3385 summary_mark_all_read(mainwin->summaryview);
3388 static void mark_as_spam_cb(MainWindow *mainwin, guint action,
3389 GtkWidget *widget)
3391 summary_mark_as_spam(mainwin->summaryview, action, NULL);
3394 static void ignore_thread_cb(MainWindow *mainwin, guint action,
3395 GtkWidget *widget)
3397 summary_ignore_thread(mainwin->summaryview);
3400 static void unignore_thread_cb(MainWindow *mainwin, guint action,
3401 GtkWidget *widget)
3403 summary_unignore_thread(mainwin->summaryview);
3406 static void lock_msgs_cb(MainWindow *mainwin, guint action,
3407 GtkWidget *widget)
3409 summary_msgs_lock(mainwin->summaryview);
3412 static void unlock_msgs_cb(MainWindow *mainwin, guint action,
3413 GtkWidget *widget)
3415 summary_msgs_unlock(mainwin->summaryview);
3419 static void reedit_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
3421 summary_reedit(mainwin->summaryview);
3424 static void open_urls_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
3426 if (!mainwin->summaryview->displayed && mainwin->summaryview->selected) {
3427 summary_display_msg_selected(mainwin->summaryview,
3428 mainwin->messageview->mimeview->textview->show_all_headers);
3430 messageview_list_urls(mainwin->messageview);
3433 static void add_address_cb(MainWindow *mainwin, guint action,
3434 GtkWidget *widget)
3436 summary_add_address(mainwin->summaryview);
3439 static void set_charset_cb(MainWindow *mainwin, guint action,
3440 GtkWidget *widget)
3442 const gchar *str;
3444 if (GTK_CHECK_MENU_ITEM(widget)->active) {
3445 str = conv_get_charset_str((CharSet)action);
3447 g_free(mainwin->messageview->forced_charset);
3448 mainwin->messageview->forced_charset = str ? g_strdup(str) : NULL;
3449 procmime_force_charset(str);
3451 summary_redisplay_msg(mainwin->summaryview);
3453 debug_print("forced charset: %s\n", str ? str : "Auto-Detect");
3457 static void set_decode_cb(MainWindow *mainwin, guint action,
3458 GtkWidget *widget)
3460 if (GTK_CHECK_MENU_ITEM(widget)->active) {
3461 mainwin->messageview->forced_encoding = (EncodingType)action;
3463 summary_redisplay_msg(mainwin->summaryview);
3465 debug_print("forced encoding: %d\n", action);
3469 static void hide_read_messages (MainWindow *mainwin, guint action,
3470 GtkWidget *widget)
3472 if (!mainwin->summaryview->folder_item
3473 || g_object_get_data(G_OBJECT(widget), "dont_toggle"))
3474 return;
3475 summary_toggle_show_read_messages(mainwin->summaryview);
3478 static void thread_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
3480 gboolean threaded = FALSE;
3481 if (mainwin->menu_lock_count) return;
3482 if (!mainwin->summaryview->folder_item) return;
3484 threaded = GTK_CHECK_MENU_ITEM(widget)->active;
3486 mainwin->summaryview->folder_item->threaded = threaded;
3488 mainwin->summaryview->threaded = threaded;
3490 summary_show(mainwin->summaryview,
3491 mainwin->summaryview->folder_item);
3494 static void expand_threads_cb(MainWindow *mainwin, guint action,
3495 GtkWidget *widget)
3497 summary_expand_threads(mainwin->summaryview);
3500 static void collapse_threads_cb(MainWindow *mainwin, guint action,
3501 GtkWidget *widget)
3503 summary_collapse_threads(mainwin->summaryview);
3506 static void set_summary_display_item_cb(MainWindow *mainwin, guint action,
3507 GtkWidget *widget)
3509 prefs_summary_column_open();
3512 static void set_folder_display_item_cb(MainWindow *mainwin, guint action,
3513 GtkWidget *widget)
3515 prefs_folder_column_open();
3518 static void sort_summary_cb(MainWindow *mainwin, guint action,
3519 GtkWidget *widget)
3521 FolderItem *item = mainwin->summaryview->folder_item;
3522 GtkWidget *menuitem;
3524 if (mainwin->menu_lock_count) return;
3526 if (GTK_CHECK_MENU_ITEM(widget)->active && item) {
3527 menuitem = gtk_item_factory_get_item
3528 (mainwin->menu_factory, "/View/Sort/Ascending");
3529 summary_sort(mainwin->summaryview, (FolderSortKey)action,
3530 GTK_CHECK_MENU_ITEM(menuitem)->active
3531 ? SORT_ASCENDING : SORT_DESCENDING);
3532 item->sort_key = action;
3536 static void sort_summary_type_cb(MainWindow *mainwin, guint action,
3537 GtkWidget *widget)
3539 FolderItem *item = mainwin->summaryview->folder_item;
3541 if (mainwin->menu_lock_count) return;
3543 if (GTK_CHECK_MENU_ITEM(widget)->active && item)
3544 summary_sort(mainwin->summaryview,
3545 item->sort_key, (FolderSortType)action);
3548 static void attract_by_subject_cb(MainWindow *mainwin, guint action,
3549 GtkWidget *widget)
3551 summary_attract_by_subject(mainwin->summaryview);
3554 static void delete_duplicated_cb(MainWindow *mainwin, guint action,
3555 GtkWidget *widget)
3557 FolderItem *item;
3559 item = folderview_get_selected_item(mainwin->folderview);
3560 if (item) {
3561 main_window_cursor_wait(mainwin);
3562 STATUSBAR_PUSH(mainwin, _("Deleting duplicated messages..."));
3564 folderutils_delete_duplicates(item, prefs_common.immediate_exec ?
3565 DELETE_DUPLICATES_REMOVE : DELETE_DUPLICATES_SETFLAG);
3567 STATUSBAR_POP(mainwin);
3568 main_window_cursor_normal(mainwin);
3572 struct DelDupsData
3574 guint dups;
3575 guint folders;
3578 static void deldup_all(FolderItem *item, gpointer _data)
3580 struct DelDupsData *data = _data;
3581 gint result;
3583 result = folderutils_delete_duplicates(item, DELETE_DUPLICATES_REMOVE);
3584 if (result >= 0) {
3585 data->dups += result;
3586 data->folders += 1;
3590 static void delete_duplicated_all_cb(MainWindow *mainwin, guint action,
3591 GtkWidget *widget)
3593 struct DelDupsData data = {0, 0};
3595 main_window_cursor_wait(mainwin);
3596 folder_func_to_all_folders(deldup_all, &data);
3597 main_window_cursor_normal(mainwin);
3599 alertpanel_notice(ngettext("Deleted %d duplicate message in %d folders.\n",
3600 "Deleted %d duplicate messages in %d folders.\n",
3601 data.dups),
3602 data.dups, data.folders);
3605 static void filter_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
3607 summary_filter(mainwin->summaryview, (gboolean)action);
3610 static void execute_summary_cb(MainWindow *mainwin, guint action,
3611 GtkWidget *widget)
3613 summary_execute(mainwin->summaryview);
3616 static void update_summary_cb(MainWindow *mainwin, guint action,
3617 GtkWidget *widget)
3619 FolderItem *fitem;
3620 FolderView *folderview = mainwin->folderview;
3622 if (!mainwin->summaryview->folder_item) return;
3623 if (!folderview->opened) return;
3625 folder_update_op_count();
3627 fitem = gtk_ctree_node_get_row_data(GTK_CTREE(folderview->ctree),
3628 folderview->opened);
3629 if (!fitem) return;
3631 folder_item_scan(fitem);
3632 summary_show(mainwin->summaryview, fitem);
3635 static void prev_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
3637 summary_step(mainwin->summaryview, GTK_SCROLL_STEP_BACKWARD);
3640 static void next_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
3642 summary_step(mainwin->summaryview, GTK_SCROLL_STEP_FORWARD);
3645 static void prev_unread_cb(MainWindow *mainwin, guint action,
3646 GtkWidget *widget)
3648 summary_select_prev_unread(mainwin->summaryview);
3651 static void next_unread_cb(MainWindow *mainwin, guint action,
3652 GtkWidget *widget)
3654 summary_select_next_unread(mainwin->summaryview);
3657 static void prev_new_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
3659 summary_select_prev_new(mainwin->summaryview);
3662 static void next_new_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
3664 summary_select_next_new(mainwin->summaryview);
3667 static void prev_marked_cb(MainWindow *mainwin, guint action,
3668 GtkWidget *widget)
3670 summary_select_prev_marked(mainwin->summaryview);
3673 static void next_marked_cb(MainWindow *mainwin, guint action,
3674 GtkWidget *widget)
3676 summary_select_next_marked(mainwin->summaryview);
3679 static void prev_labeled_cb(MainWindow *mainwin, guint action,
3680 GtkWidget *widget)
3682 summary_select_prev_labeled(mainwin->summaryview);
3685 static void next_labeled_cb(MainWindow *mainwin, guint action,
3686 GtkWidget *widget)
3688 summary_select_next_labeled(mainwin->summaryview);
3691 static void last_read_cb(MainWindow *mainwin, guint action,
3692 GtkWidget *widget)
3694 summary_select_last_read(mainwin->summaryview);
3697 static void parent_cb(MainWindow *mainwin, guint action,
3698 GtkWidget *widget)
3700 summary_select_parent(mainwin->summaryview);
3703 static void goto_folder_cb(MainWindow *mainwin, guint action,
3704 GtkWidget *widget)
3706 FolderItem *to_folder;
3708 to_folder = foldersel_folder_sel(NULL, FOLDER_SEL_ALL, NULL);
3710 if (to_folder)
3711 folderview_select(mainwin->folderview, to_folder);
3714 static void goto_unread_folder_cb(MainWindow *mainwin, guint action,
3715 GtkWidget *widget)
3717 folderview_select_next_unread(mainwin->folderview, FALSE);
3720 static void copy_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
3722 messageview_copy_clipboard(mainwin->messageview);
3725 static void allsel_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
3727 MessageView *msgview = mainwin->messageview;
3729 if (messageview_is_visible(msgview) &&
3730 (GTK_WIDGET_HAS_FOCUS(msgview->mimeview->textview->text)))
3731 messageview_select_all(mainwin->messageview);
3732 else
3733 summary_select_all(mainwin->summaryview);
3736 static void select_thread_cb(MainWindow *mainwin, guint action,
3737 GtkWidget *widget)
3739 summary_select_thread(mainwin->summaryview, FALSE);
3742 static void delete_thread_cb(MainWindow *mainwin, guint action,
3743 GtkWidget *widget)
3745 summary_select_thread(mainwin->summaryview, TRUE);
3748 static void create_filter_cb(MainWindow *mainwin, guint action,
3749 GtkWidget *widget)
3751 summary_filter_open(mainwin->summaryview, (PrefsFilterType)action, 0);
3754 static void create_processing_cb(MainWindow *mainwin, guint action,
3755 GtkWidget *widget)
3757 summary_filter_open(mainwin->summaryview, (PrefsFilterType)action, 1);
3760 static void prefs_pre_processing_open_cb(MainWindow *mainwin, guint action,
3761 GtkWidget *widget)
3763 prefs_filtering_open(&pre_global_processing,
3764 _("Processing rules to apply before folder rules"),
3765 MANUAL_ANCHOR_PROCESSING,
3766 NULL, NULL, FALSE);
3769 static void prefs_post_processing_open_cb(MainWindow *mainwin, guint action,
3770 GtkWidget *widget)
3772 prefs_filtering_open(&post_global_processing,
3773 _("Processing rules to apply after folder rules"),
3774 MANUAL_ANCHOR_PROCESSING,
3775 NULL, NULL, FALSE);
3778 static void prefs_filtering_open_cb(MainWindow *mainwin, guint action,
3779 GtkWidget *widget)
3781 prefs_filtering_open(&filtering_rules,
3782 _("Filtering configuration"),
3783 MANUAL_ANCHOR_FILTERING,
3784 NULL, NULL, TRUE);
3787 static void prefs_template_open_cb(MainWindow *mainwin, guint action,
3788 GtkWidget *widget)
3790 prefs_template_open();
3793 static void prefs_actions_open_cb(MainWindow *mainwin, guint action,
3794 GtkWidget *widget)
3796 prefs_actions_open(mainwin);
3798 #ifdef USE_OPENSSL
3799 static void ssl_manager_open_cb(MainWindow *mainwin, guint action,
3800 GtkWidget *widget)
3802 ssl_manager_open(mainwin);
3804 #endif
3805 static void prefs_account_open_cb(MainWindow *mainwin, guint action,
3806 GtkWidget *widget)
3808 if (!cur_account) {
3809 new_account_cb(mainwin, 0, widget);
3810 } else {
3811 account_open(cur_account);
3815 static void new_account_cb(MainWindow *mainwin, guint action,
3816 GtkWidget *widget)
3818 account_edit_open();
3819 if (!compose_get_compose_list()) account_add();
3822 static void account_selector_menu_cb(GtkMenuItem *menuitem, gpointer data)
3824 FolderItem *item = NULL;
3825 cur_account = (PrefsAccount *)data;
3827 if (!mainwindow_get_mainwindow())
3828 return;
3829 main_window_show_cur_account(mainwindow_get_mainwindow());
3830 toolbar_update(TOOLBAR_MAIN, mainwindow_get_mainwindow());
3831 main_window_set_menu_sensitive(mainwindow_get_mainwindow());
3832 toolbar_main_set_sensitive(mainwindow_get_mainwindow());
3833 item = folderview_get_selected_item(
3834 mainwindow_get_mainwindow()->folderview);
3835 if (item) {
3836 toolbar_set_compose_button
3837 (mainwindow_get_mainwindow()->toolbar,
3838 FOLDER_TYPE(item->folder) == F_NEWS ?
3839 COMPOSEBUTTON_NEWS : COMPOSEBUTTON_MAIL);
3843 static void account_receive_menu_cb(GtkMenuItem *menuitem, gpointer data)
3845 MainWindow *mainwin = (MainWindow *)mainwin_list->data;
3846 PrefsAccount *account = (PrefsAccount *)data;
3848 inc_account_mail(mainwin, account);
3851 static void account_compose_menu_cb(GtkMenuItem *menuitem, gpointer data)
3853 MainWindow *mainwin = (MainWindow *)mainwin_list->data;
3854 PrefsAccount *account = (PrefsAccount *)data;
3855 FolderItem *item = mainwin->summaryview->folder_item;
3857 compose_new_with_folderitem(account, item, NULL);
3860 static void prefs_open_cb(GtkMenuItem *menuitem, gpointer data)
3862 prefs_gtk_open();
3865 static void plugins_open_cb(GtkMenuItem *menuitem, gpointer data)
3867 pluginwindow_create();
3870 static void manual_open_cb(MainWindow *mainwin, guint action,
3871 GtkWidget *widget)
3873 manual_open((ManualType)action, NULL);
3876 static void legend_open_cb(GtkMenuItem *menuitem, gpointer data)
3878 legend_show();
3881 static void scan_tree_func(Folder *folder, FolderItem *item, gpointer data)
3883 MainWindow *mainwin = (MainWindow *)data;
3884 gchar *str;
3886 if (item->path)
3887 str = g_strdup_printf(_("Scanning folder %s%c%s ..."),
3888 LOCAL_FOLDER(folder)->rootpath,
3889 G_DIR_SEPARATOR,
3890 item->path);
3891 else
3892 str = g_strdup_printf(_("Scanning folder %s ..."),
3893 LOCAL_FOLDER(folder)->rootpath);
3895 STATUSBAR_PUSH(mainwin, str);
3896 STATUSBAR_POP(mainwin);
3897 g_free(str);
3900 static gboolean mainwindow_focus_in_event(GtkWidget *widget, GdkEventFocus *focus,
3901 gpointer data)
3903 SummaryView *summary;
3905 g_return_val_if_fail(data, FALSE);
3906 if (!g_list_find(mainwin_list, data))
3907 return TRUE;
3908 summary = ((MainWindow *)data)->summaryview;
3909 g_return_val_if_fail(summary, FALSE);
3911 if (GTK_CLIST(summary->ctree)->selection &&
3912 g_list_length(GTK_CLIST(summary->ctree)->selection) > 1)
3913 return FALSE;
3915 return FALSE;
3918 static gboolean mainwindow_visibility_event_cb(GtkWidget *widget, GdkEventVisibility *event,
3919 gpointer data)
3921 is_obscured = (event->state == GDK_VISIBILITY_FULLY_OBSCURED);
3922 return FALSE;
3925 static gboolean mainwindow_state_event_cb(GtkWidget *widget, GdkEventWindowState *state,
3926 gpointer data)
3928 if (!claws_is_starting()
3929 && state->changed_mask&GDK_WINDOW_STATE_ICONIFIED
3930 && state->new_window_state&GDK_WINDOW_STATE_ICONIFIED) {
3932 if (iconified_count > 0)
3933 hooks_invoke(MAIN_WINDOW_GOT_ICONIFIED, NULL);
3934 iconified_count++;
3936 if (state->new_window_state == 0)
3937 gtk_window_set_skip_taskbar_hint(GTK_WINDOW(widget), FALSE);
3938 return FALSE;
3941 gboolean mainwindow_is_obscured(void)
3943 return is_obscured;
3946 #define BREAK_ON_MODIFIER_KEY() \
3947 if ((event->state & (GDK_MOD1_MASK|GDK_CONTROL_MASK)) != 0) break
3949 gboolean mainwindow_key_pressed (GtkWidget *widget, GdkEventKey *event,
3950 gpointer data)
3952 MainWindow *mainwin = (MainWindow*) data;
3954 if (!mainwin || !event)
3955 return FALSE;
3957 if (quicksearch_has_focus(mainwin->summaryview->quicksearch))
3959 lastkey = event->keyval;
3960 return FALSE;
3963 switch (event->keyval) {
3964 case GDK_Q: /* Quit */
3965 BREAK_ON_MODIFIER_KEY();
3967 app_exit_cb(mainwin, 0, NULL);
3968 return FALSE;
3969 case GDK_space:
3970 if (mainwin->folderview && mainwin->summaryview
3971 && ((!mainwin->summaryview->displayed
3972 && !mainwin->summaryview->selected)
3973 || (mainwin->summaryview->folder_item
3974 && mainwin->summaryview->folder_item->total_msgs == 0))) {
3975 g_signal_stop_emission_by_name(G_OBJECT(widget),
3976 "key_press_event");
3977 folderview_select_next_unread(mainwin->folderview, TRUE);
3979 break;
3980 #ifdef MAEMO
3981 case GDK_F6:
3982 if (maemo_mainwindow_is_fullscreen(widget)) {
3983 gtk_window_unfullscreen(GTK_WINDOW(widget));
3984 } else {
3985 gtk_window_fullscreen(GTK_WINDOW(widget));
3987 break;
3988 #endif
3989 default:
3990 break;
3992 return FALSE;
3995 #undef BREAK_ON_MODIFIER_KEY
3998 * Harvest addresses for selected folder.
4000 static void addr_harvest_cb( MainWindow *mainwin,
4001 guint action,
4002 GtkWidget *widget )
4004 addressbook_harvest( mainwin->summaryview->folder_item, FALSE, NULL );
4008 * Harvest addresses for selected messages in summary view.
4010 static void addr_harvest_msg_cb( MainWindow *mainwin,
4011 guint action,
4012 GtkWidget *widget )
4014 summary_harvest_address( mainwin->summaryview );
4018 *\brief get a MainWindow
4020 *\return MainWindow * The first mainwindow in the mainwin_list
4022 MainWindow *mainwindow_get_mainwindow(void)
4024 if (mainwin_list && mainwin_list->data)
4025 return (MainWindow *)(mainwin_list->data);
4026 else
4027 return NULL;
4030 static gboolean mainwindow_progressindicator_hook(gpointer source, gpointer userdata)
4032 ProgressData *data = (ProgressData *) source;
4033 MainWindow *mainwin = (MainWindow *) userdata;
4035 switch (data->cmd) {
4036 case PROGRESS_COMMAND_START:
4037 case PROGRESS_COMMAND_STOP:
4038 gtk_progress_bar_set_fraction
4039 (GTK_PROGRESS_BAR(mainwin->progressbar), 0.0);
4040 break;
4041 case PROGRESS_COMMAND_SET_PERCENTAGE:
4042 gtk_progress_bar_set_fraction
4043 (GTK_PROGRESS_BAR(mainwin->progressbar), data->value);
4044 break;
4046 while (gtk_events_pending()) gtk_main_iteration ();
4048 return FALSE;
4051 static void sync_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
4053 mainwindow_check_synchronise(mainwin, FALSE);
4056 void mainwindow_learn (MainWindow *mainwin, gboolean is_spam)
4058 summary_mark_as_spam(mainwin->summaryview, is_spam, NULL);
4061 void mainwindow_jump_to(const gchar *target)
4063 gchar *tmp = NULL;
4064 gchar *p = NULL;
4065 FolderItem *item = NULL;
4066 gchar *msg = NULL;
4067 MainWindow *mainwin = mainwindow_get_mainwindow();
4069 if (!target)
4070 return;
4072 if (!mainwin) {
4073 printf("not initialized\n");
4074 return;
4077 tmp = g_strdup(target);
4079 if ((p = strstr(tmp, "\r")) != NULL)
4080 *p = '\0';
4081 if ((p = strstr(tmp, "\n")) != NULL)
4082 *p = '\0';
4084 if ((item = folder_find_item_from_identifier(tmp))) {
4085 printf("selecting folder '%s'\n", tmp);
4086 folderview_select(mainwin->folderview, item);
4087 main_window_popup(mainwin);
4088 g_free(tmp);
4089 return;
4092 msg = strrchr(tmp, G_DIR_SEPARATOR);
4093 if (msg) {
4094 *msg++ = '\0';
4095 if ((item = folder_find_item_from_identifier(tmp))) {
4096 printf("selecting folder '%s'\n", tmp);
4097 folderview_select(mainwin->folderview, item);
4098 } else {
4099 printf("'%s' not found\n", tmp);
4101 if (item && msg && atoi(msg)) {
4102 printf("selecting message %d\n", atoi(msg));
4103 summary_select_by_msgnum(mainwin->summaryview, atoi(msg));
4104 summary_display_msg_selected(mainwin->summaryview, FALSE);
4105 main_window_popup(mainwin);
4106 g_free(tmp);
4107 return;
4108 } else if (item && msg[0] == '<' && msg[strlen(msg)-1] == '>') {
4109 MsgInfo *msginfo = NULL;
4110 msg++;
4111 msg[strlen(msg)-1] = '\0';
4112 msginfo = folder_item_get_msginfo_by_msgid(item, msg);
4113 if (msginfo) {
4114 printf("selecting message %s\n", msg);
4115 summary_select_by_msgnum(mainwin->summaryview, msginfo->msgnum);
4116 summary_display_msg_selected(mainwin->summaryview, FALSE);
4117 main_window_popup(mainwin);
4118 g_free(tmp);
4119 procmsg_msginfo_free(msginfo);
4120 return;
4121 } else {
4122 printf("'%s' not found\n", msg);
4124 } else {
4125 printf("'%s' not found\n", msg);
4127 } else {
4128 printf("'%s' not found\n", tmp);
4131 g_free(tmp);
4134 void mainwindow_exit_folder(MainWindow *mainwin) {
4135 if (prefs_common.layout_mode == SMALL_LAYOUT) {
4136 folderview_close_opened(mainwin->folderview);
4137 mainwin_paned_show_first(GTK_PANED(mainwin->hpaned));
4138 mainwin->in_folder = FALSE;
4142 void mainwindow_enter_folder(MainWindow *mainwin) {
4143 if (prefs_common.layout_mode == SMALL_LAYOUT) {
4144 mainwin_paned_show_last(GTK_PANED(mainwin->hpaned));
4145 mainwin->in_folder = TRUE;
4149 #ifdef MAEMO
4150 gboolean maemo_mainwindow_is_fullscreen(GtkWidget *widget)
4152 gint w, h;
4153 gtk_window_get_size(GTK_WINDOW(widget), &w, &h);
4154 return (w == 800);
4157 void maemo_window_full_screen_if_needed (GtkWindow *window)
4159 if (maemo_mainwindow_is_fullscreen(mainwindow_get_mainwindow()->window)) {
4160 gtk_window_fullscreen(GTK_WINDOW(window));
4164 void maemo_connect_key_press_to_mainwindow (GtkWindow *window)
4166 g_signal_connect(G_OBJECT(window), "key_press_event",
4167 G_CALLBACK(mainwindow_key_pressed), mainwindow_get_mainwindow());
4169 #endif