Statistics
| Revision:

root / src / mainwindow.c @ 491

History | View | Annotate | Download (98.2 kB)

1 1 hiro
/*
2 1 hiro
 * Sylpheed -- a GTK+ based, lightweight, and fast e-mail client
3 23 hiro
 * Copyright (C) 1999-2005 Hiroyuki Yamamoto
4 1 hiro
 *
5 1 hiro
 * This program is free software; you can redistribute it and/or modify
6 1 hiro
 * it under the terms of the GNU General Public License as published by
7 1 hiro
 * the Free Software Foundation; either version 2 of the License, or
8 1 hiro
 * (at your option) any later version.
9 1 hiro
 *
10 1 hiro
 * This program is distributed in the hope that it will be useful,
11 1 hiro
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 1 hiro
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13 1 hiro
 * GNU General Public License for more details.
14 1 hiro
 *
15 1 hiro
 * You should have received a copy of the GNU General Public License
16 1 hiro
 * along with this program; if not, write to the Free Software
17 1 hiro
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18 1 hiro
 */
19 1 hiro
20 1 hiro
#include "defs.h"
21 1 hiro
22 1 hiro
#include <glib.h>
23 92 hiro
#include <glib/gi18n.h>
24 1 hiro
#include <gtk/gtkmain.h>
25 237 hiro
#include <gtk/gtkversion.h>
26 1 hiro
#include <gtk/gtkwindow.h>
27 1 hiro
#include <gtk/gtkwidget.h>
28 1 hiro
#include <gtk/gtksignal.h>
29 1 hiro
#include <gtk/gtkvbox.h>
30 1 hiro
#include <gtk/gtkcontainer.h>
31 1 hiro
#include <gtk/gtkstatusbar.h>
32 1 hiro
#include <gtk/gtkprogressbar.h>
33 1 hiro
#include <gtk/gtkhpaned.h>
34 1 hiro
#include <gtk/gtkvpaned.h>
35 1 hiro
#include <gtk/gtkcheckmenuitem.h>
36 1 hiro
#include <gtk/gtkitemfactory.h>
37 1 hiro
#include <gtk/gtkeditable.h>
38 1 hiro
#include <gtk/gtkmenu.h>
39 1 hiro
#include <gtk/gtkmenuitem.h>
40 1 hiro
#include <gtk/gtktoolbar.h>
41 1 hiro
#include <gtk/gtkbutton.h>
42 1 hiro
#include <gtk/gtktooltips.h>
43 237 hiro
#include <gtk/gtkarrow.h>
44 237 hiro
#include <gtk/gtkstock.h>
45 306 hiro
#include <gtk/gtkimage.h>
46 1 hiro
#include <string.h>
47 1 hiro
48 1 hiro
#include "main.h"
49 1 hiro
#include "mainwindow.h"
50 1 hiro
#include "folderview.h"
51 1 hiro
#include "foldersel.h"
52 1 hiro
#include "summaryview.h"
53 1 hiro
#include "summary_search.h"
54 1 hiro
#include "messageview.h"
55 152 hiro
#include "mimeview.h"
56 1 hiro
#include "message_search.h"
57 1 hiro
#include "headerview.h"
58 1 hiro
#include "menu.h"
59 1 hiro
#include "stock_pixmap.h"
60 1 hiro
#include "folder.h"
61 1 hiro
#include "inc.h"
62 1 hiro
#include "compose.h"
63 1 hiro
#include "procmsg.h"
64 1 hiro
#include "import.h"
65 1 hiro
#include "export.h"
66 1 hiro
#include "prefs_common.h"
67 1 hiro
#include "prefs_filter.h"
68 1 hiro
#include "prefs_actions.h"
69 1 hiro
#include "prefs_account.h"
70 1 hiro
#include "prefs_summary_column.h"
71 1 hiro
#include "prefs_template.h"
72 1 hiro
#include "action.h"
73 1 hiro
#include "account.h"
74 1 hiro
#include "addressbook.h"
75 1 hiro
#include "logwindow.h"
76 1 hiro
#include "manage_window.h"
77 1 hiro
#include "alertpanel.h"
78 1 hiro
#include "statusbar.h"
79 1 hiro
#include "inputdialog.h"
80 1 hiro
#include "utils.h"
81 1 hiro
#include "gtkutils.h"
82 1 hiro
#include "codeconv.h"
83 1 hiro
#include "about.h"
84 1 hiro
#include "manual.h"
85 1 hiro
#include "version.h"
86 1 hiro
87 1 hiro
#define AC_LABEL_WIDTH        240
88 1 hiro
89 1 hiro
#define STATUSBAR_PUSH(mainwin, str) \
90 1 hiro
{ \
91 1 hiro
        gtk_statusbar_push(GTK_STATUSBAR(mainwin->statusbar), \
92 1 hiro
                           mainwin->mainwin_cid, str); \
93 227 hiro
        gtkut_widget_draw_now(mainwin->statusbar); \
94 1 hiro
}
95 1 hiro
96 1 hiro
#define STATUSBAR_POP(mainwin) \
97 1 hiro
{ \
98 1 hiro
        gtk_statusbar_pop(GTK_STATUSBAR(mainwin->statusbar), \
99 1 hiro
                          mainwin->mainwin_cid); \
100 1 hiro
}
101 1 hiro
102 1 hiro
/* list of all instantiated MainWindow */
103 1 hiro
static GList *mainwin_list = NULL;
104 1 hiro
105 1 hiro
static GdkCursor *watch_cursor;
106 1 hiro
107 1 hiro
static void main_window_menu_callback_block        (MainWindow        *mainwin);
108 1 hiro
static void main_window_menu_callback_unblock        (MainWindow        *mainwin);
109 1 hiro
110 1 hiro
static void main_window_show_cur_account        (MainWindow        *mainwin);
111 1 hiro
112 1 hiro
static void main_window_set_widgets                (MainWindow        *mainwin,
113 1 hiro
                                                 SeparateType         type);
114 489 hiro
static GtkWidget *main_window_toolbar_create        (MainWindow        *mainwin);
115 1 hiro
116 1 hiro
/* callback functions */
117 1 hiro
static void toolbar_inc_cb                (GtkWidget        *widget,
118 1 hiro
                                         gpointer         data);
119 1 hiro
static void toolbar_inc_all_cb                (GtkWidget        *widget,
120 1 hiro
                                         gpointer         data);
121 1 hiro
static void toolbar_send_cb                (GtkWidget        *widget,
122 1 hiro
                                         gpointer         data);
123 1 hiro
124 1 hiro
static void toolbar_compose_cb                (GtkWidget        *widget,
125 1 hiro
                                         gpointer         data);
126 1 hiro
static void toolbar_reply_cb                (GtkWidget        *widget,
127 1 hiro
                                         gpointer         data);
128 1 hiro
static void toolbar_reply_to_all_cb        (GtkWidget        *widget,
129 1 hiro
                                         gpointer         data);
130 1 hiro
static void toolbar_forward_cb                (GtkWidget        *widget,
131 1 hiro
                                         gpointer         data);
132 1 hiro
133 1 hiro
static void toolbar_delete_cb                (GtkWidget        *widget,
134 1 hiro
                                         gpointer         data);
135 306 hiro
static void toolbar_junk_cb                (GtkWidget        *widget,
136 306 hiro
                                         gpointer         data);
137 1 hiro
static void toolbar_exec_cb                (GtkWidget        *widget,
138 1 hiro
                                         gpointer         data);
139 1 hiro
140 1 hiro
static void toolbar_next_unread_cb        (GtkWidget        *widget,
141 1 hiro
                                         gpointer         data);
142 1 hiro
143 1 hiro
#if 0
144 1 hiro
static void toolbar_prefs_cb                (GtkWidget        *widget,
145 1 hiro
                                         gpointer         data);
146 1 hiro
static void toolbar_account_cb                (GtkWidget        *widget,
147 1 hiro
                                         gpointer         data);
148 1 hiro
149 1 hiro
static void toolbar_account_button_pressed        (GtkWidget        *widget,
150 1 hiro
                                                 GdkEventButton        *event,
151 1 hiro
                                                 gpointer         data);
152 1 hiro
#endif
153 1 hiro
154 1 hiro
static void online_switch_clicked                (GtkWidget        *widget,
155 1 hiro
                                                 gpointer         data);
156 1 hiro
static void ac_label_button_pressed                (GtkWidget        *widget,
157 1 hiro
                                                 GdkEventButton        *event,
158 1 hiro
                                                 gpointer         data);
159 1 hiro
static void ac_menu_popup_closed                (GtkMenuShell        *menu_shell,
160 1 hiro
                                                 gpointer         data);
161 1 hiro
162 1 hiro
static gint main_window_close_cb                (GtkWidget        *widget,
163 1 hiro
                                                 GdkEventAny        *event,
164 1 hiro
                                                 gpointer         data);
165 1 hiro
static gint folder_window_close_cb                (GtkWidget        *widget,
166 1 hiro
                                                 GdkEventAny        *event,
167 1 hiro
                                                 gpointer         data);
168 1 hiro
static gint message_window_close_cb                (GtkWidget        *widget,
169 1 hiro
                                                 GdkEventAny        *event,
170 1 hiro
                                                 gpointer         data);
171 1 hiro
172 1 hiro
static void main_window_size_allocate_cb        (GtkWidget        *widget,
173 1 hiro
                                                 GtkAllocation        *allocation,
174 1 hiro
                                                 gpointer         data);
175 1 hiro
static void folder_window_size_allocate_cb        (GtkWidget        *widget,
176 1 hiro
                                                 GtkAllocation        *allocation,
177 1 hiro
                                                 gpointer         data);
178 1 hiro
static void message_window_size_allocate_cb        (GtkWidget        *widget,
179 1 hiro
                                                 GtkAllocation        *allocation,
180 1 hiro
                                                 gpointer         data);
181 1 hiro
182 1 hiro
static void new_folder_cb         (MainWindow        *mainwin,
183 1 hiro
                                  guint                 action,
184 1 hiro
                                  GtkWidget        *widget);
185 1 hiro
static void rename_folder_cb         (MainWindow        *mainwin,
186 1 hiro
                                  guint                 action,
187 1 hiro
                                  GtkWidget        *widget);
188 389 hiro
static void move_folder_cb         (MainWindow        *mainwin,
189 389 hiro
                                  guint                 action,
190 389 hiro
                                  GtkWidget        *widget);
191 1 hiro
static void delete_folder_cb         (MainWindow        *mainwin,
192 1 hiro
                                  guint                 action,
193 1 hiro
                                  GtkWidget        *widget);
194 1 hiro
static void update_folderview_cb (MainWindow        *mainwin,
195 1 hiro
                                  guint                 action,
196 1 hiro
                                  GtkWidget        *widget);
197 1 hiro
198 1 hiro
static void add_mailbox_cb         (MainWindow        *mainwin,
199 1 hiro
                                  guint                 action,
200 1 hiro
                                  GtkWidget        *widget);
201 1 hiro
static void remove_mailbox_cb         (MainWindow        *mainwin,
202 1 hiro
                                  guint                 action,
203 1 hiro
                                  GtkWidget        *widget);
204 1 hiro
static void rebuild_tree_cb         (MainWindow        *mainwin,
205 1 hiro
                                  guint                 action,
206 1 hiro
                                  GtkWidget        *widget);
207 1 hiro
208 1 hiro
static void import_mbox_cb         (MainWindow        *mainwin,
209 1 hiro
                                  guint                 action,
210 1 hiro
                                  GtkWidget        *widget);
211 1 hiro
static void export_mbox_cb         (MainWindow        *mainwin,
212 1 hiro
                                  guint                 action,
213 1 hiro
                                  GtkWidget        *widget);
214 1 hiro
static void empty_trash_cb         (MainWindow        *mainwin,
215 1 hiro
                                  guint                 action,
216 1 hiro
                                  GtkWidget        *widget);
217 1 hiro
218 1 hiro
static void save_as_cb                 (MainWindow        *mainwin,
219 1 hiro
                                  guint                 action,
220 1 hiro
                                  GtkWidget        *widget);
221 1 hiro
static void print_cb                 (MainWindow        *mainwin,
222 1 hiro
                                  guint                 action,
223 1 hiro
                                  GtkWidget        *widget);
224 1 hiro
static void toggle_offline_cb         (MainWindow        *mainwin,
225 1 hiro
                                  guint                 action,
226 1 hiro
                                  GtkWidget        *widget);
227 1 hiro
static void app_exit_cb                 (MainWindow        *mainwin,
228 1 hiro
                                  guint                 action,
229 1 hiro
                                  GtkWidget        *widget);
230 1 hiro
231 1 hiro
static void search_cb                 (MainWindow        *mainwin,
232 1 hiro
                                  guint                 action,
233 1 hiro
                                  GtkWidget        *widget);
234 1 hiro
235 1 hiro
static void toggle_folder_cb         (MainWindow        *mainwin,
236 1 hiro
                                  guint                 action,
237 1 hiro
                                  GtkWidget        *widget);
238 1 hiro
static void toggle_message_cb         (MainWindow        *mainwin,
239 1 hiro
                                  guint                 action,
240 1 hiro
                                  GtkWidget        *widget);
241 1 hiro
static void toggle_toolbar_cb         (MainWindow        *mainwin,
242 1 hiro
                                  guint                 action,
243 1 hiro
                                  GtkWidget        *widget);
244 1 hiro
static void toggle_statusbar_cb         (MainWindow        *mainwin,
245 1 hiro
                                  guint                 action,
246 1 hiro
                                  GtkWidget        *widget);
247 1 hiro
static void separate_widget_cb         (MainWindow        *mainwin,
248 1 hiro
                                  guint                 action,
249 1 hiro
                                  GtkWidget        *widget);
250 1 hiro
251 1 hiro
static void addressbook_open_cb        (MainWindow        *mainwin,
252 1 hiro
                                 guint                 action,
253 1 hiro
                                 GtkWidget        *widget);
254 1 hiro
static void log_window_show_cb        (MainWindow        *mainwin,
255 1 hiro
                                 guint                 action,
256 1 hiro
                                 GtkWidget        *widget);
257 1 hiro
258 1 hiro
static void inc_mail_cb                        (MainWindow        *mainwin,
259 1 hiro
                                         guint                 action,
260 1 hiro
                                         GtkWidget        *widget);
261 1 hiro
static void inc_all_account_mail_cb        (MainWindow        *mainwin,
262 1 hiro
                                         guint                 action,
263 1 hiro
                                         GtkWidget        *widget);
264 1 hiro
static void inc_cancel_cb                (MainWindow        *mainwin,
265 1 hiro
                                         guint                 action,
266 1 hiro
                                         GtkWidget        *widget);
267 1 hiro
268 1 hiro
static void send_queue_cb                (MainWindow        *mainwin,
269 1 hiro
                                         guint                 action,
270 1 hiro
                                         GtkWidget        *widget);
271 1 hiro
272 1 hiro
static void compose_cb                        (MainWindow        *mainwin,
273 1 hiro
                                         guint                 action,
274 1 hiro
                                         GtkWidget        *widget);
275 1 hiro
static void reply_cb                        (MainWindow        *mainwin,
276 1 hiro
                                         guint                 action,
277 1 hiro
                                         GtkWidget        *widget);
278 1 hiro
279 1 hiro
static void open_msg_cb                        (MainWindow        *mainwin,
280 1 hiro
                                         guint                 action,
281 1 hiro
                                         GtkWidget        *widget);
282 1 hiro
283 1 hiro
static void view_source_cb                (MainWindow        *mainwin,
284 1 hiro
                                         guint                 action,
285 1 hiro
                                         GtkWidget        *widget);
286 1 hiro
287 1 hiro
static void show_all_header_cb                (MainWindow        *mainwin,
288 1 hiro
                                         guint                 action,
289 1 hiro
                                         GtkWidget        *widget);
290 1 hiro
291 1 hiro
static void move_to_cb                        (MainWindow        *mainwin,
292 1 hiro
                                         guint                 action,
293 1 hiro
                                         GtkWidget        *widget);
294 1 hiro
static void copy_to_cb                        (MainWindow        *mainwin,
295 1 hiro
                                         guint                 action,
296 1 hiro
                                         GtkWidget        *widget);
297 1 hiro
static void delete_cb                        (MainWindow        *mainwin,
298 1 hiro
                                         guint                 action,
299 1 hiro
                                         GtkWidget        *widget);
300 1 hiro
301 1 hiro
static void mark_cb                        (MainWindow        *mainwin,
302 1 hiro
                                         guint                 action,
303 1 hiro
                                         GtkWidget        *widget);
304 1 hiro
static void unmark_cb                        (MainWindow        *mainwin,
305 1 hiro
                                         guint                 action,
306 1 hiro
                                         GtkWidget        *widget);
307 1 hiro
308 1 hiro
static void mark_as_unread_cb                (MainWindow        *mainwin,
309 1 hiro
                                         guint                 action,
310 1 hiro
                                         GtkWidget        *widget);
311 1 hiro
static void mark_as_read_cb                (MainWindow        *mainwin,
312 1 hiro
                                         guint                 action,
313 1 hiro
                                         GtkWidget        *widget);
314 1 hiro
static void mark_all_read_cb                (MainWindow        *mainwin,
315 1 hiro
                                         guint                 action,
316 1 hiro
                                         GtkWidget        *widget);
317 1 hiro
318 306 hiro
static void junk_cb                        (MainWindow        *mainwin,
319 306 hiro
                                         guint                 action,
320 306 hiro
                                         GtkWidget        *widget);
321 306 hiro
322 1 hiro
static void reedit_cb                        (MainWindow        *mainwin,
323 1 hiro
                                         guint                 action,
324 1 hiro
                                         GtkWidget        *widget);
325 1 hiro
326 1 hiro
static void add_address_cb                (MainWindow        *mainwin,
327 1 hiro
                                         guint                 action,
328 1 hiro
                                         GtkWidget        *widget);
329 1 hiro
330 1 hiro
static void set_charset_cb                (MainWindow        *mainwin,
331 1 hiro
                                         guint                 action,
332 1 hiro
                                         GtkWidget        *widget);
333 1 hiro
334 1 hiro
static void thread_cb                 (MainWindow        *mainwin,
335 1 hiro
                                  guint                 action,
336 1 hiro
                                  GtkWidget        *widget);
337 1 hiro
static void expand_threads_cb         (MainWindow        *mainwin,
338 1 hiro
                                  guint                 action,
339 1 hiro
                                  GtkWidget        *widget);
340 1 hiro
static void collapse_threads_cb         (MainWindow        *mainwin,
341 1 hiro
                                  guint                 action,
342 1 hiro
                                  GtkWidget        *widget);
343 1 hiro
344 1 hiro
static void set_display_item_cb         (MainWindow        *mainwin,
345 1 hiro
                                  guint                 action,
346 1 hiro
                                  GtkWidget        *widget);
347 1 hiro
static void sort_summary_cb         (MainWindow        *mainwin,
348 1 hiro
                                  guint                 action,
349 1 hiro
                                  GtkWidget        *widget);
350 1 hiro
static void sort_summary_type_cb (MainWindow        *mainwin,
351 1 hiro
                                  guint                 action,
352 1 hiro
                                  GtkWidget        *widget);
353 1 hiro
static void attract_by_subject_cb(MainWindow        *mainwin,
354 1 hiro
                                  guint                 action,
355 1 hiro
                                  GtkWidget        *widget);
356 1 hiro
357 1 hiro
static void delete_duplicated_cb (MainWindow        *mainwin,
358 1 hiro
                                  guint                 action,
359 1 hiro
                                  GtkWidget        *widget);
360 1 hiro
static void filter_cb                 (MainWindow        *mainwin,
361 1 hiro
                                  guint                 action,
362 1 hiro
                                  GtkWidget        *widget);
363 344 hiro
static void filter_junk_cb         (MainWindow        *mainwin,
364 344 hiro
                                  guint                 action,
365 344 hiro
                                  GtkWidget        *widget);
366 1 hiro
static void execute_summary_cb         (MainWindow        *mainwin,
367 1 hiro
                                  guint                 action,
368 1 hiro
                                  GtkWidget        *widget);
369 1 hiro
static void update_summary_cb         (MainWindow        *mainwin,
370 1 hiro
                                  guint                 action,
371 1 hiro
                                  GtkWidget        *widget);
372 1 hiro
373 1 hiro
static void prev_cb                 (MainWindow        *mainwin,
374 1 hiro
                                  guint                 action,
375 1 hiro
                                  GtkWidget        *widget);
376 1 hiro
static void next_cb                 (MainWindow        *mainwin,
377 1 hiro
                                  guint                 action,
378 1 hiro
                                  GtkWidget        *widget);
