Statistics
| Revision:

root / src / mainwindow.c @ 155

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