379 1 hiro
380 1 hiro
static void prev_unread_cb         (MainWindow        *mainwin,
381 1 hiro
                                  guint                 action,
382 1 hiro
                                  GtkWidget        *widget);
383 1 hiro
static void next_unread_cb         (MainWindow        *mainwin,
384 1 hiro
                                  guint                 action,
385 1 hiro
                                  GtkWidget        *widget);
386 1 hiro
static void prev_new_cb                 (MainWindow        *mainwin,
387 1 hiro
                                  guint                 action,
388 1 hiro
                                  GtkWidget        *widget);
389 1 hiro
static void next_new_cb                 (MainWindow        *mainwin,
390 1 hiro
                                  guint                 action,
391 1 hiro
                                  GtkWidget        *widget);
392 1 hiro
static void prev_marked_cb         (MainWindow        *mainwin,
393 1 hiro
                                  guint                 action,
394 1 hiro
                                  GtkWidget        *widget);
395 1 hiro
static void next_marked_cb         (MainWindow        *mainwin,
396 1 hiro
                                  guint                 action,
397 1 hiro
                                  GtkWidget        *widget);
398 1 hiro
static void prev_labeled_cb         (MainWindow        *mainwin,
399 1 hiro
                                  guint                 action,
400 1 hiro
                                  GtkWidget        *widget);
401 1 hiro
static void next_labeled_cb         (MainWindow        *mainwin,
402 1 hiro
                                  guint                 action,
403 1 hiro
                                  GtkWidget        *widget);
404 1 hiro
405 1 hiro
static void goto_folder_cb         (MainWindow        *mainwin,
406 1 hiro
                                  guint                 action,
407 1 hiro
                                  GtkWidget        *widget);
408 1 hiro
409 1 hiro
static void copy_cb                 (MainWindow        *mainwin,
410 1 hiro
                                  guint                 action,
411 1 hiro
                                  GtkWidget        *widget);
412 1 hiro
static void allsel_cb                 (MainWindow        *mainwin,
413 1 hiro
                                  guint                 action,
414 1 hiro
                                  GtkWidget        *widget);
415 1 hiro
static void select_thread_cb         (MainWindow        *mainwin,
416 1 hiro
                                  guint                 action,
417 1 hiro
                                  GtkWidget        *widget);
418 1 hiro
419 1 hiro
static void create_filter_cb         (MainWindow        *mainwin,
420 1 hiro
                                  guint                 action,
421 1 hiro
                                  GtkWidget        *widget);
422 1 hiro
423 1 hiro
static void prefs_common_open_cb        (MainWindow        *mainwin,
424 1 hiro
                                         guint                 action,
425 1 hiro
                                         GtkWidget        *widget);
426 1 hiro
static void prefs_filter_open_cb        (MainWindow        *mainwin,
427 1 hiro
                                         guint                 action,
428 1 hiro
                                         GtkWidget        *widget);
429 1 hiro
static void prefs_template_open_cb        (MainWindow        *mainwin,
430 1 hiro
                                         guint                 action,
431 1 hiro
                                         GtkWidget        *widget);
432 1 hiro
static void prefs_actions_open_cb        (MainWindow        *mainwin,
433 1 hiro
                                         guint                 action,
434 1 hiro
                                         GtkWidget        *widget);
435 1 hiro
static void prefs_account_open_cb        (MainWindow        *mainwin,
436 1 hiro
                                         guint                 action,
437 1 hiro
                                         GtkWidget        *widget);
438 1 hiro
439 1 hiro
static void new_account_cb         (MainWindow        *mainwin,
440 1 hiro
                                  guint                 action,
441 1 hiro
                                  GtkWidget        *widget);
442 1 hiro
443 1 hiro
static void account_selector_menu_cb         (GtkMenuItem        *menuitem,
444 1 hiro
                                          gpointer         data);
445 1 hiro
static void account_receive_menu_cb         (GtkMenuItem        *menuitem,
446 1 hiro
                                          gpointer         data);
447 1 hiro
448 1 hiro
static void manual_open_cb         (MainWindow        *mainwin,
449 1 hiro
                                  guint                 action,
450 1 hiro
                                  GtkWidget        *widget);
451 1 hiro
static void faq_open_cb                 (MainWindow        *mainwin,
452 1 hiro
                                  guint                 action,
453 1 hiro
                                  GtkWidget        *widget);
454 1 hiro
455 1 hiro
static void scan_tree_func         (Folder        *folder,
456 1 hiro
                                  FolderItem        *item,
457 1 hiro
                                  gpointer         data);
458 1 hiro
459 1 hiro
static GtkItemFactoryEntry mainwin_entries[] =
460 1 hiro
{
461 1 hiro
        {N_("/_File"),                                NULL, NULL, 0, "<Branch>"},
462 1 hiro
        {N_("/_File/_Folder"),                        NULL, NULL, 0, "<Branch>"},
463 1 hiro
        {N_("/_File/_Folder/Create _new folder..."),
464 1 hiro
                                                NULL, new_folder_cb, 0, NULL},
465 1 hiro
        {N_("/_File/_Folder/_Rename folder..."),NULL, rename_folder_cb, 0, NULL},
466 389 hiro
        {N_("/_File/_Folder/_Move folder..."),  NULL, move_folder_cb, 0, NULL},
467 1 hiro
        {N_("/_File/_Folder/_Delete folder"),        NULL, delete_folder_cb, 0, NULL},
468 1 hiro
        {N_("/_File/_Mailbox"),                        NULL, NULL, 0, "<Branch>"},
469 1 hiro
        {N_("/_File/_Mailbox/Add _mailbox..."),        NULL, add_mailbox_cb, 0, NULL},
470 1 hiro
        {N_("/_File/_Mailbox/_Remove mailbox"),        NULL, remove_mailbox_cb, 0, NULL},
471 1 hiro
        {N_("/_File/_Mailbox/---"),                NULL, NULL, 0, "<Separator>"},
472 1 hiro
        {N_("/_File/_Mailbox/_Check for new messages"),
473 1 hiro
                                                NULL, update_folderview_cb, 0, NULL},
474 1 hiro
        {N_("/_File/_Mailbox/Check for new messages in _all mailboxes"),
475 1 hiro
                                                NULL, update_folderview_cb, 1, NULL},
476 1 hiro
        {N_("/_File/_Mailbox/---"),                NULL, NULL, 0, "<Separator>"},
477 1 hiro
        {N_("/_File/_Mailbox/R_ebuild folder tree"),
478 1 hiro
                                                NULL, rebuild_tree_cb, 0, NULL},
479 1 hiro
        {N_("/_File/---"),                        NULL, NULL, 0, "<Separator>"},
480 1 hiro
        {N_("/_File/_Import mbox file..."),        NULL, import_mbox_cb, 0, NULL},
481 1 hiro
        {N_("/_File/_Export to mbox file..."),        NULL, export_mbox_cb, 0, NULL},
482 1 hiro
        {N_("/_File/---"),                        NULL, NULL, 0, "<Separator>"},
483 1 hiro
        {N_("/_File/Empty all _trash"),                NULL, empty_trash_cb, 0, NULL},
484 1 hiro
        {N_("/_File/---"),                        NULL, NULL, 0, "<Separator>"},
485 1 hiro
        {N_("/_File/_Save as..."),                "<control>S", save_as_cb, 0, NULL},
486 1 hiro
        {N_("/_File/_Print..."),                NULL, print_cb, 0, NULL},
487 1 hiro
        {N_("/_File/---"),                        NULL, NULL, 0, "<Separator>"},
488 1 hiro
        {N_("/_File/_Work offline"),                NULL, toggle_offline_cb, 0, "<ToggleItem>"},
489 1 hiro
        {N_("/_File/---"),                        NULL, NULL, 0, "<Separator>"},
490 1 hiro
        /* {N_("/_File/_Close"),                "<alt>W", app_exit_cb, 0, NULL}, */
491 1 hiro
        {N_("/_File/E_xit"),                        "<control>Q", app_exit_cb, 0, NULL},
492 1 hiro
493 1 hiro
        {N_("/_Edit"),                                NULL, NULL, 0, "<Branch>"},
494 1 hiro
        {N_("/_Edit/_Copy"),                        "<control>C", copy_cb, 0, NULL},
495 1 hiro
        {N_("/_Edit/Select _all"),                "<control>A", allsel_cb, 0, NULL},
496 1 hiro
        {N_("/_Edit/Select _thread"),                NULL, select_thread_cb, 0, NULL},
497 1 hiro
        {N_("/_Edit/---"),                        NULL, NULL, 0, "<Separator>"},
498 1 hiro
        {N_("/_Edit/_Find in current message..."),
499 1 hiro
                                                "<control>F", search_cb, 0, NULL},
500 1 hiro
        {N_("/_Edit/_Search messages..."),        "<shift><control>F", search_cb, 1, NULL},
501 1 hiro
502 1 hiro
        {N_("/_View"),                                NULL, NULL, 0, "<Branch>"},
503 1 hiro
        {N_("/_View/Show or hi_de"),                NULL, NULL, 0, "<Branch>"},
504 1 hiro
        {N_("/_View/Show or hi_de/_Folder tree"),
505 1 hiro
                                                NULL, toggle_folder_cb, 0, "<ToggleItem>"},
506 1 hiro
        {N_("/_View/Show or hi_de/_Message view"),
507 1 hiro
                                                "V", toggle_message_cb, 0, "<ToggleItem>"},
508 1 hiro
        {N_("/_View/Show or hi_de/_Toolbar"),
509 1 hiro
                                                NULL, NULL, 0, "<Branch>"},
510 1 hiro
        {N_("/_View/Show or hi_de/_Toolbar/Icon _and text"),
511 1 hiro
                                                NULL, toggle_toolbar_cb, TOOLBAR_BOTH, "<RadioItem>"},
512 1 hiro
        {N_("/_View/Show or hi_de/_Toolbar/_Icon"),
513 1 hiro
                                                NULL, toggle_toolbar_cb, TOOLBAR_ICON, "/View/Show or hide/Toolbar/Icon and text"},
514 1 hiro
        {N_("/_View/Show or hi_de/_Toolbar/_Text"),
515 1 hiro
                                                NULL, toggle_toolbar_cb, TOOLBAR_TEXT, "/View/Show or hide/Toolbar/Icon and text"},
516 1 hiro
        {N_("/_View/Show or hi_de/_Toolbar/_None"),
517 1 hiro
                                                NULL, toggle_toolbar_cb, TOOLBAR_NONE, "/View/Show or hide/Toolbar/Icon and text"},
518 1 hiro
        {N_("/_View/Show or hi_de/Status _bar"),
519 1 hiro
                                                NULL, toggle_statusbar_cb, 0, "<ToggleItem>"},
520 1 hiro
        {N_("/_View/---"),                        NULL, NULL, 0, "<Separator>"},
521 1 hiro
        {N_("/_View/Separate f_older tree"),        NULL, separate_widget_cb, SEPARATE_FOLDER, "<ToggleItem>"},
522 175 hiro
        {N_("/_View/Separate _message view"),        NULL, separate_widget_cb, SEPARATE_MESSAGE, "<ToggleItem>"},
523 1 hiro
        {N_("/_View/---"),                        NULL, NULL, 0, "<Separator>"},
524 1 hiro
        {N_("/_View/_Sort"),                        NULL, NULL, 0, "<Branch>"},
525 1 hiro
        {N_("/_View/_Sort/by _number"),                NULL, sort_summary_cb, SORT_BY_NUMBER, "<RadioItem>"},
526 1 hiro
        {N_("/_View/_Sort/by s_ize"),                NULL, sort_summary_cb, SORT_BY_SIZE, "/View/Sort/by number"},
527 1 hiro
        {N_("/_View/_Sort/by _date"),                NULL, sort_summary_cb, SORT_BY_DATE, "/View/Sort/by number"},
528 1 hiro
        {N_("/_View/_Sort/by _from"),                NULL, sort_summary_cb, SORT_BY_FROM, "/View/Sort/by number"},
529 1 hiro
        {N_("/_View/_Sort/by _recipient"),        NULL, sort_summary_cb, SORT_BY_TO, "/View/Sort/by number"},
530 1 hiro
        {N_("/_View/_Sort/by _subject"),        NULL, sort_summary_cb, SORT_BY_SUBJECT, "/View/Sort/by number"},
531 1 hiro
        {N_("/_View/_Sort/by _color label"),
532 1 hiro
                                                NULL, sort_summary_cb, SORT_BY_LABEL, "/View/Sort/by number"},
533 1 hiro
        {N_("/_View/_Sort/by _mark"),                NULL, sort_summary_cb, SORT_BY_MARK, "/View/Sort/by number"},
534 1 hiro
        {N_("/_View/_Sort/by _unread"),                NULL, sort_summary_cb, SORT_BY_UNREAD, "/View/Sort/by number"},
535 1 hiro
        {N_("/_View/_Sort/by a_ttachment"),
536 1 hiro
                                                NULL, sort_summary_cb, SORT_BY_MIME, "/View/Sort/by number"},
537 1 hiro
        {N_("/_View/_Sort/D_on't sort"),        NULL, sort_summary_cb, SORT_BY_NONE, "/View/Sort/by number"},
538 1 hiro
        {N_("/_View/_Sort/---"),                NULL, NULL, 0, "<Separator>"},
539 1 hiro
        {N_("/_View/_Sort/Ascending"),                NULL, sort_summary_type_cb, SORT_ASCENDING, "<RadioItem>"},
540 1 hiro
        {N_("/_View/_Sort/Descending"),                NULL, sort_summary_type_cb, SORT_DESCENDING, "/View/Sort/Ascending"},
541 1 hiro
        {N_("/_View/_Sort/---"),                NULL, NULL, 0, "<Separator>"},
542 1 hiro
        {N_("/_View/_Sort/_Attract by subject"),
543 1 hiro
                                                NULL, attract_by_subject_cb, 0, NULL},
544 1 hiro
        {N_("/_View/Th_read view"),                "<control>T", thread_cb, 0, "<ToggleItem>"},
545 1 hiro
        {N_("/_View/E_xpand all threads"),        NULL, expand_threads_cb, 0, NULL},
546 1 hiro
        {N_("/_View/Co_llapse all threads"),        NULL, collapse_threads_cb, 0, NULL},
547 1 hiro
        {N_("/_View/Set display _item..."),        NULL, set_display_item_cb, 0, NULL},
548 1 hiro
549 1 hiro
        {N_("/_View/---"),                        NULL, NULL, 0, "<Separator>"},
550 1 hiro
        {N_("/_View/_Go to"),                        NULL, NULL, 0, "<Branch>"},
551 1 hiro
        {N_("/_View/_Go to/_Prev message"),        "P", prev_cb, 0, NULL},
552 1 hiro
        {N_("/_View/_Go to/_Next message"),        "N", next_cb, 0, NULL},
553 1 hiro
        {N_("/_View/_Go to/---"),                NULL, NULL, 0, "<Separator>"},
554 1 hiro
        {N_("/_View/_Go to/P_rev unread message"),
555 1 hiro
                                                "<shift>P", prev_unread_cb, 0, NULL},
556 1 hiro
        {N_("/_View/_Go to/N_ext unread message"),
557 1 hiro
                                                "<shift>N", next_unread_cb, 0, NULL},
558 1 hiro
        {N_("/_View/_Go to/---"),                NULL, NULL, 0, "<Separator>"},
559 1 hiro
        {N_("/_View/_Go to/Prev ne_w message"),        NULL, prev_new_cb, 0, NULL},
560 1 hiro
        {N_("/_View/_Go to/Ne_xt new message"),        NULL, next_new_cb, 0, NULL},
561 1 hiro
        {N_("/_View/_Go to/---"),                NULL, NULL, 0, "<Separator>"},
562 1 hiro
        {N_("/_View/_Go to/Prev _marked message"),
563 1 hiro
                                                NULL, prev_marked_cb, 0, NULL},
564 1 hiro
        {N_("/_View/_Go to/Next m_arked message"),
565 1 hiro
                                                NULL, next_marked_cb, 0, NULL},
566 1 hiro
        {N_("/_View/_Go to/---"),                NULL, NULL, 0, "<Separator>"},
567 1 hiro
        {N_("/_View/_Go to/Prev _labeled message"),
568 1 hiro
                                                NULL, prev_labeled_cb, 0, NULL},
569 1 hiro
        {N_("/_View/_Go to/Next la_beled message"),
570 1 hiro
                                                NULL, next_labeled_cb, 0, NULL},
571 1 hiro
        {N_("/_View/_Go to/---"),                NULL, NULL, 0, "<Separator>"},
572 1 hiro
        {N_("/_View/_Go to/Other _folder..."),        "G", goto_folder_cb, 0, NULL},
573 1 hiro
        {N_("/_View/---"),                        NULL, NULL, 0, "<Separator>"},
574 1 hiro
575 175 hiro
#define ENC_SEPARATOR \
576 175 hiro
        {N_("/_View/Character _encoding/---"),                NULL, NULL, 0, "<Separator>"}
577 175 hiro
#define ENC_ACTION(action) \
578 175 hiro
         NULL, set_charset_cb, action, "/View/Character encoding/Auto detect"
579 1 hiro
580 175 hiro
        {N_("/_View/Character _encoding"),                NULL, NULL, 0, "<Branch>"},
581 175 hiro
        {N_("/_View/Character _encoding/_Auto detect"),
582 1 hiro
         NULL, set_charset_cb, C_AUTO, "<RadioItem>"},
583 175 hiro
        {N_("/_View/Character _encoding/---"),                NULL, NULL, 0, "<Separator>"},
584 175 hiro
        {N_("/_View/Character _encoding/7bit ascii (US-ASC_II)"),
585 175 hiro
         ENC_ACTION(C_US_ASCII)},
586 175 hiro
        {N_("/_View/Character _encoding/Unicode (_UTF-8)"),
587 175 hiro
         ENC_ACTION(C_UTF_8)},
588 175 hiro
        ENC_SEPARATOR,
589 1 hiro
590 175 hiro
        {N_("/_View/Character _encoding/Western European (ISO-8859-_1)"),
591 175 hiro
         ENC_ACTION(C_ISO_8859_1)},
592 175 hiro
        {N_("/_View/Character _encoding/Western European (ISO-8859-15)"),
593 175 hiro
         ENC_ACTION(C_ISO_8859_15)},
594 175 hiro
        ENC_SEPARATOR,
595 1 hiro
596 175 hiro
        {N_("/_View/Character _encoding/Central European (ISO-8859-_2)"),
597 175 hiro
         ENC_ACTION(C_ISO_8859_2)},
598 175 hiro
        ENC_SEPARATOR,
599 175 hiro
600 175 hiro
        {N_("/_View/Character _encoding/_Baltic (ISO-8859-13)"),
601 175 hiro
         ENC_ACTION(C_ISO_8859_13)},
602 175 hiro
        {N_("/_View/Character _encoding/Baltic (ISO-8859-_4)"),
603 175 hiro
         ENC_ACTION(C_ISO_8859_4)},
604 175 hiro
        ENC_SEPARATOR,
605 175 hiro
606 175 hiro
        {N_("/_View/Character _encoding/Greek (ISO-8859-_7)"),
607 175 hiro
         ENC_ACTION(C_ISO_8859_7)},
608 175 hiro
        ENC_SEPARATOR,
609 175 hiro
610 312 hiro
        {N_("/_View/Character _encoding/Hebrew (ISO-8859-_8)"),
611 312 hiro
         ENC_ACTION(C_ISO_8859_8)},
612 312 hiro
        {N_("/_View/Character _encoding/Hebrew (Windows-1255)"),
613 312 hiro
         ENC_ACTION(C_CP1255)},
614 312 hiro
        ENC_SEPARATOR,
615 312 hiro
616 175 hiro
        {N_("/_View/Character _encoding/Turkish (ISO-8859-_9)"),
617 175 hiro
         ENC_ACTION(C_ISO_8859_9)},
618 175 hiro
        ENC_SEPARATOR,
619 175 hiro
620 175 hiro
        {N_("/_View/Character _encoding/Cyrillic (ISO-8859-_5)"),
621 175 hiro
         ENC_ACTION(C_ISO_8859_5)},
622 175 hiro
        {N_("/_View/Character _encoding/Cyrillic (KOI8-_R)"),
623 175 hiro
         ENC_ACTION(C_KOI8_R)},
624 175 hiro
        {N_("/_View/Character _encoding/Cyrillic (KOI8-U)"),
625 175 hiro
         ENC_ACTION(C_KOI8_U)},
626 175 hiro
        {N_("/_View/Character _encoding/Cyrillic (Windows-1251)"),
627 175 hiro
         ENC_ACTION(C_CP1251)},
628 175 hiro
        ENC_SEPARATOR,
629 175 hiro
630 175 hiro
        {N_("/_View/Character _encoding/Japanese (ISO-2022-_JP)"),
631 175 hiro
         ENC_ACTION(C_ISO_2022_JP)},
632 175 hiro
        {N_("/_View/Character _encoding/Japanese (ISO-2022-JP-2)"),
633 175 hiro
         ENC_ACTION(C_ISO_2022_JP_2)},
634 175 hiro
        {N_("/_View/Character _encoding/Japanese (_EUC-JP)"),
635 175 hiro
         ENC_ACTION(C_EUC_JP)},
636 175 hiro
        {N_("/_View/Character _encoding/Japanese (_Shift__JIS)"),
637 175 hiro
         ENC_ACTION(C_SHIFT_JIS)},
638 175 hiro
        ENC_SEPARATOR,
639 175 hiro
640 175 hiro
        {N_("/_View/Character _encoding/Simplified Chinese (_GB2312)"),
641 175 hiro
         ENC_ACTION(C_GB2312)},
642 211 hiro
        {N_("/_View/Character _encoding/Simplified Chinese (GBK)"),
643 211 hiro
         ENC_ACTION(C_GBK)},
644 175 hiro
        {N_("/_View/Character _encoding/Traditional Chinese (_Big5)"),
645 175 hiro
         ENC_ACTION(C_BIG5)},
646 175 hiro
        {N_("/_View/Character _encoding/Traditional Chinese (EUC-_TW)"),
647 175 hiro
         ENC_ACTION(C_EUC_TW)},
648 175 hiro
        {N_("/_View/Character _encoding/Chinese (ISO-2022-_CN)"),
649 175 hiro
         ENC_ACTION(C_ISO_2022_CN)},
650 175 hiro
        ENC_SEPARATOR,
651 175 hiro
652 175 hiro
        {N_("/_View/Character _encoding/Korean (EUC-_KR)"),
653 175 hiro
         ENC_ACTION(C_EUC_KR)},
654 175 hiro
        {N_("/_View/Character _encoding/Korean (ISO-2022-KR)"),
655 175 hiro
         ENC_ACTION(C_ISO_2022_KR)},
656 175 hiro
        ENC_SEPARATOR,
657 175 hiro
658 175 hiro
        {N_("/_View/Character _encoding/Thai (TIS-620)"),
659 175 hiro
         ENC_ACTION(C_TIS_620)},
660 175 hiro
        {N_("/_View/Character _encoding/Thai (Windows-874)"),
661 175 hiro
         ENC_ACTION(C_WINDOWS_874)},
662 175 hiro
663 1 hiro
#undef CODESET_SEPARATOR
664 1 hiro
#undef CODESET_ACTION
665 1 hiro
666 1 hiro
        {N_("/_View/---"),                        NULL, NULL, 0, "<Separator>"},
667 1 hiro
        {N_("/_View/Open in new _window"),        "<control><alt>N", open_msg_cb, 0, NULL},
668 1 hiro
        {N_("/_View/Mess_age source"),                "<control>U", view_source_cb, 0, NULL},
669 1 hiro
        {N_("/_View/Show all _header"),                "<control>H", show_all_header_cb, 0, "<ToggleItem>"},
670 1 hiro
        {N_("/_View/---"),                        NULL, NULL, 0, "<Separator>"},
671 1 hiro
        {N_("/_View/_Update summary"),                "<control><alt>U", update_summary_cb,  0, NULL},
672 1 hiro
673 1 hiro
        {N_("/_Message"),                        NULL, NULL, 0, "<Branch>"},
674 1 hiro
        {N_("/_Message/Recei_ve"),                NULL, NULL, 0, "<Branch>"},
675 1 hiro
        {N_("/_Message/Recei_ve/Get from _current account"),
676 1 hiro
                                                "<control>I",        inc_mail_cb, 0, NULL},
677 1 hiro
        {N_("/_Message/Recei_ve/Get from _all accounts"),
678 1 hiro
                                                "<shift><control>I", inc_all_account_mail_cb, 0, NULL},
679 1 hiro
        {N_("/_Message/Recei_ve/Cancel receivin_g"),
680 1 hiro
                                                NULL, inc_cancel_cb, 0, NULL},
681 1 hiro
        {N_("/_Message/Recei_ve/---"),                NULL, NULL, 0, "<Separator>"},
682 1 hiro
        {N_("/_Message/_Send queued messages"), NULL, send_queue_cb, 0, NULL},
683 1 hiro
        {N_("/_Message/---"),                        NULL, NULL, 0, "<Separator>"},
684 1 hiro
        {N_("/_Message/Compose _new message"),        "<control>M",        compose_cb, 0, NULL},
685 1 hiro
        {N_("/_Message/---"),                        NULL, NULL, 0, "<Separator>"},
686 1 hiro
        {N_("/_Message/_Reply"),                "<control>R",         reply_cb, COMPOSE_REPLY, NULL},
687 1 hiro
        {N_("/_Message/Repl_y to"),                NULL, NULL, 0, "<Branch>"},
688 1 hiro
        {N_("/_Message/Repl_y to/_all"),        "<shift><control>R", reply_cb, COMPOSE_REPLY_TO_ALL, NULL},
689 1 hiro
        {N_("/_Message/Repl_y to/_sender"),        NULL, reply_cb, COMPOSE_REPLY_TO_SENDER, NULL},
690 1 hiro
        {N_("/_Message/Repl_y to/mailing _list"),
691 1 hiro
                                                "<control>L", reply_cb, COMPOSE_REPLY_TO_LIST, NULL},
692 1 hiro
        {N_("/_Message/---"),                        NULL, NULL, 0, "<Separator>"},
693 1 hiro
        {N_("/_Message/_Forward"),                "<control><alt>F", reply_cb, COMPOSE_FORWARD, NULL},
694 1 hiro
        {N_("/_Message/For_ward as attachment"),
695 1 hiro
                                                "<shift><control><alt>F", reply_cb, COMPOSE_FORWARD_AS_ATTACH, NULL},
696 1 hiro
        {N_("/_Message/Redirec_t"),                NULL, reply_cb, COMPOSE_REDIRECT, NULL},
697 1 hiro
        {N_("/_Message/---"),                        NULL, NULL, 0, "<Separator>"},
698 1 hiro
        {N_("/_Message/M_ove..."),                "<control>O", move_to_cb, 0, NULL},
699 1 hiro
        {N_("/_Message/_Copy..."),                "<shift><control>O", copy_to_cb, 0, NULL},
700 306 hiro
        {N_("/_Message/_Delete"),                "<control>D", delete_cb, 0, NULL},
701 1 hiro
        {N_("/_Message/---"),                        NULL, NULL, 0, "<Separator>"},
702 1 hiro
        {N_("/_Message/_Mark"),                        NULL, NULL, 0, "<Branch>"},
703 1 hiro
        {N_("/_Message/_Mark/_Mark"),                "<shift>asterisk", mark_cb, 0, NULL},
704 1 hiro
        {N_("/_Message/_Mark/_Unmark"),                "U", unmark_cb, 0, NULL},
705 1 hiro
        {N_("/_Message/_Mark/---"),                NULL, NULL, 0, "<Separator>"},
706 1 hiro
        {N_("/_Message/_Mark/Mark as unr_ead"),        "<shift>exclam", mark_as_unread_cb, 0, NULL},
707 1 hiro
        {N_("/_Message/_Mark/Mark as rea_d"),
708 1 hiro
                                                NULL, mark_as_read_cb, 0, NULL},
709 1 hiro
        {N_("/_Message/_Mark/Mark all _read"),        NULL, mark_all_read_cb, 0, NULL},
710 1 hiro
        {N_("/_Message/---"),                        NULL, NULL, 0, "<Separator>"},
711 306 hiro
        {N_("/_Message/Set as _junk mail"),        "<control>J", junk_cb, 0, NULL},
712 306 hiro
        {N_("/_Message/Set as not j_unk mail"),        "<shift><control>J", junk_cb, 1, NULL},
713 306 hiro
        {N_("/_Message/---"),                        NULL, NULL, 0, "<Separator>"},
714 1 hiro
        {N_("/_Message/Re-_edit"),                NULL, reedit_cb, 0, NULL},
715 1 hiro
716 1 hiro
        {N_("/_Tools"),                                NULL, NULL, 0, "<Branch>"},
717 1 hiro
        {N_("/_Tools/_Address book"),                "<shift><control>A", addressbook_open_cb, 0, NULL},
718 352 hiro
        {N_("/_Tools/Add sender to address boo_k..."),
719 1 hiro
                                                NULL, add_address_cb, 0, NULL},
720 1 hiro
        {N_("/_Tools/---"),                        NULL, NULL, 0, "<Separator>"},
721 1 hiro
        {N_("/_Tools/_Filter all messages in folder"),
722 1 hiro
                                                NULL, filter_cb, 0, NULL},
723 1 hiro
        {N_("/_Tools/Filter _selected messages"),
724 1 hiro
                                                NULL, filter_cb, 1, NULL},
725 1 hiro
        {N_("/_Tools/_Create filter rule"),        NULL, NULL, 0, "<Branch>"},
726 1 hiro
        {N_("/_Tools/_Create filter rule/_Automatically"),
727 1 hiro
                                                NULL, create_filter_cb, FILTER_BY_AUTO, NULL},
728 1 hiro
        {N_("/_Tools/_Create filter rule/by _From"),
729 1 hiro
                                                NULL, create_filter_cb, FILTER_BY_FROM, NULL},
730 1 hiro
        {N_("/_Tools/_Create filter rule/by _To"),
731 1 hiro
                                                NULL, create_filter_cb, FILTER_BY_TO, NULL},
732 1 hiro
        {N_("/_Tools/_Create filter rule/by _Subject"),
733 1 hiro
                                                NULL, create_filter_cb, FILTER_BY_SUBJECT, NULL},
734 1 hiro
        {N_("/_Tools/---"),                        NULL, NULL, 0, "<Separator>"},
735 344 hiro
        {N_("/_Tools/Filter _junk mails in folder"),
736 344 hiro
                                                NULL, filter_junk_cb, 0, NULL},
737 344 hiro
        {N_("/_Tools/Filter junk _mails in selected messages"),
738 344 hiro
                                                NULL, filter_junk_cb, 1, NULL},
739 344 hiro
        {N_("/_Tools/---"),                        NULL, NULL, 0, "<Separator>"},
740 1 hiro
        {N_("/_Tools/Actio_ns"),                NULL, NULL, 0, "<Branch>"},
741 1 hiro
        {N_("/_Tools/---"),                        NULL, NULL, 0, "<Separator>"},
742 1 hiro
        {N_("/_Tools/Delete du_plicated messages"),
743 1 hiro
                                                NULL, delete_duplicated_cb,   0, NULL},
744 1 hiro
        {N_("/_Tools/---"),                        NULL, NULL, 0, "<Separator>"},
745 1 hiro
        {N_("/_Tools/E_xecute"),                "X", execute_summary_cb, 0, NULL},
746 1 hiro
        {N_("/_Tools/---"),                        NULL, NULL, 0, "<Separator>"},
747 1 hiro
        {N_("/_Tools/_Log window"),                "<shift><control>L", log_window_show_cb, 0, NULL},
748 1 hiro
749 1 hiro
        {N_("/_Configuration"),                        NULL, NULL, 0, "<Branch>"},
750 1 hiro
        {N_("/_Configuration/_Common preferences..."),
751 1 hiro
                                                NULL, prefs_common_open_cb, 0, NULL},
752 1 hiro
        {N_("/_Configuration/_Filter setting..."),
753 1 hiro
                                                NULL, prefs_filter_open_cb, 0, NULL},
754 1 hiro
        {N_("/_Configuration/_Template..."),        NULL, prefs_template_open_cb, 0, NULL},
755 1 hiro
        {N_("/_Configuration/_Actions..."),        NULL, prefs_actions_open_cb, 0, NULL},
756 1 hiro
        {N_("/_Configuration/---"),                NULL, NULL, 0, "<Separator>"},
757 1 hiro
        {N_("/_Configuration/_Preferences for current account..."),
758 1 hiro
                                                NULL, prefs_account_open_cb, 0, NULL},
759 1 hiro
        {N_("/_Configuration/Create _new account..."),
760 1 hiro
                                                NULL, new_account_cb, 0, NULL},
761 1 hiro
        {N_("/_Configuration/_Edit accounts..."),
762 1 hiro
                                                NULL, account_edit_open, 0, NULL},
763 1 hiro
        {N_("/_Configuration/C_hange current account"),
764 1 hiro
                                                NULL, NULL, 0, "<Branch>"},
765 1 hiro
766 1 hiro
        {N_("/_Help"),                                NULL, NULL, 0, "<Branch>"},
767 1 hiro
        {N_("/_Help/_Manual"),                        NULL, NULL, 0, "<Branch>"},
768 1 hiro
        {N_("/_Help/_Manual/_English"),                NULL, manual_open_cb, MANUAL_LANG_EN, NULL},
769 1 hiro
        {N_("/_Help/_Manual/_Japanese"),        NULL, manual_open_cb, MANUAL_LANG_JA, NULL},
770 1 hiro
        {N_("/_Help/_FAQ"),                        NULL, NULL, 0, "<Branch>"},
771 1 hiro
        {N_("/_Help/_FAQ/_English"),                NULL, faq_open_cb, MANUAL_LANG_EN, NULL},
772 1 hiro
        {N_("/_Help/_FAQ/_German"),                NULL, faq_open_cb, MANUAL_LANG_DE, NULL},
773 1 hiro
        {N_("/_Help/_FAQ/_Spanish"),                NULL, faq_open_cb, MANUAL_LANG_ES, NULL},
774 1 hiro
        {N_("/_Help/_FAQ/_French"),                NULL, faq_open_cb, MANUAL_LANG_FR, NULL},
775 1 hiro
        {N_("/_Help/_FAQ/_Italian"),                NULL, faq_open_cb, MANUAL_LANG_IT, NULL},
776 1 hiro
        {N_("/_Help/---"),                        NULL, NULL, 0, "<Separator>"},
777 1 hiro
        {N_("/_Help/_About"),                        NULL, about_show, 0, NULL}
778 1 hiro
};
779 1 hiro
780 1 hiro
MainWindow *main_window_create(SeparateType type)
781 1 hiro
{
782 1 hiro
        MainWindow *mainwin;
783 1 hiro
        GtkWidget *window;
784 1 hiro
        GtkWidget *vbox;
785 1 hiro
        GtkWidget *menubar;
786 489 hiro
        GtkWidget *toolbar;
787 1 hiro
        GtkWidget *vbox_body;
788 1 hiro
        GtkWidget *statusbar;
789 1 hiro
        GtkWidget *progressbar;
790 1 hiro
        GtkWidget *statuslabel;
791 1 hiro
        GtkWidget *online_hbox;
792 1 hiro
        GtkWidget *online_switch;
793 1 hiro
        GtkWidget *online_pixmap;
794 1 hiro
        GtkWidget *offline_pixmap;
795 1 hiro
        GtkTooltips *online_tip;
796 232 hiro
#if !GTK_CHECK_VERSION(2, 6, 0)
797 23 hiro
        GtkWidget *spacer_hbox;
798 232 hiro
#endif
799 1 hiro
        GtkWidget *ac_button;
800 1 hiro
        GtkWidget *ac_label;
801 1 hiro
802 1 hiro
        FolderView *folderview;
803 1 hiro
        SummaryView *summaryview;
804 1 hiro
        MessageView *messageview;
805 1 hiro
        GdkColormap *colormap;
806 1 hiro
        GdkColor color[3];
807 1 hiro
        gboolean success[3];
808 1 hiro
        guint n_menu_entries;
809 1 hiro
        GtkItemFactory *ifactory;
810 1 hiro
        GtkWidget *ac_menu;
811 1 hiro
        GtkWidget *menuitem;
812 1 hiro
        gint i;
813 1 hiro
814 1 hiro
        static GdkGeometry geometry;
815 1 hiro
816 1 hiro
        debug_print(_("Creating main window...\n"));
817 1 hiro
        mainwin = g_new0(MainWindow, 1);
818 1 hiro
819 1 hiro
        /* main window */
820 1 hiro
        window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
821 1 hiro
        gtk_window_set_title(GTK_WINDOW(window), PROG_VERSION);
822 1 hiro
        gtk_window_set_policy(GTK_WINDOW(window), TRUE, TRUE, FALSE);
823 1 hiro
        gtk_window_set_wmclass(GTK_WINDOW(window), "main_window", "Sylpheed");
824 1 hiro
825 1 hiro
        if (!geometry.min_height) {
826 1 hiro
                geometry.min_width = 320;
827 1 hiro
                geometry.min_height = 200;
828 1 hiro
        }
829 1 hiro
        gtk_window_set_geometry_hints(GTK_WINDOW(window), NULL, &geometry,
830 1 hiro
                                      GDK_HINT_MIN_SIZE);
831 1 hiro
832 1 hiro
        g_signal_connect(G_OBJECT(window), "delete_event",
833 1 hiro
                         G_CALLBACK(main_window_close_cb), mainwin);
834 1 hiro
        MANAGE_WINDOW_SIGNALS_CONNECT(window);
835 1 hiro
        gtk_widget_realize(window);
836 1 hiro
837 1 hiro
        vbox = gtk_vbox_new(FALSE, 0);
838 1 hiro
        gtk_widget_show(vbox);
839 1 hiro
        gtk_container_add(GTK_CONTAINER(window), vbox);
840 1 hiro
841 1 hiro
        /* menu bar */
842 1 hiro
        n_menu_entries = sizeof(mainwin_entries) / sizeof(mainwin_entries[0]);
843 1 hiro
        menubar = menubar_create(window, mainwin_entries,
844 1 hiro
                                 n_menu_entries, "<Main>", mainwin);
845 1 hiro
        gtk_widget_show(menubar);
846 489 hiro
        gtk_widget_set_size_request(menubar, 300, -1);
847 1 hiro
        gtk_box_pack_start(GTK_BOX(vbox), menubar, FALSE, TRUE, 0);
848 1 hiro
        ifactory = gtk_item_factory_from_widget(menubar);
849 1 hiro
850 489 hiro
        toolbar = main_window_toolbar_create(mainwin);
851 489 hiro
        gtk_widget_set_size_request(toolbar, 300, -1);
852 489 hiro
        gtk_box_pack_start(GTK_BOX(vbox), toolbar, FALSE, FALSE, 0);
853 1 hiro
854 1 hiro
        /* vbox that contains body */
855 1 hiro
        vbox_body = gtk_vbox_new(FALSE, BORDER_WIDTH);
856 1 hiro
        gtk_widget_show(vbox_body);
857 1 hiro
        gtk_container_set_border_width(GTK_CONTAINER(vbox_body), BORDER_WIDTH);
858 1 hiro
        gtk_box_pack_start(GTK_BOX(vbox), vbox_body, TRUE, TRUE, 0);
859 1 hiro
860 1 hiro
        statusbar = statusbar_create();
861 23 hiro
        gtk_box_pack_end(GTK_BOX(vbox_body), statusbar, FALSE, FALSE, 0);
862 1 hiro
863 1 hiro
        progressbar = gtk_progress_bar_new();
864 1 hiro
        gtk_widget_set_size_request(progressbar, 120, 1);
865 23 hiro
        gtk_box_pack_start(GTK_BOX(statusbar), progressbar, FALSE, FALSE, 0);
866 1 hiro
867 1 hiro
        statuslabel = gtk_label_new("");
868 23 hiro
        gtk_box_pack_start(GTK_BOX(statusbar), statuslabel, FALSE, FALSE, 0);
869 1 hiro
870 1 hiro
        online_hbox = gtk_hbox_new(FALSE, 0);
871 1 hiro
872 398 hiro
        online_pixmap = stock_pixbuf_widget(statusbar, STOCK_PIXMAP_ONLINE);
873 398 hiro
        offline_pixmap = stock_pixbuf_widget(statusbar, STOCK_PIXMAP_OFFLINE);
874 1 hiro
        gtk_box_pack_start(GTK_BOX(online_hbox), online_pixmap,
875 1 hiro
                           FALSE, FALSE, 0);
876 1 hiro
        gtk_box_pack_start(GTK_BOX(online_hbox), offline_pixmap,
877 1 hiro
                           FALSE, FALSE, 0);
878 1 hiro
879 1 hiro
        online_switch = gtk_button_new();
880 1 hiro
        gtk_button_set_relief(GTK_BUTTON(online_switch), GTK_RELIEF_NONE);
881 1 hiro
        GTK_WIDGET_UNSET_FLAGS(online_switch, GTK_CAN_FOCUS);
882 1 hiro
        gtk_container_add(GTK_CONTAINER(online_switch), online_hbox);
883 1 hiro
        g_signal_connect(G_OBJECT(online_switch), "clicked",
884 1 hiro
                         G_CALLBACK(online_switch_clicked), mainwin);
885 23 hiro
        gtk_box_pack_start(GTK_BOX(statusbar), online_switch, FALSE, FALSE, 0);
886 1 hiro
887 1 hiro
        online_tip = gtk_tooltips_new();
888 1 hiro
889 232 hiro
#if !GTK_CHECK_VERSION(2, 6, 0)
890 23 hiro
        spacer_hbox = gtk_hbox_new(FALSE, 0);
891 23 hiro
        gtk_box_pack_end(GTK_BOX(statusbar), spacer_hbox, FALSE, FALSE, 0);
892 232 hiro
#endif
893 23 hiro
894 1 hiro
        ac_button = gtk_button_new();
895 1 hiro
        gtk_button_set_relief(GTK_BUTTON(ac_button), GTK_RELIEF_NONE);
896 1 hiro
        GTK_WIDGET_UNSET_FLAGS(ac_button, GTK_CAN_FOCUS);
897 1 hiro
        gtk_widget_set_size_request(ac_button, -1, 1);
898 23 hiro
        gtk_box_pack_end(GTK_BOX(statusbar), ac_button, FALSE, FALSE, 0);
899 1 hiro
        g_signal_connect(G_OBJECT(ac_button), "button_press_event",
900 1 hiro
                         G_CALLBACK(ac_label_button_pressed), mainwin);
901 1 hiro
902 1 hiro
        ac_label = gtk_label_new("");
903 1 hiro
        gtk_container_add(GTK_CONTAINER(ac_button), ac_label);
904 1 hiro
905 23 hiro
        gtk_widget_show_all(statusbar);
906 1 hiro
907 1 hiro
        /* create views */
908 1 hiro
        mainwin->folderview  = folderview  = folderview_create();
909 1 hiro
        mainwin->summaryview = summaryview = summary_create();
910 1 hiro
        mainwin->messageview = messageview = messageview_create();
911 1 hiro
        mainwin->logwin      = log_window_create();
912 1 hiro
913 1 hiro
        folderview->mainwin      = mainwin;
914 1 hiro
        folderview->summaryview  = summaryview;
915 1 hiro
916 1 hiro
        summaryview->mainwin     = mainwin;
917 1 hiro
        summaryview->folderview  = folderview;
918 1 hiro
        summaryview->messageview = messageview;
919 1 hiro
        summaryview->window      = window;
920 1 hiro
921 1 hiro
        messageview->statusbar   = statusbar;
922 1 hiro
        messageview->mainwin     = mainwin;
923 1 hiro
924 1 hiro
        mainwin->window         = window;
925 1 hiro
        mainwin->vbox           = vbox;
926 1 hiro
        mainwin->menubar        = menubar;
927 1 hiro
        mainwin->menu_factory   = ifactory;
928 489 hiro
        mainwin->toolbar        = toolbar;
929 1 hiro
        mainwin->vbox_body      = vbox_body;
930 1 hiro
        mainwin->statusbar      = statusbar;
931 1 hiro
        mainwin->progressbar    = progressbar;
932 1 hiro
        mainwin->statuslabel    = statuslabel;
933 1 hiro
        mainwin->online_switch  = online_switch;
934 1 hiro
        mainwin->online_pixmap  = online_pixmap;
935 1 hiro
        mainwin->offline_pixmap = offline_pixmap;
936 1 hiro
        mainwin->online_tip     = online_tip;
937 1 hiro
        mainwin->ac_button      = ac_button;
938 1 hiro
        mainwin->ac_label       = ac_label;
939 1 hiro
940 1 hiro
        /* set context IDs for status bar */
941 1 hiro
        mainwin->mainwin_cid = gtk_statusbar_get_context_id
942 1 hiro
                (GTK_STATUSBAR(statusbar), "Main Window");
943 1 hiro
        mainwin->folderview_cid = gtk_statusbar_get_context_id
944 1 hiro
                (GTK_STATUSBAR(statusbar), "Folder View");
945 1 hiro
        mainwin->summaryview_cid = gtk_statusbar_get_context_id
946 1 hiro
                (GTK_STATUSBAR(statusbar), "Summary View");
947 1 hiro
        mainwin->messageview_cid = gtk_statusbar_get_context_id
948 1 hiro
                (GTK_STATUSBAR(statusbar), "Message View");
949 1 hiro
950 1 hiro
        messageview->statusbar_cid = mainwin->messageview_cid;
951 1 hiro
952 1 hiro
        /* allocate colors for summary view and folder view */
953 1 hiro
        summaryview->color_marked.red = summaryview->color_marked.green = 0;
954 1 hiro
        summaryview->color_marked.blue = (guint16)65535;
955 1 hiro
956 1 hiro
        summaryview->color_dim.red = summaryview->color_dim.green =
957 1 hiro
                summaryview->color_dim.blue = COLOR_DIM;
958 1 hiro
959 1 hiro
        folderview->color_new.red = (guint16)55000;
960 1 hiro
        folderview->color_new.green = folderview->color_new.blue = 15000;
961 1 hiro
962 1 hiro
        folderview->color_noselect.red = folderview->color_noselect.green =
963 1 hiro
                folderview->color_noselect.blue = COLOR_DIM;
964 1 hiro
965 1 hiro
        color[0] = summaryview->color_marked;
966 1 hiro
        color[1] = summaryview->color_dim;
967 1 hiro
        color[2] = folderview->color_new;
968 1 hiro
969 1 hiro
        colormap = gdk_window_get_colormap(window->window);
970 1 hiro
        gdk_colormap_alloc_colors(colormap, color, 3, FALSE, TRUE, success);
971 1 hiro
        for (i = 0; i < 3; i++) {
972 1 hiro
                if (success[i] == FALSE)
973 1 hiro
                        g_warning(_("MainWindow: color allocation %d failed\n"), i);
974 1 hiro
        }
975 1 hiro
976 1 hiro
        messageview->visible = prefs_common.msgview_visible;
977 1 hiro
978 1 hiro
        main_window_set_widgets(mainwin, type);
979 1 hiro
980 1 hiro
        g_signal_connect(G_OBJECT(window), "size_allocate",
981 1 hiro
                         G_CALLBACK(main_window_size_allocate_cb), mainwin);
982 1 hiro
983 1 hiro
        /* set menu items */
984 1 hiro
        menuitem = gtk_item_factory_get_item
985 175 hiro
                (ifactory, "/View/Character encoding/Auto detect");
986 1 hiro
        gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), TRUE);
987 1 hiro
988 1 hiro
        switch (prefs_common.toolbar_style) {
989 1 hiro
        case TOOLBAR_NONE:
990 1 hiro
                menuitem = gtk_item_factory_get_item
991 1 hiro
                        (ifactory, "/View/Show or hide/Toolbar/None");
992 1 hiro
                break;
993 1 hiro
        case TOOLBAR_ICON:
994 1 hiro
                menuitem = gtk_item_factory_get_item
995 1 hiro
                        (ifactory, "/View/Show or hide/Toolbar/Icon");
996 1 hiro
                break;
997 1 hiro
        case TOOLBAR_TEXT:
998 1 hiro
                menuitem = gtk_item_factory_get_item
999 1 hiro
                        (ifactory, "/View/Show or hide/Toolbar/Text");
1000 1 hiro
                break;
1001 1 hiro
        case TOOLBAR_BOTH:
1002 1 hiro
                menuitem = gtk_item_factory_get_item
1003 1 hiro
                        (ifactory, "/View/Show or hide/Toolbar/Icon and text");
1004 1 hiro
        }
1005 1 hiro
        gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), TRUE);
1006 1 hiro
1007 23 hiro
        gtk_widget_hide(mainwin->statusbar);
1008 1 hiro
        menuitem = gtk_item_factory_get_item
1009 1 hiro
                (ifactory, "/View/Show or hide/Status bar");
1010 1 hiro
        gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem),
1011 1 hiro
                                       prefs_common.show_statusbar);
1012 1 hiro
1013 1 hiro
        /* set account selection menu */
1014 1 hiro
        ac_menu = gtk_item_factory_get_widget
1015 1 hiro
                (ifactory, "/Configuration/Change current account");
1016 1 hiro
        g_signal_connect(G_OBJECT(ac_menu), "selection_done",
1017 1 hiro
                         G_CALLBACK(ac_menu_popup_closed), mainwin);
1018 1 hiro
        mainwin->ac_menu = ac_menu;
1019 1 hiro
1020 1 hiro
        main_window_set_toolbar_sensitive(mainwin);
1021 1 hiro
1022 1 hiro
        /* create actions menu */
1023 1 hiro
        action_update_mainwin_menu(ifactory, mainwin);
1024 1 hiro
1025 1 hiro
        /* initialize online switch */
1026 1 hiro
        prefs_common.online_mode = !prefs_common.online_mode;
1027 1 hiro
        online_switch_clicked(online_switch, mainwin);
1028 1 hiro
1029 1 hiro
        /* show main window */
1030 1 hiro
        gtk_widget_show(mainwin->window);
1031 1 hiro
1032 232 hiro
#if !GTK_CHECK_VERSION(2, 6, 0)
1033 232 hiro
        {
1034 232 hiro
                gint w, h;
1035 232 hiro
                gdk_drawable_get_size
1036 232 hiro
                        (GDK_DRAWABLE(GTK_STATUSBAR(statusbar)->grip_window),
1037 232 hiro
                         &w, &h);
1038 232 hiro
                gtk_widget_set_size_request(spacer_hbox, w, -1);
1039 232 hiro
        }
1040 232 hiro
#endif
1041 23 hiro
1042 1 hiro
        /* initialize views */
1043 1 hiro
        folderview_init(folderview);
1044 1 hiro
        summary_init(summaryview);
1045 1 hiro
        messageview_init(messageview);
1046 1 hiro
        log_window_init(mainwin->logwin);
1047 1 hiro
1048 1 hiro
        mainwin->lock_count = 0;
1049 1 hiro
        mainwin->menu_lock_count = 0;
1050 1 hiro
        mainwin->cursor_count = 0;
1051 1 hiro
1052 1 hiro
        if (!watch_cursor)
1053 1 hiro
                watch_cursor = gdk_cursor_new(GDK_WATCH);
1054 1 hiro
1055 1 hiro
        mainwin_list = g_list_append(mainwin_list, mainwin);
1056 1 hiro
1057 1 hiro
        debug_print(_("done.\n"));
1058 1 hiro
1059 1 hiro
        return mainwin;
1060 1 hiro
}
1061 1 hiro
1062 1 hiro
void main_window_cursor_wait(MainWindow *mainwin)
1063 1 hiro
{
1064 1 hiro
1065 1 hiro
        if (mainwin->cursor_count == 0)
1066 1 hiro
                gdk_window_set_cursor(mainwin->window->window, watch_cursor);
1067 1 hiro
1068 1 hiro
        mainwin->cursor_count++;
1069 1 hiro
1070 1 hiro
        gdk_flush();
1071 1 hiro
}
1072 1 hiro
1073 1 hiro
void main_window_cursor_normal(MainWindow *mainwin)
1074 1 hiro
{
1075 1 hiro
        if (mainwin->cursor_count)
1076 1 hiro
                mainwin->cursor_count--;
1077 1 hiro
1078 1 hiro
        if (mainwin->cursor_count == 0)
1079 1 hiro
                gdk_window_set_cursor(mainwin->window->window, NULL);
1080 1 hiro
1081 1 hiro
        gdk_flush();
1082 1 hiro
}
1083 1 hiro
1084 1 hiro
/* lock / unlock the user-interface */
1085 1 hiro
void main_window_lock(MainWindow *mainwin)
1086 1 hiro
{
1087 1 hiro
        if (mainwin->lock_count == 0)
1088 1 hiro
                gtk_widget_set_sensitive(mainwin->ac_button, FALSE);
1089 1 hiro
1090 1 hiro
        mainwin->lock_count++;
1091 1 hiro
1092 1 hiro
        main_window_set_menu_sensitive(mainwin);
1093 1 hiro
        main_window_set_toolbar_sensitive(mainwin);
1094 1 hiro
}
1095 1 hiro
1096 1 hiro
void main_window_unlock(MainWindow *mainwin)
1097 1 hiro
{
1098 1 hiro
        if (mainwin->lock_count)
1099 1 hiro
                mainwin->lock_count--;
1100 1 hiro
1101 1 hiro
        main_window_set_menu_sensitive(mainwin);
1102 1 hiro
        main_window_set_toolbar_sensitive(mainwin);
1103 1 hiro
1104 1 hiro
        if (mainwin->lock_count == 0)
1105 1 hiro
                gtk_widget_set_sensitive(mainwin->ac_button, TRUE);
1106 1 hiro
}
1107 1 hiro
1108 1 hiro
static void main_window_menu_callback_block(MainWindow *mainwin)
1109 1 hiro
{
1110 1 hiro
        mainwin->menu_lock_count++;
1111 1 hiro
}
1112 1 hiro
1113 1 hiro
static void main_window_menu_callback_unblock(MainWindow *mainwin)
1114 1 hiro
{
1115 1 hiro
        if (mainwin->menu_lock_count)
1116 1 hiro
                mainwin->menu_lock_count--;
1117 1 hiro
}
1118 1 hiro
1119 1 hiro
void main_window_reflect_prefs_all(void)
1120 1 hiro
{
1121 1 hiro
        GList *cur;
1122 1 hiro
        MainWindow *mainwin;
1123 1 hiro
1124 1 hiro
        for (cur = mainwin_list; cur != NULL; cur = cur->next) {
1125 1 hiro
                mainwin = (MainWindow *)cur->data;
1126 1 hiro
1127 1 hiro
                main_window_show_cur_account(mainwin);
1128 1 hiro
                main_window_set_menu_sensitive(mainwin);
1129 1 hiro
                main_window_set_toolbar_sensitive(mainwin);
1130 1 hiro
1131 306 hiro
                if (prefs_common.enable_junk)
1132 306 hiro
                        gtk_widget_show(mainwin->junk_btn);
1133 306 hiro
                else
1134 306 hiro
                        gtk_widget_hide(mainwin->junk_btn);
1135 306 hiro
1136 1 hiro
                if (prefs_common.immediate_exec)
1137 1 hiro
                        gtk_widget_hide(mainwin->exec_btn);
1138 1 hiro
                else
1139 1 hiro
                        gtk_widget_show(mainwin->exec_btn);
1140 1 hiro
1141 1 hiro
                headerview_set_visibility(mainwin->messageview->headerview,
1142 1 hiro
                                          prefs_common.display_header_pane);
1143 269 hiro
1144 269 hiro
                textview_reflect_prefs(mainwin->messageview->textview);
1145 269 hiro
                textview_reflect_prefs(mainwin->messageview->mimeview->textview);
1146 269 hiro
1147 269 hiro
                summary_redisplay_msg(mainwin->summaryview);
1148 1 hiro
        }
1149 1 hiro
}
1150 1 hiro
1151 1 hiro
void main_window_set_summary_column(void)
1152 1 hiro
{
1153 1 hiro
        GList *cur;
1154 1 hiro
        MainWindow *mainwin;
1155 1 hiro
1156 1 hiro
        for (cur = mainwin_list; cur != NULL; cur = cur->next) {
1157 1 hiro
                mainwin = (MainWindow *)cur->data;
1158 1 hiro
                summary_set_column_order(mainwin->summaryview);
1159 1 hiro
        }
1160 1 hiro
}
1161 1 hiro
1162 1 hiro
static void main_window_set_account_selector_menu(MainWindow *mainwin,
1163 1 hiro
                                                  GList *account_list)
1164 1 hiro
{
1165 1 hiro
        GList *cur_ac, *cur_item;
1166 1 hiro
        GtkWidget *menuitem;
1167 1 hiro
        PrefsAccount *ac_prefs;
1168 1 hiro
1169 1 hiro
        /* destroy all previous menu item */
1170 1 hiro
        cur_item = GTK_MENU_SHELL(mainwin->ac_menu)->children;
1171 1 hiro
        while (cur_item != NULL) {
1172 1 hiro
                GList *next = cur_item->next;
1173 1 hiro
                gtk_widget_destroy(GTK_WIDGET(cur_item->data));
1174 1 hiro
                cur_item = next;
1175 1 hiro
        }
1176 1 hiro
1177 1 hiro
        for (cur_ac = account_list; cur_ac != NULL; cur_ac = cur_ac->next) {
1178 1 hiro
                ac_prefs = (PrefsAccount *)cur_ac->data;
1179 1 hiro
1180 1 hiro
                menuitem = gtk_menu_item_new_with_label
1181 1 hiro
                        (ac_prefs->account_name
1182 1 hiro
                         ? ac_prefs->account_name : _("Untitled"));
1183 1 hiro
                gtk_widget_show(menuitem);
1184 1 hiro
                gtk_menu_append(GTK_MENU(mainwin->ac_menu), menuitem);
1185 1 hiro
                g_signal_connect(G_OBJECT(menuitem), "activate",
1186 1 hiro
                                 G_CALLBACK(account_selector_menu_cb),
1187 1 hiro
                                 ac_prefs);
1188 1 hiro
        }
1189 1 hiro
}
1190 1 hiro
1191 1 hiro
static void main_window_set_account_receive_menu(MainWindow *mainwin,
1192 1 hiro
                                                 GList *account_list)
1193 1 hiro
{
1194 1 hiro
        GList *cur_ac, *cur_item;
1195 1 hiro
        GtkWidget *menu;
1196 1 hiro
        GtkWidget *menuitem;
1197 1 hiro
        PrefsAccount *ac_prefs;
1198 1 hiro
1199 1 hiro
        menu = gtk_item_factory_get_widget(mainwin->menu_factory,
1200 1 hiro
                                           "/Message/Receive");
1201 1 hiro
1202 1 hiro
        /* search for separator */
1203 1 hiro
        for (cur_item = GTK_MENU_SHELL(menu)->children; cur_item != NULL;
1204 1 hiro
             cur_item = cur_item->next) {
1205 1 hiro
                if (GTK_BIN(cur_item->data)->child == NULL) {
1206 1 hiro
                        cur_item = cur_item->next;
1207 1 hiro
                        break;
1208 1 hiro
                }
1209 1 hiro
        }
1210 1 hiro
1211 1 hiro
        /* destroy all previous menu item */
1212 1 hiro
        while (cur_item != NULL) {
1213 1 hiro
                GList *next = cur_item->next;
1214 1 hiro
                gtk_widget_destroy(GTK_WIDGET(cur_item->data));
1215 1 hiro
                cur_item = next;
1216 1 hiro
        }
1217 1 hiro
1218 1 hiro
        for (cur_ac = account_list; cur_ac != NULL; cur_ac = cur_ac->next) {
1219 1 hiro
                ac_prefs = (PrefsAccount *)cur_ac->data;
1220 1 hiro
1221 1 hiro
                menuitem = gtk_menu_item_new_with_label
1222 1 hiro
                        (ac_prefs->account_name ? ac_prefs->account_name
1223 1 hiro
                         : _("Untitled"));
1224 1 hiro
                gtk_widget_show(menuitem);
1225 1 hiro
                gtk_menu_append(GTK_MENU(menu), menuitem);
1226 1 hiro
                g_signal_connect(G_OBJECT(menuitem), "activate",
1227 1 hiro
                                 G_CALLBACK(account_receive_menu_cb),
1228 1 hiro
                                 ac_prefs);
1229 1 hiro
        }
1230 1 hiro
}
1231 1 hiro
1232 1 hiro
void main_window_set_account_menu(GList *account_list)
1233 1 hiro
{
1234 1 hiro
        GList *cur;
1235 1 hiro
        MainWindow *mainwin;
1236 1 hiro
1237 1 hiro
        for (cur = mainwin_list; cur != NULL; cur = cur->next) {
1238 1 hiro
                mainwin = (MainWindow *)cur->data;
1239 1 hiro
                main_window_set_account_selector_menu(mainwin, account_list);
1240 1 hiro
                main_window_set_account_receive_menu(mainwin, account_list);
1241 1 hiro
        }
1242 1 hiro
}
1243 1 hiro
1244 1 hiro
static void main_window_show_cur_account(MainWindow *mainwin)
1245 1 hiro
{
1246 1 hiro
        gchar *buf;
1247 1 hiro
        gchar *ac_name;
1248 1 hiro
1249 1 hiro
        ac_name = g_strdup(cur_account
1250 1 hiro
                           ? (cur_account->account_name
1251 1 hiro
                              ? cur_account->account_name : _("Untitled"))
1252 1 hiro
                           : _("none"));
1253 1 hiro
1254 1 hiro
        if (cur_account)
1255 1 hiro
                buf = g_strdup_printf("%s - %s", ac_name, PROG_VERSION);
1256 1 hiro
        else
1257 1 hiro
                buf = g_strdup(PROG_VERSION);
1258 1 hiro
        gtk_window_set_title(GTK_WINDOW(mainwin->window), buf);
1259 1 hiro
        g_free(buf);
1260 1 hiro
1261 1 hiro
        gtk_label_set_text(GTK_LABEL(mainwin->ac_label), ac_name);
1262 1 hiro
        gtk_widget_queue_resize(mainwin->ac_button);
1263 1 hiro
1264 1 hiro
        g_free(ac_name);
1265 1 hiro
}
1266 1 hiro
1267 1 hiro
MainWindow *main_window_get(void)
1268 1 hiro
{
1269 1 hiro
        return (MainWindow *)mainwin_list->data;
1270 1 hiro
}
1271 1 hiro
1272 1 hiro
GtkWidget *main_window_get_folder_window(MainWindow *mainwin)
1273 1 hiro
{
1274 1 hiro
        switch (mainwin->type) {
1275 1 hiro
        case SEPARATE_FOLDER:
1276 1 hiro
                return mainwin->win.sep_folder.folderwin;
1277 1 hiro
        case SEPARATE_BOTH:
1278 1 hiro
                return mainwin->win.sep_both.folderwin;
1279 1 hiro
        default:
1280 1 hiro
                return NULL;
1281 1 hiro
        }
1282 1 hiro
}
1283 1 hiro
1284 1 hiro
GtkWidget *main_window_get_message_window(MainWindow *mainwin)
1285 1 hiro
{
1286 1 hiro
        switch (mainwin->type) {
1287 1 hiro
        case SEPARATE_MESSAGE:
1288 1 hiro
                return mainwin->win.sep_message.messagewin;
1289 1 hiro
        case SEPARATE_BOTH:
1290 1 hiro
                return mainwin->win.sep_both.messagewin;
1291 1 hiro
        default:
1292 1 hiro
                return NULL;
1293 1 hiro
        }
1294 1 hiro
}
1295 1 hiro
1296 1 hiro
void main_window_separation_change(MainWindow *mainwin, SeparateType type)
1297 1 hiro
{
1298 1 hiro
        GtkWidget *folder_wid  = GTK_WIDGET_PTR(mainwin->folderview);
1299 1 hiro
        GtkWidget *summary_wid = GTK_WIDGET_PTR(mainwin->summaryview);
1300 1 hiro
        GtkWidget *message_wid = GTK_WIDGET_PTR(mainwin->messageview);
1301 1 hiro
1302 1 hiro
        debug_print(_("Changing window separation type from %d to %d\n"),
1303 1 hiro
                    mainwin->type, type);
1304 1 hiro
1305 1 hiro
        if (mainwin->type == type) return;
1306 1 hiro
1307 1 hiro
        /* remove widgets from those containers */
1308 1 hiro
        gtk_widget_ref(folder_wid);
1309 1 hiro
        gtk_widget_ref(summary_wid);
1310 1 hiro
        gtk_widget_ref(message_wid);
1311 1 hiro
        gtkut_container_remove
1312 1 hiro
                (GTK_CONTAINER(folder_wid->parent), folder_wid);
1313 1 hiro
        gtkut_container_remove
1314 1 hiro
                (GTK_CONTAINER(summary_wid->parent), summary_wid);
1315 1 hiro
        gtkut_container_remove
1316 1 hiro
                (GTK_CONTAINER(message_wid->parent), message_wid);
1317 1 hiro
1318 1 hiro
        /* clean containers */
1319 1 hiro
        switch (mainwin->type) {
1320 1 hiro
        case SEPARATE_NONE:
1321 1 hiro
                gtk_widget_destroy(mainwin->win.sep_none.hpaned);
1322 1 hiro
                break;
1323 1 hiro
        case SEPARATE_FOLDER:
1324 1 hiro
                gtk_widget_destroy(mainwin->win.sep_folder.vpaned);
1325 1 hiro
                gtk_widget_destroy(mainwin->win.sep_folder.folderwin);
1326 1 hiro
                break;
1327 1 hiro
        case SEPARATE_MESSAGE:
1328 1 hiro
                gtk_widget_destroy(mainwin->win.sep_message.hpaned);
1329 1 hiro
                gtk_widget_destroy(mainwin->win.sep_message.messagewin);
1330 1 hiro
                break;
1331 1 hiro
        case SEPARATE_BOTH:
1332 1 hiro
                gtk_widget_destroy(mainwin->win.sep_both.messagewin);
1333 1 hiro
                gtk_widget_destroy(mainwin->win.sep_both.folderwin);
1334 1 hiro
                break;
1335 1 hiro
        }
1336 1 hiro
1337 1 hiro
        gtk_widget_hide(mainwin->window);
1338 1 hiro
        main_window_set_widgets(mainwin, type);
1339 1 hiro
        gtk_widget_show(mainwin->window);
1340 1 hiro
1341 1 hiro
        gtk_widget_unref(folder_wid);
1342 1 hiro
        gtk_widget_unref(summary_wid);
1343 1 hiro
        gtk_widget_unref(message_wid);
1344 1 hiro
}
1345 1 hiro
1346 1 hiro
void main_window_toggle_message_view(MainWindow *mainwin)
1347 1 hiro
{
1348 1 hiro
        SummaryView *summaryview = mainwin->summaryview;
1349 1 hiro
        union CompositeWin *cwin = &mainwin->win;
1350 1 hiro
        GtkWidget *vpaned = NULL;
1351 1 hiro
        GtkWidget *container = NULL;
1352 1 hiro
        GtkWidget *msgwin = NULL;
1353 1 hiro
1354 1 hiro
        switch (mainwin->type) {
1355 1 hiro
        case SEPARATE_NONE:
1356 1 hiro
                vpaned = cwin->sep_none.vpaned;
1357 1 hiro
                container = cwin->sep_none.hpaned;
1358 1 hiro
                break;
1359 1 hiro
        case SEPARATE_FOLDER:
1360 1 hiro
                vpaned = cwin->sep_folder.vpaned;
1361 1 hiro
                container = mainwin->vbox_body;
1362 1 hiro
                break;
1363 1 hiro
        case SEPARATE_MESSAGE:
1364 1 hiro
                msgwin = mainwin->win.sep_message.messagewin;
1365 1 hiro
                break;
1366 1 hiro
        case SEPARATE_BOTH:
1367 1 hiro
                msgwin = mainwin->win.sep_both.messagewin;
1368 1 hiro
                break;
1369 1 hiro
        }
1370 1 hiro
1371 1 hiro
        if (msgwin) {
1372 1 hiro
                if (GTK_WIDGET_VISIBLE(msgwin)) {
1373 1 hiro
                        gtk_widget_hide(msgwin);
1374 1 hiro
                        mainwin->messageview->visible = FALSE;
1375 1 hiro
                        summaryview->displayed = NULL;
1376 1 hiro
                } else {
1377 1 hiro
                        gtk_widget_show(msgwin);
1378 1 hiro
                        mainwin->messageview->visible = TRUE;
1379 1 hiro
                }
1380 1 hiro
        } else if (vpaned->parent != NULL) {
1381 1 hiro
                mainwin->messageview->visible = FALSE;
1382 1 hiro
                summaryview->displayed = NULL;
1383 1 hiro
                gtk_widget_ref(vpaned);
1384 1 hiro
                gtkut_container_remove(GTK_CONTAINER(container), vpaned);
1385 1 hiro
                gtk_widget_reparent(GTK_WIDGET_PTR(summaryview), container);
1386 1 hiro
        } else {
1387 1 hiro
                mainwin->messageview->visible = TRUE;
1388 1 hiro
                gtk_widget_reparent(GTK_WIDGET_PTR(summaryview), vpaned);
1389 1 hiro
                gtk_container_add(GTK_CONTAINER(container), vpaned);
1390 1 hiro
                gtk_widget_unref(vpaned);
1391 1 hiro
        }
1392 1 hiro
1393 157 hiro
        if (messageview_is_visible(mainwin->messageview))
1394 157 hiro
                gtk_arrow_set(GTK_ARROW(mainwin->summaryview->toggle_arrow),
1395 157 hiro
                              GTK_ARROW_DOWN, GTK_SHADOW_OUT);
1396 157 hiro
        else
1397 157 hiro
                gtk_arrow_set(GTK_ARROW(mainwin->summaryview->toggle_arrow),
1398 157 hiro
                              GTK_ARROW_UP, GTK_SHADOW_OUT);
1399 157 hiro
1400 1 hiro
        if (mainwin->messageview->visible == FALSE)
1401 1 hiro
                messageview_clear(mainwin->messageview);
1402 1 hiro
1403 1 hiro
        main_window_set_menu_sensitive(mainwin);
1404 1 hiro
1405 1 hiro
        prefs_common.msgview_visible = mainwin->messageview->visible;
1406 1 hiro
1407 237 hiro
        gtk_widget_grab_focus(summaryview->treeview);
1408 1 hiro
}
1409 1 hiro
1410 1 hiro
void main_window_get_size(MainWindow *mainwin)
1411 1 hiro
{
1412 1 hiro
        GtkAllocation *allocation;
1413 1 hiro
1414 1 hiro
        allocation = &(GTK_WIDGET_PTR(mainwin->summaryview)->allocation);
1415 1 hiro
1416 1 hiro
        if (allocation->width > 1 && allocation->height > 1) {
1417 1 hiro
                prefs_common.summaryview_width = allocation->width;
1418 1 hiro
1419 1 hiro
                if ((mainwin->type == SEPARATE_NONE ||
1420 1 hiro
                     mainwin->type == SEPARATE_FOLDER) &&
1421 1 hiro
                    messageview_is_visible(mainwin->messageview))
1422 1 hiro
                        prefs_common.summaryview_height = allocation->height;
1423 1 hiro
1424 1 hiro
                prefs_common.mainview_width = allocation->width;
1425 1 hiro
        }
1426 1 hiro
1427 1 hiro
        allocation = &mainwin->window->allocation;
1428 1 hiro
        if (allocation->width > 1 && allocation->height > 1) {
1429 1 hiro
                prefs_common.mainview_height = allocation->height;
1430 1 hiro
                prefs_common.mainwin_width   = allocation->width;
1431 1 hiro
                prefs_common.mainwin_height  = allocation->height;
1432 1 hiro
        }
1433 1 hiro
1434 1 hiro
        allocation = &(GTK_WIDGET_PTR(mainwin->folderview)->allocation);
1435 1 hiro
        if (allocation->width > 1 && allocation->height > 1) {
1436 1 hiro
                prefs_common.folderview_width  = allocation->width;
1437 1 hiro
                prefs_common.folderview_height = allocation->height;
1438 1 hiro
        }
1439 1 hiro
1440 1 hiro
        allocation = &(GTK_WIDGET_PTR(mainwin->messageview)->allocation);
1441 1 hiro
        if (allocation->width > 1 && allocation->height > 1) {
1442 1 hiro
                prefs_common.msgview_width = allocation->width;
1443 1 hiro
                prefs_common.msgview_height = allocation->height;
1444 1 hiro
        }
1445 1 hiro
1446 1 hiro
#if 0
1447 1 hiro
        debug_print("summaryview size: %d x %d\n",
1448 1 hiro
                    prefs_common.summaryview_width,
1449 1 hiro
                    prefs_common.summaryview_height);
1450 1 hiro
        debug_print("folderview size: %d x %d\n",
1451 1 hiro
                    prefs_common.folderview_width,
1452 1 hiro
                    prefs_common.folderview_height);
1453 1 hiro
        debug_print("messageview size: %d x %d\n",
1454 1 hiro
                    prefs_common.msgview_width,
1455 1 hiro
                    prefs_common.msgview_height);
1456 1 hiro
#endif
1457 1 hiro
}
1458 1 hiro
1459 1 hiro
void main_window_get_position(MainWindow *mainwin)
1460 1 hiro
{
1461 1 hiro
        gint x, y;
1462 1 hiro
        GtkWidget *window;
1463 1 hiro
1464 1 hiro
        gtkut_widget_get_uposition(mainwin->window, &x, &y);
1465 1 hiro
1466 1 hiro
        prefs_common.mainview_x = x;
1467 1 hiro
        prefs_common.mainview_y = y;
1468 1 hiro
        prefs_common.mainwin_x = x;
1469 1 hiro
        prefs_common.mainwin_y = y;
1470 1 hiro
1471 1 hiro
        debug_print("main window position: %d, %d\n", x, y);
1472 1 hiro
1473 1 hiro
        window = main_window_get_folder_window(mainwin);
1474 1 hiro
        if (window) {
1475 1 hiro
                gtkut_widget_get_uposition(window, &x, &y);
1476 1 hiro
                prefs_common.folderwin_x = x;
1477 1 hiro
                prefs_common.folderwin_y = y;
1478 1 hiro
                debug_print("folder window position: %d, %d\n", x, y);
1479 1 hiro
        }
1480 1 hiro
        window = main_window_get_message_window(mainwin);
1481 1 hiro
        if (window) {
1482 1 hiro
                gtkut_widget_get_uposition(window, &x, &y);
1483 1 hiro
                prefs_common.main_msgwin_x = x;
1484 1 hiro
                prefs_common.main_msgwin_y = y;
1485 1 hiro
                debug_print("message window position: %d, %d\n", x, y);
1486 1 hiro
        }
1487 1 hiro
}
1488 1 hiro
1489 1 hiro
void main_window_progress_on(MainWindow *mainwin)
1490 1 hiro
{
1491 1 hiro
        gtk_progress_set_show_text(GTK_PROGRESS(mainwin->progressbar), TRUE);
1492 1 hiro
        gtk_progress_set_format_string(GTK_PROGRESS(mainwin->progressbar), "");
1493 1 hiro
}
1494 1 hiro
1495 1 hiro
void main_window_progress_off(MainWindow *mainwin)
1496 1 hiro
{
1497 1 hiro
        gtk_progress_set_show_text(GTK_PROGRESS(mainwin->progressbar), FALSE);
1498 1 hiro
        gtk_progress_bar_update(GTK_PROGRESS_BAR(mainwin->progressbar), 0.0);
1499 1 hiro
        gtk_progress_set_format_string(GTK_PROGRESS(mainwin->progressbar), "");
1500 1 hiro
}
1501 1 hiro
1502 1 hiro
void main_window_progress_set(MainWindow *mainwin, gint cur, gint total)
1503 1 hiro
{
1504 1 hiro
        gchar buf[32];
1505 1 hiro
1506 1 hiro
        g_snprintf(buf, sizeof(buf), "%d / %d", cur, total);
1507 1 hiro
        gtk_progress_set_format_string(GTK_PROGRESS(mainwin->progressbar), buf);
1508 1 hiro
        gtk_progress_bar_update(GTK_PROGRESS_BAR(mainwin->progressbar),
1509 1 hiro
                                (cur == 0 && total == 0) ? 0 :
1510 1 hiro
                                (gfloat)cur / (gfloat)total);
1511 1 hiro
}
1512 1 hiro
1513 1 hiro
void main_window_toggle_online(MainWindow *mainwin, gboolean online)
1514 1 hiro
{
1515 1 hiro
        if (prefs_common.online_mode != online)
1516 1 hiro
                online_switch_clicked(mainwin->online_switch, mainwin);
1517 1 hiro
}
1518 1 hiro
1519 1 hiro
gboolean main_window_toggle_online_if_offline(MainWindow *mainwin)
1520 1 hiro
{
1521 1 hiro
        if (!prefs_common.online_mode) {
1522 1 hiro
                if (alertpanel(_("Offline"),
1523 1 hiro
                               _("You are offline. Go online?"),
1524 30 hiro
                               GTK_STOCK_YES, GTK_STOCK_NO, NULL)
1525 30 hiro
                    == G_ALERTDEFAULT)
1526 1 hiro
                        main_window_toggle_online(mainwin, TRUE);
1527 1 hiro
        }
1528 1 hiro
1529 1 hiro
        return prefs_common.online_mode;
1530 1 hiro
}
1531 1 hiro
1532 1 hiro
void main_window_empty_trash(MainWindow *mainwin, gboolean confirm)
1533 1 hiro
{
1534 1 hiro
        GList *list;
1535 1 hiro
1536 1 hiro
        if (confirm) {
1537 1 hiro
                if (alertpanel(_("Empty all trash"),
1538 1 hiro
                               _("Empty messages in all trash?"),
1539 30 hiro
                               GTK_STOCK_YES, GTK_STOCK_NO, NULL)
1540 30 hiro
                    != G_ALERTDEFAULT)
1541 1 hiro
                        return;
1542 1 hiro
                manage_window_focus_in(mainwin->window, NULL, NULL);
1543 1 hiro
        }
1544 1 hiro
1545 1 hiro
        procmsg_empty_all_trash();
1546 1 hiro
        statusbar_pop_all();
1547 1 hiro
1548 1 hiro
        for (list = folder_get_list(); list != NULL; list = list->next) {
1549 1 hiro
                Folder *folder;
1550 1 hiro
1551 1 hiro
                folder = list->data;
1552 1 hiro
                if (folder->trash)
1553 1 hiro
                        folderview_update_item(folder->trash, TRUE);
1554 1 hiro
        }
1555 1 hiro
1556 1 hiro
        if (mainwin->summaryview->folder_item &&
1557 1 hiro
            mainwin->summaryview->folder_item->stype == F_TRASH)
1558 202 hiro
                gtk_widget_grab_focus(mainwin->folderview->treeview);
1559 1 hiro
}
1560 1 hiro
1561 1 hiro
void main_window_add_mailbox(MainWindow *mainwin)
1562 1 hiro
{
1563 1 hiro
        gchar *path;
1564 1 hiro
        Folder *folder;
1565 1 hiro
1566 1 hiro
        path = input_dialog(_("Add mailbox"),
1567 1 hiro
                            _("Input the location of mailbox.\n"
1568 1 hiro
                              "If the existing mailbox is specified, it will be\n"
1569 1 hiro
                              "scanned automatically."),
1570 1 hiro
                            "Mail");
1571 1 hiro
        if (!path) return;
1572 1 hiro
        if (folder_find_from_path(path)) {
1573 1 hiro
                alertpanel_error(_("The mailbox `%s' already exists."), path);
1574 1 hiro
                g_free(path);
1575 1 hiro
                return;
1576 1 hiro
        }
1577 1 hiro
        if (!strcmp(path, "Mail"))
1578 1 hiro
                folder = folder_new(F_MH, _("Mailbox"), path);
1579 1 hiro
        else
1580 1 hiro
                folder = folder_new(F_MH, g_basename(path), path);
1581 1 hiro
        g_free(path);
1582 1 hiro
1583 1 hiro
        if (folder->klass->create_tree(folder) < 0) {
1584 1 hiro
                alertpanel_error(_("Creation of the mailbox failed.\n"
1585 1 hiro
                                   "Maybe some files already exist, or you don't have the permission to write there."));
1586 1 hiro
                folder_destroy(folder);
1587 1 hiro
                return;
1588 1 hiro
        }
1589 1 hiro
1590 1 hiro
        folder_add(folder);
1591 1 hiro
        folder_set_ui_func(folder, scan_tree_func, mainwin);
1592 1 hiro
        folder->klass->scan_tree(folder);
1593 1 hiro
        folder_set_ui_func(folder, NULL, NULL);
1594 1 hiro
1595 1 hiro
        folderview_set(mainwin->folderview);
1596 1 hiro
}
1597 1 hiro
1598 1 hiro
typedef enum
1599 1 hiro
{
1600 1 hiro
        M_UNLOCKED            = 1 << 0,
1601 1 hiro
        M_MSG_EXIST           = 1 << 1,
1602 1 hiro
        M_TARGET_EXIST        = 1 << 2,
1603 1 hiro
        M_SINGLE_TARGET_EXIST = 1 << 3,
1604 1 hiro
        M_EXEC                = 1 << 4,
1605 1 hiro
        M_ALLOW_REEDIT        = 1 << 5,
1606 1 hiro
        M_HAVE_ACCOUNT        = 1 << 6,
1607 1 hiro
        M_THREADED              = 1 << 7,
1608 1 hiro
        M_UNTHREADED              = 1 << 8,
1609 1 hiro
        M_ALLOW_DELETE              = 1 << 9,
1610 1 hiro
        M_INC_ACTIVE              = 1 << 10,
1611 306 hiro
        M_ENABLE_JUNK              = 1 << 11,
1612 1 hiro
1613 306 hiro
        M_FOLDER_NEWOK              = 1 << 17,
1614 306 hiro
        M_FOLDER_RENOK              = 1 << 18,
1615 389 hiro
        M_FOLDER_MOVEOK              = 1 << 19,
1616 389 hiro
        M_FOLDER_DELOK              = 1 << 20,
1617 389 hiro
        M_MBOX_ADDOK              = 1 << 21,
1618 389 hiro
        M_MBOX_RMOK              = 1 << 22,
1619 389 hiro
        M_MBOX_CHKOK              = 1 << 23,
1620 389 hiro
        M_MBOX_CHKALLOK              = 1 << 24,
1621 389 hiro
        M_MBOX_REBUILDOK      = 1 << 25
1622 1 hiro
} SensitiveCond;
1623 1 hiro
1624 1 hiro
static SensitiveCond main_window_get_current_state(MainWindow *mainwin)
1625 1 hiro
{
1626 1 hiro
        SensitiveCond state = 0;
1627 1 hiro
        SummarySelection selection;
1628 1 hiro
        FolderItem *item = mainwin->summaryview->folder_item;
1629 1 hiro
1630 1 hiro
        selection = summary_get_selection_type(mainwin->summaryview);
1631 1 hiro
1632 1 hiro
        if (mainwin->lock_count == 0)
1633 1 hiro
                state |= M_UNLOCKED;
1634 1 hiro
        if (selection != SUMMARY_NONE)
1635 1 hiro
                state |= M_MSG_EXIST;
1636 1 hiro
        if (item && item->path && item->parent && !item->no_select) {
1637 1 hiro
                state |= M_EXEC;
1638 1 hiro
                if (item->threaded)
1639 1 hiro
                        state |= M_THREADED;
1640 1 hiro
                else
1641 1 hiro
                        state |= M_UNTHREADED;
1642 1 hiro
                if (FOLDER_TYPE(item->folder) != F_NEWS)
1643 1 hiro
                        state |= M_ALLOW_DELETE;
1644 1 hiro
        }
1645 1 hiro
        if (selection == SUMMARY_SELECTED_SINGLE ||
1646 1 hiro
            selection == SUMMARY_SELECTED_MULTIPLE)
1647 1 hiro
                state |= M_TARGET_EXIST;
1648 1 hiro
        if (selection == SUMMARY_SELECTED_SINGLE)
1649 1 hiro
                state |= M_SINGLE_TARGET_EXIST;
1650 1 hiro
        if (selection == SUMMARY_SELECTED_SINGLE &&
1651 1 hiro
            (item &&
1652 1 hiro
             (item->stype == F_OUTBOX || item->stype == F_DRAFT ||
1653 1 hiro
              item->stype == F_QUEUE)))
1654 1 hiro
                state |= M_ALLOW_REEDIT;
1655 1 hiro
        if (cur_account)
1656 1 hiro
                state |= M_HAVE_ACCOUNT;
1657 1 hiro
1658 1 hiro
        if (inc_is_active())
1659 1 hiro
                state |= M_INC_ACTIVE;
1660 1 hiro
1661 306 hiro
        if (prefs_common.enable_junk)
1662 306 hiro
                state |= M_ENABLE_JUNK;
1663 306 hiro
1664 1 hiro
        item = folderview_get_selected_item(mainwin->folderview);
1665 1 hiro
        if (item) {
1666 1 hiro
                state |= M_FOLDER_NEWOK;
1667 1 hiro
                if (item->parent == NULL) {
1668 1 hiro
                        state |= M_MBOX_RMOK;
1669 1 hiro
                        state |= M_MBOX_CHKOK;
1670 1 hiro
                }
1671 1 hiro
                if (FOLDER_IS_LOCAL(item->folder) ||
1672 1 hiro
                    FOLDER_TYPE(item->folder) == F_IMAP) {
1673 1 hiro
                        if (item->parent == NULL)
1674 1 hiro
                                state |= M_MBOX_REBUILDOK;
1675 1 hiro
                        else if (item->stype == F_NORMAL) {
1676 1 hiro
                                state |= M_FOLDER_RENOK;
1677 1 hiro
                                state |= M_FOLDER_DELOK;
1678 389 hiro
                                if (item->folder->klass->move_folder)
1679 389 hiro
                                        state |= M_FOLDER_MOVEOK;
1680 1 hiro
                        }
1681 1 hiro
                } else if (FOLDER_TYPE(item->folder) == F_NEWS) {
1682 1 hiro
                        if (item->parent != NULL)
1683 1 hiro
                                state |= M_FOLDER_DELOK;
1684 1 hiro
                }
1685 1 hiro
        }
1686 1 hiro
        state |= M_MBOX_ADDOK;
1687 1 hiro
        state |= M_MBOX_CHKALLOK;
1688 1 hiro
1689 1 hiro
        return state;
1690 1 hiro
}
1691 1 hiro
1692 1 hiro
void main_window_set_toolbar_sensitive(MainWindow *mainwin)
1693 1 hiro
{
1694 1 hiro
        SensitiveCond state;
1695 1 hiro
        gboolean sensitive;
1696 1 hiro
        gint i = 0;
1697 1 hiro
1698 1 hiro
        struct {
1699 1 hiro
                GtkWidget *widget;
1700 1 hiro
                SensitiveCond cond;
1701 306 hiro
        } entry[13];
1702 1 hiro
1703 1 hiro
#define SET_WIDGET_COND(w, c)        \
1704 1 hiro
{                                \
1705 1 hiro
        entry[i].widget = w;        \
1706 1 hiro
        entry[i].cond = c;        \
1707 1 hiro
        i++;                        \
1708 1 hiro
}
1709 1 hiro
1710 1 hiro
        SET_WIDGET_COND(mainwin->get_btn, M_HAVE_ACCOUNT|M_UNLOCKED);
1711 1 hiro
        SET_WIDGET_COND(mainwin->getall_btn, M_HAVE_ACCOUNT|M_UNLOCKED);
1712 1 hiro
        SET_WIDGET_COND(mainwin->compose_btn, M_HAVE_ACCOUNT);
1713 1 hiro
        SET_WIDGET_COND(mainwin->reply_btn,
1714 1 hiro
                        M_HAVE_ACCOUNT|M_SINGLE_TARGET_EXIST);
1715 1 hiro
        SET_WIDGET_COND(GTK_WIDGET_PTR(mainwin->reply_combo),
1716 1 hiro
                        M_HAVE_ACCOUNT|M_SINGLE_TARGET_EXIST);
1717 1 hiro
        SET_WIDGET_COND(mainwin->replyall_btn,
1718 1 hiro
                        M_HAVE_ACCOUNT|M_SINGLE_TARGET_EXIST);
1719 1 hiro
        SET_WIDGET_COND(mainwin->fwd_btn, M_HAVE_ACCOUNT|M_TARGET_EXIST);
1720 1 hiro
        SET_WIDGET_COND(GTK_WIDGET_PTR(mainwin->fwd_combo),
1721 1 hiro
                        M_HAVE_ACCOUNT|M_TARGET_EXIST);
1722 1 hiro
#if 0
1723 1 hiro
        SET_WIDGET_COND(mainwin->prefs_btn, M_UNLOCKED);
1724 1 hiro
        SET_WIDGET_COND(mainwin->account_btn, M_UNLOCKED);
1725 1 hiro
#endif
1726 1 hiro
        SET_WIDGET_COND(mainwin->next_btn, M_MSG_EXIST);
1727 1 hiro
        SET_WIDGET_COND(mainwin->delete_btn,
1728 1 hiro
                        M_TARGET_EXIST|M_ALLOW_DELETE);
1729 306 hiro
        SET_WIDGET_COND(mainwin->junk_btn,
1730 306 hiro
                        M_TARGET_EXIST|M_ALLOW_DELETE|M_ENABLE_JUNK);
1731 1 hiro
        SET_WIDGET_COND(mainwin->exec_btn, M_MSG_EXIST|M_EXEC);
1732 1 hiro
        SET_WIDGET_COND(NULL, 0);
1733 1 hiro
1734 1 hiro
#undef SET_WIDGET_COND
1735 1 hiro
1736 1 hiro
        state = main_window_get_current_state(mainwin);
1737 1 hiro
1738 1 hiro
        for (i = 0; entry[i].widget != NULL; i++) {
1739 1 hiro
                sensitive = ((entry[i].cond & state) == entry[i].cond);
1740 1 hiro
                gtk_widget_set_sensitive(entry[i].widget, sensitive);
1741 1 hiro
        }
1742 1 hiro
}
1743 1 hiro
1744 1 hiro
void main_window_set_menu_sensitive(MainWindow *mainwin)
1745 1 hiro
{
1746 1 hiro
        GtkItemFactory *ifactory = mainwin->menu_factory;
1747 1 hiro
        SensitiveCond state;
1748 1 hiro
        gboolean sensitive;
1749 1 hiro
        GtkWidget *menu;
1750 1 hiro
        GtkWidget *menuitem;
1751 1 hiro
        FolderItem *item;
1752 1 hiro
        gchar *menu_path;
1753 1 hiro
        gint i;
1754 1 hiro
        GList *cur_item;
1755 1 hiro
1756 1 hiro
        static const struct {
1757 1 hiro
                gchar *const entry;
1758 1 hiro
                SensitiveCond cond;
1759 1 hiro
        } entry[] = {
1760 1 hiro
                {"/File/Folder/Create new folder...", M_UNLOCKED|M_FOLDER_NEWOK},
1761 1 hiro
                {"/File/Folder/Rename folder..."    , M_UNLOCKED|M_FOLDER_RENOK},
1762 389 hiro
                {"/File/Folder/Move folder..."      , M_UNLOCKED|M_FOLDER_MOVEOK},
1763 1 hiro
                {"/File/Folder/Delete folder"       , M_UNLOCKED|M_FOLDER_DELOK},
1764 1 hiro
                {"/File/Mailbox/Add mailbox..."     , M_UNLOCKED|M_MBOX_ADDOK},
1765 1 hiro
                {"/File/Mailbox/Remove mailbox"     , M_UNLOCKED|M_MBOX_RMOK},
1766 1 hiro
                {"/File/Mailbox/Check for new messages"
1767 1 hiro
                                                    , M_UNLOCKED|M_MBOX_CHKOK},
1768 1 hiro
                {"/File/Mailbox/Check for new messages in all mailboxes"
1769 1 hiro
                                                    , M_UNLOCKED|M_MBOX_CHKALLOK},
1770 1 hiro
                {"/File/Mailbox/Rebuild folder tree", M_UNLOCKED|M_MBOX_REBUILDOK},
1771 1 hiro
                {"/File/Import mbox file..."        , M_UNLOCKED},
1772 1 hiro
                {"/File/Export to mbox file..."     , M_UNLOCKED},
1773 1 hiro
                {"/File/Empty all trash"            , M_UNLOCKED},
1774 1 hiro
1775 1 hiro
                {"/File/Save as..."  , M_SINGLE_TARGET_EXIST},
1776 1 hiro
                {"/File/Print..."    , M_TARGET_EXIST},
1777 1 hiro
                {"/File/Work offline", M_UNLOCKED},
1778 1 hiro
                /* {"/File/Close"    , M_UNLOCKED}, */
1779 1 hiro
                {"/File/Exit"        , M_UNLOCKED},
1780 1 hiro
1781 1 hiro
                {"/Edit/Select thread"             , M_SINGLE_TARGET_EXIST},
1782 1 hiro
1783 1 hiro
                {"/View/Sort"                      , M_EXEC},
1784 1 hiro
                {"/View/Thread view"               , M_EXEC},
1785 1 hiro
                {"/View/Expand all threads"        , M_MSG_EXIST},
1786 1 hiro
                {"/View/Collapse all threads"      , M_MSG_EXIST},
1787 1 hiro
                {"/View/Go to/Prev message"        , M_MSG_EXIST},
1788 1 hiro
                {"/View/Go to/Next message"        , M_MSG_EXIST},
1789 1 hiro
                {"/View/Go to/Prev unread message" , M_MSG_EXIST},
1790 1 hiro
                {"/View/Go to/Next unread message" , M_MSG_EXIST},
1791 1 hiro
                {"/View/Go to/Prev new message"    , M_MSG_EXIST},
1792 1 hiro
                {"/View/Go to/Next new message"    , M_MSG_EXIST},
1793 1 hiro
                {"/View/Go to/Prev marked message" , M_MSG_EXIST},
1794 1 hiro
                {"/View/Go to/Next marked message" , M_MSG_EXIST},
1795 1 hiro
                {"/View/Go to/Prev labeled message", M_MSG_EXIST},
1796 1 hiro
                {"/View/Go to/Next labeled message", M_MSG_EXIST},
1797 1 hiro
                {"/View/Open in new window"        , M_SINGLE_TARGET_EXIST},
1798 1 hiro
                {"/View/Show all header"           , M_SINGLE_TARGET_EXIST},
1799 1 hiro
                {"/View/Message source"            , M_SINGLE_TARGET_EXIST},
1800 1 hiro
1801 1 hiro
                {"/Message/Receive/Get from current account"
1802 1 hiro
                                                 , M_HAVE_ACCOUNT|M_UNLOCKED},
1803 1 hiro
                {"/Message/Receive/Get from all accounts"
1804 1 hiro
                                                 , M_HAVE_ACCOUNT|M_UNLOCKED},
1805 1 hiro
                {"/Message/Receive/Cancel receiving"
1806 1 hiro
                                                 , M_INC_ACTIVE},
1807 1 hiro
1808 1 hiro
                {"/Message/Compose new message"  , M_HAVE_ACCOUNT},
1809 1 hiro
                {"/Message/Reply"                , M_HAVE_ACCOUNT|M_SINGLE_TARGET_EXIST},
1810 1 hiro
                {"/Message/Reply to"             , M_HAVE_ACCOUNT|M_SINGLE_TARGET_EXIST},
1811 1 hiro
                {"/Message/Forward"              , M_HAVE_ACCOUNT|M_TARGET_EXIST},
1812 1 hiro
                {"/Message/Forward as attachment", M_HAVE_ACCOUNT|M_TARGET_EXIST},
1813 1 hiro
                {"/Message/Redirect"             , M_HAVE_ACCOUNT|M_SINGLE_TARGET_EXIST},
1814 1 hiro
                {"/Message/Move..."              , M_TARGET_EXIST|M_ALLOW_DELETE},
1815 1 hiro
                {"/Message/Copy..."              , M_TARGET_EXIST|M_EXEC},
1816 1 hiro
                {"/Message/Delete"               , M_TARGET_EXIST|M_ALLOW_DELETE},
1817 1 hiro
                {"/Message/Mark"                 , M_TARGET_EXIST},
1818 306 hiro
                {"/Message/Set as junk mail"     , M_TARGET_EXIST|M_ALLOW_DELETE|M_ENABLE_JUNK},
1819 306 hiro
                {"/Message/Set as not junk mail" , M_TARGET_EXIST|M_ALLOW_DELETE|M_ENABLE_JUNK},
1820 1 hiro
                {"/Message/Re-edit"              , M_HAVE_ACCOUNT|M_ALLOW_REEDIT},
1821 1 hiro
1822 352 hiro
                {"/Tools/Add sender to address book...", M_SINGLE_TARGET_EXIST},
1823 1 hiro
                {"/Tools/Filter all messages in folder", M_MSG_EXIST|M_EXEC},
1824 1 hiro
                {"/Tools/Filter selected messages"     , M_TARGET_EXIST|M_EXEC},
1825 1 hiro
                {"/Tools/Create filter rule"           , M_SINGLE_TARGET_EXIST|M_UNLOCKED},
1826 344 hiro
                {"/Tools/Filter junk mails in folder"  , M_MSG_EXIST|M_EXEC|M_ENABLE_JUNK},
1827 344 hiro
                {"/Tools/Filter junk mails in selected messages", M_TARGET_EXIST|M_EXEC|M_ENABLE_JUNK},
1828 1 hiro
                {"/Tools/Actions"                      , M_TARGET_EXIST|M_UNLOCKED},
1829 1 hiro
                {"/Tools/Execute"                      , M_MSG_EXIST|M_EXEC},
1830 1 hiro
                {"/Tools/Delete duplicated messages"   , M_MSG_EXIST|M_ALLOW_DELETE},
1831 1 hiro
1832 1 hiro
                {"/Configuration", M_UNLOCKED},
1833 1 hiro
1834 1 hiro
                {NULL, 0}
1835 1 hiro
        };
1836 1 hiro
1837 1 hiro
        state = main_window_get_current_state(mainwin);
1838 1 hiro
1839 1 hiro
        for (i = 0; entry[i].entry != NULL; i++) {
1840 1 hiro
                sensitive = ((entry[i].cond & state) == entry[i].cond);
1841 1 hiro
                menu_set_sensitive(ifactory, entry[i].entry, sensitive);
1842 1 hiro
        }
1843 1 hiro
1844 1 hiro
        menu = gtk_item_factory_get_widget(ifactory, "/Message/Receive");
1845 1 hiro
1846 1 hiro
        /* search for separator */
1847 1 hiro
        for (cur_item = GTK_MENU_SHELL(menu)->children; cur_item != NULL;
1848 1 hiro
             cur_item = cur_item->next) {
1849 1 hiro
                if (GTK_BIN(cur_item->data)->child == NULL) {
1850 1 hiro
                        cur_item = cur_item->next;
1851 1 hiro
                        break;
1852 1 hiro
                }
1853 1 hiro
        }
1854 1 hiro
1855 1 hiro
        for (; cur_item != NULL; cur_item = cur_item->next) {
1856 1 hiro
                gtk_widget_set_sensitive(GTK_WIDGET(cur_item->data),
1857 1 hiro
                                         (M_UNLOCKED & state) != 0);
1858 1 hiro
        }
1859 1 hiro
1860 1 hiro
        main_window_menu_callback_block(mainwin);
1861 1 hiro
1862 1 hiro
#define SET_CHECK_MENU_ACTIVE(path, active) \
1863 1 hiro
{ \
1864 1 hiro
        menuitem = gtk_item_factory_get_widget(ifactory, path); \
1865 1 hiro
        gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), active); \
1866 1 hiro
}
1867 1 hiro
1868 1 hiro
        SET_CHECK_MENU_ACTIVE("/View/Show or hide/Message view",
1869 1 hiro
                              messageview_is_visible(mainwin->messageview));
1870 1 hiro
1871 1 hiro
        item = mainwin->summaryview->folder_item;
1872 1 hiro
        menu_path = "/View/Sort/Don't sort";
1873 1 hiro
        if (item) {
1874 1 hiro
                switch (item->sort_key) {
1875 1 hiro
                case SORT_BY_NUMBER:
1876 1 hiro
                        menu_path = "/View/Sort/by number"; break;
1877 1 hiro
                case SORT_BY_SIZE:
1878 1 hiro
                        menu_path = "/View/Sort/by size"; break;
1879 1 hiro
                case SORT_BY_DATE:
1880 1 hiro
                        menu_path = "/View/Sort/by date"; break;
1881 1 hiro
                case SORT_BY_FROM:
1882 1 hiro
                        menu_path = "/View/Sort/by from"; break;
1883 1 hiro
                case SORT_BY_TO:
1884 1 hiro
                        menu_path = "/View/Sort/by recipient"; break;
1885 1 hiro
                case SORT_BY_SUBJECT:
1886 1 hiro
                        menu_path = "/View/Sort/by subject"; break;
1887 1 hiro
                case SORT_BY_LABEL:
1888 1 hiro
                        menu_path = "/View/Sort/by color label"; break;
1889 1 hiro
                case SORT_BY_MARK:
1890 1 hiro
                        menu_path = "/View/Sort/by mark"; break;
1891 1 hiro
                case SORT_BY_UNREAD:
1892 1 hiro
                        menu_path = "/View/Sort/by unread"; break;
1893 1 hiro
                case SORT_BY_MIME:
1894 1 hiro
                        menu_path = "/View/Sort/by attachment"; break;
1895 1 hiro
                case SORT_BY_NONE:
1896 1 hiro
                default:
1897 1 hiro
                        menu_path = "/View/Sort/Don't sort"; break;
1898 1 hiro
                }
1899 1 hiro
        }
1900 1 hiro
        SET_CHECK_MENU_ACTIVE(menu_path, TRUE);
1901 1 hiro
1902 1 hiro
        if (!item || item->sort_type == SORT_ASCENDING) {
1903 1 hiro
                SET_CHECK_MENU_ACTIVE("/View/Sort/Ascending", TRUE);
1904 1 hiro
        } else {
1905 1 hiro
                SET_CHECK_MENU_ACTIVE("/View/Sort/Descending", TRUE);
1906 1 hiro
        }
1907 1 hiro
1908 1 hiro
        if (item && item->sort_key != SORT_BY_NONE) {
1909 1 hiro
                menu_set_sensitive(ifactory, "/View/Sort/Ascending", TRUE);
1910 1 hiro
                menu_set_sensitive(ifactory, "/View/Sort/Descending", TRUE);
1911 248 hiro
                menu_set_sensitive(ifactory, "/View/Sort/Attract by subject",
1912 248 hiro
                                   FALSE);
1913 1 hiro
        } else {
1914 1 hiro
                menu_set_sensitive(ifactory, "/View/Sort/Ascending", FALSE);
1915 1 hiro
                menu_set_sensitive(ifactory, "/View/Sort/Descending", FALSE);
1916 248 hiro
                menu_set_sensitive(ifactory, "/View/Sort/Attract by subject",
1917 248 hiro
                                   (item != NULL));
1918 1 hiro
        }
1919 1 hiro
1920 1 hiro
        SET_CHECK_MENU_ACTIVE("/View/Show all header",
1921 1 hiro
                              mainwin->messageview->textview->show_all_headers);
1922 1 hiro
        SET_CHECK_MENU_ACTIVE("/View/Thread view", (state & M_THREADED) != 0);
1923 1 hiro
1924 1 hiro
#undef SET_CHECK_MENU_ACTIVE
1925 1 hiro
1926 1 hiro
        main_window_menu_callback_unblock(mainwin);
1927 1 hiro
}
1928 1 hiro
1929 1 hiro
void main_window_popup(MainWindow *mainwin)
1930 1 hiro
{
1931 1 hiro
        gtkut_window_popup(mainwin->window);
1932 1 hiro
1933 1 hiro
        switch (mainwin->type) {
1934 1 hiro
        case SEPARATE_FOLDER:
1935 1 hiro
                gtkut_window_popup(mainwin->win.sep_folder.folderwin);
1936 1 hiro
                break;
1937 1 hiro
        case SEPARATE_MESSAGE:
1938 1 hiro
                gtkut_window_popup(mainwin->win.sep_message.messagewin);
1939 1 hiro
                break;
1940 1 hiro
        case SEPARATE_BOTH:
1941 1 hiro
                gtkut_window_popup(mainwin->win.sep_both.folderwin);
1942 1 hiro
                gtkut_window_popup(mainwin->win.sep_both.messagewin);
1943 1 hiro
                break;
1944 1 hiro
        default:
1945 1 hiro
                break;
1946 1 hiro
        }
1947 1 hiro
}
1948 1 hiro
1949 1 hiro
static void main_window_set_widgets(MainWindow *mainwin, SeparateType type)
1950 1 hiro
{
1951 1 hiro
        GtkWidget *folderwin = NULL;
1952 1 hiro
        GtkWidget *messagewin = NULL;
1953 1 hiro
        GtkWidget *hpaned;
1954 1 hiro
        GtkWidget *vpaned;
1955 1 hiro
        GtkWidget *vbox_body = mainwin->vbox_body;
1956 1 hiro
        GtkItemFactory *ifactory = mainwin->menu_factory;
1957 1 hiro
        GtkWidget *menuitem;
1958 1 hiro
1959 1 hiro
        debug_print("Setting widgets... ");
1960 1 hiro
1961 161 hiro
        gtk_widget_set_size_request(GTK_WIDGET_PTR(mainwin->folderview),
1962 161 hiro
                                    prefs_common.folderview_width,
1963 161 hiro
                                    prefs_common.folderview_height);
1964 161 hiro
        gtk_widget_set_size_request(GTK_WIDGET_PTR(mainwin->summaryview),
1965 161 hiro
                                    prefs_common.summaryview_width,
1966 161 hiro
                                    prefs_common.summaryview_height);
1967 161 hiro
        gtk_widget_set_size_request(GTK_WIDGET_PTR(mainwin->messageview),
1968 161 hiro
                                    prefs_common.msgview_width,
1969 161 hiro
                                    prefs_common.msgview_height);
1970 161 hiro
1971 1 hiro
        /* create separated window(s) if needed */
1972 1 hiro
        if (type & SEPARATE_FOLDER) {
1973 1 hiro
                folderwin = gtk_window_new(GTK_WINDOW_TOPLEVEL);
1974 1 hiro
                gtk_window_set_title(GTK_WINDOW(folderwin),
1975 1 hiro
                                     _("Sylpheed - Folder View"));
1976 1 hiro
                gtk_window_set_wmclass(GTK_WINDOW(folderwin),
1977 1 hiro
                                       "folder_view", "Sylpheed");
1978 1 hiro
                gtk_window_set_policy(GTK_WINDOW(folderwin),
1979 1 hiro
                                      TRUE, TRUE, FALSE);
1980 1 hiro
                gtk_widget_set_uposition(folderwin, prefs_common.folderwin_x,
1981 1 hiro
                                         prefs_common.folderwin_y);
1982 1 hiro
                gtk_container_set_border_width(GTK_CONTAINER(folderwin),
1983 1 hiro
                                               BORDER_WIDTH);
1984 1 hiro
                g_signal_connect(G_OBJECT(folderwin), "delete_event",
1985 1 hiro
                                 G_CALLBACK(folder_window_close_cb), mainwin);
1986 1 hiro
                gtk_container_add(GTK_CONTAINER(folderwin),
1987 1 hiro
                                  GTK_WIDGET_PTR(mainwin->folderview));
1988 1 hiro
                gtk_widget_realize(folderwin);
1989 1 hiro
                if (prefs_common.folderview_visible)
1990 1 hiro
                        gtk_widget_show(folderwin);
1991 1 hiro
        }
1992 1 hiro
        if (type & SEPARATE_MESSAGE) {
1993 1 hiro
                messagewin = gtk_window_new(GTK_WINDOW_TOPLEVEL);
1994 1 hiro
                gtk_window_set_title(GTK_WINDOW(messagewin),
1995 1 hiro
                                     _("Sylpheed - Message View"));
1996 1 hiro
                gtk_window_set_wmclass(GTK_WINDOW(messagewin),
1997 1 hiro
                                       "message_view", "Sylpheed");
1998 1 hiro
                gtk_window_set_policy(GTK_WINDOW(messagewin),
1999 1 hiro
                                      TRUE, TRUE, FALSE);
2000 1 hiro
                gtk_widget_set_uposition(messagewin, prefs_common.main_msgwin_x,
2001 1 hiro
                                         prefs_common.main_msgwin_y);
2002 1 hiro
                gtk_container_set_border_width(GTK_CONTAINER(messagewin),
2003 1 hiro
                                               BORDER_WIDTH);
2004 1 hiro
                g_signal_connect(G_OBJECT(messagewin), "delete_event",
2005 1 hiro
                                 G_CALLBACK(message_window_close_cb), mainwin);
2006 1 hiro
                gtk_container_add(GTK_CONTAINER(messagewin),
2007 1 hiro
                                  GTK_WIDGET_PTR(mainwin->messageview));
2008 1 hiro
                gtk_widget_realize(messagewin);
2009 1 hiro
                if (messageview_is_visible(mainwin->messageview))
2010 1 hiro
                        gtk_widget_show(messagewin);
2011 1 hiro
        }
2012 1 hiro
2013 1 hiro
        switch (type) {
2014 1 hiro
        case SEPARATE_NONE:
2015 1 hiro
                hpaned = gtk_hpaned_new();
2016 1 hiro
                gtk_box_pack_start(GTK_BOX(vbox_body), hpaned, TRUE, TRUE, 0);
2017 1 hiro
                gtk_paned_add1(GTK_PANED(hpaned),
2018 1 hiro
                               GTK_WIDGET_PTR(mainwin->folderview));
2019 1 hiro
                gtk_widget_show(hpaned);
2020 1 hiro
                gtk_widget_queue_resize(hpaned);
2021 1 hiro
2022 1 hiro
                vpaned = gtk_vpaned_new();
2023 1 hiro
                if (messageview_is_visible(mainwin->messageview)) {
2024 1 hiro
                        gtk_paned_add2(GTK_PANED(hpaned), vpaned);
2025 1 hiro
                        gtk_paned_add1(GTK_PANED(vpaned),
2026 1 hiro
                                       GTK_WIDGET_PTR(mainwin->summaryview));
2027 1 hiro
                } else {
2028 1 hiro
                        gtk_paned_add2(GTK_PANED(hpaned),
2029 1 hiro
                                       GTK_WIDGET_PTR(mainwin->summaryview));
2030 1 hiro
                        gtk_widget_ref(vpaned);
2031 1 hiro
                }
2032 1 hiro
                gtk_paned_add2(GTK_PANED(vpaned),
2033 1 hiro
                               GTK_WIDGET_PTR(mainwin->messageview));
2034 1 hiro
                gtk_widget_show(vpaned);
2035 1 hiro
                gtk_widget_queue_resize(vpaned);
2036 1 hiro
2037 1 hiro
                mainwin->win.sep_none.hpaned = hpaned;
2038 1 hiro
                mainwin->win.sep_none.vpaned = vpaned;
2039 1 hiro
                break;
2040 1 hiro
        case SEPARATE_FOLDER:
2041 1 hiro
                vpaned = gtk_vpaned_new();
2042 1 hiro
                if (messageview_is_visible(mainwin->messageview)) {
2043 1 hiro
                        gtk_box_pack_start(GTK_BOX(vbox_body), vpaned,
2044 1 hiro
                                           TRUE, TRUE, 0);
2045 1 hiro
                        gtk_paned_add1(GTK_PANED(vpaned),
2046 1 hiro
                                       GTK_WIDGET_PTR(mainwin->summaryview));
2047 1 hiro
                } else {
2048 1 hiro
                        gtk_box_pack_start(GTK_BOX(vbox_body),
2049 1 hiro
                                           GTK_WIDGET_PTR(mainwin->summaryview),
2050 1 hiro
                                           TRUE, TRUE, 0);
2051 1 hiro
                        gtk_widget_ref(vpaned);
2052 1 hiro
                }
2053 1 hiro
                gtk_paned_add2(GTK_PANED(vpaned),
2054 1 hiro
                               GTK_WIDGET_PTR(mainwin->messageview));
2055 1 hiro
                gtk_widget_show(vpaned);
2056 1 hiro
                gtk_widget_queue_resize(vpaned);
2057 1 hiro
2058 1 hiro
                mainwin->win.sep_folder.folderwin = folderwin;
2059 1 hiro
                mainwin->win.sep_folder.vpaned    = vpaned;
2060 1 hiro
2061 1 hiro
                break;
2062 1 hiro
        case SEPARATE_MESSAGE:
2063 1 hiro
                hpaned = gtk_hpaned_new();
2064 1 hiro
                gtk_box_pack_start(GTK_BOX(vbox_body), hpaned, TRUE, TRUE, 0);
2065 1 hiro
                gtk_paned_add1(GTK_PANED(hpaned),
2066 1 hiro
                               GTK_WIDGET_PTR(mainwin->folderview));
2067 1 hiro
                gtk_paned_add2(GTK_PANED(hpaned),
2068 1 hiro
                               GTK_WIDGET_PTR(mainwin->summaryview));
2069 1 hiro
                gtk_widget_show(hpaned);
2070 1 hiro
                gtk_widget_queue_resize(hpaned);
2071 1 hiro
2072 1 hiro
                mainwin->win.sep_message.messagewin = messagewin;
2073 1 hiro
                mainwin->win.sep_message.hpaned     = hpaned;
2074 1 hiro
2075 1 hiro
                break;
2076 1 hiro
        case SEPARATE_BOTH:
2077 1 hiro
                gtk_box_pack_start(GTK_BOX(vbox_body),
2078 1 hiro
                                   GTK_WIDGET_PTR(mainwin->summaryview),
2079 1 hiro
                                   TRUE, TRUE, 0);
2080 1 hiro
2081 1 hiro
                mainwin->win.sep_both.folderwin = folderwin;
2082 1 hiro
                mainwin->win.sep_both.messagewin = messagewin;
2083 1 hiro
2084 1 hiro
                break;
2085 1 hiro
        }
2086 1 hiro
2087 157 hiro
        if (messageview_is_visible(mainwin->messageview))
2088 157 hiro
                gtk_arrow_set(GTK_ARROW(mainwin->summaryview->toggle_arrow),
2089 157 hiro
                              GTK_ARROW_DOWN, GTK_SHADOW_OUT);
2090 157 hiro
        else
2091 157 hiro
                gtk_arrow_set(GTK_ARROW(mainwin->summaryview->toggle_arrow),
2092 157 hiro
                              GTK_ARROW_UP, GTK_SHADOW_OUT);
2093 157 hiro
2094 1 hiro
        gtk_widget_set_uposition(mainwin->window,
2095 1 hiro
                                 prefs_common.mainwin_x,
2096 1 hiro
                                 prefs_common.mainwin_y);
2097 1 hiro
2098 1 hiro
        gtk_widget_queue_resize(vbox_body);
2099 1 hiro
        gtk_widget_queue_resize(mainwin->vbox);
2100 1 hiro
        gtk_widget_queue_resize(mainwin->window);
2101 1 hiro
2102 1 hiro
        mainwin->type = type;
2103 1 hiro
2104 1 hiro
        /* toggle menu state */
2105 1 hiro
        menuitem = gtk_item_factory_get_item
2106 1 hiro
                (ifactory, "/View/Show or hide/Folder tree");
2107 1 hiro
        gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem),
2108 1 hiro
                                       (type & SEPARATE_FOLDER) == 0 ? TRUE :
2109 1 hiro
                                       prefs_common.folderview_visible);
2110 1 hiro
        gtk_widget_set_sensitive(menuitem, ((type & SEPARATE_FOLDER) != 0));
2111 1 hiro
        menuitem = gtk_item_factory_get_item
2112 1 hiro
                (ifactory, "/View/Show or hide/Message view");
2113 157 hiro
        gtk_check_menu_item_set_active
2114 157 hiro
                (GTK_CHECK_MENU_ITEM(menuitem),
2115 157 hiro
                 messageview_is_visible(mainwin->messageview));
2116 1 hiro
2117 1 hiro
        menuitem = gtk_item_factory_get_item
2118 1 hiro
                (ifactory, "/View/Separate folder tree");
2119 1 hiro
        gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem),
2120 1 hiro
                                       ((type & SEPARATE_FOLDER) != 0));
2121 1 hiro
        menuitem = gtk_item_factory_get_item
2122 1 hiro
                (ifactory, "/View/Separate message view");
2123 1 hiro
        gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem),
2124 1 hiro
                                       ((type & SEPARATE_MESSAGE) != 0));
2125 1 hiro
2126 1 hiro
        if (folderwin) {
2127 1 hiro
                g_signal_connect
2128 1 hiro
                        (G_OBJECT(folderwin), "size_allocate",
2129 1 hiro
                         G_CALLBACK(folder_window_size_allocate_cb), mainwin);
2130 1 hiro
        }
2131 1 hiro
        if (messagewin) {
2132 1 hiro
                g_signal_connect
2133 1 hiro
                        (G_OBJECT(messagewin), "size_allocate",
2134 1 hiro
                         G_CALLBACK(message_window_size_allocate_cb), mainwin);
2135 1 hiro
        }
2136 1 hiro
2137 1 hiro
        debug_print("done.\n");
2138 1 hiro
}
2139 1 hiro
2140 1 hiro
static GtkItemFactoryEntry reply_entries[] =
2141 1 hiro
{
2142 1 hiro
        {N_("/_Reply"),                        NULL, reply_cb, COMPOSE_REPLY, NULL},
2143 1 hiro
        {N_("/Reply to _all"),                NULL, reply_cb, COMPOSE_REPLY_TO_ALL, NULL},
2144 1 hiro
        {N_("/Reply to _sender"),        NULL, reply_cb, COMPOSE_REPLY_TO_SENDER, NULL},
2145 1 hiro
        {N_("/Reply to mailing _list"),        NULL, reply_cb, COMPOSE_REPLY_TO_LIST, NULL}
2146 1 hiro
};
2147 1 hiro
2148 1 hiro
static GtkItemFactoryEntry forward_entries[] =
2149 1 hiro
{
2150 1 hiro
        {N_("/_Forward"),                NULL, reply_cb, COMPOSE_FORWARD, NULL},
2151 1 hiro
        {N_("/For_ward as attachment"), NULL, reply_cb, COMPOSE_FORWARD_AS_ATTACH, NULL},
2152 1 hiro
        {N_("/Redirec_t"),                NULL, reply_cb, COMPOSE_REDIRECT, NULL}
2153 1 hiro
};
2154 1 hiro
2155 489 hiro
static GtkWidget *main_window_toolbar_create(MainWindow *mainwin)
2156 1 hiro
{
2157 1 hiro
        GtkWidget *toolbar;
2158 1 hiro
        GtkWidget *icon_wid;
2159 1 hiro
        GtkWidget *get_btn;
2160 1 hiro
        GtkWidget *getall_btn;
2161 1 hiro
        GtkWidget *send_btn;
2162 1 hiro
        GtkWidget *compose_btn;
2163 1 hiro
        GtkWidget *reply_btn;
2164 1 hiro
        ComboButton *reply_combo;
2165 1 hiro
        GtkWidget *replyall_btn;
2166 1 hiro
        GtkWidget *fwd_btn;
2167 1 hiro
        ComboButton *fwd_combo;
2168 1 hiro
#if 0
2169 1 hiro
        GtkWidget *prefs_btn;
2170 1 hiro
        GtkWidget *account_btn;
2171 1 hiro
#endif
2172 1 hiro
        GtkWidget *next_btn;
2173 1 hiro
        GtkWidget *delete_btn;
2174 306 hiro
        GtkWidget *junk_btn;
2175 1 hiro
        GtkWidget *exec_btn;
2176 1 hiro
2177 1 hiro
        gint n_entries;
2178 1 hiro
2179 1 hiro
        toolbar = gtk_toolbar_new();
2180 1 hiro
        gtk_toolbar_set_orientation(GTK_TOOLBAR(toolbar),
2181 1 hiro
                                    GTK_ORIENTATION_HORIZONTAL);
2182 1 hiro
        gtk_toolbar_set_style(GTK_TOOLBAR(toolbar), GTK_TOOLBAR_BOTH);
2183 306 hiro
        gtk_toolbar_set_icon_size(GTK_TOOLBAR(toolbar),
2184 398 hiro
                                  GTK_ICON_SIZE_LARGE_TOOLBAR);
2185 1 hiro
2186 489 hiro
        icon_wid = stock_pixbuf_widget(NULL, STOCK_PIXMAP_MAIL_RECEIVE);
2187 1 hiro
        get_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
2188 1 hiro
                                          _("Get"),
2189 1 hiro
                                          _("Incorporate new mail"),
2190 1 hiro
                                          "Get",
2191 1 hiro
                                          icon_wid,
2192 1 hiro
                                          G_CALLBACK(toolbar_inc_cb),
2193 1 hiro
                                          mainwin);
2194 489 hiro
        icon_wid = stock_pixbuf_widget(NULL, STOCK_PIXMAP_MAIL_RECEIVE_ALL);
2195 1 hiro
        getall_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
2196 1 hiro
                                             _("Get all"),
2197 1 hiro
                                             _("Incorporate new mail of all accounts"),
2198 1 hiro
                                             "Get all",
2199 1 hiro
                                             icon_wid,
2200 1 hiro
                                             G_CALLBACK(toolbar_inc_all_cb),
2201 1 hiro
                                             mainwin);
2202 1 hiro
2203 1 hiro
        gtk_toolbar_append_space(GTK_TOOLBAR(toolbar));
2204 1 hiro
2205 489 hiro
        icon_wid = stock_pixbuf_widget(NULL, STOCK_PIXMAP_MAIL_SEND);
2206 1 hiro
        send_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
2207 1 hiro
                                           _("Send"),
2208 1 hiro
                                           _("Send queued message(s)"),
2209 1 hiro
                                           "Send",
2210 1 hiro
                                           icon_wid,
2211 1 hiro
                                           G_CALLBACK(toolbar_send_cb),
2212 1 hiro
                                           mainwin);
2213 1 hiro
2214 1 hiro
        gtk_toolbar_append_space(GTK_TOOLBAR(toolbar));
2215 1 hiro
2216 489 hiro
        icon_wid = stock_pixbuf_widget(NULL, STOCK_PIXMAP_MAIL_COMPOSE);
2217 1 hiro
        compose_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
2218 1 hiro
                                              _("Compose"),
2219 1 hiro
                                              _("Compose new message"),
2220 1 hiro
                                              "New",
2221 1 hiro
                                              icon_wid,
2222 1 hiro
                                              G_CALLBACK(toolbar_compose_cb),
2223 1 hiro
                                              mainwin);
2224 1 hiro
2225 489 hiro
        icon_wid = stock_pixbuf_widget(NULL, STOCK_PIXMAP_MAIL_REPLY);
2226 1 hiro
        reply_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
2227 1 hiro
                                            _("Reply"),
2228 1 hiro
                                            _("Reply to the message"),
2229 1 hiro
                                            "Reply",
2230 1 hiro
                                            icon_wid,
2231 1 hiro
                                            G_CALLBACK(toolbar_reply_cb),
2232 1 hiro
                                            mainwin);
2233 1 hiro
2234 1 hiro
        n_entries = sizeof(reply_entries) / sizeof(reply_entries[0]);
2235 1 hiro
        reply_combo = gtkut_combo_button_create(reply_btn,
2236 1 hiro
                                                reply_entries, n_entries,
2237 1 hiro
                                                "<Reply>", mainwin);
2238 1 hiro
        gtk_button_set_relief(GTK_BUTTON(reply_combo->arrow), GTK_RELIEF_NONE);
2239 1 hiro
        gtk_toolbar_append_widget(GTK_TOOLBAR(toolbar),
2240 1 hiro
                                  GTK_WIDGET_PTR(reply_combo),
2241 1 hiro
                                  _("Reply to the message"), "Reply");
2242 1 hiro
2243 489 hiro
        icon_wid = stock_pixbuf_widget(NULL, STOCK_PIXMAP_MAIL_REPLY_TO_ALL);
2244 1 hiro
        replyall_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
2245 1 hiro
                                               _("Reply all"),
2246 1 hiro
                                               _("Reply to all"),
2247 1 hiro
                                               "Reply to all",
2248 1 hiro
                                               icon_wid,
2249 1 hiro
                                               G_CALLBACK(toolbar_reply_to_all_cb),
2250 1 hiro
                                               mainwin);
2251 1 hiro
2252 489 hiro
        icon_wid = stock_pixbuf_widget(NULL, STOCK_PIXMAP_MAIL_FORWARD);
2253 1 hiro
        fwd_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
2254 1 hiro
                                          _("Forward"),
2255 1 hiro
                                          _("Forward the message"),
2256 1 hiro
                                          "Fwd",
2257 1 hiro
                                          icon_wid,
2258 1 hiro
                                          G_CALLBACK(toolbar_forward_cb),
2259 1 hiro
                                          mainwin);
2260 1 hiro
2261 1 hiro
        n_entries = sizeof(forward_entries) / sizeof(forward_entries[0]);
2262 1 hiro
        fwd_combo = gtkut_combo_button_create(fwd_btn,
2263 1 hiro
                                              forward_entries, n_entries,
2264 1 hiro
                                              "<Forward>", mainwin);
2265 1 hiro
        gtk_button_set_relief(GTK_BUTTON(fwd_combo->arrow), GTK_RELIEF_NONE);
2266 1 hiro
        gtk_toolbar_append_widget(GTK_TOOLBAR(toolbar),
2267 1 hiro
                                  GTK_WIDGET_PTR(fwd_combo),
2268 1 hiro
                                  _("Forward the message"), "Fwd");
2269 1 hiro
2270 1 hiro
        gtk_toolbar_append_space(GTK_TOOLBAR(toolbar));
2271 1 hiro
2272 489 hiro
        icon_wid = stock_pixbuf_widget(NULL, STOCK_PIXMAP_DELETE);
2273 1 hiro
        delete_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
2274 1 hiro
                                          _("Delete"),
2275 1 hiro
                                          _("Delete the message"),
2276 1 hiro
                                          "Delete",
2277 1 hiro
                                          icon_wid,
2278 1 hiro
                                          G_CALLBACK(toolbar_delete_cb),
2279 1 hiro
                                          mainwin);
2280 1 hiro
2281 489 hiro
        icon_wid = stock_pixbuf_widget(NULL, STOCK_PIXMAP_SPAM);
2282 306 hiro
        junk_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
2283 306 hiro
                                           _("Junk"),
2284 306 hiro
                                           _("Set as junk mail"),
2285 306 hiro
                                           "Junk",
2286 306 hiro
                                           icon_wid,
2287 306 hiro
                                           G_CALLBACK(toolbar_junk_cb),
2288 306 hiro
                                           mainwin);
2289 306 hiro
2290 306 hiro
        icon_wid = gtk_image_new_from_stock(GTK_STOCK_EXECUTE,
2291 398 hiro
                                            GTK_ICON_SIZE_LARGE_TOOLBAR);
2292 1 hiro
        exec_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
2293 1 hiro
                                           _("Execute"),
2294 1 hiro
                                           _("Execute marked process"),
2295 1 hiro
                                           "Execute",
2296 1 hiro
                                           icon_wid,
2297 1 hiro
                                           G_CALLBACK(toolbar_exec_cb),
2298 1 hiro
                                           mainwin);
2299 1 hiro
2300 306 hiro
        icon_wid = gtk_image_new_from_stock(GTK_STOCK_GO_DOWN,
2301 398 hiro
                                            GTK_ICON_SIZE_LARGE_TOOLBAR);
2302 1 hiro
        next_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
2303 1 hiro
                                           _("Next"),
2304 1 hiro
                                           _("Next unread message"),
2305 1 hiro
                                           "Next unread",
2306 1 hiro
                                           icon_wid,
2307 1 hiro
                                           G_CALLBACK(toolbar_next_unread_cb),
2308 1 hiro
                                           mainwin);
2309 1 hiro
2310 1 hiro
#if 0
2311 1 hiro
        gtk_toolbar_append_space(GTK_TOOLBAR(toolbar));
2312 1 hiro
2313 403 hiro
        icon_wid = gtk_image_new_from_stock(GTK_STOCK_PREFERENCES,
2314 403 hiro
                                            GTK_ICON_SIZE_LARGE_TOOLBAR);
2315 1 hiro
        prefs_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
2316 1 hiro
                                            _("Prefs"),
2317 1 hiro
                                            _("Common preferences"),
2318 1 hiro
                                            "Prefs",
2319 1 hiro
                                            icon_wid,
2320 1 hiro
                                            G_CALLBACK(toolbar_prefs_cb),
2321 1 hiro
                                            mainwin);
2322 403 hiro
        icon_wid = gtk_image_new_from_stock(GTK_STOCK_PROPERTIES,
2323 403 hiro
                                            GTK_ICON_SIZE_LARGE_TOOLBAR);
2324 1 hiro
        account_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
2325 1 hiro
                                              _("Account"),
2326 1 hiro
                                              _("Account setting"),
2327 1 hiro
                                              "Account",
2328 1 hiro
                                              icon_wid,
2329 1 hiro
                                              G_CALLBACK(toolbar_account_cb),
2330 1 hiro
                                              mainwin);
2331 1 hiro
        g_signal_connect(G_OBJECT(account_btn), "button_press_event",
2332 1 hiro
                         G_CALLBACK(toolbar_account_button_pressed), mainwin);
2333 1 hiro
#endif
2334 1 hiro
2335 1 hiro
        mainwin->get_btn      = get_btn;
2336 1 hiro
        mainwin->getall_btn   = getall_btn;
2337 1 hiro
        mainwin->compose_btn  = compose_btn;
2338 1 hiro
        mainwin->reply_btn    = reply_btn;
2339 1 hiro
        mainwin->reply_combo  = reply_combo;
2340 1 hiro
        mainwin->replyall_btn = replyall_btn;
2341 1 hiro
        mainwin->fwd_btn      = fwd_btn;
2342 1 hiro
        mainwin->fwd_combo    = fwd_combo;
2343 1 hiro
        mainwin->send_btn     = send_btn;
2344 1 hiro
#if 0
2345 1 hiro
        mainwin->prefs_btn    = prefs_btn;
2346 1 hiro
        mainwin->account_btn  = account_btn;
2347 1 hiro
#endif
2348 1 hiro
        mainwin->next_btn     = next_btn;
2349 1 hiro
        mainwin->delete_btn   = delete_btn;
2350 306 hiro
        mainwin->junk_btn     = junk_btn;
2351 1 hiro
        mainwin->exec_btn     = exec_btn;
2352 1 hiro
2353 1 hiro
        gtk_widget_show_all(toolbar);
2354 489 hiro
2355 489 hiro
        return toolbar;
2356 1 hiro
}
2357 1 hiro
2358 1 hiro
/* callback functions */
2359 1 hiro
2360 1 hiro
static void toolbar_inc_cb        (GtkWidget        *widget,
2361 1 hiro
                                 gpointer         data)
2362 1 hiro
{
2363 1 hiro
        MainWindow *mainwin = (MainWindow *)data;
2364 1 hiro
2365 1 hiro
        inc_mail_cb(mainwin, 0, NULL);
2366 1 hiro
}
2367 1 hiro
2368 1 hiro
static void toolbar_inc_all_cb        (GtkWidget        *widget,
2369 1 hiro
                                 gpointer         data)
2370 1 hiro
{
2371 1 hiro
        MainWindow *mainwin = (MainWindow *)data;
2372 1 hiro
2373 1 hiro
        inc_all_account_mail_cb(mainwin, 0, NULL);
2374 1 hiro
}
2375 1 hiro
2376 1 hiro
static void toolbar_send_cb        (GtkWidget        *widget,
2377 1 hiro
                                 gpointer         data)
2378 1 hiro
{
2379 1 hiro
        MainWindow *mainwin = (MainWindow *)data;
2380 1 hiro
2381 1 hiro
        send_queue_cb(mainwin, 0, NULL);
2382 1 hiro
}
2383 1 hiro
2384 1 hiro
static void toolbar_compose_cb        (GtkWidget        *widget,
2385 1 hiro
                                 gpointer         data)
2386 1 hiro
{
2387 1 hiro
        MainWindow *mainwin = (MainWindow *)data;
2388 1 hiro
2389 1 hiro
        compose_cb(mainwin, 0, NULL);
2390 1 hiro
}
2391 1 hiro
2392 1 hiro
static void toolbar_reply_cb        (GtkWidget        *widget,
2393 1 hiro
                                 gpointer         data)
2394 1 hiro
{
2395 1 hiro
        MainWindow *mainwin = (MainWindow *)data;
2396 1 hiro
2397 1 hiro
        if (prefs_common.default_reply_list)
2398 1 hiro
                reply_cb(mainwin, COMPOSE_REPLY_TO_LIST, NULL);
2399 1 hiro
        else
2400 1 hiro
                reply_cb(mainwin, COMPOSE_REPLY, NULL);
2401 1 hiro
}
2402 1 hiro
2403 1 hiro
static void toolbar_reply_to_all_cb        (GtkWidget        *widget,
2404 1 hiro
                                         gpointer         data)
2405 1 hiro
{
2406 1 hiro
        MainWindow *mainwin = (MainWindow *)data;
2407 1 hiro
2408 1 hiro
        reply_cb(mainwin, COMPOSE_REPLY_TO_ALL, NULL);
2409 1 hiro
}
2410 1 hiro
2411 1 hiro
static void toolbar_forward_cb        (GtkWidget        *widget,
2412 1 hiro
                                 gpointer         data)
2413 1 hiro
{
2414 1 hiro
        MainWindow *mainwin = (MainWindow *)data;
2415 1 hiro
2416 1 hiro
        reply_cb(mainwin, COMPOSE_FORWARD, NULL);
2417 1 hiro
}
2418 1 hiro
2419 1 hiro
static void toolbar_delete_cb        (GtkWidget        *widget,
2420 1 hiro
                                 gpointer         data)
2421 1 hiro
{
2422 1 hiro
        MainWindow *mainwin = (MainWindow *)data;
2423 1 hiro
2424 1 hiro
        summary_delete(mainwin->summaryview);
2425 1 hiro
}
2426 1 hiro
2427 306 hiro
static void toolbar_junk_cb        (GtkWidget        *widget,
2428 306 hiro
                                 gpointer         data)
2429 306 hiro
{
2430 306 hiro
        MainWindow *mainwin = (MainWindow *)data;
2431 306 hiro
2432 306 hiro
        summary_junk(mainwin->summaryview);
2433 306 hiro
}
2434 306 hiro
2435 1 hiro
static void toolbar_exec_cb        (GtkWidget        *widget,
2436 1 hiro
                                 gpointer         data)
2437 1 hiro
{
2438 1 hiro
        MainWindow *mainwin = (MainWindow *)data;
2439 1 hiro
2440 1 hiro
        summary_execute(mainwin->summaryview);
2441 1 hiro
}
2442 1 hiro
2443 1 hiro
static void toolbar_next_unread_cb        (GtkWidget        *widget,
2444 1 hiro
                                         gpointer         data)
2445 1 hiro
{
2446 1 hiro
        MainWindow *mainwin = (MainWindow *)data;
2447 1 hiro
2448 1 hiro
        next_unread_cb(mainwin, 0, NULL);
2449 1 hiro
}
2450 1 hiro
2451 1 hiro
#if 0
2452 1 hiro
static void toolbar_prefs_cb        (GtkWidget        *widget,
2453 1 hiro
                                 gpointer         data)
2454 1 hiro
{
2455 1 hiro
        prefs_common_open();
2456 1 hiro
}
2457 1 hiro
2458 1 hiro
static void toolbar_account_cb        (GtkWidget        *widget,
2459 1 hiro
                                 gpointer         data)
2460 1 hiro
{
2461 1 hiro
        MainWindow *mainwin = (MainWindow *)data;
2462 1 hiro
2463 1 hiro
        prefs_account_open_cb(mainwin, 0, NULL);
2464 1 hiro
}
2465 1 hiro
2466 1 hiro
static void toolbar_account_button_pressed(GtkWidget *widget,
2467 1 hiro
                                           GdkEventButton *event,
2468 1 hiro
                                           gpointer data)
2469 1 hiro
{
2470 1 hiro
        MainWindow *mainwin = (MainWindow *)data;
2471 1 hiro
2472 1 hiro
        if (!event) return;
2473 1 hiro
        if (event->button != 3) return;
2474 1 hiro
2475 1 hiro
        gtk_button_set_relief(GTK_BUTTON(widget), GTK_RELIEF_NORMAL);
2476 1 hiro
        g_object_set_data(G_OBJECT(mainwin->ac_menu), "menu_button", widget);
2477 1 hiro
2478 1 hiro
        gtk_menu_popup(GTK_MENU(mainwin->ac_menu), NULL, NULL,
2479 1 hiro
                       menu_button_position, widget,
2480 1 hiro
                       event->button, event->time);
2481 1 hiro
}
2482 1 hiro
#endif
2483 1 hiro
2484 1 hiro
static void online_switch_clicked(GtkWidget *widget, gpointer data)
2485 1 hiro
{
2486 1 hiro
        MainWindow *mainwin = (MainWindow *)data;
2487 1 hiro
        GtkWidget *menuitem;
2488 1 hiro
2489 1 hiro
        menuitem = gtk_item_factory_get_item(mainwin->menu_factory,
2490 1 hiro
                                             "/File/Work offline");
2491 1 hiro
2492 1 hiro
        if (prefs_common.online_mode == TRUE) {
2493 1 hiro
                prefs_common.online_mode = FALSE;
2494 1 hiro
                gtk_widget_hide(mainwin->online_pixmap);
2495 1 hiro
                gtk_widget_show(mainwin->offline_pixmap);
2496 1 hiro
                gtk_tooltips_set_tip
2497 1 hiro
                        (mainwin->online_tip, mainwin->online_switch,
2498 1 hiro
                         _("You are offline. Click the icon to go online."),
2499 1 hiro
                         NULL);
2500 1 hiro
                gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem),
2501 1 hiro
                                               TRUE);
2502 1 hiro
                inc_autocheck_timer_remove();
2503 1 hiro
        } else {
2504 1 hiro
                prefs_common.online_mode = TRUE;
2505 1 hiro
                gtk_widget_hide(mainwin->offline_pixmap);
2506 1 hiro
                gtk_widget_show(mainwin->online_pixmap);
2507 1 hiro
                gtk_tooltips_set_tip
2508 1 hiro
                        (mainwin->online_tip, mainwin->online_switch,
2509 1 hiro
                         _("You are online. Click the icon to go offline."),
2510 1 hiro
                         NULL);
2511 1 hiro
                gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem),
2512 1 hiro
                                               FALSE);
2513 1 hiro
                inc_autocheck_timer_set();
2514 1 hiro
        }
2515 1 hiro
}
2516 1 hiro
2517 1 hiro
static void ac_label_button_pressed(GtkWidget *widget, GdkEventButton *event,
2518 1 hiro
                                    gpointer data)
2519 1 hiro
{
2520 1 hiro
        MainWindow *mainwin = (MainWindow *)data;
2521 1 hiro
2522 1 hiro
        if (!event) return;
2523 1 hiro
2524 1 hiro
        gtk_button_set_relief(GTK_BUTTON(widget), GTK_RELIEF_NORMAL);
2525 1 hiro
        g_object_set_data(G_OBJECT(mainwin->ac_menu), "menu_button", widget);
2526 1 hiro
2527 1 hiro
        gtk_menu_popup(GTK_MENU(mainwin->ac_menu), NULL, NULL,
2528 1 hiro
                       menu_button_position, widget,
2529 1 hiro
                       event->button, event->time);
2530 1 hiro
}
2531 1 hiro
2532 1 hiro
static void ac_menu_popup_closed(GtkMenuShell *menu_shell, gpointer data)
2533 1 hiro
{
2534 1 hiro
        MainWindow *mainwin = (MainWindow *)data;
2535 1 hiro
        GtkWidget *button;
2536 1 hiro
2537 1 hiro
        button = g_object_get_data(G_OBJECT(menu_shell), "menu_button");
2538 1 hiro
        if (!button) return;
2539 1 hiro
        gtk_button_set_relief(GTK_BUTTON(button), GTK_RELIEF_NONE);
2540 1 hiro
        g_object_set_data(G_OBJECT(mainwin->ac_menu), "menu_button", NULL);
2541 1 hiro
        manage_window_focus_in(mainwin->window, NULL, NULL);
2542 1 hiro
}
2543 1 hiro
2544 1 hiro
static gint main_window_close_cb(GtkWidget *widget, GdkEventAny *event,
2545 1 hiro
                                 gpointer data)
2546 1 hiro
{
2547 1 hiro
        MainWindow *mainwin = (MainWindow *)data;
2548 1 hiro
2549 1 hiro
        if (mainwin->lock_count == 0)
2550 1 hiro
                app_exit_cb(data, 0, widget);
2551 1 hiro
2552 1 hiro
        return TRUE;
2553 1 hiro
}
2554 1 hiro
2555 1 hiro
static gint folder_window_close_cb(GtkWidget *widget, GdkEventAny *event,
2556 1 hiro
                                   gpointer data)
2557 1 hiro
{
2558 1 hiro
        MainWindow *mainwin = (MainWindow *)data;
2559 1 hiro
        GtkWidget *menuitem;
2560 1 hiro
2561 1 hiro
        menuitem = gtk_item_factory_get_item
2562 1 hiro
                (mainwin->menu_factory, "/View/Show or hide/Folder tree");
2563 1 hiro
        gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), FALSE);
2564 1 hiro
2565 1 hiro
        return TRUE;
2566 1 hiro
}
2567 1 hiro
2568 1 hiro
static gint message_window_close_cb(GtkWidget *widget, GdkEventAny *event,
2569 1 hiro
                                    gpointer data)
2570 1 hiro
{
2571 1 hiro
        MainWindow *mainwin = (MainWindow *)data;
2572 1 hiro
        GtkWidget *menuitem;
2573 1 hiro
2574 1 hiro
        menuitem = gtk_item_factory_get_item
2575 1 hiro
                (mainwin->menu_factory, "/View/Show or hide/Message view");
2576 1 hiro
        gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), FALSE);
2577 1 hiro
2578 1 hiro
        return TRUE;
2579 1 hiro
}
2580 1 hiro
2581 1 hiro
static void main_window_size_allocate_cb(GtkWidget *widget,
2582 1 hiro
                                         GtkAllocation *allocation,
2583 1 hiro
                                         gpointer data)
2584 1 hiro
{
2585