diff options
Diffstat (limited to 'src/mainwindow.c')
| -rw-r--r-- | src/mainwindow.c | 4276 |
1 files changed, 4276 insertions, 0 deletions
diff --git a/src/mainwindow.c b/src/mainwindow.c new file mode 100644 index 0000000..bc7e713 --- /dev/null +++ b/src/mainwindow.c | |||
| @@ -0,0 +1,4276 @@ | |||
| 1 | /* | ||
| 2 | * Sylpheed -- a GTK+ based, lightweight, and fast e-mail client | ||
| 3 | * Copyright (C) 1999-2017 Hiroyuki Yamamoto | ||
| 4 | * | ||
| 5 | * This program is free software; you can redistribute it and/or modify | ||
| 6 | * it under the terms of the GNU General Public License as published by | ||
| 7 | * the Free Software Foundation; either version 2 of the License, or | ||
| 8 | * (at your option) any later version. | ||
| 9 | * | ||
| 10 | * This program is distributed in the hope that it will be useful, | ||
| 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 13 | * GNU General Public License for more details. | ||
| 14 | * | ||
| 15 | * You should have received a copy of the GNU General Public License | ||
| 16 | * along with this program; if not, write to the Free Software | ||
| 17 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | ||
| 18 | */ | ||
| 19 | |||
| 20 | #include "defs.h" | ||
| 21 | |||
| 22 | #include <glib.h> | ||
| 23 | #include <glib/gi18n.h> | ||
| 24 | #include <gdk/gdkkeysyms.h> | ||
| 25 | #include <gtk/gtkmain.h> | ||
| 26 | #include <gtk/gtkversion.h> | ||
| 27 | #include <gtk/gtkwindow.h> | ||
| 28 | #include <gtk/gtkwidget.h> | ||
| 29 | #include <gtk/gtksignal.h> | ||
| 30 | #include <gtk/gtkvbox.h> | ||
| 31 | #include <gtk/gtkcontainer.h> | ||
| 32 | #include <gtk/gtkstatusbar.h> | ||
| 33 | #include <gtk/gtkprogressbar.h> | ||
| 34 | #include <gtk/gtkhpaned.h> | ||
| 35 | #include <gtk/gtkvpaned.h> | ||
| 36 | #include <gtk/gtkcheckmenuitem.h> | ||
| 37 | #include <gtk/gtkitemfactory.h> | ||
| 38 | #include <gtk/gtkeditable.h> | ||
| 39 | #include <gtk/gtkmenu.h> | ||
| 40 | #include <gtk/gtkmenuitem.h> | ||
| 41 | #include <gtk/gtktoolbar.h> | ||
| 42 | #include <gtk/gtktoolitem.h> | ||
| 43 | #include <gtk/gtktoolbutton.h> | ||
| 44 | #include <gtk/gtkseparatortoolitem.h> | ||
| 45 | #include <gtk/gtkbutton.h> | ||
| 46 | #include <gtk/gtktooltips.h> | ||
| 47 | #include <gtk/gtkarrow.h> | ||
| 48 | #include <gtk/gtkstock.h> | ||
| 49 | #include <gtk/gtkimage.h> | ||
| 50 | #include <string.h> | ||
| 51 | |||
| 52 | #include "main.h" | ||
| 53 | #include "mainwindow.h" | ||
| 54 | #include "folderview.h" | ||
| 55 | #include "foldersel.h" | ||
| 56 | #include "summaryview.h" | ||
| 57 | #include "quick_search.h" | ||
| 58 | #include "query_search.h" | ||
| 59 | #include "messageview.h" | ||
| 60 | #include "mimeview.h" | ||
| 61 | #include "message_search.h" | ||
| 62 | #include "headerview.h" | ||
| 63 | #include "menu.h" | ||
| 64 | #include "stock_pixmap.h" | ||
| 65 | #include "folder.h" | ||
| 66 | #include "inc.h" | ||
| 67 | #include "rpop3.h" | ||
| 68 | #include "compose.h" | ||
| 69 | #include "procmsg.h" | ||
| 70 | #include "send_message.h" | ||
| 71 | #include "import.h" | ||
| 72 | #include "export.h" | ||
| 73 | #include "prefs_common.h" | ||
| 74 | #include "prefs_common_dialog.h" | ||
| 75 | #include "prefs_filter.h" | ||
| 76 | #include "prefs_actions.h" | ||
| 77 | #include "prefs_account.h" | ||
| 78 | #include "prefs_summary_column.h" | ||
| 79 | #include "prefs_template.h" | ||
| 80 | #include "prefs_search_folder.h" | ||
| 81 | #include "prefs_toolbar.h" | ||
| 82 | #include "plugin_manager.h" | ||
| 83 | #include "action.h" | ||
| 84 | #include "account.h" | ||
| 85 | #include "account_dialog.h" | ||
| 86 | #include "addressbook.h" | ||
| 87 | #include "logwindow.h" | ||
| 88 | #include "manage_window.h" | ||
| 89 | #include "alertpanel.h" | ||
| 90 | #include "statusbar.h" | ||
| 91 | #include "inputdialog.h" | ||
| 92 | #include "trayicon.h" | ||
| 93 | #include "printing.h" | ||
| 94 | #include "utils.h" | ||
| 95 | #include "gtkutils.h" | ||
| 96 | #include "codeconv.h" | ||
| 97 | #include "about.h" | ||
| 98 | #include "manual.h" | ||
| 99 | #include "update_check.h" | ||
| 100 | #include "setup.h" | ||
| 101 | #include "plugin.h" | ||
| 102 | #include "version.h" | ||
| 103 | |||
| 104 | #define AC_LABEL_WIDTH 240 | ||
| 105 | |||
| 106 | #define STATUSBAR_PUSH(mainwin, str) \ | ||
| 107 | { \ | ||
| 108 | gtk_statusbar_push(GTK_STATUSBAR(mainwin->statusbar), \ | ||
| 109 | mainwin->mainwin_cid, str); \ | ||
| 110 | gtkut_widget_draw_now(mainwin->statusbar); \ | ||
| 111 | } | ||
| 112 | |||
| 113 | #define STATUSBAR_POP(mainwin) \ | ||
| 114 | { \ | ||
| 115 | gtk_statusbar_pop(GTK_STATUSBAR(mainwin->statusbar), \ | ||
| 116 | mainwin->mainwin_cid); \ | ||
| 117 | } | ||
| 118 | |||
| 119 | /* list of all instantiated MainWindow */ | ||
| 120 | static GList *mainwin_list = NULL; | ||
| 121 | |||
| 122 | static GdkCursor *watch_cursor; | ||
| 123 | |||
| 124 | static void main_window_menu_callback_block (MainWindow *mainwin); | ||
| 125 | static void main_window_menu_callback_unblock (MainWindow *mainwin); | ||
| 126 | |||
| 127 | static void main_window_show_cur_account (MainWindow *mainwin); | ||
| 128 | |||
| 129 | static void main_window_set_toolbar_button_visibility | ||
| 130 | (MainWindow *mainwin); | ||
| 131 | |||
| 132 | static void main_window_set_widgets (MainWindow *mainwin, | ||
| 133 | LayoutType layout, | ||
| 134 | SeparateType type); | ||
| 135 | static GtkWidget *main_window_toolbar_create (MainWindow *mainwin); | ||
| 136 | static GtkWidget *main_window_toolbar_create_from_list | ||
| 137 | (MainWindow *mainwin, | ||
| 138 | GList *item_list); | ||
| 139 | static void main_window_toolbar_toggle_menu_set_active | ||
| 140 | (MainWindow *mainwin, | ||
| 141 | ToolbarStyle style); | ||
| 142 | |||
| 143 | /* callback functions */ | ||
| 144 | static void toolbar_inc_cb (GtkWidget *widget, | ||
| 145 | gpointer data); | ||
| 146 | static void toolbar_inc_all_cb (GtkWidget *widget, | ||
| 147 | gpointer data); | ||
| 148 | static void toolbar_rpop3_cb (GtkWidget *widget, | ||
| 149 | gpointer data); | ||
| 150 | static void toolbar_send_cb (GtkWidget *widget, | ||
| 151 | gpointer data); | ||
| 152 | |||
| 153 | static void toolbar_compose_cb (GtkWidget *widget, | ||
| 154 | gpointer data); | ||
| 155 | static void toolbar_reply_cb (GtkWidget *widget, | ||
| 156 | gpointer data); | ||
| 157 | static void toolbar_reply_to_all_cb (GtkWidget *widget, | ||
| 158 | gpointer data); | ||
| 159 | static void toolbar_forward_cb (GtkWidget *widget, | ||
| 160 | gpointer data); | ||
| 161 | |||
| 162 | static void toolbar_delete_cb (GtkWidget *widget, | ||
| 163 | gpointer data); | ||
| 164 | static void toolbar_junk_cb (GtkWidget *widget, | ||
| 165 | gpointer data); | ||
| 166 | static void toolbar_notjunk_cb (GtkWidget *widget, | ||
| 167 | gpointer data); | ||
| 168 | static void toolbar_exec_cb (GtkWidget *widget, | ||
| 169 | gpointer data); | ||
| 170 | |||
| 171 | static void toolbar_next_unread_cb (GtkWidget *widget, | ||
| 172 | gpointer data); | ||
| 173 | static void toolbar_prev_unread_cb (GtkWidget *widget, | ||
| 174 | gpointer data); | ||
| 175 | static void toolbar_address_cb (GtkWidget *widget, | ||
| 176 | gpointer data); | ||
| 177 | static void toolbar_search_cb (GtkWidget *widget, | ||
| 178 | gpointer data); | ||
| 179 | static void toolbar_print_cb (GtkWidget *widget, | ||
| 180 | gpointer data); | ||
| 181 | static void toolbar_stop_cb (GtkWidget *widget, | ||
| 182 | gpointer data); | ||
| 183 | static void toolbar_prefs_common_cb (GtkWidget *widget, | ||
| 184 | gpointer data); | ||
| 185 | static void toolbar_prefs_account_cb (GtkWidget *widget, | ||
| 186 | gpointer data); | ||
| 187 | |||
| 188 | static gboolean toolbar_button_pressed (GtkWidget *widget, | ||
| 189 | GdkEventButton *event, | ||
| 190 | gpointer data); | ||
| 191 | |||
| 192 | static void online_switch_clicked (GtkWidget *widget, | ||
| 193 | gpointer data); | ||
| 194 | static gboolean ac_label_button_pressed (GtkWidget *widget, | ||
| 195 | GdkEventButton *event, | ||
| 196 | gpointer data); | ||
| 197 | static void ac_menu_popup_closed (GtkMenuShell *menu_shell, | ||
| 198 | gpointer data); | ||
| 199 | |||
| 200 | static gboolean main_window_key_pressed (GtkWidget *widget, | ||
| 201 | GdkEventKey *event, | ||
| 202 | gpointer data); | ||
| 203 | |||
| 204 | static gint main_window_close_cb (GtkWidget *widget, | ||
| 205 | GdkEventAny *event, | ||
| 206 | gpointer data); | ||
| 207 | static gint folder_window_close_cb (GtkWidget *widget, | ||
| 208 | GdkEventAny *event, | ||
| 209 | gpointer data); | ||
| 210 | static gint message_window_close_cb (GtkWidget *widget, | ||
| 211 | GdkEventAny *event, | ||
| 212 | gpointer data); | ||
| 213 | |||
| 214 | static void main_window_size_allocate_cb (GtkWidget *widget, | ||
| 215 | GtkAllocation *allocation, | ||
| 216 | gpointer data); | ||
| 217 | static void folder_window_size_allocate_cb (GtkWidget *widget, | ||
| 218 | GtkAllocation *allocation, | ||
| 219 | gpointer data); | ||
| 220 | static void message_window_size_allocate_cb (GtkWidget *widget, | ||
| 221 | GtkAllocation *allocation, | ||
| 222 | gpointer data); | ||
| 223 | |||
| 224 | static gboolean main_window_window_state_cb (GtkWidget *widget, | ||
| 225 | GdkEventWindowState *event, | ||
| 226 | gpointer data); | ||
| 227 | static gboolean main_window_visibility_notify_cb(GtkWidget *widget, | ||
| 228 | GdkEventVisibility *event, | ||
| 229 | gpointer data); | ||
| 230 | |||
| 231 | static void new_folder_cb (MainWindow *mainwin, | ||
| 232 | guint action, | ||
| 233 | GtkWidget *widget); | ||
| 234 | static void rename_folder_cb (MainWindow *mainwin, | ||
| 235 | guint action, | ||
| 236 | GtkWidget *widget); | ||
| 237 | static void move_folder_cb (MainWindow *mainwin, | ||
| 238 | guint action, | ||
| 239 | GtkWidget *widget); | ||
| 240 | static void delete_folder_cb (MainWindow *mainwin, | ||
| 241 | guint action, | ||
| 242 | GtkWidget *widget); | ||
| 243 | static void update_folderview_cb (MainWindow *mainwin, | ||
| 244 | guint action, | ||
| 245 | GtkWidget *widget); | ||
| 246 | |||
| 247 | static void add_mailbox_cb (MainWindow *mainwin, | ||
| 248 | guint action, | ||
| 249 | GtkWidget *widget); | ||
| 250 | static void remove_mailbox_cb (MainWindow *mainwin, | ||
| 251 | guint action, | ||
| 252 | GtkWidget *widget); | ||
| 253 | static void rebuild_tree_cb (MainWindow *mainwin, | ||
| 254 | guint action, | ||
| 255 | GtkWidget *widget); | ||
| 256 | |||
| 257 | static void import_mail_cb (MainWindow *mainwin, | ||
| 258 | guint action, | ||
| 259 | GtkWidget *widget); | ||
| 260 | static void export_mail_cb (MainWindow *mainwin, | ||
| 261 | guint action, | ||
| 262 | GtkWidget *widget); | ||
| 263 | static void empty_trash_cb (MainWindow *mainwin, | ||
| 264 | guint action, | ||
| 265 | GtkWidget *widget); | ||
| 266 | |||
| 267 | static void save_as_cb (MainWindow *mainwin, | ||
| 268 | guint action, | ||
| 269 | GtkWidget *widget); | ||
| 270 | #if GTK_CHECK_VERSION(2, 10, 0) | ||
| 271 | static void page_setup_cb (MainWindow *mainwin, | ||
| 272 | guint action, | ||
| 273 | GtkWidget *widget); | ||
| 274 | #endif | ||
| 275 | static void print_cb (MainWindow *mainwin, | ||
| 276 | guint action, | ||
| 277 | GtkWidget *widget); | ||
| 278 | static void toggle_offline_cb (MainWindow *mainwin, | ||
| 279 | guint action, | ||
| 280 | GtkWidget *widget); | ||
| 281 | static void app_exit_cb (MainWindow *mainwin, | ||
| 282 | guint action, | ||
| 283 | GtkWidget *widget); | ||
| 284 | |||
| 285 | static void search_cb (MainWindow *mainwin, | ||
| 286 | guint action, | ||
| 287 | GtkWidget *widget); | ||
| 288 | |||
| 289 | static void toggle_folder_cb (MainWindow *mainwin, | ||
| 290 | guint action, | ||
| 291 | GtkWidget *widget); | ||
| 292 | static void toggle_message_cb (MainWindow *mainwin, | ||
| 293 | guint action, | ||
| 294 | GtkWidget *widget); | ||
| 295 | static void toggle_toolbar_cb (MainWindow *mainwin, | ||
| 296 | guint action, | ||
| 297 | GtkWidget *widget); | ||
| 298 | static void toggle_searchbar_cb (MainWindow *mainwin, | ||
| 299 | guint action, | ||
| 300 | GtkWidget *widget); | ||
| 301 | static void toggle_statusbar_cb (MainWindow *mainwin, | ||
| 302 | guint action, | ||
| 303 | GtkWidget *widget); | ||
| 304 | static void toolbar_customize_cb (MainWindow *mainwin, | ||
| 305 | guint action, | ||
| 306 | GtkWidget *widget); | ||
| 307 | static void change_layout_cb (MainWindow *mainwin, | ||
| 308 | guint action, | ||
| 309 | GtkWidget *widget); | ||
| 310 | static void separate_widget_cb (MainWindow *mainwin, | ||
| 311 | guint action, | ||
| 312 | GtkWidget *widget); | ||
| 313 | |||
| 314 | static void addressbook_open_cb (MainWindow *mainwin, | ||
| 315 | guint action, | ||
| 316 | GtkWidget *widget); | ||
| 317 | static void log_window_show_cb (MainWindow *mainwin, | ||
| 318 | guint action, | ||
| 319 | GtkWidget *widget); | ||
| 320 | |||
| 321 | static void inc_mail_cb (MainWindow *mainwin, | ||
| 322 | guint action, | ||
| 323 | GtkWidget *widget); | ||
| 324 | static void inc_all_account_mail_cb (MainWindow *mainwin, | ||
| 325 | guint action, | ||
| 326 | GtkWidget *widget); | ||
| 327 | static void inc_stop_cb (MainWindow *mainwin, | ||
| 328 | guint action, | ||
| 329 | GtkWidget *widget); | ||
| 330 | |||
| 331 | static void rpop3_cb (MainWindow *mainwin, | ||
| 332 | guint action, | ||
| 333 | GtkWidget *widget); | ||
| 334 | |||
| 335 | static void send_queue_cb (MainWindow *mainwin, | ||
| 336 | guint action, | ||
| 337 | GtkWidget *widget); | ||
| 338 | |||
| 339 | static void compose_cb (MainWindow *mainwin, | ||
| 340 | guint action, | ||
| 341 | GtkWidget *widget); | ||
| 342 | static void reply_cb (MainWindow *mainwin, | ||
| 343 | guint action, | ||
| 344 | GtkWidget *widget); | ||
| 345 | |||
| 346 | static void open_msg_cb (MainWindow *mainwin, | ||
| 347 | guint action, | ||
| 348 | GtkWidget *widget); | ||
| 349 | |||
| 350 | static void view_source_cb (MainWindow *mainwin, | ||
| 351 | guint action, | ||
| 352 | GtkWidget *widget); | ||
| 353 | |||
| 354 | static void show_all_header_cb (MainWindow *mainwin, | ||
| 355 | guint action, | ||
| 356 | GtkWidget *widget); | ||
| 357 | |||
| 358 | static void move_to_cb (MainWindow *mainwin, | ||
| 359 | guint action, | ||
| 360 | GtkWidget *widget); | ||
| 361 | static void copy_to_cb (MainWindow *mainwin, | ||
| 362 | guint action, | ||
| 363 | GtkWidget *widget); | ||
| 364 | static void delete_cb (MainWindow *mainwin, | ||
| 365 | guint action, | ||
| 366 | GtkWidget *widget); | ||
| 367 | |||
| 368 | static void mark_cb (MainWindow *mainwin, | ||
| 369 | guint action, | ||
| 370 | GtkWidget *widget); | ||
| 371 | static void unmark_cb (MainWindow *mainwin, | ||
| 372 | guint action, | ||
| 373 | GtkWidget *widget); | ||
| 374 | |||
| 375 | static void mark_as_unread_cb (MainWindow *mainwin, | ||
| 376 | guint action, | ||
| 377 | GtkWidget *widget); | ||
| 378 | static void mark_as_read_cb (MainWindow *mainwin, | ||
| 379 | guint action, | ||
| 380 | GtkWidget *widget); | ||
| 381 | static void mark_thread_as_read_cb (MainWindow *mainwin, | ||
| 382 | guint action, | ||
| 383 | GtkWidget *widget); | ||
| 384 | static void mark_all_read_cb (MainWindow *mainwin, | ||
| 385 | guint action, | ||
| 386 | GtkWidget *widget); | ||
| 387 | |||
| 388 | static void junk_cb (MainWindow *mainwin, | ||
| 389 | guint action, | ||
| 390 | GtkWidget *widget); | ||
| 391 | |||
| 392 | static void reedit_cb (MainWindow *mainwin, | ||
| 393 | guint action, | ||
| 394 | GtkWidget *widget); | ||
| 395 | |||
| 396 | static void add_address_cb (MainWindow *mainwin, | ||
| 397 | guint action, | ||
| 398 | GtkWidget *widget); | ||
| 399 | |||
| 400 | static void set_charset_cb (MainWindow *mainwin, | ||
| 401 | guint action, | ||
| 402 | GtkWidget *widget); | ||
| 403 | |||
| 404 | static void thread_cb (MainWindow *mainwin, | ||
| 405 | guint action, | ||
| 406 | GtkWidget *widget); | ||
| 407 | static void expand_threads_cb (MainWindow *mainwin, | ||
| 408 | guint action, | ||
| 409 | GtkWidget *widget); | ||
| 410 | static void collapse_threads_cb (MainWindow *mainwin, | ||
| 411 | guint action, | ||
| 412 | GtkWidget *widget); | ||
| 413 | |||
| 414 | static void set_display_item_cb (MainWindow *mainwin, | ||
| 415 | guint action, | ||
| 416 | GtkWidget *widget); | ||
| 417 | static void sort_summary_cb (MainWindow *mainwin, | ||
| 418 | guint action, | ||
| 419 | GtkWidget *widget); | ||
| 420 | static void sort_summary_type_cb (MainWindow *mainwin, | ||
| 421 | guint action, | ||
| 422 | GtkWidget *widget); | ||
| 423 | static void attract_by_subject_cb(MainWindow *mainwin, | ||
| 424 | guint action, | ||
| 425 | GtkWidget *widget); | ||
| 426 | |||
| 427 | static void delete_duplicated_cb (MainWindow *mainwin, | ||
| 428 | guint action, | ||
| 429 | GtkWidget *widget); | ||
| 430 | static void concat_partial_cb (MainWindow *mainwin, | ||
| 431 | guint action, | ||
| 432 | GtkWidget *widget); | ||
| 433 | static void filter_cb (MainWindow *mainwin, | ||
| 434 | guint action, | ||
| 435 | GtkWidget *widget); | ||
| 436 | static void filter_junk_cb (MainWindow *mainwin, | ||
| 437 | guint action, | ||
| 438 | GtkWidget *widget); | ||
| 439 | static void execute_summary_cb (MainWindow *mainwin, | ||
| 440 | guint action, | ||
| 441 | GtkWidget *widget); | ||
| 442 | static void update_summary_cb (MainWindow *mainwin, | ||
| 443 | guint action, | ||
| 444 | GtkWidget *widget); | ||
| 445 | static void open_config_folder_cb(MainWindow *mainwin, | ||
| 446 | guint action, | ||
| 447 | GtkWidget *widget); | ||
| 448 | static void open_attachments_folder_cb | ||
| 449 | (MainWindow *mainwin, | ||
| 450 | guint action, | ||
| 451 | GtkWidget *widget); | ||
| 452 | |||
| 453 | static void prev_cb (MainWindow *mainwin, | ||
| 454 | guint action, | ||
| 455 | GtkWidget *widget); | ||
| 456 | static void next_cb (MainWindow *mainwin, | ||
| 457 | guint action, | ||
| 458 | GtkWidget *widget); | ||
| 459 | |||
| 460 | static void prev_unread_cb (MainWindow *mainwin, | ||
| 461 | guint action, | ||
| 462 | GtkWidget *widget); | ||
| 463 | static void next_unread_cb (MainWindow *mainwin, | ||
| 464 | guint action, | ||
| 465 | GtkWidget *widget); | ||
| 466 | static void prev_new_cb (MainWindow *mainwin, | ||
| 467 | guint action, | ||
| 468 | GtkWidget *widget); | ||
| 469 | static void next_new_cb (MainWindow *mainwin, | ||
| 470 | guint action, | ||
| 471 | GtkWidget *widget); | ||
| 472 | static void prev_marked_cb (MainWindow *mainwin, | ||
| 473 | guint action, | ||
| 474 | GtkWidget *widget); | ||
| 475 | static void next_marked_cb (MainWindow *mainwin, | ||
| 476 | guint action, | ||
| 477 | GtkWidget *widget); | ||
| 478 | static void prev_labeled_cb (MainWindow *mainwin, | ||
| 479 | guint action, | ||
| 480 | GtkWidget *widget); | ||
| 481 | static void next_labeled_cb (MainWindow *mainwin, | ||
| 482 | guint action, | ||
| 483 | GtkWidget *widget); | ||
| 484 | |||
| 485 | static void goto_folder_cb (MainWindow *mainwin, | ||
| 486 | guint action, | ||
| 487 | GtkWidget *widget); | ||
| 488 | |||
| 489 | static void copy_cb (MainWindow *mainwin, | ||
| 490 | guint action, | ||
| 491 | GtkWidget *widget); | ||
| 492 | static void allsel_cb (MainWindow *mainwin, | ||
| 493 | guint action, | ||
| 494 | GtkWidget *widget); | ||
| 495 | static void select_thread_cb (MainWindow *mainwin, | ||
| 496 | guint action, | ||
| 497 | GtkWidget *widget); | ||
| 498 | |||
| 499 | static void create_filter_cb (MainWindow *mainwin, | ||
| 500 | guint action, | ||
| 501 | GtkWidget *widget); | ||
| 502 | |||
| 503 | static void prefs_common_open_cb (MainWindow *mainwin, | ||
| 504 | guint action, | ||
| 505 | GtkWidget *widget); | ||
| 506 | static void prefs_filter_open_cb (MainWindow *mainwin, | ||
| 507 | guint action, | ||
| 508 | GtkWidget *widget); | ||
| 509 | static void prefs_template_open_cb (MainWindow *mainwin, | ||
| 510 | guint action, | ||
| 511 | GtkWidget *widget); | ||
| 512 | static void plugin_manager_open_cb (MainWindow *mainwin, | ||
| 513 | guint action, | ||
| 514 | GtkWidget *widget); | ||
| 515 | #ifndef G_OS_WIN32 | ||
| 516 | static void prefs_actions_open_cb (MainWindow *mainwin, | ||
| 517 | guint action, | ||
| 518 | GtkWidget *widget); | ||
| 519 | #endif | ||
| 520 | static void prefs_account_open_cb (MainWindow *mainwin, | ||
| 521 | guint action, | ||
| 522 | GtkWidget *widget); | ||
| 523 | |||
| 524 | static void new_account_cb (MainWindow *mainwin, | ||
| 525 | guint action, | ||
| 526 | GtkWidget *widget); | ||
| 527 | |||
| 528 | static void account_selector_menu_cb (GtkMenuItem *menuitem, | ||
| 529 | gpointer data); | ||
| 530 | static void account_receive_menu_cb (GtkMenuItem *menuitem, | ||
| 531 | gpointer data); | ||
| 532 | |||
| 533 | static void manual_open_cb (MainWindow *mainwin, | ||
| 534 | guint action, | ||
| 535 | GtkWidget *widget); | ||
| 536 | static void faq_open_cb (MainWindow *mainwin, | ||
| 537 | guint action, | ||
| 538 | GtkWidget *widget); | ||
| 539 | static void help_cmdline_cb (MainWindow *mainwin, | ||
| 540 | guint action, | ||
| 541 | GtkWidget *widget); | ||
| 542 | #if USE_UPDATE_CHECK | ||
| 543 | static void update_check_cb (MainWindow *mainwin, | ||
| 544 | guint action, | ||
| 545 | GtkWidget *widget); | ||
| 546 | #ifdef USE_UPDATE_CHECK_PLUGIN | ||
| 547 | static void update_check_plugin_cb(MainWindow *mainwin, guint action, | ||
| 548 | GtkWidget *widget); | ||
| 549 | #endif | ||
| 550 | #endif | ||
| 551 | |||
| 552 | static void scan_tree_func (Folder *folder, | ||
| 553 | FolderItem *item, | ||
| 554 | gpointer data); | ||
| 555 | |||
| 556 | static GtkItemFactoryEntry mainwin_entries[] = | ||
| 557 | { | ||
| 558 | {N_("/_File"), NULL, NULL, 0, "<Branch>"}, | ||
| 559 | {N_("/_File/_Folder"), NULL, NULL, 0, "<Branch>"}, | ||
| 560 | {N_("/_File/_Folder/Create _new folder..."), | ||
| 561 | NULL, new_folder_cb, 0, NULL}, | ||
| 562 | {N_("/_File/_Folder/_Rename folder..."),NULL, rename_folder_cb, 0, NULL}, | ||
| 563 | {N_("/_File/_Folder/_Move folder..."), NULL, move_folder_cb, 0, NULL}, | ||
| 564 | {N_("/_File/_Folder/_Delete folder"), NULL, delete_folder_cb, 0, NULL}, | ||
| 565 | {N_("/_File/_Mailbox"), NULL, NULL, 0, "<Branch>"}, | ||
| 566 | {N_("/_File/_Mailbox/Add _mailbox..."), NULL, add_mailbox_cb, 0, NULL}, | ||
| 567 | {N_("/_File/_Mailbox/_Remove mailbox"), NULL, remove_mailbox_cb, 0, NULL}, | ||
| 568 | {N_("/_File/_Mailbox/---"), NULL, NULL, 0, "<Separator>"}, | ||
| 569 | {N_("/_File/_Mailbox/_Check for new messages"), | ||
| 570 | NULL, update_folderview_cb, 0, NULL}, | ||
| 571 | {N_("/_File/_Mailbox/Check for new messages in _all mailboxes"), | ||
| 572 | NULL, update_folderview_cb, 1, NULL}, | ||
| 573 | {N_("/_File/_Mailbox/---"), NULL, NULL, 0, "<Separator>"}, | ||
| 574 | {N_("/_File/_Mailbox/R_ebuild folder tree"), | ||
| 575 | NULL, rebuild_tree_cb, 0, NULL}, | ||
| 576 | {N_("/_File/---"), NULL, NULL, 0, "<Separator>"}, | ||
| 577 | {N_("/_File/_Import mail data..."), NULL, import_mail_cb, 0, NULL}, | ||
| 578 | {N_("/_File/_Export mail data..."), NULL, export_mail_cb, 0, NULL}, | ||
| 579 | {N_("/_File/---"), NULL, NULL, 0, "<Separator>"}, | ||
| 580 | {N_("/_File/Empty all _trash"), NULL, empty_trash_cb, 0, NULL}, | ||
| 581 | {N_("/_File/---"), NULL, NULL, 0, "<Separator>"}, | ||
| 582 | {N_("/_File/_Save as..."), "<control>S", save_as_cb, 0, NULL}, | ||
| 583 | {N_("/_File/---"), NULL, NULL, 0, "<Separator>"}, | ||
| 584 | #if GTK_CHECK_VERSION(2, 10, 0) | ||
| 585 | {N_("/_File/Page set_up..."), NULL, page_setup_cb, 0, NULL}, | ||
| 586 | #endif | ||
| 587 | {N_("/_File/_Print..."), NULL, print_cb, 0, NULL}, | ||
| 588 | {N_("/_File/---"), NULL, NULL, 0, "<Separator>"}, | ||
| 589 | {N_("/_File/_Work offline"), NULL, toggle_offline_cb, 0, "<ToggleItem>"}, | ||
| 590 | {N_("/_File/---"), NULL, NULL, 0, "<Separator>"}, | ||
| 591 | /* {N_("/_File/_Close"), "<alt>W", app_exit_cb, 0, NULL}, */ | ||
| 592 | {N_("/_File/E_xit"), "<control>Q", app_exit_cb, 0, NULL}, | ||
| 593 | |||
| 594 | {N_("/_Edit"), NULL, NULL, 0, "<Branch>"}, | ||
| 595 | {N_("/_Edit/_Copy"), "<control>C", copy_cb, 0, NULL}, | ||
| 596 | {N_("/_Edit/Select _all"), "<control>A", allsel_cb, 0, NULL}, | ||
| 597 | {N_("/_Edit/Select _thread"), NULL, select_thread_cb, 0, NULL}, | ||
| 598 | {N_("/_Edit/---"), NULL, NULL, 0, "<Separator>"}, | ||
| 599 | {N_("/_Edit/_Find in current message..."), | ||
| 600 | "<control>F", search_cb, 0, NULL}, | ||
| 601 | {N_("/_Edit/_Search messages..."), "<shift><control>F", search_cb, 1, NULL}, | ||
| 602 | {N_("/_Edit/_Quick search"), "<shift><control>S", search_cb, 2, NULL}, | ||
| 603 | |||
| 604 | {N_("/_View"), NULL, NULL, 0, "<Branch>"}, | ||
| 605 | {N_("/_View/Show or hi_de"), NULL, NULL, 0, "<Branch>"}, | ||
| 606 | {N_("/_View/Show or hi_de/_Folder tree"), | ||
| 607 | NULL, toggle_folder_cb, 0, "<ToggleItem>"}, | ||
| 608 | {N_("/_View/Show or hi_de/_Message view"), | ||
| 609 | "V", toggle_message_cb, 0, "<ToggleItem>"}, | ||
| 610 | {N_("/_View/Show or hi_de/_Toolbar"), | ||
| 611 | NULL, NULL, 0, "<Branch>"}, | ||
| 612 | {N_("/_View/Show or hi_de/_Toolbar/Icon _and text"), | ||
| 613 | NULL, toggle_toolbar_cb, TOOLBAR_BOTH, "<RadioItem>"}, | ||
| 614 | {N_("/_View/Show or hi_de/_Toolbar/Text at the _right of icon"), | ||
| 615 | NULL, toggle_toolbar_cb, TOOLBAR_BOTH_HORIZ, "/View/Show or hide/Toolbar/Icon and text"}, | ||
| 616 | {N_("/_View/Show or hi_de/_Toolbar/_Icon"), | ||
| 617 | NULL, toggle_toolbar_cb, TOOLBAR_ICON, "/View/Show or hide/Toolbar/Icon and text"}, | ||
| 618 | {N_("/_View/Show or hi_de/_Toolbar/_Text"), | ||
| 619 | NULL, toggle_toolbar_cb, TOOLBAR_TEXT, "/View/Show or hide/Toolbar/Icon and text"}, | ||
| 620 | {N_("/_View/Show or hi_de/_Toolbar/_None"), | ||
| 621 | NULL, toggle_toolbar_cb, TOOLBAR_NONE, "/View/Show or hide/Toolbar/Icon and text"}, | ||
| 622 | {N_("/_View/Show or hi_de/_Search bar"), | ||
| 623 | NULL, toggle_searchbar_cb, 0, "<ToggleItem>"}, | ||
| 624 | {N_("/_View/Show or hi_de/Status _bar"), | ||
| 625 | NULL, toggle_statusbar_cb, 0, "<ToggleItem>"}, | ||
| 626 | {N_("/_View/_Customize toolbar..."), NULL, toolbar_customize_cb, 0, NULL}, | ||
| 627 | {N_("/_View/---"), NULL, NULL, 0, "<Separator>"}, | ||
| 628 | {N_("/_View/Layou_t"), NULL, NULL, 0, "<Branch>"}, | ||
| 629 | {N_("/_View/Layou_t/_Normal"), NULL, change_layout_cb, LAYOUT_NORMAL, "<RadioItem>"}, | ||
| 630 | {N_("/_View/Layou_t/_Vertical"), NULL, change_layout_cb, LAYOUT_VERTICAL, "/View/Layout/Normal"}, | ||
| 631 | {N_("/_View/Separate f_older tree"), NULL, separate_widget_cb, SEPARATE_FOLDER, "<ToggleItem>"}, | ||
| 632 | {N_("/_View/Separate _message view"), NULL, separate_widget_cb, SEPARATE_MESSAGE, "<ToggleItem>"}, | ||
| 633 | {N_("/_View/---"), NULL, NULL, 0, "<Separator>"}, | ||
| 634 | {N_("/_View/_Sort"), NULL, NULL, 0, "<Branch>"}, | ||
| 635 | {N_("/_View/_Sort/by _number"), NULL, sort_summary_cb, SORT_BY_NUMBER, "<RadioItem>"}, | ||
| 636 | {N_("/_View/_Sort/by s_ize"), NULL, sort_summary_cb, SORT_BY_SIZE, "/View/Sort/by number"}, | ||
| 637 | {N_("/_View/_Sort/by _date"), NULL, sort_summary_cb, SORT_BY_DATE, "/View/Sort/by number"}, | ||
| 638 | {N_("/_View/_Sort/by t_hread date"), NULL, sort_summary_cb, SORT_BY_TDATE, "/View/Sort/by number"}, | ||
| 639 | {N_("/_View/_Sort/by _from"), NULL, sort_summary_cb, SORT_BY_FROM, "/View/Sort/by number"}, | ||
| 640 | {N_("/_View/_Sort/by _recipient"), NULL, sort_summary_cb, SORT_BY_TO, "/View/Sort/by number"}, | ||
| 641 | {N_("/_View/_Sort/by _subject"), NULL, sort_summary_cb, SORT_BY_SUBJECT, "/View/Sort/by number"}, | ||
| 642 | {N_("/_View/_Sort/by _color label"), | ||
| 643 | NULL, sort_summary_cb, SORT_BY_LABEL, "/View/Sort/by number"}, | ||
| 644 | {N_("/_View/_Sort/by _mark"), NULL, sort_summary_cb, SORT_BY_MARK, "/View/Sort/by number"}, | ||
| 645 | {N_("/_View/_Sort/by _unread"), NULL, sort_summary_cb, SORT_BY_UNREAD, "/View/Sort/by number"}, | ||
| 646 | {N_("/_View/_Sort/by a_ttachment"), | ||
| 647 | NULL, sort_summary_cb, SORT_BY_MIME, "/View/Sort/by number"}, | ||
| 648 | {N_("/_View/_Sort/D_on't sort"), NULL, sort_summary_cb, SORT_BY_NONE, "/View/Sort/by number"}, | ||
| 649 | {N_("/_View/_Sort/---"), NULL, NULL, 0, "<Separator>"}, | ||
| 650 | {N_("/_View/_Sort/Ascending"), NULL, sort_summary_type_cb, SORT_ASCENDING, "<RadioItem>"}, | ||
| 651 | {N_("/_View/_Sort/Descending"), NULL, sort_summary_type_cb, SORT_DESCENDING, "/View/Sort/Ascending"}, | ||
| 652 | {N_("/_View/_Sort/---"), NULL, NULL, 0, "<Separator>"}, | ||
| 653 | {N_("/_View/_Sort/_Attract by subject"), | ||
| 654 | NULL, attract_by_subject_cb, 0, NULL}, | ||
| 655 | {N_("/_View/Th_read view"), "<control>T", thread_cb, 0, "<ToggleItem>"}, | ||
| 656 | {N_("/_View/E_xpand all threads"), NULL, expand_threads_cb, 0, NULL}, | ||
| 657 | {N_("/_View/Co_llapse all threads"), NULL, collapse_threads_cb, 0, NULL}, | ||
| 658 | {N_("/_View/Set display _item..."), NULL, set_display_item_cb, 0, NULL}, | ||
| 659 | |||
| 660 | {N_("/_View/---"), NULL, NULL, 0, "<Separator>"}, | ||
| 661 | {N_("/_View/_Go to"), NULL, NULL, 0, "<Branch>"}, | ||
| 662 | {N_("/_View/_Go to/_Prev message"), "P", prev_cb, 0, NULL}, | ||
| 663 | {N_("/_View/_Go to/_Next message"), "N", next_cb, 0, NULL}, | ||
| 664 | {N_("/_View/_Go to/---"), NULL, NULL, 0, "<Separator>"}, | ||
| 665 | {N_("/_View/_Go to/P_rev unread message"), | ||
| 666 | "<shift>P", prev_unread_cb, 0, NULL}, | ||
| 667 | {N_("/_View/_Go to/N_ext unread message"), | ||
| 668 | "<shift>N", next_unread_cb, 0, NULL}, | ||
| 669 | {N_("/_View/_Go to/---"), NULL, NULL, 0, "<Separator>"}, | ||
| 670 | {N_("/_View/_Go to/Prev ne_w message"), NULL, prev_new_cb, 0, NULL}, | ||
| 671 | {N_("/_View/_Go to/Ne_xt new message"), NULL, next_new_cb, 0, NULL}, | ||
| 672 | {N_("/_View/_Go to/---"), NULL, NULL, 0, "<Separator>"}, | ||
| 673 | {N_("/_View/_Go to/Prev _marked message"), | ||
| 674 | NULL, prev_marked_cb, 0, NULL}, | ||
| 675 | {N_("/_View/_Go to/Next m_arked message"), | ||
| 676 | NULL, next_marked_cb, 0, NULL}, | ||
| 677 | {N_("/_View/_Go to/---"), NULL, NULL, 0, "<Separator>"}, | ||
| 678 | {N_("/_View/_Go to/Prev _labeled message"), | ||
| 679 | NULL, prev_labeled_cb, 0, NULL}, | ||
| 680 | {N_("/_View/_Go to/Next la_beled message"), | ||
| 681 | NULL, next_labeled_cb, 0, NULL}, | ||
| 682 | {N_("/_View/_Go to/---"), NULL, NULL, 0, "<Separator>"}, | ||
| 683 | {N_("/_View/_Go to/Other _folder..."), "G", goto_folder_cb, 0, NULL}, | ||
| 684 | {N_("/_View/---"), NULL, NULL, 0, "<Separator>"}, | ||
| 685 | |||
| 686 | #define ENC_SEPARATOR \ | ||
| 687 | {N_("/_View/Character _encoding/---"), NULL, NULL, 0, "<Separator>"} | ||
| 688 | #define ENC_ACTION(action) \ | ||
| 689 | NULL, set_charset_cb, action, "/View/Character encoding/Auto detect" | ||
| 690 | |||
| 691 | {N_("/_View/Character _encoding"), NULL, NULL, 0, "<Branch>"}, | ||
| 692 | {N_("/_View/Character _encoding/_Auto detect"), | ||
| 693 | NULL, set_charset_cb, C_AUTO, "<RadioItem>"}, | ||
| 694 | {N_("/_View/Character _encoding/---"), NULL, NULL, 0, "<Separator>"}, | ||
| 695 | {N_("/_View/Character _encoding/7bit ascii (US-ASC_II)"), | ||
| 696 | ENC_ACTION(C_US_ASCII)}, | ||
| 697 | {N_("/_View/Character _encoding/Unicode (_UTF-8)"), | ||
| 698 | ENC_ACTION(C_UTF_8)}, | ||
| 699 | ENC_SEPARATOR, | ||
| 700 | |||
| 701 | {N_("/_View/Character _encoding/Western European (ISO-8859-_1)"), | ||
| 702 | ENC_ACTION(C_ISO_8859_1)}, | ||
| 703 | {N_("/_View/Character _encoding/Western European (ISO-8859-15)"), | ||
| 704 | ENC_ACTION(C_ISO_8859_15)}, | ||
| 705 | {N_("/_View/Character _encoding/Western European (Windows-1252)"), | ||
| 706 | ENC_ACTION(C_WINDOWS_1252)}, | ||
| 707 | ENC_SEPARATOR, | ||
| 708 | |||
| 709 | {N_("/_View/Character _encoding/Central European (ISO-8859-_2)"), | ||
| 710 | ENC_ACTION(C_ISO_8859_2)}, | ||
| 711 | ENC_SEPARATOR, | ||
| 712 | |||
| 713 | {N_("/_View/Character _encoding/_Baltic (ISO-8859-13)"), | ||
| 714 | ENC_ACTION(C_ISO_8859_13)}, | ||
| 715 | {N_("/_View/Character _encoding/Baltic (ISO-8859-_4)"), | ||
| 716 | ENC_ACTION(C_ISO_8859_4)}, | ||
| 717 | {N_("/_View/Character _encoding/Baltic (Windows-1257)"), | ||
| 718 | ENC_ACTION(C_WINDOWS_1257)}, | ||
| 719 | ENC_SEPARATOR, | ||
| 720 | |||
| 721 | {N_("/_View/Character _encoding/Greek (ISO-8859-_7)"), | ||
| 722 | ENC_ACTION(C_ISO_8859_7)}, | ||
| 723 | ENC_SEPARATOR, | ||
| 724 | |||
| 725 | {N_("/_View/Character _encoding/Arabic (ISO-8859-_6)"), | ||
| 726 | ENC_ACTION(C_ISO_8859_6)}, | ||
| 727 | {N_("/_View/Character _encoding/Arabic (Windows-1256)"), | ||
| 728 | ENC_ACTION(C_CP1256)}, | ||
| 729 | ENC_SEPARATOR, | ||
| 730 | |||
| 731 | {N_("/_View/Character _encoding/Hebrew (ISO-8859-_8)"), | ||
| 732 | ENC_ACTION(C_ISO_8859_8)}, | ||
| 733 | {N_("/_View/Character _encoding/Hebrew (Windows-1255)"), | ||
| 734 | ENC_ACTION(C_CP1255)}, | ||
| 735 | ENC_SEPARATOR, | ||
| 736 | |||
| 737 | {N_("/_View/Character _encoding/Turkish (ISO-8859-_9)"), | ||
| 738 | ENC_ACTION(C_ISO_8859_9)}, | ||
| 739 | ENC_SEPARATOR, | ||
| 740 | |||
| 741 | {N_("/_View/Character _encoding/Cyrillic (ISO-8859-_5)"), | ||
| 742 | ENC_ACTION(C_ISO_8859_5)}, | ||
| 743 | {N_("/_View/Character _encoding/Cyrillic (KOI8-_R)"), | ||
| 744 | ENC_ACTION(C_KOI8_R)}, | ||
| 745 | {N_("/_View/Character _encoding/Cyrillic (KOI8-U)"), | ||
| 746 | ENC_ACTION(C_KOI8_U)}, | ||
| 747 | {N_("/_View/Character _encoding/Cyrillic (Windows-1251)"), | ||
| 748 | ENC_ACTION(C_CP1251)}, | ||
| 749 | ENC_SEPARATOR, | ||
| 750 | |||
| 751 | {N_("/_View/Character _encoding/Japanese (ISO-2022-_JP)"), | ||
| 752 | ENC_ACTION(C_ISO_2022_JP)}, | ||
| 753 | {N_("/_View/Character _encoding/Japanese (ISO-2022-JP-2)"), | ||
| 754 | ENC_ACTION(C_ISO_2022_JP_2)}, | ||
| 755 | {N_("/_View/Character _encoding/Japanese (_EUC-JP)"), | ||
| 756 | ENC_ACTION(C_EUC_JP)}, | ||
| 757 | {N_("/_View/Character _encoding/Japanese (_Shift__JIS)"), | ||
| 758 | ENC_ACTION(C_SHIFT_JIS)}, | ||
| 759 | ENC_SEPARATOR, | ||
| 760 | |||
| 761 | {N_("/_View/Character _encoding/Simplified Chinese (_GB2312)"), | ||
| 762 | ENC_ACTION(C_GB2312)}, | ||
| 763 | {N_("/_View/Character _encoding/Simplified Chinese (GBK)"), | ||
| 764 | ENC_ACTION(C_GBK)}, | ||
| 765 | {N_("/_View/Character _encoding/Traditional Chinese (_Big5)"), | ||
| 766 | ENC_ACTION(C_BIG5)}, | ||
| 767 | {N_("/_View/Character _encoding/Traditional Chinese (EUC-_TW)"), | ||
| 768 | ENC_ACTION(C_EUC_TW)}, | ||
| 769 | {N_("/_View/Character _encoding/Chinese (ISO-2022-_CN)"), | ||
| 770 | ENC_ACTION(C_ISO_2022_CN)}, | ||
| 771 | ENC_SEPARATOR, | ||
| 772 | |||
| 773 | {N_("/_View/Character _encoding/Korean (EUC-_KR)"), | ||
| 774 | ENC_ACTION(C_EUC_KR)}, | ||
| 775 | {N_("/_View/Character _encoding/Korean (ISO-2022-KR)"), | ||
| 776 | ENC_ACTION(C_ISO_2022_KR)}, | ||
| 777 | ENC_SEPARATOR, | ||
| 778 | |||
| 779 | {N_("/_View/Character _encoding/Thai (TIS-620)"), | ||
| 780 | ENC_ACTION(C_TIS_620)}, | ||
| 781 | {N_("/_View/Character _encoding/Thai (Windows-874)"), | ||
| 782 | ENC_ACTION(C_WINDOWS_874)}, | ||
| 783 | |||
| 784 | #undef CODESET_SEPARATOR | ||
| 785 | #undef CODESET_ACTION | ||
| 786 | |||
| 787 | {N_("/_View/---"), NULL, NULL, 0, "<Separator>"}, | ||
| 788 | {N_("/_View/Open in new _window"), "<control><alt>N", open_msg_cb, 0, NULL}, | ||
| 789 | {N_("/_View/Mess_age source"), "<control>U", view_source_cb, 0, NULL}, | ||
| 790 | {N_("/_View/All _headers"), "<control>H", show_all_header_cb, 0, "<ToggleItem>"}, | ||
| 791 | {N_("/_View/---"), NULL, NULL, 0, "<Separator>"}, | ||
| 792 | {N_("/_View/_Update summary"), "<control><alt>U", update_summary_cb, 0, NULL}, | ||
| 793 | |||
| 794 | {N_("/_Message"), NULL, NULL, 0, "<Branch>"}, | ||
| 795 | {N_("/_Message/Recei_ve"), NULL, NULL, 0, "<Branch>"}, | ||
| 796 | {N_("/_Message/Recei_ve/Get from _current account"), | ||
| 797 | "<control>I", inc_mail_cb, 0, NULL}, | ||
| 798 | {N_("/_Message/Recei_ve/Get from _all accounts"), | ||
| 799 | "<shift><control>I", inc_all_account_mail_cb, 0, NULL}, | ||
| 800 | {N_("/_Message/Recei_ve/Stop receivin_g"), | ||
| 801 | NULL, inc_stop_cb, 0, NULL}, | ||
| 802 | {N_("/_Message/Recei_ve/_Remote mailbox..."), | ||
| 803 | NULL, rpop3_cb, 0, NULL}, | ||
| 804 | {N_("/_Message/Recei_ve/---"), NULL, NULL, 0, "<Separator>"}, | ||
| 805 | {N_("/_Message/_Send queued messages"), NULL, send_queue_cb, 0, NULL}, | ||
| 806 | {N_("/_Message/---"), NULL, NULL, 0, "<Separator>"}, | ||
| 807 | {N_("/_Message/Compose _new message"), "<control>M", compose_cb, 0, NULL}, | ||
| 808 | {N_("/_Message/---"), NULL, NULL, 0, "<Separator>"}, | ||
| 809 | {N_("/_Message/_Reply"), "<control>R", reply_cb, COMPOSE_REPLY, NULL}, | ||
| 810 | {N_("/_Message/Repl_y to"), NULL, NULL, 0, "<Branch>"}, | ||
| 811 | {N_("/_Message/Repl_y to/_all"), "<shift><control>R", reply_cb, COMPOSE_REPLY_TO_ALL, NULL}, | ||
| 812 | {N_("/_Message/Repl_y to/_sender"), NULL, reply_cb, COMPOSE_REPLY_TO_SENDER, NULL}, | ||
| 813 | {N_("/_Message/Repl_y to/mailing _list"), | ||
| 814 | "<control>L", reply_cb, COMPOSE_REPLY_TO_LIST, NULL}, | ||
| 815 | {N_("/_Message/---"), NULL, NULL, 0, "<Separator>"}, | ||
| 816 | {N_("/_Message/_Forward"), "<control><alt>F", reply_cb, COMPOSE_FORWARD, NULL}, | ||
| 817 | {N_("/_Message/For_ward as attachment"), | ||
| 818 | "<shift><control><alt>F", reply_cb, COMPOSE_FORWARD_AS_ATTACH, NULL}, | ||
| 819 | {N_("/_Message/Redirec_t"), NULL, reply_cb, COMPOSE_REDIRECT, NULL}, | ||
| 820 | {N_("/_Message/---"), NULL, NULL, 0, "<Separator>"}, | ||
| 821 | {N_("/_Message/M_ove..."), "<control>O", move_to_cb, 0, NULL}, | ||
| 822 | {N_("/_Message/_Copy..."), "<shift><control>O", copy_to_cb, 0, NULL}, | ||
| 823 | {N_("/_Message/---"), NULL, NULL, 0, "<Separator>"}, | ||
| 824 | {N_("/_Message/_Mark"), NULL, NULL, 0, "<Branch>"}, | ||
| 825 | {N_("/_Message/_Mark/Set _flag"), "<shift>asterisk", mark_cb, 0, NULL}, | ||
| 826 | {N_("/_Message/_Mark/_Unset flag"), "U", unmark_cb, 0, NULL}, | ||
| 827 | {N_("/_Message/_Mark/---"), NULL, NULL, 0, "<Separator>"}, | ||
| 828 | {N_("/_Message/_Mark/Mark as unr_ead"), "<shift>exclam", mark_as_unread_cb, 0, NULL}, | ||
| 829 | {N_("/_Message/_Mark/Mark as rea_d"), | ||
| 830 | NULL, mark_as_read_cb, 0, NULL}, | ||
| 831 | {N_("/_Message/_Mark/Mark _thread as read"), | ||
| 832 | NULL, mark_thread_as_read_cb, 0, NULL}, | ||
| 833 | {N_("/_Message/_Mark/Mark all _read"), NULL, mark_all_read_cb, 0, NULL}, | ||
| 834 | {N_("/_Message/---"), NULL, NULL, 0, "<Separator>"}, | ||
| 835 | {N_("/_Message/_Delete"), "<control>D", delete_cb, 0, NULL}, | ||
| 836 | {N_("/_Message/---"), NULL, NULL, 0, "<Separator>"}, | ||
| 837 | {N_("/_Message/Set as _junk mail"), "<control>J", junk_cb, 0, NULL}, | ||
| 838 | {N_("/_Message/Set as not j_unk mail"), "<shift><control>J", junk_cb, 1, NULL}, | ||
| 839 | {N_("/_Message/---"), NULL, NULL, 0, "<Separator>"}, | ||
| 840 | {N_("/_Message/Re-_edit"), NULL, reedit_cb, 0, NULL}, | ||
| 841 | |||
| 842 | {N_("/_Tools"), NULL, NULL, 0, "<Branch>"}, | ||
| 843 | {N_("/_Tools/_Address book"), "<shift><control>A", addressbook_open_cb, 0, NULL}, | ||
| 844 | {N_("/_Tools/Add sender to address boo_k..."), | ||
| 845 | NULL, add_address_cb, 0, NULL}, | ||
| 846 | {N_("/_Tools/---"), NULL, NULL, 0, "<Separator>"}, | ||
| 847 | {N_("/_Tools/_Filter all messages in folder"), | ||
| 848 | NULL, filter_cb, 0, NULL}, | ||
| 849 | {N_("/_Tools/Filter _selected messages"), | ||
| 850 | NULL, filter_cb, 1, NULL}, | ||
| 851 | {N_("/_Tools/_Create filter rule"), NULL, NULL, 0, "<Branch>"}, | ||
| 852 | {N_("/_Tools/_Create filter rule/_Automatically"), | ||
| 853 | NULL, create_filter_cb, FLT_BY_AUTO, NULL}, | ||
| 854 | {N_("/_Tools/_Create filter rule/by _From"), | ||
| 855 | NULL, create_filter_cb, FLT_BY_FROM, NULL}, | ||
| 856 | {N_("/_Tools/_Create filter rule/by _To"), | ||
| 857 | NULL, create_filter_cb, FLT_BY_TO, NULL}, | ||
| 858 | {N_("/_Tools/_Create filter rule/by _Subject"), | ||
| 859 | NULL, create_filter_cb, FLT_BY_SUBJECT, NULL}, | ||
| 860 | {N_("/_Tools/---"), NULL, NULL, 0, "<Separator>"}, | ||
| 861 | {N_("/_Tools/Filter _junk mails in folder"), | ||
| 862 | NULL, filter_junk_cb, 0, NULL}, | ||
| 863 | {N_("/_Tools/Filter junk _mails in selected messages"), | ||
| 864 | NULL, filter_junk_cb, 1, NULL}, | ||
| 865 | {N_("/_Tools/---"), NULL, NULL, 0, "<Separator>"}, | ||
| 866 | #ifndef G_OS_WIN32 | ||
| 867 | {N_("/_Tools/Actio_ns"), NULL, NULL, 0, "<Branch>"}, | ||
| 868 | {N_("/_Tools/---"), NULL, NULL, 0, "<Separator>"}, | ||
| 869 | #endif | ||
| 870 | {N_("/_Tools/Delete du_plicated messages"), | ||
| 871 | NULL, delete_duplicated_cb, 0, NULL}, | ||
| 872 | {N_("/_Tools/C_oncatenate separated messages"), | ||
| 873 | NULL, concat_partial_cb, 0, NULL}, | ||
| 874 | {N_("/_Tools/---"), NULL, NULL, 0, "<Separator>"}, | ||
| 875 | {N_("/_Tools/E_xecute marked process"), "X", execute_summary_cb, 0, NULL}, | ||
| 876 | {N_("/_Tools/---"), NULL, NULL, 0, "<Separator>"}, | ||
| 877 | {N_("/_Tools/Op_en configuration folder"), | ||
| 878 | NULL, open_config_folder_cb, 0, NULL}, | ||
| 879 | {N_("/_Tools/Open a_ttachments folder"),NULL, open_attachments_folder_cb, 0, NULL}, | ||
| 880 | {N_("/_Tools/---"), NULL, NULL, 0, "<Separator>"}, | ||
| 881 | {N_("/_Tools/_Log window"), "<shift><control>L", log_window_show_cb, 0, NULL}, | ||
| 882 | |||
| 883 | {N_("/_Configuration"), NULL, NULL, 0, "<Branch>"}, | ||
| 884 | {N_("/_Configuration/_Common preferences..."), | ||
| 885 | NULL, prefs_common_open_cb, 0, NULL}, | ||
| 886 | {N_("/_Configuration/_Filter settings..."), | ||
| 887 | NULL, prefs_filter_open_cb, 0, NULL}, | ||
| 888 | {N_("/_Configuration/_Template..."), NULL, prefs_template_open_cb, 0, NULL}, | ||
| 889 | #ifndef G_OS_WIN32 | ||
| 890 | {N_("/_Configuration/_Actions..."), NULL, prefs_actions_open_cb, 0, NULL}, | ||
| 891 | #endif | ||
| 892 | {N_("/_Configuration/Plug-in _manager..."), | ||
| 893 | NULL, plugin_manager_open_cb, 0, NULL}, | ||
| 894 | {N_("/_Configuration/---"), NULL, NULL, 0, "<Separator>"}, | ||
| 895 | {N_("/_Configuration/_Preferences for current account..."), | ||
| 896 | NULL, prefs_account_open_cb, 0, NULL}, | ||
| 897 | {N_("/_Configuration/Create _new account..."), | ||
| 898 | NULL, new_account_cb, 0, NULL}, | ||
| 899 | {N_("/_Configuration/_Edit accounts..."), | ||
| 900 | NULL, account_edit_open, 0, NULL}, | ||
| 901 | {N_("/_Configuration/C_hange current account"), | ||
| 902 | NULL, NULL, 0, "<Branch>"}, | ||
| 903 | |||
| 904 | {N_("/_Help"), NULL, NULL, 0, "<Branch>"}, | ||
| 905 | {N_("/_Help/_Manual"), NULL, NULL, 0, "<Branch>"}, | ||
| 906 | {N_("/_Help/_Manual/_English"), NULL, manual_open_cb, MANUAL_LANG_EN, NULL}, | ||
| 907 | {N_("/_Help/_Manual/_Japanese"), NULL, manual_open_cb, MANUAL_LANG_JA, NULL}, | ||
| 908 | {N_("/_Help/_FAQ"), NULL, NULL, 0, "<Branch>"}, | ||
| 909 | {N_("/_Help/_FAQ/_English"), NULL, faq_open_cb, MANUAL_LANG_EN, NULL}, | ||
| 910 | {N_("/_Help/_FAQ/_German"), NULL, faq_open_cb, MANUAL_LANG_DE, NULL}, | ||
| 911 | {N_("/_Help/_FAQ/_Spanish"), NULL, faq_open_cb, MANUAL_LANG_ES, NULL}, | ||
| 912 | {N_("/_Help/_FAQ/_French"), NULL, faq_open_cb, MANUAL_LANG_FR, NULL}, | ||
| 913 | {N_("/_Help/_FAQ/_Italian"), NULL, faq_open_cb, MANUAL_LANG_IT, NULL}, | ||
| 914 | {N_("/_Help/_Command line options"), NULL, help_cmdline_cb, 0, NULL}, | ||
| 915 | #if USE_UPDATE_CHECK | ||
| 916 | {N_("/_Help/---"), NULL, NULL, 0, "<Separator>"}, | ||
| 917 | {N_("/_Help/_Update check..."), NULL, update_check_cb, 0, NULL}, | ||
| 918 | #ifdef USE_UPDATE_CHECK_PLUGIN | ||
| 919 | {N_("/_Help/Update check of _plug-ins..."), | ||
| 920 | NULL, update_check_plugin_cb, 0, NULL}, | ||
| 921 | #endif | ||
| 922 | #endif | ||
| 923 | {N_("/_Help/---"), NULL, NULL, 0, "<Separator>"}, | ||
| 924 | {N_("/_Help/_About"), NULL, about_show, 0, NULL} | ||
| 925 | }; | ||
| 926 | |||
| 927 | MainWindow *main_window_create(SeparateType type) | ||
| 928 | { | ||
| 929 | MainWindow *mainwin; | ||
| 930 | GtkWidget *window; | ||
| 931 | GtkWidget *vbox; | ||
| 932 | GtkWidget *menubar; | ||
| 933 | GtkWidget *toolbar; | ||
| 934 | GtkWidget *hbox_spc; | ||
| 935 | GtkWidget *vbox_body; | ||
| 936 | GtkWidget *statusbar; | ||
| 937 | GtkWidget *progressbar; | ||
| 938 | GtkWidget *statuslabel; | ||
| 939 | GtkWidget *online_hbox; | ||
| 940 | GtkWidget *online_switch; | ||
| 941 | GtkWidget *online_pixmap; | ||
| 942 | GtkWidget *offline_pixmap; | ||
| 943 | GtkTooltips *online_tip; | ||
| 944 | #if !GTK_CHECK_VERSION(2, 6, 0) | ||
| 945 | GtkWidget *spacer_hbox; | ||
| 946 | #endif | ||
| 947 | GtkWidget *ac_button; | ||
| 948 | GtkWidget *ac_label; | ||
| 949 | |||
| 950 | TrayIcon *tray_icon; | ||
| 951 | |||
| 952 | FolderView *folderview; | ||
| 953 | SummaryView *summaryview; | ||
| 954 | MessageView *messageview; | ||
| 955 | GdkColormap *colormap; | ||
| 956 | GdkColor color[3]; | ||
| 957 | gboolean success[3]; | ||
| 958 | guint n_menu_entries; | ||
| 959 | GtkItemFactory *ifactory; | ||
| 960 | GtkWidget *ac_menu; | ||
| 961 | GtkWidget *menuitem; | ||
| 962 | gint i; | ||
| 963 | |||
| 964 | static GdkGeometry geometry; | ||
| 965 | |||
| 966 | debug_print(_("Creating main window...\n")); | ||
| 967 | mainwin = g_new0(MainWindow, 1); | ||
| 968 | |||
| 969 | /* main window */ | ||
| 970 | window = gtk_window_new(GTK_WINDOW_TOPLEVEL); | ||
| 971 | gtk_window_set_title(GTK_WINDOW(window), PROG_VERSION); | ||
| 972 | gtk_window_set_policy(GTK_WINDOW(window), TRUE, TRUE, FALSE); | ||
| 973 | gtk_window_set_wmclass(GTK_WINDOW(window), "main_window", "Sylpheed"); | ||
| 974 | gtk_widget_add_events(window, GDK_VISIBILITY_NOTIFY_MASK); | ||
| 975 | g_signal_connect(G_OBJECT(window), "key_press_event", | ||
| 976 | G_CALLBACK(main_window_key_pressed), mainwin); | ||
| 977 | |||
| 978 | if (!geometry.min_height) { | ||
| 979 | geometry.min_width = 320; | ||
| 980 | geometry.min_height = 200; | ||
| 981 | } | ||
| 982 | gtk_window_set_geometry_hints(GTK_WINDOW(window), NULL, &geometry, | ||
| 983 | GDK_HINT_MIN_SIZE); | ||
| 984 | |||
| 985 | g_signal_connect(G_OBJECT(window), "delete_event", | ||
| 986 | G_CALLBACK(main_window_close_cb), mainwin); | ||
| 987 | MANAGE_WINDOW_SIGNALS_CONNECT(window); | ||
| 988 | gtk_widget_realize(window); | ||
| 989 | |||
| 990 | vbox = gtk_vbox_new(FALSE, 0); | ||
| 991 | gtk_widget_show(vbox); | ||
| 992 | gtk_container_add(GTK_CONTAINER(window), vbox); | ||
| 993 | |||
| 994 | /* menu bar */ | ||
| 995 | n_menu_entries = sizeof(mainwin_entries) / sizeof(mainwin_entries[0]); | ||
| 996 | menubar = menubar_create(window, mainwin_entries, | ||
| 997 | n_menu_entries, "<Main>", mainwin); | ||
| 998 | gtk_widget_show(menubar); | ||
| 999 | gtk_widget_set_size_request(menubar, 300, -1); | ||
| 1000 | gtk_box_pack_start(GTK_BOX(vbox), menubar, FALSE, TRUE, 0); | ||
| 1001 | ifactory = gtk_item_factory_from_widget(menubar); | ||
| 1002 | |||
| 1003 | /* toolbar */ | ||
| 1004 | mainwin->toolbar_tip = gtk_tooltips_new(); | ||
| 1005 | toolbar = main_window_toolbar_create(mainwin); | ||
| 1006 | gtk_widget_set_size_request(toolbar, 300, -1); | ||
| 1007 | gtk_box_pack_start(GTK_BOX(vbox), toolbar, FALSE, FALSE, 0); | ||
| 1008 | |||
| 1009 | hbox_spc = gtk_hbox_new(FALSE, 0); | ||
| 1010 | gtk_widget_show(hbox_spc); | ||
| 1011 | gtk_widget_set_size_request(hbox_spc, -1, BORDER_WIDTH); | ||
| 1012 | gtk_box_pack_start(GTK_BOX(vbox), hbox_spc, FALSE, FALSE, 0); | ||
| 1013 | |||
| 1014 | /* vbox that contains body */ | ||
| 1015 | vbox_body = gtk_vbox_new(FALSE, BORDER_WIDTH); | ||
| 1016 | gtk_widget_show(vbox_body); | ||
| 1017 | gtk_container_set_border_width(GTK_CONTAINER(vbox_body), 0); | ||
| 1018 | gtk_box_pack_start(GTK_BOX(vbox), vbox_body, TRUE, TRUE, 0); | ||
| 1019 | |||
| 1020 | statusbar = statusbar_create(); | ||
| 1021 | gtk_box_pack_end(GTK_BOX(vbox_body), statusbar, FALSE, FALSE, 0); | ||
| 1022 | |||
| 1023 | progressbar = gtk_progress_bar_new(); | ||
| 1024 | gtk_widget_set_size_request(progressbar, 120, 1); | ||
| 1025 | gtk_box_pack_start(GTK_BOX(statusbar), progressbar, FALSE, FALSE, 0); | ||
| 1026 | |||
| 1027 | statuslabel = gtk_label_new(""); | ||
| 1028 | gtk_box_pack_start(GTK_BOX(statusbar), statuslabel, FALSE, FALSE, 0); | ||
| 1029 | |||
| 1030 | online_hbox = gtk_hbox_new(FALSE, 0); | ||
| 1031 | |||
| 1032 | online_pixmap = stock_pixbuf_widget(statusbar, STOCK_PIXMAP_ONLINE); | ||
| 1033 | offline_pixmap = stock_pixbuf_widget(statusbar, STOCK_PIXMAP_OFFLINE); | ||
| 1034 | gtk_box_pack_start(GTK_BOX(online_hbox), online_pixmap, | ||
| 1035 | FALSE, FALSE, 0); | ||
| 1036 | gtk_box_pack_start(GTK_BOX(online_hbox), offline_pixmap, | ||
| 1037 | FALSE, FALSE, 0); | ||
| 1038 | |||
| 1039 | online_switch = gtk_button_new(); | ||
| 1040 | gtk_button_set_relief(GTK_BUTTON(online_switch), GTK_RELIEF_NONE); | ||
| 1041 | GTK_WIDGET_UNSET_FLAGS(online_switch, GTK_CAN_FOCUS); | ||
| 1042 | #ifdef G_OS_WIN32 | ||
| 1043 | gtk_widget_set_size_request(online_switch, 34, 20); | ||
| 1044 | #else | ||
| 1045 | gtk_widget_set_size_request(online_switch, 34, 24); | ||
| 1046 | #endif | ||
| 1047 | gtk_container_add(GTK_CONTAINER(online_switch), online_hbox); | ||
| 1048 | g_signal_connect(G_OBJECT(online_switch), "clicked", | ||
| 1049 | G_CALLBACK(online_switch_clicked), mainwin); | ||
| 1050 | gtk_box_pack_start(GTK_BOX(statusbar), online_switch, FALSE, FALSE, 0); | ||
| 1051 | |||
| 1052 | online_tip = gtk_tooltips_new(); | ||
| 1053 | |||
| 1054 | #if !GTK_CHECK_VERSION(2, 6, 0) | ||
| 1055 | spacer_hbox = gtk_hbox_new(FALSE, 0); | ||
| 1056 | gtk_box_pack_end(GTK_BOX(statusbar), spacer_hbox, FALSE, FALSE, 0); | ||
| 1057 | #endif | ||
| 1058 | |||
| 1059 | ac_button = gtk_button_new(); | ||
| 1060 | gtk_button_set_relief(GTK_BUTTON(ac_button), GTK_RELIEF_NONE); | ||
| 1061 | GTK_WIDGET_UNSET_FLAGS(ac_button, GTK_CAN_FOCUS); | ||
| 1062 | gtk_widget_set_size_request(ac_button, -1, 1); | ||
| 1063 | gtk_box_pack_end(GTK_BOX(statusbar), ac_button, FALSE, FALSE, 0); | ||
| 1064 | g_signal_connect(G_OBJECT(ac_button), "button_press_event", | ||
| 1065 | G_CALLBACK(ac_label_button_pressed), mainwin); | ||
| 1066 | |||
| 1067 | ac_label = gtk_label_new(""); | ||
| 1068 | gtk_container_add(GTK_CONTAINER(ac_button), ac_label); | ||
| 1069 | |||
| 1070 | gtk_widget_show_all(statusbar); | ||
| 1071 | |||
| 1072 | tray_icon = trayicon_create(mainwin); | ||
| 1073 | if (tray_icon && prefs_common.show_trayicon) | ||
| 1074 | trayicon_show(tray_icon); | ||
| 1075 | |||
| 1076 | /* create views */ | ||
| 1077 | mainwin->folderview = folderview = folderview_create(); | ||
| 1078 | mainwin->summaryview = summaryview = summary_create(); | ||
| 1079 | mainwin->messageview = messageview = messageview_create(); | ||
| 1080 | mainwin->logwin = log_window_create(); | ||
| 1081 | |||
| 1082 | quick_search_create(summaryview); | ||
| 1083 | |||
| 1084 | folderview->mainwin = mainwin; | ||
| 1085 | folderview->summaryview = summaryview; | ||
| 1086 | |||
| 1087 | summaryview->mainwin = mainwin; | ||
| 1088 | summaryview->folderview = folderview; | ||
| 1089 | summaryview->messageview = messageview; | ||
| 1090 | summaryview->window = window; | ||
| 1091 | |||
| 1092 | messageview->statusbar = statusbar; | ||
| 1093 | messageview->mainwin = mainwin; | ||
| 1094 | |||
| 1095 | mainwin->window = window; | ||
| 1096 | mainwin->vbox = vbox; | ||
| 1097 | mainwin->menubar = menubar; | ||
| 1098 | mainwin->menu_factory = ifactory; | ||
| 1099 | mainwin->toolbar = toolbar; | ||
| 1100 | mainwin->vbox_body = vbox_body; | ||
| 1101 | mainwin->statusbar = statusbar; | ||
| 1102 | mainwin->progressbar = progressbar; | ||
| 1103 | mainwin->statuslabel = statuslabel; | ||
| 1104 | mainwin->online_switch = online_switch; | ||
| 1105 | mainwin->online_pixmap = online_pixmap; | ||
| 1106 | mainwin->offline_pixmap = offline_pixmap; | ||
| 1107 | mainwin->online_tip = online_tip; | ||
| 1108 | mainwin->ac_button = ac_button; | ||
| 1109 | mainwin->ac_label = ac_label; | ||
| 1110 | |||
| 1111 | mainwin->tray_icon = tray_icon; | ||
| 1112 | |||
| 1113 | /* set context IDs for status bar */ | ||
| 1114 | mainwin->mainwin_cid = gtk_statusbar_get_context_id | ||
| 1115 | (GTK_STATUSBAR(statusbar), "Main Window"); | ||
| 1116 | mainwin->folderview_cid = gtk_statusbar_get_context_id | ||
| 1117 | (GTK_STATUSBAR(statusbar), "Folder View"); | ||
| 1118 | mainwin->summaryview_cid = gtk_statusbar_get_context_id | ||
| 1119 | (GTK_STATUSBAR(statusbar), "Summary View"); | ||
| 1120 | mainwin->messageview_cid = gtk_statusbar_get_context_id | ||
| 1121 | (GTK_STATUSBAR(statusbar), "Message View"); | ||
| 1122 | |||
| 1123 | messageview->statusbar_cid = mainwin->messageview_cid; | ||
| 1124 | |||
| 1125 | /* allocate colors for summary view and folder view */ | ||
| 1126 | summaryview->color_marked.red = summaryview->color_marked.green = 0; | ||
| 1127 | summaryview->color_marked.blue = (guint16)65535; | ||
| 1128 | |||
| 1129 | summaryview->color_dim.red = summaryview->color_dim.green = | ||
| 1130 | summaryview->color_dim.blue = COLOR_DIM; | ||
| 1131 | |||
| 1132 | folderview->color_new.red = (guint16)55000; | ||
| 1133 | folderview->color_new.green = folderview->color_new.blue = 15000; | ||
| 1134 | |||
| 1135 | folderview->color_noselect.red = folderview->color_noselect.green = | ||
| 1136 | folderview->color_noselect.blue = COLOR_DIM; | ||
| 1137 | |||
| 1138 | color[0] = summaryview->color_marked; | ||
| 1139 | color[1] = summaryview->color_dim; | ||
| 1140 | color[2] = folderview->color_new; | ||
| 1141 | |||
| 1142 | colormap = gdk_window_get_colormap(window->window); | ||
| 1143 | gdk_colormap_alloc_colors(colormap, color, 3, FALSE, TRUE, success); | ||
| 1144 | for (i = 0; i < 3; i++) { | ||
| 1145 | if (success[i] == FALSE) | ||
| 1146 | g_warning(_("MainWindow: color allocation %d failed\n"), i); | ||
| 1147 | } | ||
| 1148 | |||
| 1149 | if (prefs_common.layout_type == LAYOUT_VERTICAL) | ||
| 1150 | messageview->visible = TRUE; | ||
| 1151 | else | ||
| 1152 | messageview->visible = prefs_common.msgview_visible; | ||
| 1153 | |||
| 1154 | main_window_set_widgets(mainwin, prefs_common.layout_type, type); | ||
| 1155 | |||
| 1156 | if (prefs_common.mainwin_maximized) | ||
| 1157 | gtk_window_maximize(GTK_WINDOW(window)); | ||
| 1158 | |||
| 1159 | g_signal_connect(G_OBJECT(window), "size_allocate", | ||
| 1160 | G_CALLBACK(main_window_size_allocate_cb), mainwin); | ||
| 1161 | g_signal_connect(G_OBJECT(window), "window_state_event", | ||
| 1162 | G_CALLBACK(main_window_window_state_cb), mainwin); | ||
| 1163 | g_signal_connect(G_OBJECT(window), "visibility_notify_event", | ||
| 1164 | G_CALLBACK(main_window_visibility_notify_cb), mainwin); | ||
| 1165 | |||
| 1166 | /* set menu items */ | ||
| 1167 | menuitem = gtk_item_factory_get_item | ||
| 1168 | (ifactory, "/View/Character encoding/Auto detect"); | ||
| 1169 | gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), TRUE); | ||
| 1170 | |||
| 1171 | main_window_toolbar_toggle_menu_set_active | ||
| 1172 | (mainwin, prefs_common.toolbar_style); | ||
| 1173 | |||
| 1174 | gtk_widget_hide(GTK_WIDGET_PTR(summaryview->qsearch)); | ||
| 1175 | menuitem = gtk_item_factory_get_item | ||
| 1176 | (ifactory, "/View/Show or hide/Search bar"); | ||
| 1177 | gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), | ||
| 1178 | prefs_common.show_searchbar); | ||
| 1179 | |||
| 1180 | gtk_widget_hide(mainwin->statusbar); | ||
| 1181 | menuitem = gtk_item_factory_get_item | ||
| 1182 | (ifactory, "/View/Show or hide/Status bar"); | ||
| 1183 | gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), | ||
| 1184 | prefs_common.show_statusbar); | ||
| 1185 | |||
| 1186 | /* set account selection menu */ | ||
| 1187 | ac_menu = gtk_item_factory_get_widget | ||
| 1188 | (ifactory, "/Configuration/Change current account"); | ||
| 1189 | g_signal_connect(G_OBJECT(ac_menu), "selection_done", | ||
| 1190 | G_CALLBACK(ac_menu_popup_closed), mainwin); | ||
| 1191 | mainwin->ac_menu = ac_menu; | ||
| 1192 | |||
| 1193 | main_window_set_toolbar_sensitive(mainwin); | ||
| 1194 | main_window_set_toolbar_button_visibility(mainwin); | ||
| 1195 | |||
| 1196 | /* create actions menu */ | ||
| 1197 | #ifndef G_OS_WIN32 | ||
| 1198 | action_update_mainwin_menu(ifactory, mainwin); | ||
| 1199 | #endif | ||
| 1200 | |||
| 1201 | /* initialize online switch */ | ||
| 1202 | if (prefs_common.startup_online_mode == 1) | ||
| 1203 | prefs_common.online_mode = TRUE; | ||
| 1204 | else if (prefs_common.startup_online_mode == 0) | ||
| 1205 | prefs_common.online_mode = FALSE; | ||
| 1206 | prefs_common.online_mode = !prefs_common.online_mode; | ||
| 1207 | online_switch_clicked(online_switch, mainwin); | ||
| 1208 | |||
| 1209 | /* show main window */ | ||
| 1210 | gtk_widget_show(mainwin->window); | ||
| 1211 | |||
| 1212 | #if !GTK_CHECK_VERSION(2, 6, 0) | ||
| 1213 | { | ||
| 1214 | gint w, h; | ||
| 1215 | gdk_drawable_get_size | ||
| 1216 | (GDK_DRAWABLE(GTK_STATUSBAR(statusbar)->grip_window), | ||
| 1217 | &w, &h); | ||
| 1218 | gtk_widget_set_size_request(spacer_hbox, w, -1); | ||
| 1219 | } | ||
| 1220 | #endif | ||
| 1221 | |||
| 1222 | /* initialize views */ | ||
| 1223 | folderview_init(folderview); | ||
| 1224 | summary_init(summaryview); | ||
| 1225 | messageview_init(messageview); | ||
| 1226 | log_window_init(mainwin->logwin); | ||
| 1227 | |||
| 1228 | mainwin->lock_count = 0; | ||
| 1229 | mainwin->menu_lock_count = 0; | ||
| 1230 | mainwin->cursor_count = 0; | ||
| 1231 | |||
| 1232 | mainwin->window_hidden = FALSE; | ||
| 1233 | mainwin->window_obscured = FALSE; | ||
| 1234 | |||
| 1235 | if (!watch_cursor) | ||
| 1236 | watch_cursor = gdk_cursor_new(GDK_WATCH); | ||
| 1237 | |||
| 1238 | mainwin_list = g_list_append(mainwin_list, mainwin); | ||
| 1239 | |||
| 1240 | debug_print(_("done.\n")); | ||
| 1241 | |||
| 1242 | return mainwin; | ||
| 1243 | } | ||
| 1244 | |||
| 1245 | void main_window_cursor_wait(MainWindow *mainwin) | ||
| 1246 | { | ||
| 1247 | |||
| 1248 | if (mainwin->cursor_count == 0) | ||
| 1249 | gdk_window_set_cursor(mainwin->window->window, watch_cursor); | ||
| 1250 | |||
| 1251 | mainwin->cursor_count++; | ||
| 1252 | |||
| 1253 | gdk_flush(); | ||
| 1254 | } | ||
| 1255 | |||
| 1256 | void main_window_cursor_normal(MainWindow *mainwin) | ||
| 1257 | { | ||
| 1258 | if (mainwin->cursor_count) | ||
| 1259 | mainwin->cursor_count--; | ||
| 1260 | |||
| 1261 | if (mainwin->cursor_count == 0) | ||
| 1262 | gdk_window_set_cursor(mainwin->window->window, NULL); | ||
| 1263 | |||
| 1264 | gdk_flush(); | ||
| 1265 | } | ||
| 1266 | |||
| 1267 | /* lock / unlock the user-interface */ | ||
| 1268 | void main_window_lock(MainWindow *mainwin) | ||
| 1269 | { | ||
| 1270 | if (mainwin->lock_count == 0) | ||
| 1271 | gtk_widget_set_sensitive(mainwin->ac_button, FALSE); | ||
| 1272 | |||
| 1273 | mainwin->lock_count++; | ||
| 1274 | |||
| 1275 | main_window_set_menu_sensitive(mainwin); | ||
| 1276 | main_window_set_toolbar_sensitive(mainwin); | ||
| 1277 | } | ||
| 1278 | |||
| 1279 | void main_window_unlock(MainWindow *mainwin) | ||
| 1280 | { | ||
| 1281 | if (mainwin->lock_count) | ||
| 1282 | mainwin->lock_count--; | ||
| 1283 | |||
| 1284 | main_window_set_menu_sensitive(mainwin); | ||
| 1285 | main_window_set_toolbar_sensitive(mainwin); | ||
| 1286 | |||
| 1287 | if (mainwin->lock_count == 0) | ||
| 1288 | gtk_widget_set_sensitive(mainwin->ac_button, TRUE); | ||
| 1289 | } | ||
| 1290 | |||
| 1291 | static void main_window_menu_callback_block(MainWindow *mainwin) | ||
| 1292 | { | ||
| 1293 | mainwin->menu_lock_count++; | ||
| 1294 | } | ||
| 1295 | |||
| 1296 | static void main_window_menu_callback_unblock(MainWindow *mainwin) | ||
| 1297 | { | ||
| 1298 | if (mainwin->menu_lock_count) | ||
| 1299 | mainwin->menu_lock_count--; | ||
| 1300 | } | ||
| 1301 | |||
| 1302 | void main_window_reflect_prefs_all(void) | ||
| 1303 | { | ||
| 1304 | MainWindow *mainwin; | ||
| 1305 | |||
| 1306 | mainwin = main_window_get(); | ||
| 1307 | |||
| 1308 | main_window_show_cur_account(mainwin); | ||
| 1309 | main_window_set_menu_sensitive(mainwin); | ||
| 1310 | main_window_set_toolbar_sensitive(mainwin); | ||
| 1311 | main_window_set_toolbar_button_visibility(mainwin); | ||
| 1312 | |||
| 1313 | if (mainwin->tray_icon) { | ||
| 1314 | if (prefs_common.show_trayicon) | ||
| 1315 | trayicon_show(mainwin->tray_icon); | ||
| 1316 | else { | ||
| 1317 | /* trayicon is automatically replaced by new one */ | ||
| 1318 | trayicon_hide(mainwin->tray_icon); | ||
| 1319 | } | ||
| 1320 | } | ||
| 1321 | |||
| 1322 | folderview_reflect_prefs(mainwin->folderview); | ||
| 1323 | |||
| 1324 | messageview_reflect_prefs(mainwin->messageview); | ||
| 1325 | |||
| 1326 | headerview_set_visibility(mainwin->messageview->headerview, | ||
| 1327 | prefs_common.display_header_pane); | ||
| 1328 | |||
| 1329 | textview_reflect_prefs(mainwin->messageview->textview); | ||
| 1330 | textview_reflect_prefs(mainwin->messageview->mimeview->textview); | ||
| 1331 | |||
| 1332 | summary_redisplay_msg(mainwin->summaryview); | ||
| 1333 | } | ||
| 1334 | |||
| 1335 | void main_window_set_summary_column(void) | ||
| 1336 | { | ||
| 1337 | summary_set_column_order(main_window_get()->summaryview); | ||
| 1338 | } | ||
| 1339 | |||
| 1340 | static void main_window_set_account_selector_menu(MainWindow *mainwin, | ||
| 1341 | GList *account_list) | ||
| 1342 | { | ||
| 1343 | GList *cur_ac, *cur_item; | ||
| 1344 | GtkWidget *menuitem; | ||
| 1345 | PrefsAccount *ac_prefs; | ||
| 1346 | |||
| 1347 | /* destroy all previous menu item */ | ||
| 1348 | cur_item = GTK_MENU_SHELL(mainwin->ac_menu)->children; | ||
| 1349 | while (cur_item != NULL) { | ||
| 1350 | GList *next = cur_item->next; | ||
| 1351 | gtk_widget_destroy(GTK_WIDGET(cur_item->data)); | ||
| 1352 | cur_item = next; | ||
| 1353 | } | ||
| 1354 | |||
| 1355 | for (cur_ac = account_list; cur_ac != NULL; cur_ac = cur_ac->next) { | ||
| 1356 | ac_prefs = (PrefsAccount *)cur_ac->data; | ||
| 1357 | |||
| 1358 | menuitem = gtk_menu_item_new_with_label | ||
| 1359 | (ac_prefs->account_name | ||
| 1360 | ? ac_prefs->account_name : _("Untitled")); | ||
| 1361 | gtk_widget_show(menuitem); | ||
| 1362 | gtk_menu_append(GTK_MENU(mainwin->ac_menu), menuitem); | ||
| 1363 | g_signal_connect(G_OBJECT(menuitem), "activate", | ||
| 1364 | G_CALLBACK(account_selector_menu_cb), | ||
| 1365 | ac_prefs); | ||
| 1366 | } | ||
| 1367 | } | ||
| 1368 | |||
| 1369 | static void main_window_set_account_receive_menu(MainWindow *mainwin, | ||
| 1370 | GList *account_list) | ||
| 1371 | { | ||
| 1372 | GList *cur_ac, *cur_item; | ||
| 1373 | GtkWidget *menu; | ||
| 1374 | GtkWidget *menuitem; | ||
| 1375 | PrefsAccount *ac_prefs; | ||
| 1376 | |||
| 1377 | menu = gtk_item_factory_get_widget(mainwin->menu_factory, | ||
| 1378 | "/Message/Receive"); | ||
| 1379 | |||
| 1380 | /* search for separator */ | ||
| 1381 | for (cur_item = GTK_MENU_SHELL(menu)->children; cur_item != NULL; | ||
| 1382 | cur_item = cur_item->next) { | ||
| 1383 | if (GTK_BIN(cur_item->data)->child == NULL) { | ||
| 1384 | cur_item = cur_item->next; | ||
| 1385 | break; | ||
| 1386 | } | ||
| 1387 | } | ||
| 1388 | |||
| 1389 | /* destroy all previous menu item */ | ||
| 1390 | while (cur_item != NULL) { | ||
| 1391 | GList *next = cur_item->next; | ||
| 1392 | gtk_widget_destroy(GTK_WIDGET(cur_item->data)); | ||
| 1393 | cur_item = next; | ||
| 1394 | } | ||
| 1395 | |||
| 1396 | for (cur_ac = account_list; cur_ac != NULL; cur_ac = cur_ac->next) { | ||
| 1397 | ac_prefs = (PrefsAccount *)cur_ac->data; | ||
| 1398 | |||
| 1399 | menuitem = gtk_menu_item_new_with_label | ||
| 1400 | (ac_prefs->account_name ? ac_prefs->account_name | ||
| 1401 | : _("Untitled")); | ||
| 1402 | gtk_widget_show(menuitem); | ||
| 1403 | gtk_menu_append(GTK_MENU(menu), menuitem); | ||
| 1404 | g_signal_connect(G_OBJECT(menuitem), "activate", | ||
| 1405 | G_CALLBACK(account_receive_menu_cb), | ||
| 1406 | ac_prefs); | ||
| 1407 | } | ||
| 1408 | } | ||
| 1409 | |||
| 1410 | void main_window_set_account_menu(GList *account_list) | ||
| 1411 | { | ||
| 1412 | MainWindow *mainwin; | ||
| 1413 | |||
| 1414 | mainwin = main_window_get(); | ||
| 1415 | main_window_set_account_selector_menu(mainwin, account_list); | ||
| 1416 | main_window_set_account_receive_menu(mainwin, account_list); | ||
| 1417 | } | ||
| 1418 | |||
| 1419 | static void main_window_show_cur_account(MainWindow *mainwin) | ||
| 1420 | { | ||
| 1421 | gchar *buf; | ||
| 1422 | gchar *ac_name; | ||
| 1423 | |||
| 1424 | ac_name = g_strdup(cur_account | ||
| 1425 | ? (cur_account->account_name | ||
| 1426 | ? cur_account->account_name : _("Untitled")) | ||
| 1427 | : _("none")); | ||
| 1428 | |||
| 1429 | if (cur_account) | ||
| 1430 | buf = g_strdup_printf("%s - %s", ac_name, PROG_VERSION); | ||
| 1431 | else | ||
| 1432 | buf = g_strdup(PROG_VERSION); | ||
| 1433 | gtk_window_set_title(GTK_WINDOW(mainwin->window), buf); | ||
| 1434 | g_free(buf); | ||
| 1435 | |||
| 1436 | gtk_label_set_text(GTK_LABEL(mainwin->ac_label), ac_name); | ||
| 1437 | gtk_widget_queue_resize(mainwin->ac_button); | ||
| 1438 | |||
| 1439 | g_free(ac_name); | ||
| 1440 | } | ||
| 1441 | |||
| 1442 | void main_window_change_cur_account(void) | ||
| 1443 | { | ||
| 1444 | MainWindow *mainwin; | ||
| 1445 | |||
| 1446 | mainwin = main_window_get(); | ||
| 1447 | main_window_show_cur_account(mainwin); | ||
| 1448 | main_window_set_menu_sensitive(mainwin); | ||
| 1449 | main_window_set_toolbar_sensitive(mainwin); | ||
| 1450 | } | ||
| 1451 | |||
| 1452 | MainWindow *main_window_get(void) | ||
| 1453 | { | ||
| 1454 | if (mainwin_list) | ||
| 1455 | return (MainWindow *)mainwin_list->data; | ||
| 1456 | else | ||
| 1457 | return NULL; | ||
| 1458 | } | ||
| 1459 | |||
| 1460 | GtkWidget *main_window_get_folder_window(MainWindow *mainwin) | ||
| 1461 | { | ||
| 1462 | switch (mainwin->type) { | ||
| 1463 | case SEPARATE_FOLDER: | ||
| 1464 | return mainwin->win.sep_folder.folderwin; | ||
| 1465 | case SEPARATE_BOTH: | ||
| 1466 | return mainwin->win.sep_both.folderwin; | ||
| 1467 | default: | ||
| 1468 | return NULL; | ||
| 1469 | } | ||
| 1470 | } | ||
| 1471 | |||
| 1472 | GtkWidget *main_window_get_message_window(MainWindow *mainwin) | ||
| 1473 | { | ||
| 1474 | switch (mainwin->type) { | ||
| 1475 | case SEPARATE_MESSAGE: | ||
| 1476 | return mainwin->win.sep_message.messagewin; | ||
| 1477 | case SEPARATE_BOTH: | ||
| 1478 | return mainwin->win.sep_both.messagewin; | ||
| 1479 | default: | ||
| 1480 | return NULL; | ||
| 1481 | } | ||
| 1482 | } | ||
| 1483 | |||
| 1484 | void main_window_hide(MainWindow *mainwin) | ||
| 1485 | { | ||
| 1486 | GtkWidget *folder_wid = GTK_WIDGET_PTR(mainwin->folderview); | ||
| 1487 | GtkWidget *summary_wid = GTK_WIDGET_PTR(mainwin->summaryview); | ||
| 1488 | GtkWidget *message_wid = GTK_WIDGET_PTR(mainwin->messageview); | ||
| 1489 | GtkWidget *qsearch_wid = GTK_WIDGET_PTR(mainwin->summaryview->qsearch); | ||
| 1490 | GtkWidget *vbox_summary = qsearch_wid->parent; | ||
| 1491 | |||
| 1492 | /* remove widgets from those containers */ | ||
| 1493 | gtkut_container_remove | ||
| 1494 | (GTK_CONTAINER(folder_wid->parent), folder_wid); | ||
| 1495 | gtkut_container_remove | ||
| 1496 | (GTK_CONTAINER(summary_wid->parent), summary_wid); | ||
| 1497 | gtkut_container_remove | ||
| 1498 | (GTK_CONTAINER(message_wid->parent), message_wid); | ||
| 1499 | gtkut_container_remove | ||
| 1500 | (GTK_CONTAINER(qsearch_wid->parent), qsearch_wid); | ||
| 1501 | |||
| 1502 | /* clean containers */ | ||
| 1503 | switch (mainwin->type) { | ||
| 1504 | case SEPARATE_NONE: | ||
| 1505 | if (!mainwin->win.sep_none.vpaned->parent) | ||
| 1506 | gtk_widget_destroy(mainwin->win.sep_none.vpaned); | ||
| 1507 | gtk_widget_destroy(mainwin->win.sep_none.hpaned); | ||
| 1508 | mainwin->win.sep_none.hpaned = NULL; | ||
| 1509 | mainwin->win.sep_none.vpaned = NULL; | ||
| 1510 | break; | ||
| 1511 | case SEPARATE_FOLDER: | ||
| 1512 | gtk_widget_destroy(mainwin->win.sep_folder.folderwin); | ||
| 1513 | if (!mainwin->win.sep_folder.vpaned->parent) | ||
| 1514 | gtk_widget_destroy(mainwin->win.sep_folder.vpaned); | ||
| 1515 | gtk_widget_destroy(vbox_summary); | ||
| 1516 | mainwin->win.sep_folder.folderwin = NULL; | ||
| 1517 | mainwin->win.sep_folder.vpaned = NULL; | ||
| 1518 | break; | ||
| 1519 | case SEPARATE_MESSAGE: | ||
| 1520 | gtk_widget_destroy(mainwin->win.sep_message.messagewin); | ||
| 1521 | gtk_widget_destroy(mainwin->win.sep_message.hpaned); | ||
| 1522 | mainwin->win.sep_message.messagewin = NULL; | ||
| 1523 | mainwin->win.sep_message.hpaned = NULL; | ||
| 1524 | break; | ||
| 1525 | case SEPARATE_BOTH: | ||
| 1526 | gtk_widget_destroy(vbox_summary); | ||
| 1527 | gtk_widget_destroy(mainwin->win.sep_both.folderwin); | ||
| 1528 | gtk_widget_destroy(mainwin->win.sep_both.messagewin); | ||
| 1529 | mainwin->win.sep_both.folderwin = NULL; | ||
| 1530 | mainwin->win.sep_both.messagewin = NULL; | ||
| 1531 | break; | ||
| 1532 | } | ||
| 1533 | |||
| 1534 | gtk_widget_hide(mainwin->window); | ||
| 1535 | } | ||
| 1536 | |||
| 1537 | void main_window_change_layout(MainWindow *mainwin, LayoutType layout, | ||
| 1538 | SeparateType type) | ||
| 1539 | { | ||
| 1540 | GtkWidget *folder_wid = GTK_WIDGET_PTR(mainwin->folderview); | ||
| 1541 | GtkWidget *summary_wid = GTK_WIDGET_PTR(mainwin->summaryview); | ||
| 1542 | GtkWidget *message_wid = GTK_WIDGET_PTR(mainwin->messageview); | ||
| 1543 | GtkWidget *qsearch_wid = GTK_WIDGET_PTR(mainwin->summaryview->qsearch); | ||
| 1544 | GtkWidget *focus_widget; | ||
| 1545 | |||
| 1546 | debug_print("Changing window layout type (layout: %d -> %d, separation: %d -> %d)\n", prefs_common.layout_type, layout, mainwin->type, type); | ||
| 1547 | |||
| 1548 | if (prefs_common.layout_type == layout && mainwin->type == type) | ||
| 1549 | return; | ||
| 1550 | |||
| 1551 | /* keep previous focus */ | ||
| 1552 | focus_widget = gtk_window_get_focus(GTK_WINDOW(mainwin->window)); | ||
| 1553 | |||
| 1554 | gtk_widget_ref(folder_wid); | ||
| 1555 | gtk_widget_ref(summary_wid); | ||
| 1556 | gtk_widget_ref(message_wid); | ||
| 1557 | gtk_widget_ref(qsearch_wid); | ||
| 1558 | |||
| 1559 | main_window_hide(mainwin); | ||
| 1560 | main_window_set_widgets(mainwin, layout, type); | ||
| 1561 | gtk_widget_show(mainwin->window); | ||
| 1562 | if (focus_widget) | ||
| 1563 | gtk_widget_grab_focus(focus_widget); | ||
| 1564 | |||
| 1565 | gtk_widget_unref(folder_wid); | ||
| 1566 | gtk_widget_unref(summary_wid); | ||
| 1567 | gtk_widget_unref(message_wid); | ||
| 1568 | gtk_widget_unref(qsearch_wid); | ||
| 1569 | } | ||
| 1570 | |||
| 1571 | void main_window_toggle_message_view(MainWindow *mainwin) | ||
| 1572 | { | ||
| 1573 | SummaryView *summaryview = mainwin->summaryview; | ||
| 1574 | union CompositeWin *cwin = &mainwin->win; | ||
| 1575 | GtkWidget *vpaned = NULL; | ||
| 1576 | GtkWidget *container = NULL; | ||
| 1577 | GtkWidget *msgwin = NULL; | ||
| 1578 | gboolean use_vlayout = (prefs_common.layout_type == LAYOUT_VERTICAL); | ||
| 1579 | |||
| 1580 | switch (mainwin->type) { | ||
| 1581 | case SEPARATE_NONE: | ||
| 1582 | vpaned = cwin->sep_none.vpaned; | ||
| 1583 | container = GTK_WIDGET_PTR(summaryview->qsearch)->parent; | ||
| 1584 | break; | ||
| 1585 | case SEPARATE_FOLDER: | ||
| 1586 | vpaned = cwin->sep_folder.vpaned; | ||
| 1587 | container = GTK_WIDGET_PTR(summaryview->qsearch)->parent; | ||
| 1588 | break; | ||
| 1589 | case SEPARATE_MESSAGE: | ||
| 1590 | msgwin = mainwin->win.sep_message.messagewin; | ||
| 1591 | break; | ||
| 1592 | case SEPARATE_BOTH: | ||
| 1593 | msgwin = mainwin->win.sep_both.messagewin; | ||
| 1594 | break; | ||
| 1595 | } | ||
| 1596 | |||
| 1597 | if (msgwin) { | ||
| 1598 | /* separate message view */ | ||
| 1599 | if (GTK_WIDGET_VISIBLE(msgwin)) { | ||
| 1600 | gtk_widget_hide(msgwin); | ||
| 1601 | mainwin->messageview->visible = FALSE; | ||
| 1602 | summaryview->displayed = NULL; | ||
| 1603 | } else { | ||
| 1604 | gtk_widget_show(msgwin); | ||
| 1605 | mainwin->messageview->visible = TRUE; | ||
| 1606 | } | ||
| 1607 | } else if (vpaned->parent != NULL) { | ||
| 1608 | /* hide message view */ | ||
| 1609 | mainwin->messageview->visible = FALSE; | ||
| 1610 | summaryview->displayed = NULL; | ||
| 1611 | gtk_widget_ref(vpaned); | ||
| 1612 | gtkut_container_remove(GTK_CONTAINER(container), vpaned); | ||
| 1613 | gtk_widget_reparent(GTK_WIDGET_PTR(summaryview), container); | ||
| 1614 | if (!use_vlayout) | ||
| 1615 | gtk_widget_hide(summaryview->hseparator); | ||
| 1616 | } else { | ||
| 1617 | /* show message view */ | ||
| 1618 | mainwin->messageview->visible = TRUE; | ||
| 1619 | gtk_widget_reparent(GTK_WIDGET_PTR(summaryview), vpaned); | ||
| 1620 | gtk_container_add(GTK_CONTAINER(container), vpaned); | ||
| 1621 | gtk_widget_unref(vpaned); | ||
| 1622 | if (!use_vlayout) | ||
| 1623 | gtk_widget_show(summaryview->hseparator); | ||
| 1624 | } | ||
| 1625 | |||
| 1626 | if (messageview_is_visible(mainwin->messageview)) | ||
| 1627 | gtk_arrow_set(GTK_ARROW(mainwin->summaryview->toggle_arrow), | ||
| 1628 | use_vlayout ? GTK_ARROW_RIGHT : GTK_ARROW_DOWN, | ||
| 1629 | GTK_SHADOW_OUT); | ||
| 1630 | else | ||
| 1631 | gtk_arrow_set(GTK_ARROW(mainwin->summaryview->toggle_arrow), | ||
| 1632 | use_vlayout ? GTK_ARROW_LEFT : GTK_ARROW_UP, | ||
| 1633 | GTK_SHADOW_OUT); | ||
| 1634 | |||
| 1635 | if (mainwin->messageview->visible == FALSE) | ||
| 1636 | messageview_clear(mainwin->messageview); | ||
| 1637 | |||
| 1638 | main_window_set_menu_sensitive(mainwin); | ||
| 1639 | |||
| 1640 | prefs_common.msgview_visible = mainwin->messageview->visible; | ||
| 1641 | |||
| 1642 | gtk_widget_grab_focus(summaryview->treeview); | ||
| 1643 | } | ||
| 1644 | |||
| 1645 | void main_window_get_size(MainWindow *mainwin) | ||
| 1646 | { | ||
| 1647 | GtkAllocation *allocation; | ||
| 1648 | gboolean vlayout = (prefs_common.layout_type == LAYOUT_VERTICAL); | ||
| 1649 | |||
| 1650 | allocation = &(GTK_WIDGET_PTR(mainwin->summaryview)->allocation); | ||
| 1651 | if (allocation->width > 1 && allocation->height > 1) { | ||
| 1652 | if (vlayout) { | ||
| 1653 | if (!(mainwin->type & SEPARATE_MESSAGE) && | ||
| 1654 | messageview_is_visible(mainwin->messageview)) | ||
| 1655 | prefs_common.summaryview_vwidth = allocation->width; | ||
| 1656 | prefs_common.summaryview_vheight = allocation->height; | ||
| 1657 | } else { | ||
| 1658 | if (!prefs_common.mainwin_maximized) { | ||
| 1659 | prefs_common.summaryview_width = allocation->width; | ||
| 1660 | prefs_common.mainview_width = allocation->width; | ||
| 1661 | } | ||
| 1662 | if ((mainwin->type == SEPARATE_NONE || | ||
| 1663 | mainwin->type == SEPARATE_FOLDER) && | ||
| 1664 | messageview_is_visible(mainwin->messageview)) | ||
| 1665 | prefs_common.summaryview_height = allocation->height; | ||
| 1666 | } | ||
| 1667 | } | ||
| 1668 | |||
| 1669 | if (prefs_common.mainwin_maximized) { | ||
| 1670 | allocation = &(GTK_WIDGET_PTR(mainwin->folderview)->allocation); | ||
| 1671 | if (allocation->width > 1 && allocation->height > 1) | ||
| 1672 | prefs_common.folderview_width = allocation->width; | ||
| 1673 | return; | ||
| 1674 | } | ||
| 1675 | |||
| 1676 | allocation = &mainwin->window->allocation; | ||
| 1677 | if (allocation->width > 1 && allocation->height > 1) { | ||
| 1678 | prefs_common.mainview_height = allocation->height; | ||
| 1679 | prefs_common.mainwin_width = allocation->width; | ||
| 1680 | prefs_common.mainwin_height = allocation->height; | ||
| 1681 | } | ||
| 1682 | |||
| 1683 | allocation = &(GTK_WIDGET_PTR(mainwin->folderview)->allocation); | ||
| 1684 | if (allocation->width > 1 && allocation->height > 1) { | ||
| 1685 | prefs_common.folderview_width = allocation->width; | ||
| 1686 | prefs_common.folderview_height = allocation->height; | ||
| 1687 | } | ||
| 1688 | |||
| 1689 | allocation = &(GTK_WIDGET_PTR(mainwin->messageview)->allocation); | ||
| 1690 | if (allocation->width > 1 && allocation->height > 1) { | ||
| 1691 | if (vlayout) { | ||
| 1692 | prefs_common.msgview_vwidth = allocation->width; | ||
| 1693 | prefs_common.msgview_vheight = allocation->height; | ||
| 1694 | } else { | ||
| 1695 | prefs_common.msgview_width = allocation->width; | ||
| 1696 | prefs_common.msgview_height = allocation->height; | ||
| 1697 | } | ||
| 1698 | } | ||
| 1699 | |||
| 1700 | #if 0 | ||
| 1701 | debug_print("summaryview size: %d x %d\n", | ||
| 1702 | prefs_common.summaryview_width, | ||
| 1703 | prefs_common.summaryview_height); | ||
| 1704 | debug_print("mainwin size: %d x %d\n", | ||
| 1705 | prefs_common.mainwin_width, | ||
| 1706 | prefs_common.mainwin_height); | ||
| 1707 | debug_print("folderview size: %d x %d\n", | ||
| 1708 | prefs_common.folderview_width, | ||
| 1709 | prefs_common.folderview_height); | ||
| 1710 | debug_print("messageview size: %d x %d\n", | ||
| 1711 | prefs_common.msgview_width, | ||
| 1712 | prefs_common.msgview_height); | ||
| 1713 | #endif | ||
| 1714 | } | ||
| 1715 | |||
| 1716 | void main_window_get_position(MainWindow *mainwin) | ||
| 1717 | { | ||
| 1718 | gint x, y; | ||
| 1719 | GtkWidget *window; | ||
| 1720 | |||
| 1721 | if (prefs_common.mainwin_maximized || mainwin->window_hidden) | ||
| 1722 | return; | ||
| 1723 | |||
| 1724 | gtkut_widget_get_uposition(mainwin->window, &x, &y); | ||
| 1725 | |||
| 1726 | prefs_common.mainview_x = x; | ||
| 1727 | prefs_common.mainview_y = y; | ||
| 1728 | prefs_common.mainwin_x = x; | ||
| 1729 | prefs_common.mainwin_y = y; | ||
| 1730 | |||
| 1731 | debug_print("main window position: %d, %d\n", x, y); | ||
| 1732 | |||
| 1733 | window = main_window_get_folder_window(mainwin); | ||
| 1734 | if (window) { | ||
| 1735 | gtkut_widget_get_uposition(window, &x, &y); | ||
| 1736 | prefs_common.folderwin_x = x; | ||
| 1737 | prefs_common.folderwin_y = y; | ||
| 1738 | debug_print("folder window position: %d, %d\n", x, y); | ||
| 1739 | } | ||
| 1740 | window = main_window_get_message_window(mainwin); | ||
| 1741 | if (window) { | ||
| 1742 | gtkut_widget_get_uposition(window, &x, &y); | ||
| 1743 | prefs_common.main_msgwin_x = x; | ||
| 1744 | prefs_common.main_msgwin_y = y; | ||
| 1745 | debug_print("message window position: %d, %d\n", x, y); | ||
| 1746 | } | ||
| 1747 | } | ||
| 1748 | |||
| 1749 | void main_window_progress_on(MainWindow *mainwin) | ||
| 1750 | { | ||
| 1751 | gtk_progress_set_show_text(GTK_PROGRESS(mainwin->progressbar), TRUE); | ||
| 1752 | gtk_progress_set_format_string(GTK_PROGRESS(mainwin->progressbar), ""); | ||
| 1753 | } | ||
| 1754 | |||
| 1755 | void main_window_progress_off(MainWindow *mainwin) | ||
| 1756 | { | ||
| 1757 | gtk_progress_set_show_text(GTK_PROGRESS(mainwin->progressbar), FALSE); | ||
| 1758 | gtk_progress_bar_update(GTK_PROGRESS_BAR(mainwin->progressbar), 0.0); | ||
| 1759 | gtk_progress_set_format_string(GTK_PROGRESS(mainwin->progressbar), ""); | ||
| 1760 | } | ||
| 1761 | |||
| 1762 | void main_window_progress_set(MainWindow *mainwin, gint cur, gint total) | ||
| 1763 | { | ||
| 1764 | gchar buf[32]; | ||
| 1765 | |||
| 1766 | g_snprintf(buf, sizeof(buf), "%d / %d", cur, total); | ||
| 1767 | gtk_progress_set_format_string(GTK_PROGRESS(mainwin->progressbar), buf); | ||
| 1768 | gtk_progress_bar_update(GTK_PROGRESS_BAR(mainwin->progressbar), | ||
| 1769 | (cur == 0 && total == 0) ? 0 : | ||
| 1770 | (gfloat)cur / (gfloat)total); | ||
| 1771 | } | ||
| 1772 | |||
| 1773 | void main_window_progress_show(gint cur, gint total) | ||
| 1774 | { | ||
| 1775 | MainWindow *mainwin; | ||
| 1776 | |||
| 1777 | mainwin = main_window_get(); | ||
| 1778 | |||
| 1779 | if (total > 0) { | ||
| 1780 | gtk_progress_set_show_text(GTK_PROGRESS(mainwin->progressbar), | ||
| 1781 | TRUE); | ||
| 1782 | main_window_progress_set(mainwin, cur, total); | ||
| 1783 | } else | ||
| 1784 | main_window_progress_off(mainwin); | ||
| 1785 | } | ||
| 1786 | |||
| 1787 | void main_window_toggle_online(MainWindow *mainwin, gboolean online) | ||
| 1788 | { | ||
| 1789 | if (prefs_common.online_mode != online) | ||
| 1790 | online_switch_clicked(mainwin->online_switch, mainwin); | ||
| 1791 | } | ||
| 1792 | |||
| 1793 | gboolean main_window_toggle_online_if_offline(MainWindow *mainwin) | ||
| 1794 | { | ||
| 1795 | if (!prefs_common.online_mode) { | ||
| 1796 | if (alertpanel(_("Offline"), | ||
| 1797 | _("You are offline. Go online?"), | ||
| 1798 | GTK_STOCK_YES, GTK_STOCK_NO, NULL) | ||
| 1799 | == G_ALERTDEFAULT) | ||
| 1800 | main_window_toggle_online(mainwin, TRUE); | ||
| 1801 | } | ||
| 1802 | |||
| 1803 | return prefs_common.online_mode; | ||
| 1804 | } | ||
| 1805 | |||
| 1806 | void main_window_empty_trash(MainWindow *mainwin, gboolean confirm) | ||
| 1807 | { | ||
| 1808 | GList *list; | ||
| 1809 | |||
| 1810 | if (!procmsg_trash_messages_exist()) | ||
| 1811 | return; | ||
| 1812 | |||
| 1813 | if (confirm) { | ||
| 1814 | if (alertpanel(_("Empty all trash"), | ||
| 1815 | _("Delete all messages in trash folders?"), | ||
| 1816 | GTK_STOCK_YES, GTK_STOCK_NO, NULL) | ||
| 1817 | != G_ALERTDEFAULT) | ||
| 1818 | return; | ||
| 1819 | manage_window_focus_in(mainwin->window, NULL, NULL); | ||
| 1820 | } | ||
| 1821 | |||
| 1822 | procmsg_empty_all_trash(); | ||
| 1823 | statusbar_pop_all(); | ||
| 1824 | trayicon_set_tooltip(NULL); | ||
| 1825 | trayicon_set_notify(FALSE); | ||
| 1826 | |||
| 1827 | for (list = folder_get_list(); list != NULL; list = list->next) { | ||
| 1828 | Folder *folder; | ||
| 1829 | |||
| 1830 | folder = list->data; | ||
| 1831 | if (folder->trash) | ||
| 1832 | folderview_update_item(folder->trash, TRUE); | ||
| 1833 | } | ||
| 1834 | |||
| 1835 | if (mainwin->summaryview->folder_item && | ||
| 1836 | mainwin->summaryview->folder_item->stype == F_TRASH) | ||
| 1837 | gtk_widget_grab_focus(mainwin->folderview->treeview); | ||
| 1838 | } | ||
| 1839 | |||
| 1840 | void main_window_add_mailbox(MainWindow *mainwin) | ||
| 1841 | { | ||
| 1842 | gchar *path; | ||
| 1843 | Folder *folder; | ||
| 1844 | |||
| 1845 | path = input_dialog_with_filesel | ||
| 1846 | (_("Add mailbox"), | ||
| 1847 | _("Specify the location of mailbox.\n" | ||
| 1848 | "If the existing mailbox is specified, it will be\n" | ||
| 1849 | "scanned automatically."), | ||
| 1850 | "Mail", GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER); | ||
| 1851 | if (!path) return; | ||
| 1852 | if (folder_find_from_path(path)) { | ||
| 1853 | alertpanel_error(_("The mailbox `%s' already exists."), path); | ||
| 1854 | g_free(path); | ||
| 1855 | return; | ||
| 1856 | } | ||
| 1857 | if (!strcmp(path, "Mail")) | ||
| 1858 | folder = folder_new(F_MH, _("Mailbox"), path); | ||
| 1859 | else | ||
| 1860 | folder = folder_new(F_MH, g_basename(path), path); | ||
| 1861 | g_free(path); | ||
| 1862 | |||
| 1863 | if (folder->klass->create_tree(folder) < 0) { | ||
| 1864 | alertpanel_error(_("Creation of the mailbox failed.\n" | ||
| 1865 | "Maybe some files already exist, or you don't have the permission to write there.")); | ||
| 1866 | folder_destroy(folder); | ||
| 1867 | return; | ||
| 1868 | } | ||
| 1869 | |||
| 1870 | folder_add(folder); | ||
| 1871 | folder_set_ui_func(folder, scan_tree_func, mainwin); | ||
| 1872 | folder->klass->scan_tree(folder); | ||
| 1873 | folder_set_ui_func(folder, NULL, NULL); | ||
| 1874 | |||
| 1875 | folderview_set(mainwin->folderview); | ||
| 1876 | } | ||
| 1877 | |||
| 1878 | void main_window_send_queue(MainWindow *mainwin) | ||
| 1879 | { | ||
| 1880 | GList *list; | ||
| 1881 | |||
| 1882 | if (inc_is_active()) | ||
| 1883 | return; | ||
| 1884 | if (!main_window_toggle_online_if_offline(mainwin)) | ||
| 1885 | return; | ||
| 1886 | |||
| 1887 | for (list = folder_get_list(); list != NULL; list = list->next) { | ||
| 1888 | Folder *folder = list->data; | ||
| 1889 | |||
| 1890 | if (folder->queue) { | ||
| 1891 | gint ret; | ||
| 1892 | |||
| 1893 | ret = send_message_queue_all(folder->queue, | ||
| 1894 | prefs_common.savemsg, | ||
| 1895 | prefs_common.filter_sent); | ||
| 1896 | statusbar_pop_all(); | ||
| 1897 | if (ret > 0) | ||
| 1898 | folder_item_scan(folder->queue); | ||
| 1899 | } | ||
| 1900 | } | ||
| 1901 | |||
| 1902 | folderview_update_all_updated(TRUE); | ||
| 1903 | main_window_set_menu_sensitive(mainwin); | ||
| 1904 | main_window_set_toolbar_sensitive(mainwin); | ||
| 1905 | } | ||
| 1906 | |||
| 1907 | typedef enum | ||
| 1908 | { | ||
| 1909 | M_UNLOCKED = 1 << 0, | ||
| 1910 | M_MSG_EXIST = 1 << 1, | ||
| 1911 | M_TARGET_EXIST = 1 << 2, | ||
| 1912 | M_SINGLE_TARGET_EXIST = 1 << 3, | ||
| 1913 | M_EXEC = 1 << 4, | ||
| 1914 | M_ALLOW_REEDIT = 1 << 5, | ||
| 1915 | M_HAVE_ACCOUNT = 1 << 6, | ||
| 1916 | M_THREADED = 1 << 7, | ||
| 1917 | M_UNTHREADED = 1 << 8, | ||
| 1918 | M_ALLOW_DELETE = 1 << 9, | ||
| 1919 | M_INC_ACTIVE = 1 << 10, | ||
| 1920 | M_ENABLE_JUNK = 1 << 11, | ||
| 1921 | M_HAVE_QUEUED_MSG = 1 << 12, | ||
| 1922 | M_POP3_ACCOUNT = 1 << 13, | ||
| 1923 | |||
| 1924 | M_FOLDER_NEWOK = 1 << 17, | ||
| 1925 | M_FOLDER_RENOK = 1 << 18, | ||
| 1926 | M_FOLDER_MOVEOK = 1 << 19, | ||
| 1927 | M_FOLDER_DELOK = 1 << 20, | ||
| 1928 | M_MBOX_ADDOK = 1 << 21, | ||
| 1929 | M_MBOX_RMOK = 1 << 22, | ||
| 1930 | M_MBOX_CHKOK = 1 << 23, | ||
| 1931 | M_MBOX_CHKALLOK = 1 << 24, | ||
| 1932 | M_MBOX_REBUILDOK = 1 << 25 | ||
| 1933 | } SensitiveCond; | ||
| 1934 | |||
| 1935 | static SensitiveCond main_window_get_current_state(MainWindow *mainwin) | ||
| 1936 | { | ||
| 1937 | SensitiveCond state = 0; | ||
| 1938 | SummarySelection selection; | ||
| 1939 | GList *list; | ||
| 1940 | FolderItem *item = mainwin->summaryview->folder_item; | ||
| 1941 | |||
| 1942 | selection = summary_get_selection_type(mainwin->summaryview); | ||
| 1943 | |||
| 1944 | if (mainwin->lock_count == 0) | ||
| 1945 | state |= M_UNLOCKED; | ||
| 1946 | if (selection != SUMMARY_NONE) | ||
| 1947 | state |= M_MSG_EXIST; | ||
| 1948 | if (item && item->path && item->parent && !item->no_select) { | ||
| 1949 | state |= M_EXEC; | ||
| 1950 | if (item->threaded) | ||
| 1951 | state |= M_THREADED; | ||
| 1952 | else | ||
| 1953 | state |= M_UNTHREADED; | ||
| 1954 | if (FOLDER_TYPE(item->folder) != F_NEWS) | ||
| 1955 | state |= M_ALLOW_DELETE; | ||
| 1956 | } | ||
| 1957 | if (selection == SUMMARY_SELECTED_SINGLE || | ||
| 1958 | selection == SUMMARY_SELECTED_MULTIPLE) | ||
| 1959 | state |= M_TARGET_EXIST; | ||
| 1960 | if (selection == SUMMARY_SELECTED_SINGLE) | ||
| 1961 | state |= M_SINGLE_TARGET_EXIST; | ||
| 1962 | if (selection == SUMMARY_SELECTED_SINGLE && | ||
| 1963 | FOLDER_ITEM_IS_SENT_FOLDER(item)) | ||
| 1964 | state |= M_ALLOW_REEDIT; | ||
| 1965 | if (cur_account) { | ||
| 1966 | state |= M_HAVE_ACCOUNT; | ||
| 1967 | if (cur_account->protocol == A_POP3) | ||
| 1968 | state |= M_POP3_ACCOUNT; | ||
| 1969 | } | ||
| 1970 | |||
| 1971 | if (inc_is_active()) | ||
| 1972 | state |= M_INC_ACTIVE; | ||
| 1973 | |||
| 1974 | if (prefs_common.enable_junk) | ||
| 1975 | state |= M_ENABLE_JUNK; | ||
| 1976 | |||
| 1977 | for (list = folder_get_list(); list != NULL; list = list->next) { | ||
| 1978 | Folder *folder = list->data; | ||
| 1979 | if (folder->queue && folder->queue->total > 0) { | ||
| 1980 | state |= M_HAVE_QUEUED_MSG; | ||
| 1981 | break; | ||
| 1982 | } | ||
| 1983 | } | ||
| 1984 | |||
| 1985 | item = folderview_get_selected_item(mainwin->folderview); | ||
| 1986 | if (item) { | ||
| 1987 | state |= M_FOLDER_NEWOK; | ||
| 1988 | if (item->parent == NULL) { | ||
| 1989 | state |= M_MBOX_RMOK; | ||
| 1990 | state |= M_MBOX_CHKOK; | ||
| 1991 | } | ||
| 1992 | if (FOLDER_IS_LOCAL(item->folder) || | ||
| 1993 | FOLDER_TYPE(item->folder) == F_IMAP) { | ||
| 1994 | if (item->parent == NULL) | ||
| 1995 | state |= M_MBOX_REBUILDOK; | ||
| 1996 | else if (item->stype == F_NORMAL) { | ||
| 1997 | state |= M_FOLDER_RENOK; | ||
| 1998 | state |= M_FOLDER_DELOK; | ||
| 1999 | if (item->folder->klass->move_folder) | ||
| 2000 | state |= M_FOLDER_MOVEOK; | ||
| 2001 | } | ||
| 2002 | } else if (FOLDER_TYPE(item->folder) == F_NEWS) { | ||
| 2003 | if (item->parent != NULL) | ||
| 2004 | state |= M_FOLDER_DELOK; | ||
| 2005 | } | ||
| 2006 | } | ||
| 2007 | state |= M_MBOX_ADDOK; | ||
| 2008 | state |= M_MBOX_CHKALLOK; | ||
| 2009 | |||
| 2010 | return state; | ||
| 2011 | } | ||
| 2012 | |||
| 2013 | void main_window_set_toolbar_sensitive(MainWindow *mainwin) | ||
| 2014 | { | ||
| 2015 | SensitiveCond state; | ||
| 2016 | gboolean sensitive, prev_sensitive; | ||
| 2017 | gint n; | ||
| 2018 | gint i = 0; | ||
| 2019 | |||
| 2020 | struct { | ||
| 2021 | GtkWidget *widget; | ||
| 2022 | SensitiveCond cond; | ||
| 2023 | } entry[20]; | ||
| 2024 | |||
| 2025 | #define SET_WIDGET_COND(w, c) \ | ||
| 2026 | { \ | ||
| 2027 | entry[i].widget = w; \ | ||
| 2028 | entry[i].cond = c; \ | ||
| 2029 | i++; \ | ||
| 2030 | } | ||
| 2031 | |||
| 2032 | SET_WIDGET_COND(mainwin->get_btn, M_HAVE_ACCOUNT|M_UNLOCKED); | ||
| 2033 | SET_WIDGET_COND(mainwin->getall_btn, M_HAVE_ACCOUNT|M_UNLOCKED); | ||
| 2034 | SET_WIDGET_COND(mainwin->rpop3_btn, | ||
| 2035 | M_HAVE_ACCOUNT|M_UNLOCKED|M_POP3_ACCOUNT); | ||
| 2036 | SET_WIDGET_COND(mainwin->send_btn, | ||
| 2037 | M_HAVE_ACCOUNT|M_UNLOCKED|M_HAVE_QUEUED_MSG); | ||
| 2038 | SET_WIDGET_COND(mainwin->compose_btn, M_HAVE_ACCOUNT); | ||
| 2039 | SET_WIDGET_COND(mainwin->reply_btn, | ||
| 2040 | M_HAVE_ACCOUNT|M_SINGLE_TARGET_EXIST); | ||
| 2041 | SET_WIDGET_COND(mainwin->reply_combo ? | ||
| 2042 | GTK_WIDGET_PTR(mainwin->reply_combo) : NULL, | ||
| 2043 | M_HAVE_ACCOUNT|M_SINGLE_TARGET_EXIST); | ||
| 2044 | SET_WIDGET_COND(mainwin->replyall_btn, | ||
| 2045 | M_HAVE_ACCOUNT|M_SINGLE_TARGET_EXIST); | ||
| 2046 | SET_WIDGET_COND(mainwin->fwd_btn, M_HAVE_ACCOUNT|M_TARGET_EXIST); | ||
| 2047 | SET_WIDGET_COND(mainwin->fwd_combo ? GTK_WIDGET_PTR(mainwin->fwd_combo) | ||
| 2048 | : NULL, | ||
| 2049 | M_HAVE_ACCOUNT|M_TARGET_EXIST); | ||
| 2050 | SET_WIDGET_COND(mainwin->delete_btn, | ||
| 2051 | M_TARGET_EXIST|M_ALLOW_DELETE); | ||
| 2052 | SET_WIDGET_COND(mainwin->junk_btn, | ||
| 2053 | M_TARGET_EXIST|M_ALLOW_DELETE|M_ENABLE_JUNK); | ||
| 2054 | SET_WIDGET_COND(mainwin->notjunk_btn, | ||
| 2055 | M_TARGET_EXIST|M_ALLOW_DELETE|M_ENABLE_JUNK); | ||
| 2056 | SET_WIDGET_COND(mainwin->exec_btn, M_MSG_EXIST|M_EXEC); | ||
| 2057 | SET_WIDGET_COND(mainwin->next_btn, M_MSG_EXIST); | ||
| 2058 | SET_WIDGET_COND(mainwin->prev_btn, M_MSG_EXIST); | ||
| 2059 | SET_WIDGET_COND(mainwin->print_btn, M_TARGET_EXIST); | ||
| 2060 | SET_WIDGET_COND(mainwin->stop_btn, M_INC_ACTIVE); | ||
| 2061 | SET_WIDGET_COND(mainwin->prefs_common_btn, M_UNLOCKED); | ||
| 2062 | SET_WIDGET_COND(mainwin->prefs_account_btn, M_HAVE_ACCOUNT|M_UNLOCKED); | ||
| 2063 | |||
| 2064 | #undef SET_WIDGET_COND | ||
| 2065 | |||
| 2066 | state = main_window_get_current_state(mainwin); | ||
| 2067 | |||
| 2068 | n = sizeof(entry) / sizeof(entry[0]); | ||
| 2069 | for (i = 0; i < n; i++) { | ||
| 2070 | if (entry[i].widget) { | ||
| 2071 | prev_sensitive = | ||
| 2072 | GTK_WIDGET_IS_SENSITIVE(entry[i].widget); | ||
| 2073 | sensitive = ((entry[i].cond & state) == entry[i].cond); | ||
| 2074 | if (prev_sensitive != sensitive) { | ||
| 2075 | /* workaround for GTK+ bug (#56070) */ | ||
| 2076 | if (!prev_sensitive) | ||
| 2077 | gtk_widget_hide(entry[i].widget); | ||
| 2078 | gtk_widget_set_sensitive(entry[i].widget, | ||
| 2079 | sensitive); | ||
| 2080 | if (!prev_sensitive) | ||
| 2081 | gtk_widget_show(entry[i].widget); | ||
| 2082 | } | ||
| 2083 | } | ||
| 2084 | } | ||
| 2085 | } | ||
| 2086 | |||
| 2087 | static void main_window_set_toolbar_button_visibility(MainWindow *mainwin) | ||
| 2088 | { | ||
| 2089 | GtkToolbarStyle style = GTK_TOOLBAR_BOTH_HORIZ; | ||
| 2090 | |||
| 2091 | if (prefs_common.toolbar_style == TOOLBAR_NONE) | ||
| 2092 | style = -1; | ||
| 2093 | else if (prefs_common.toolbar_style == TOOLBAR_ICON) | ||
| 2094 | style = GTK_TOOLBAR_ICONS; | ||
| 2095 | else if (prefs_common.toolbar_style == TOOLBAR_TEXT) | ||
| 2096 | style = GTK_TOOLBAR_TEXT; | ||
| 2097 | else if (prefs_common.toolbar_style == TOOLBAR_BOTH) | ||
| 2098 | style = GTK_TOOLBAR_BOTH; | ||
| 2099 | else if (prefs_common.toolbar_style == TOOLBAR_BOTH_HORIZ) | ||
| 2100 | style = GTK_TOOLBAR_BOTH_HORIZ; | ||
| 2101 | |||
| 2102 | if (style != -1) { | ||
| 2103 | gtk_toolbar_set_style(GTK_TOOLBAR(mainwin->toolbar), style); | ||
| 2104 | gtk_widget_show(mainwin->toolbar); | ||
| 2105 | gtk_widget_queue_resize(mainwin->toolbar); | ||
| 2106 | } else | ||
| 2107 | gtk_widget_hide(mainwin->toolbar); | ||
| 2108 | |||
| 2109 | #if 0 | ||
| 2110 | if (mainwin->junk_btn) { | ||
| 2111 | if (prefs_common.enable_junk) | ||
| 2112 | gtk_widget_show(mainwin->junk_btn); | ||
| 2113 | else | ||
| 2114 | gtk_widget_hide(mainwin->junk_btn); | ||
| 2115 | } | ||
| 2116 | |||
| 2117 | if (mainwin->exec_btn) { | ||
| 2118 | if (prefs_common.immediate_exec) | ||
| 2119 | gtk_widget_hide(mainwin->exec_btn); | ||
| 2120 | else | ||
| 2121 | gtk_widget_show(mainwin->exec_btn); | ||
| 2122 | } | ||
| 2123 | #endif | ||
| 2124 | } | ||
| 2125 | |||
| 2126 | void main_window_set_menu_sensitive(MainWindow *mainwin) | ||
| 2127 | { | ||
| 2128 | GtkItemFactory *ifactory = mainwin->menu_factory; | ||
| 2129 | SensitiveCond state; | ||
| 2130 | gboolean sensitive; | ||
| 2131 | GtkWidget *menu; | ||
| 2132 | GtkWidget *menuitem; | ||
| 2133 | FolderItem *item; | ||
| 2134 | gchar *menu_path; | ||
| 2135 | gint i; | ||
| 2136 | GList *cur_item; | ||
| 2137 | |||
| 2138 | static const struct { | ||
| 2139 | gchar *const entry; | ||
| 2140 | SensitiveCond cond; | ||
| 2141 | } entry[] = { | ||
| 2142 | {"/File/Folder/Create new folder...", M_UNLOCKED|M_FOLDER_NEWOK}, | ||
| 2143 | {"/File/Folder/Rename folder..." , M_UNLOCKED|M_FOLDER_RENOK}, | ||
| 2144 | {"/File/Folder/Move folder..." , M_UNLOCKED|M_FOLDER_MOVEOK}, | ||
| 2145 | {"/File/Folder/Delete folder" , M_UNLOCKED|M_FOLDER_DELOK}, | ||
| 2146 | {"/File/Mailbox/Add mailbox..." , M_UNLOCKED|M_MBOX_ADDOK}, | ||
| 2147 | {"/File/Mailbox/Remove mailbox" , M_UNLOCKED|M_MBOX_RMOK}, | ||
| 2148 | {"/File/Mailbox/Check for new messages" | ||
| 2149 | , M_UNLOCKED|M_MBOX_CHKOK}, | ||
| 2150 | {"/File/Mailbox/Check for new messages in all mailboxes" | ||
| 2151 | , M_UNLOCKED|M_MBOX_CHKALLOK}, | ||
| 2152 | {"/File/Mailbox/Rebuild folder tree", M_UNLOCKED|M_MBOX_REBUILDOK}, | ||
| 2153 | {"/File/Import mail data..." , M_UNLOCKED}, | ||
| 2154 | {"/File/Export mail data..." , M_UNLOCKED}, | ||
| 2155 | {"/File/Empty all trash" , M_UNLOCKED}, | ||
| 2156 | |||
| 2157 | {"/File/Save as..." , M_SINGLE_TARGET_EXIST}, | ||
| 2158 | {"/File/Print..." , M_TARGET_EXIST}, | ||
| 2159 | {"/File/Work offline", M_UNLOCKED}, | ||
| 2160 | /* {"/File/Close" , M_UNLOCKED}, */ | ||
| 2161 | {"/File/Exit" , M_UNLOCKED}, | ||
| 2162 | |||
| 2163 | {"/Edit/Select thread" , M_SINGLE_TARGET_EXIST}, | ||
| 2164 | |||
| 2165 | {"/View/Sort" , M_EXEC}, | ||
| 2166 | {"/View/Thread view" , M_EXEC}, | ||
| 2167 | {"/View/Expand all threads" , M_MSG_EXIST}, | ||
| 2168 | {"/View/Collapse all threads" , M_MSG_EXIST}, | ||
| 2169 | {"/View/Go to/Prev message" , M_MSG_EXIST}, | ||
| 2170 | {"/View/Go to/Next message" , M_MSG_EXIST}, | ||
| 2171 | {"/View/Go to/Prev unread message" , M_MSG_EXIST}, | ||
| 2172 | {"/View/Go to/Next unread message" , M_MSG_EXIST}, | ||
| 2173 | {"/View/Go to/Prev new message" , M_MSG_EXIST}, | ||
| 2174 | {"/View/Go to/Next new message" , M_MSG_EXIST}, | ||
| 2175 | {"/View/Go to/Prev marked message" , M_MSG_EXIST}, | ||
| 2176 | {"/View/Go to/Next marked message" , M_MSG_EXIST}, | ||
| 2177 | {"/View/Go to/Prev labeled message", M_MSG_EXIST}, | ||
| 2178 | {"/View/Go to/Next labeled message", M_MSG_EXIST}, | ||
| 2179 | {"/View/Open in new window" , M_SINGLE_TARGET_EXIST}, | ||
| 2180 | {"/View/All headers" , M_SINGLE_TARGET_EXIST}, | ||
| 2181 | {"/View/Message source" , M_SINGLE_TARGET_EXIST}, | ||
| 2182 | |||
| 2183 | {"/Message/Receive/Get from current account" | ||
| 2184 | , M_HAVE_ACCOUNT|M_UNLOCKED}, | ||
| 2185 | {"/Message/Receive/Get from all accounts" | ||
| 2186 | , M_HAVE_ACCOUNT|M_UNLOCKED}, | ||
| 2187 | {"/Message/Receive/Stop receiving" | ||
| 2188 | , M_INC_ACTIVE}, | ||
| 2189 | {"/Message/Receive/Remote mailbox..." | ||
| 2190 | , M_HAVE_ACCOUNT|M_UNLOCKED|M_POP3_ACCOUNT}, | ||
| 2191 | {"/Message/Send queued messages" , M_HAVE_ACCOUNT|M_UNLOCKED|M_HAVE_QUEUED_MSG}, | ||
| 2192 | |||
| 2193 | {"/Message/Compose new message" , M_HAVE_ACCOUNT}, | ||
| 2194 | {"/Message/Reply" , M_HAVE_ACCOUNT|M_SINGLE_TARGET_EXIST}, | ||
| 2195 | {"/Message/Reply to" , M_HAVE_ACCOUNT|M_SINGLE_TARGET_EXIST}, | ||
| 2196 | {"/Message/Forward" , M_HAVE_ACCOUNT|M_TARGET_EXIST}, | ||
| 2197 | {"/Message/Forward as attachment", M_HAVE_ACCOUNT|M_TARGET_EXIST}, | ||
| 2198 | {"/Message/Redirect" , M_HAVE_ACCOUNT|M_SINGLE_TARGET_EXIST}, | ||
| 2199 | {"/Message/Move..." , M_TARGET_EXIST|M_ALLOW_DELETE}, | ||
| 2200 | {"/Message/Copy..." , M_TARGET_EXIST|M_EXEC}, | ||
| 2201 | {"/Message/Delete" , M_TARGET_EXIST|M_ALLOW_DELETE}, | ||
| 2202 | {"/Message/Mark" , M_TARGET_EXIST}, | ||
| 2203 | {"/Message/Set as junk mail" , M_TARGET_EXIST|M_ALLOW_DELETE|M_ENABLE_JUNK}, | ||
| 2204 | {"/Message/Set as not junk mail" , M_TARGET_EXIST|M_ALLOW_DELETE|M_ENABLE_JUNK}, | ||
| 2205 | {"/Message/Re-edit" , M_HAVE_ACCOUNT|M_ALLOW_REEDIT}, | ||
| 2206 | |||
| 2207 | {"/Tools/Add sender to address book...", M_SINGLE_TARGET_EXIST}, | ||
| 2208 | {"/Tools/Filter all messages in folder", M_MSG_EXIST|M_EXEC}, | ||
| 2209 | {"/Tools/Filter selected messages" , M_TARGET_EXIST|M_EXEC}, | ||
| 2210 | {"/Tools/Create filter rule" , M_SINGLE_TARGET_EXIST|M_UNLOCKED}, | ||
| 2211 | {"/Tools/Filter junk mails in folder" , M_MSG_EXIST|M_EXEC|M_ENABLE_JUNK}, | ||
| 2212 | {"/Tools/Filter junk mails in selected messages", M_TARGET_EXIST|M_EXEC|M_ENABLE_JUNK}, | ||
| 2213 | #ifndef G_OS_WIN32 | ||
| 2214 | {"/Tools/Actions" , M_TARGET_EXIST|M_UNLOCKED}, | ||
| 2215 | #endif | ||
| 2216 | {"/Tools/Execute marked process" , M_MSG_EXIST|M_EXEC}, | ||
| 2217 | {"/Tools/Delete duplicated messages" , M_MSG_EXIST|M_ALLOW_DELETE}, | ||
| 2218 | {"/Tools/Concatenate separated messages" | ||
| 2219 | , M_TARGET_EXIST|M_UNLOCKED|M_ALLOW_DELETE}, | ||
| 2220 | |||
| 2221 | {"/Configuration/Common preferences...", M_UNLOCKED}, | ||
| 2222 | {"/Configuration/Filter settings...", M_UNLOCKED}, | ||
| 2223 | {"/Configuration/Preferences for current account...", M_UNLOCKED}, | ||
| 2224 | {"/Configuration/Create new account...", M_UNLOCKED}, | ||
| 2225 | {"/Configuration/Edit accounts...", M_UNLOCKED}, | ||
| 2226 | {"/Configuration/Change current account", M_UNLOCKED}, | ||
| 2227 | |||
| 2228 | {NULL, 0} | ||
| 2229 | }; | ||
| 2230 | |||
| 2231 | state = main_window_get_current_state(mainwin); | ||
| 2232 | |||
| 2233 | for (i = 0; entry[i].entry != NULL; i++) { | ||
| 2234 | sensitive = ((entry[i].cond & state) == entry[i].cond); | ||
| 2235 | menu_set_sensitive(ifactory, entry[i].entry, sensitive); | ||
| 2236 | } | ||
| 2237 | |||
| 2238 | menu = gtk_item_factory_get_widget(ifactory, "/Message/Receive"); | ||
| 2239 | |||
| 2240 | /* search for separator */ | ||
| 2241 | for (cur_item = GTK_MENU_SHELL(menu)->children; cur_item != NULL; | ||
| 2242 | cur_item = cur_item->next) { | ||
| 2243 | if (GTK_BIN(cur_item->data)->child == NULL) { | ||
| 2244 | cur_item = cur_item->next; | ||
| 2245 | break; | ||
| 2246 | } | ||
| 2247 | } | ||
| 2248 | |||
| 2249 | for (; cur_item != NULL; cur_item = cur_item->next) { | ||
| 2250 | gtk_widget_set_sensitive(GTK_WIDGET(cur_item->data), | ||
| 2251 | (M_UNLOCKED & state) != 0); | ||
| 2252 | } | ||
| 2253 | |||
| 2254 | main_window_menu_callback_block(mainwin); | ||
| 2255 | |||
| 2256 | #define SET_CHECK_MENU_ACTIVE(path, active) \ | ||
| 2257 | { \ | ||
| 2258 | menuitem = gtk_item_factory_get_widget(ifactory, path); \ | ||
| 2259 | gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), active); \ | ||
| 2260 | } | ||
| 2261 | |||
| 2262 | SET_CHECK_MENU_ACTIVE("/View/Show or hide/Message view", | ||
| 2263 | messageview_is_visible(mainwin->messageview)); | ||
| 2264 | |||
| 2265 | item = mainwin->summaryview->folder_item; | ||
| 2266 | menu_path = "/View/Sort/Don't sort"; | ||
| 2267 | if (item) { | ||
| 2268 | switch (item->sort_key) { | ||
| 2269 | case SORT_BY_NUMBER: | ||
| 2270 | menu_path = "/View/Sort/by number"; break; | ||
| 2271 | case SORT_BY_SIZE: | ||
| 2272 | menu_path = "/View/Sort/by size"; break; | ||
| 2273 | case SORT_BY_DATE: | ||
| 2274 | menu_path = "/View/Sort/by date"; break; | ||
| 2275 | case SORT_BY_TDATE: | ||
| 2276 | menu_path = "/View/Sort/by thread date"; break; | ||
| 2277 | case SORT_BY_FROM: | ||
| 2278 | menu_path = "/View/Sort/by from"; break; | ||
| 2279 | case SORT_BY_TO: | ||
| 2280 | menu_path = "/View/Sort/by recipient"; break; | ||
| 2281 | case SORT_BY_SUBJECT: | ||
| 2282 | menu_path = "/View/Sort/by subject"; break; | ||
| 2283 | case SORT_BY_LABEL: | ||
| 2284 | menu_path = "/View/Sort/by color label"; break; | ||
| 2285 | case SORT_BY_MARK: | ||
| 2286 | menu_path = "/View/Sort/by mark"; break; | ||
| 2287 | case SORT_BY_UNREAD: | ||
| 2288 | menu_path = "/View/Sort/by unread"; break; | ||
| 2289 | case SORT_BY_MIME: | ||
| 2290 | menu_path = "/View/Sort/by attachment"; break; | ||
| 2291 | case SORT_BY_NONE: | ||
| 2292 | default: | ||
| 2293 | menu_path = "/View/Sort/Don't sort"; break; | ||
| 2294 | } | ||
| 2295 | } | ||
| 2296 | SET_CHECK_MENU_ACTIVE(menu_path, TRUE); | ||
| 2297 | |||
| 2298 | if (!item || item->sort_type == SORT_ASCENDING) { | ||
| 2299 | SET_CHECK_MENU_ACTIVE("/View/Sort/Ascending", TRUE); | ||
| 2300 | } else { | ||
| 2301 | SET_CHECK_MENU_ACTIVE("/View/Sort/Descending", TRUE); | ||
| 2302 | } | ||
| 2303 | |||
| 2304 | if (item && item->sort_key != SORT_BY_NONE) { | ||
| 2305 | menu_set_sensitive(ifactory, "/View/Sort/Ascending", TRUE); | ||
| 2306 | menu_set_sensitive(ifactory, "/View/Sort/Descending", TRUE); | ||
| 2307 | menu_set_sensitive(ifactory, "/View/Sort/Attract by subject", | ||
| 2308 | FALSE); | ||
| 2309 | } else { | ||
| 2310 | menu_set_sensitive(ifactory, "/View/Sort/Ascending", FALSE); | ||
| 2311 | menu_set_sensitive(ifactory, "/View/Sort/Descending", FALSE); | ||
| 2312 | menu_set_sensitive(ifactory, "/View/Sort/Attract by subject", | ||
| 2313 | (item != NULL)); | ||
| 2314 | } | ||
| 2315 | |||
| 2316 | SET_CHECK_MENU_ACTIVE("/View/All headers", | ||
| 2317 | mainwin->messageview->textview->show_all_headers); | ||
| 2318 | SET_CHECK_MENU_ACTIVE("/View/Thread view", (state & M_THREADED) != 0); | ||
| 2319 | |||
| 2320 | #undef SET_CHECK_MENU_ACTIVE | ||
| 2321 | |||
| 2322 | main_window_menu_callback_unblock(mainwin); | ||
| 2323 | } | ||
| 2324 | |||
| 2325 | void main_window_popup(MainWindow *mainwin) | ||
| 2326 | { | ||
| 2327 | gtkut_window_popup(mainwin->window); | ||
| 2328 | |||
| 2329 | switch (mainwin->type) { | ||
| 2330 | case SEPARATE_FOLDER: | ||
| 2331 | if (prefs_common.folderview_visible) | ||
| 2332 | gtkut_window_popup(mainwin->win.sep_folder.folderwin); | ||
| 2333 | break; | ||
| 2334 | case SEPARATE_MESSAGE: | ||
| 2335 | if (messageview_is_visible(mainwin->messageview)) | ||
| 2336 | gtkut_window_popup(mainwin->win.sep_message.messagewin); | ||
| 2337 | break; | ||
| 2338 | case SEPARATE_BOTH: | ||
| 2339 | if (prefs_common.folderview_visible) | ||
| 2340 | gtkut_window_popup(mainwin->win.sep_both.folderwin); | ||
| 2341 | if (messageview_is_visible(mainwin->messageview)) | ||
| 2342 | gtkut_window_popup(mainwin->win.sep_both.messagewin); | ||
| 2343 | break; | ||
| 2344 | default: | ||
| 2345 | break; | ||
| 2346 | } | ||
| 2347 | } | ||
| 2348 | |||
| 2349 | static void main_window_set_widgets(MainWindow *mainwin, LayoutType layout, | ||
| 2350 | SeparateType type) | ||
| 2351 | { | ||
| 2352 | GtkWidget *folderwin = NULL; | ||
| 2353 | GtkWidget *messagewin = NULL; | ||
| 2354 | GtkWidget *hpaned; | ||
| 2355 | GtkWidget *vpaned; | ||
| 2356 | GtkWidget *vbox_body = mainwin->vbox_body; | ||
| 2357 | GtkWidget *vbox_summary; | ||
| 2358 | GtkItemFactory *ifactory = mainwin->menu_factory; | ||
| 2359 | GtkWidget *menuitem; | ||
| 2360 | gboolean use_vlayout = (layout == LAYOUT_VERTICAL); | ||
| 2361 | |||
| 2362 | debug_print("Setting main window widgets...\n"); | ||
| 2363 | |||
| 2364 | gtk_widget_set_size_request(GTK_WIDGET_PTR(mainwin->folderview), | ||
| 2365 | prefs_common.folderview_width, | ||
| 2366 | prefs_common.folderview_height); | ||
| 2367 | if (use_vlayout) { | ||
| 2368 | gtk_widget_set_size_request | ||
| 2369 | (GTK_WIDGET_PTR(mainwin->summaryview), | ||
| 2370 | prefs_common.summaryview_vwidth, | ||
| 2371 | prefs_common.summaryview_vheight); | ||
| 2372 | gtk_widget_set_size_request | ||
| 2373 | (GTK_WIDGET_PTR(mainwin->messageview), | ||
| 2374 | prefs_common.msgview_vwidth, | ||
| 2375 | prefs_common.msgview_vheight); | ||
| 2376 | } else { | ||
| 2377 | gtk_widget_set_size_request | ||
| 2378 | (GTK_WIDGET_PTR(mainwin->summaryview), | ||
| 2379 | prefs_common.summaryview_width, | ||
| 2380 | prefs_common.summaryview_height); | ||
| 2381 | gtk_widget_set_size_request | ||
| 2382 | (GTK_WIDGET_PTR(mainwin->messageview), | ||
| 2383 | prefs_common.msgview_width, | ||
| 2384 | prefs_common.msgview_height); | ||
| 2385 | } | ||
| 2386 | |||
| 2387 | /* create separated window(s) if needed */ | ||
| 2388 | if (type & SEPARATE_FOLDER) { | ||
| 2389 | folderwin = gtk_window_new(GTK_WINDOW_TOPLEVEL); | ||
| 2390 | gtk_window_set_title(GTK_WINDOW(folderwin), | ||
| 2391 | _("Sylpheed - Folder View")); | ||
| 2392 | gtk_window_set_wmclass(GTK_WINDOW(folderwin), | ||
| 2393 | "folder_view", "Sylpheed"); | ||
| 2394 | gtk_window_set_policy(GTK_WINDOW(folderwin), | ||
| 2395 | TRUE, TRUE, FALSE); | ||
| 2396 | gtkut_window_move(GTK_WINDOW(folderwin), | ||
| 2397 | prefs_common.folderwin_x, | ||
| 2398 | prefs_common.folderwin_y); | ||
| 2399 | gtk_container_set_border_width(GTK_CONTAINER(folderwin), 0); | ||
| 2400 | g_signal_connect(G_OBJECT(folderwin), "delete_event", | ||
| 2401 | G_CALLBACK(folder_window_close_cb), mainwin); | ||
| 2402 | gtk_container_add(GTK_CONTAINER(folderwin), | ||
| 2403 | GTK_WIDGET_PTR(mainwin->folderview)); | ||
| 2404 | gtk_widget_realize(folderwin); | ||
| 2405 | if (prefs_common.folderview_visible) | ||
| 2406 | gtk_widget_show(folderwin); | ||
| 2407 | } | ||
| 2408 | if (type & SEPARATE_MESSAGE) { | ||
| 2409 | messagewin = gtk_window_new(GTK_WINDOW_TOPLEVEL); | ||
| 2410 | gtk_window_set_title(GTK_WINDOW(messagewin), | ||
| 2411 | _("Sylpheed - Message View")); | ||
| 2412 | gtk_window_set_wmclass(GTK_WINDOW(messagewin), | ||
| 2413 | "message_view", "Sylpheed"); | ||
| 2414 | gtk_window_set_policy(GTK_WINDOW(messagewin), | ||
| 2415 | TRUE, TRUE, FALSE); | ||
| 2416 | gtkut_window_move(GTK_WINDOW(messagewin), | ||
| 2417 | prefs_common.main_msgwin_x, | ||
| 2418 | prefs_common.main_msgwin_y); | ||
| 2419 | gtk_container_set_border_width(GTK_CONTAINER(messagewin), 0); | ||
| 2420 | g_signal_connect(G_OBJECT(messagewin), "delete_event", | ||
| 2421 | G_CALLBACK(message_window_close_cb), mainwin); | ||
| 2422 | gtk_container_add(GTK_CONTAINER(messagewin), | ||
| 2423 | GTK_WIDGET_PTR(mainwin->messageview)); | ||
| 2424 | gtk_widget_realize(messagewin); | ||
| 2425 | if (messageview_is_visible(mainwin->messageview)) | ||
| 2426 | gtk_widget_show(messagewin); | ||
| 2427 | } | ||
| 2428 | |||
| 2429 | vbox_summary = gtk_vbox_new(FALSE, 1); | ||
| 2430 | gtk_box_pack_start(GTK_BOX(vbox_summary), | ||
| 2431 | GTK_WIDGET_PTR(mainwin->summaryview->qsearch), | ||
| 2432 | FALSE, FALSE, 0); | ||
| 2433 | gtk_widget_show(vbox_summary); | ||
| 2434 | |||
| 2435 | switch (type) { | ||
| 2436 | case SEPARATE_NONE: | ||
| 2437 | hpaned = gtk_hpaned_new(); | ||
| 2438 | gtk_box_pack_start(GTK_BOX(vbox_body), hpaned, TRUE, TRUE, 0); | ||
| 2439 | gtk_paned_add1(GTK_PANED(hpaned), | ||
| 2440 | GTK_WIDGET_PTR(mainwin->folderview)); | ||
| 2441 | gtk_paned_add2(GTK_PANED(hpaned), vbox_summary); | ||
| 2442 | gtk_widget_show(hpaned); | ||
| 2443 | gtk_widget_queue_resize(hpaned); | ||
| 2444 | |||
| 2445 | if (use_vlayout) { | ||
| 2446 | vpaned = gtk_hpaned_new(); | ||
| 2447 | gtk_widget_hide(mainwin->summaryview->hseparator); | ||
| 2448 | } else | ||
| 2449 | vpaned = gtk_vpaned_new(); | ||
| 2450 | if (messageview_is_visible(mainwin->messageview)) { | ||
| 2451 | gtk_paned_add1(GTK_PANED(vpaned), | ||
| 2452 | GTK_WIDGET_PTR(mainwin->summaryview)); | ||
| 2453 | gtk_box_pack_start(GTK_BOX(vbox_summary), vpaned, | ||
| 2454 | TRUE, TRUE, 0); | ||
| 2455 | if (!use_vlayout) | ||
| 2456 | gtk_widget_show | ||
| 2457 | (mainwin->summaryview->hseparator); | ||
| 2458 | } else { | ||
| 2459 | gtk_box_pack_start(GTK_BOX(vbox_summary), | ||
| 2460 | GTK_WIDGET_PTR(mainwin->summaryview), | ||
| 2461 | TRUE, TRUE, 0); | ||
| 2462 | gtk_widget_ref(vpaned); | ||
| 2463 | gtk_widget_hide(mainwin->summaryview->hseparator); | ||
| 2464 | } | ||
| 2465 | gtk_paned_add2(GTK_PANED(vpaned), | ||
| 2466 | GTK_WIDGET_PTR(mainwin->messageview)); | ||
| 2467 | gtk_widget_show(vpaned); | ||
| 2468 | gtk_widget_queue_resize(vpaned); | ||
| 2469 | |||
| 2470 | mainwin->win.sep_none.hpaned = hpaned; | ||
| 2471 | mainwin->win.sep_none.vpaned = vpaned; | ||
| 2472 | |||
| 2473 | break; | ||
| 2474 | case SEPARATE_FOLDER: | ||
| 2475 | gtk_box_pack_start(GTK_BOX(vbox_body), vbox_summary, | ||
| 2476 | TRUE, TRUE, 0); | ||
| 2477 | |||
| 2478 | if (use_vlayout) { | ||
| 2479 | vpaned = gtk_hpaned_new(); | ||
| 2480 | gtk_widget_hide(mainwin->summaryview->hseparator); | ||
| 2481 | } else | ||
| 2482 | vpaned = gtk_vpaned_new(); | ||
| 2483 | if (messageview_is_visible(mainwin->messageview)) { | ||
| 2484 | gtk_paned_add1(GTK_PANED(vpaned), | ||
| 2485 | GTK_WIDGET_PTR(mainwin->summaryview)); | ||
| 2486 | gtk_box_pack_start(GTK_BOX(vbox_summary), vpaned, | ||
| 2487 | TRUE, TRUE, 0); | ||
| 2488 | if (!use_vlayout) | ||
| 2489 | gtk_widget_show | ||
| 2490 | (mainwin->summaryview->hseparator); | ||
| 2491 | } else { | ||
| 2492 | gtk_box_pack_start(GTK_BOX(vbox_summary), | ||
| 2493 | GTK_WIDGET_PTR(mainwin->summaryview), | ||
| 2494 | TRUE, TRUE, 0); | ||
| 2495 | gtk_widget_ref(vpaned); | ||
| 2496 | gtk_widget_hide(mainwin->summaryview->hseparator); | ||
| 2497 | } | ||
| 2498 | gtk_paned_add2(GTK_PANED(vpaned), | ||
| 2499 | GTK_WIDGET_PTR(mainwin->messageview)); | ||
| 2500 | gtk_widget_show(vpaned); | ||
| 2501 | gtk_widget_queue_resize(vpaned); | ||
| 2502 | |||
| 2503 | mainwin->win.sep_folder.folderwin = folderwin; | ||
| 2504 | mainwin->win.sep_folder.vpaned = vpaned; | ||
| 2505 | |||
| 2506 | break; | ||
| 2507 | case SEPARATE_MESSAGE: | ||
| 2508 | hpaned = gtk_hpaned_new(); | ||
| 2509 | gtk_box_pack_start(GTK_BOX(vbox_body), hpaned, TRUE, TRUE, 0); | ||
| 2510 | gtk_paned_add1(GTK_PANED(hpaned), | ||
| 2511 | GTK_WIDGET_PTR(mainwin->folderview)); | ||
| 2512 | gtk_paned_add2(GTK_PANED(hpaned), vbox_summary); | ||
| 2513 | gtk_box_pack_start(GTK_BOX(vbox_summary), | ||
| 2514 | GTK_WIDGET_PTR(mainwin->summaryview), | ||
| 2515 | TRUE, TRUE, 0); | ||
| 2516 | gtk_widget_hide(mainwin->summaryview->hseparator); | ||
| 2517 | gtk_widget_show(hpaned); | ||
| 2518 | gtk_widget_queue_resize(hpaned); | ||
| 2519 | |||
| 2520 | mainwin->win.sep_message.messagewin = messagewin; | ||
| 2521 | mainwin->win.sep_message.hpaned = hpaned; | ||
| 2522 | |||
| 2523 | break; | ||
| 2524 | case SEPARATE_BOTH: | ||
| 2525 | gtk_box_pack_start(GTK_BOX(vbox_body), vbox_summary, | ||
| 2526 | TRUE, TRUE, 0); | ||
| 2527 | gtk_box_pack_start(GTK_BOX(vbox_summary), | ||
| 2528 | GTK_WIDGET_PTR(mainwin->summaryview), | ||
| 2529 | TRUE, TRUE, 0); | ||
| 2530 | gtk_widget_hide(mainwin->summaryview->hseparator); | ||
| 2531 | |||
| 2532 | mainwin->win.sep_both.folderwin = folderwin; | ||
| 2533 | mainwin->win.sep_both.messagewin = messagewin; | ||
| 2534 | |||
| 2535 | break; | ||
| 2536 | } | ||
| 2537 | |||
| 2538 | if (messageview_is_visible(mainwin->messageview)) | ||
| 2539 | gtk_arrow_set(GTK_ARROW(mainwin->summaryview->toggle_arrow), | ||
| 2540 | use_vlayout ? GTK_ARROW_RIGHT : GTK_ARROW_DOWN, | ||
| 2541 | GTK_SHADOW_OUT); | ||
| 2542 | else | ||
| 2543 | gtk_arrow_set(GTK_ARROW(mainwin->summaryview->toggle_arrow), | ||
| 2544 | use_vlayout ? GTK_ARROW_LEFT : GTK_ARROW_UP, | ||
| 2545 | GTK_SHADOW_OUT); | ||
| 2546 | |||
| 2547 | gtkut_window_move(GTK_WINDOW(mainwin->window), | ||
| 2548 | prefs_common.mainwin_x, prefs_common.mainwin_y); | ||
| 2549 | |||
| 2550 | gtk_widget_queue_resize(vbox_body); | ||
| 2551 | gtk_widget_queue_resize(mainwin->vbox); | ||
| 2552 | gtk_widget_queue_resize(mainwin->window); | ||
| 2553 | |||
| 2554 | mainwin->type = type; | ||
| 2555 | prefs_common.layout_type = layout; | ||
| 2556 | |||
| 2557 | /* toggle menu state */ | ||
| 2558 | menuitem = gtk_item_factory_get_item | ||
| 2559 | (ifactory, "/View/Show or hide/Folder tree"); | ||
| 2560 | gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), | ||
| 2561 | (type & SEPARATE_FOLDER) == 0 ? TRUE : | ||
| 2562 | prefs_common.folderview_visible); | ||
| 2563 | gtk_widget_set_sensitive(menuitem, ((type & SEPARATE_FOLDER) != 0)); | ||
| 2564 | menuitem = gtk_item_factory_get_item | ||
| 2565 | (ifactory, "/View/Show or hide/Message view"); | ||
| 2566 | gtk_check_menu_item_set_active | ||
| 2567 | (GTK_CHECK_MENU_ITEM(menuitem), | ||
| 2568 | messageview_is_visible(mainwin->messageview)); | ||
| 2569 | |||
| 2570 | if (layout == LAYOUT_NORMAL) { | ||
| 2571 | menuitem = gtk_item_factory_get_item | ||
| 2572 | (ifactory, "/View/Layout/Normal"); | ||
| 2573 | gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), | ||
| 2574 | TRUE); | ||
| 2575 | } else if (layout == LAYOUT_VERTICAL) { | ||
| 2576 | menuitem = gtk_item_factory_get_item | ||
| 2577 | (ifactory, "/View/Layout/Vertical"); | ||
| 2578 | gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), | ||
| 2579 | TRUE); | ||
| 2580 | } | ||
| 2581 | |||
| 2582 | menuitem = gtk_item_factory_get_item | ||
| 2583 | (ifactory, "/View/Separate folder tree"); | ||
| 2584 | gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), | ||
| 2585 | ((type & SEPARATE_FOLDER) != 0)); | ||
| 2586 | menuitem = gtk_item_factory_get_item | ||
| 2587 | (ifactory, "/View/Separate message view"); | ||
| 2588 | gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), | ||
| 2589 | ((type & SEPARATE_MESSAGE) != 0)); | ||
| 2590 | |||
| 2591 | if (folderwin) { | ||
| 2592 | g_signal_connect | ||
| 2593 | (G_OBJECT(folderwin), "size_allocate", | ||
| 2594 | G_CALLBACK(folder_window_size_allocate_cb), mainwin); | ||
| 2595 | } | ||
| 2596 | if (messagewin) { | ||
| 2597 | g_signal_connect | ||
| 2598 | (G_OBJECT(messagewin), "size_allocate", | ||
| 2599 | G_CALLBACK(message_window_size_allocate_cb), mainwin); | ||
| 2600 | } | ||
| 2601 | |||
| 2602 | debug_print("done.\n"); | ||
| 2603 | } | ||
| 2604 | |||
| 2605 | static GtkItemFactoryEntry reply_entries[] = | ||
| 2606 | { | ||
| 2607 | {N_("/_Reply"), NULL, reply_cb, COMPOSE_REPLY, NULL}, | ||
| 2608 | {N_("/Reply to _all"), NULL, reply_cb, COMPOSE_REPLY_TO_ALL, NULL}, | ||
| 2609 | {N_("/Reply to _sender"), NULL, reply_cb, COMPOSE_REPLY_TO_SENDER, NULL}, | ||
| 2610 | {N_("/Reply to mailing _list"), NULL, reply_cb, COMPOSE_REPLY_TO_LIST, NULL} | ||
| 2611 | }; | ||
| 2612 | |||
| 2613 | static GtkItemFactoryEntry forward_entries[] = | ||
| 2614 | { | ||
| 2615 | {N_("/_Forward"), NULL, reply_cb, COMPOSE_FORWARD, NULL}, | ||
| 2616 | {N_("/For_ward as attachment"), NULL, reply_cb, COMPOSE_FORWARD_AS_ATTACH, NULL}, | ||
| 2617 | {N_("/Redirec_t"), NULL, reply_cb, COMPOSE_REDIRECT, NULL} | ||
| 2618 | }; | ||
| 2619 | |||
| 2620 | static PrefsToolbarItem items[] = | ||
| 2621 | { | ||
| 2622 | {T_GET, TRUE, toolbar_inc_cb}, | ||
| 2623 | {T_GET_ALL, TRUE, toolbar_inc_all_cb}, | ||
| 2624 | {T_SEND_QUEUE, TRUE, toolbar_send_cb}, | ||
| 2625 | {T_COMPOSE, TRUE, toolbar_compose_cb}, | ||
| 2626 | {T_REPLY, TRUE, toolbar_reply_cb}, | ||
| 2627 | {T_REPLY_ALL, TRUE, toolbar_reply_to_all_cb}, | ||
| 2628 | {T_FORWARD, TRUE, toolbar_forward_cb}, | ||
| 2629 | {T_DELETE, FALSE, toolbar_delete_cb}, | ||
| 2630 | {T_JUNK, TRUE, toolbar_junk_cb}, | ||
| 2631 | {T_NOTJUNK, FALSE, toolbar_notjunk_cb}, | ||
| 2632 | {T_NEXT, FALSE, toolbar_next_unread_cb}, | ||
| 2633 | {T_PREV, FALSE, toolbar_prev_unread_cb}, | ||
| 2634 | {T_SEARCH, FALSE, toolbar_search_cb}, | ||
| 2635 | {T_PRINT, FALSE, toolbar_print_cb}, | ||
| 2636 | {T_STOP, FALSE, toolbar_stop_cb}, | ||
| 2637 | {T_ADDRESS_BOOK, FALSE, toolbar_address_cb}, | ||
| 2638 | {T_EXECUTE, FALSE, toolbar_exec_cb}, | ||
| 2639 | {T_COMMON_PREFS, FALSE, toolbar_prefs_common_cb}, | ||
| 2640 | {T_ACCOUNT_PREFS, FALSE, toolbar_prefs_account_cb}, | ||
| 2641 | {T_REMOTE_MAILBOX, FALSE, toolbar_rpop3_cb}, | ||
| 2642 | |||
| 2643 | {-1, FALSE, NULL} | ||
| 2644 | }; | ||
| 2645 | |||
| 2646 | static GtkWidget *main_window_toolbar_create(MainWindow *mainwin) | ||
| 2647 | { | ||
| 2648 | GtkWidget *toolbar; | ||
| 2649 | const gchar *setting; | ||
| 2650 | GList *item_list; | ||
| 2651 | |||
| 2652 | if (prefs_common.main_toolbar_setting && | ||
| 2653 | *prefs_common.main_toolbar_setting != '\0') | ||
| 2654 | setting = prefs_common.main_toolbar_setting; | ||
| 2655 | else | ||
| 2656 | setting = prefs_toolbar_get_default_main_setting_name_list(); | ||
| 2657 | |||
| 2658 | item_list = prefs_toolbar_get_item_list_from_name_list(setting); | ||
| 2659 | toolbar = main_window_toolbar_create_from_list(mainwin, item_list); | ||
| 2660 | g_list_free(item_list); | ||
| 2661 | |||
| 2662 | return toolbar; | ||
| 2663 | } | ||
| 2664 | |||
| 2665 | static GtkWidget *main_window_toolbar_create_from_list(MainWindow *mainwin, | ||
| 2666 | GList *item_list) | ||
| 2667 | { | ||
| 2668 | GtkWidget *toolbar; | ||
| 2669 | GtkWidget *icon_wid; | ||
| 2670 | GtkToolItem *toolitem; | ||
| 2671 | GtkToolItem *comboitem; | ||
| 2672 | ComboButton *combo; | ||
| 2673 | gint n_entries; | ||
| 2674 | gint i; | ||
| 2675 | GList *cur; | ||
| 2676 | |||
| 2677 | toolbar = gtk_toolbar_new(); | ||
| 2678 | gtk_toolbar_set_orientation(GTK_TOOLBAR(toolbar), | ||
| 2679 | GTK_ORIENTATION_HORIZONTAL); | ||
| 2680 | gtk_toolbar_set_style(GTK_TOOLBAR(toolbar), GTK_TOOLBAR_BOTH); | ||
| 2681 | g_signal_connect(G_OBJECT(toolbar), "button_press_event", | ||
| 2682 | G_CALLBACK(toolbar_button_pressed), mainwin); | ||
| 2683 | |||
| 2684 | items[0].data = &mainwin->get_btn; | ||
| 2685 | items[1].data = &mainwin->getall_btn; | ||
| 2686 | items[2].data = &mainwin->send_btn; | ||
| 2687 | items[3].data = &mainwin->compose_btn; | ||
| 2688 | items[4].data = &mainwin->reply_btn; | ||
| 2689 | items[5].data = &mainwin->replyall_btn; | ||
| 2690 | items[6].data = &mainwin->fwd_btn; | ||
| 2691 | items[7].data = &mainwin->delete_btn; | ||
| 2692 | items[8].data = &mainwin->junk_btn; | ||
| 2693 | items[9].data = &mainwin->notjunk_btn; | ||
| 2694 | items[10].data = &mainwin->next_btn; | ||
| 2695 | items[11].data = &mainwin->prev_btn; | ||
| 2696 | items[12].data = &mainwin->search_btn; | ||
| 2697 | items[13].data = &mainwin->print_btn; | ||
| 2698 | items[14].data = &mainwin->stop_btn; | ||
| 2699 | items[15].data = &mainwin->address_btn; | ||
| 2700 | items[16].data = &mainwin->exec_btn; | ||
| 2701 | items[17].data = &mainwin->prefs_common_btn; | ||
| 2702 | items[18].data = &mainwin->prefs_account_btn; | ||
| 2703 | items[19].data = &mainwin->rpop3_btn; | ||
| 2704 | for (i = 0; i <= 19; i++) | ||
| 2705 | *(GtkWidget **)items[i].data = NULL; | ||
| 2706 | mainwin->reply_combo = NULL; | ||
| 2707 | mainwin->fwd_combo = NULL; | ||
| 2708 | |||
| 2709 | for (cur = item_list; cur != NULL; cur = cur->next) { | ||
| 2710 | const PrefsDisplayItem *ditem = cur->data; | ||
| 2711 | PrefsToolbarItem *item; | ||
| 2712 | gint width; | ||
| 2713 | |||
| 2714 | if (ditem->id == T_SEPARATOR) { | ||
| 2715 | toolitem = gtk_separator_tool_item_new(); | ||
| 2716 | gtk_toolbar_insert(GTK_TOOLBAR(toolbar), toolitem, -1); | ||
| 2717 | continue; | ||
| 2718 | } | ||
| 2719 | |||
| 2720 | for (item = items; item->id != -1; item++) { | ||
| 2721 | if (ditem->id == item->id) | ||
| 2722 | break; | ||
| 2723 | } | ||
| 2724 | if (item->id == -1) | ||
| 2725 | continue; | ||
| 2726 | |||
| 2727 | icon_wid = stock_pixbuf_widget_for_toolbar(ditem->icon); | ||
| 2728 | toolitem = gtk_tool_button_new(icon_wid, gettext(ditem->label)); | ||
| 2729 | if (ditem->description) { | ||
| 2730 | gtk_tool_item_set_tooltip(toolitem, | ||
| 2731 | mainwin->toolbar_tip, | ||
| 2732 | gettext(ditem->description), | ||
| 2733 | ditem->name); | ||
| 2734 | } | ||
| 2735 | |||
| 2736 | gtkut_get_str_size(GTK_WIDGET(toolitem), gettext(ditem->label), | ||
| 2737 | &width, NULL); | ||
| 2738 | gtk_tool_item_set_homogeneous | ||
| 2739 | (toolitem, width < 52 ? TRUE : FALSE); | ||
| 2740 | gtk_tool_item_set_is_important(toolitem, item->is_important); | ||
| 2741 | |||
| 2742 | gtk_toolbar_insert(GTK_TOOLBAR(toolbar), toolitem, -1); | ||
| 2743 | |||
| 2744 | g_signal_connect(G_OBJECT(toolitem), "clicked", | ||
| 2745 | G_CALLBACK(item->callback), mainwin); | ||
| 2746 | g_signal_connect(G_OBJECT(GTK_BIN(toolitem)->child), | ||
| 2747 | "button_press_event", | ||
| 2748 | G_CALLBACK(toolbar_button_pressed), mainwin); | ||
| 2749 | |||
| 2750 | if (ditem->id == T_REPLY) { | ||
| 2751 | n_entries = sizeof(reply_entries) / | ||
| 2752 | sizeof(reply_entries[0]); | ||
| 2753 | combo = gtkut_combo_button_create | ||
| 2754 | (GTK_WIDGET(toolitem), | ||
| 2755 | reply_entries, n_entries, "<Reply>", mainwin); | ||
| 2756 | gtk_button_set_relief(GTK_BUTTON(combo->arrow), | ||
| 2757 | GTK_RELIEF_NONE); | ||
| 2758 | |||
| 2759 | comboitem = gtk_tool_item_new(); | ||
| 2760 | gtk_tool_item_set_homogeneous(comboitem, FALSE); | ||
| 2761 | gtk_container_add(GTK_CONTAINER(comboitem), | ||
| 2762 | GTK_WIDGET_PTR(combo)); | ||
| 2763 | if (ditem->description) { | ||
| 2764 | gtk_tool_item_set_tooltip | ||
| 2765 | (comboitem, mainwin->toolbar_tip, | ||
| 2766 | gettext(ditem->description), | ||
| 2767 | ditem->name); | ||
| 2768 | } | ||
| 2769 | |||
| 2770 | gtk_toolbar_insert(GTK_TOOLBAR(toolbar), comboitem, -1); | ||
| 2771 | |||
| 2772 | mainwin->reply_combo = combo; | ||
| 2773 | } else if (ditem->id == T_FORWARD) { | ||
| 2774 | n_entries = sizeof(forward_entries) / | ||
| 2775 | sizeof(forward_entries[0]); | ||
| 2776 | combo = gtkut_combo_button_create | ||
| 2777 | (GTK_WIDGET(toolitem), | ||
| 2778 | forward_entries, n_entries, "<Forward>", | ||
| 2779 | mainwin); | ||
| 2780 | gtk_button_set_relief(GTK_BUTTON(combo->arrow), | ||
| 2781 | GTK_RELIEF_NONE); | ||
| 2782 | |||
| 2783 | comboitem = gtk_tool_item_new(); | ||
| 2784 | gtk_tool_item_set_homogeneous(comboitem, FALSE); | ||
| 2785 | gtk_container_add(GTK_CONTAINER(comboitem), | ||
| 2786 | GTK_WIDGET_PTR(combo)); | ||
| 2787 | if (ditem->description) { | ||
| 2788 | gtk_tool_item_set_tooltip | ||
| 2789 | (comboitem, mainwin->toolbar_tip, | ||
| 2790 | gettext(ditem->description), | ||
| 2791 | ditem->name); | ||
| 2792 | } | ||
| 2793 | |||
| 2794 | gtk_toolbar_insert(GTK_TOOLBAR(toolbar), comboitem, -1); | ||
| 2795 | |||
| 2796 | mainwin->fwd_combo = combo; | ||
| 2797 | } | ||
| 2798 | |||
| 2799 | *(GtkWidget **)item->data = GTK_WIDGET(toolitem); | ||
| 2800 | } | ||
| 2801 | |||
| 2802 | gtk_widget_show_all(toolbar); | ||
| 2803 | |||
| 2804 | return toolbar; | ||
| 2805 | } | ||
| 2806 | |||
| 2807 | static void main_window_toolbar_toggle_menu_set_active(MainWindow *mainwin, | ||
| 2808 | ToolbarStyle style) | ||
| 2809 | { | ||
| 2810 | GtkWidget *menuitem = NULL; | ||
| 2811 | GtkItemFactory *ifactory = mainwin->menu_factory; | ||
| 2812 | |||
| 2813 | switch (style) { | ||
| 2814 | case TOOLBAR_NONE: | ||
| 2815 | menuitem = gtk_item_factory_get_item | ||
| 2816 | (ifactory, "/View/Show or hide/Toolbar/None"); | ||
| 2817 | break; | ||
| 2818 | case TOOLBAR_ICON: | ||
| 2819 | menuitem = gtk_item_factory_get_item | ||
| 2820 | (ifactory, "/View/Show or hide/Toolbar/Icon"); | ||
| 2821 | break; | ||
| 2822 | case TOOLBAR_TEXT: | ||
| 2823 | menuitem = gtk_item_factory_get_item | ||
| 2824 | (ifactory, "/View/Show or hide/Toolbar/Text"); | ||
| 2825 | break; | ||
| 2826 | case TOOLBAR_BOTH: | ||
| 2827 | menuitem = gtk_item_factory_get_item | ||
| 2828 | (ifactory, "/View/Show or hide/Toolbar/Icon and text"); | ||
| 2829 | break; | ||
| 2830 | case TOOLBAR_BOTH_HORIZ: | ||
| 2831 | menuitem = gtk_item_factory_get_item | ||
| 2832 | (ifactory, "/View/Show or hide/Toolbar/Text at the right of icon"); | ||
| 2833 | break; | ||
| 2834 | } | ||
| 2835 | |||
| 2836 | if (menuitem) | ||
| 2837 | gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), | ||
| 2838 | TRUE); | ||
| 2839 | } | ||
| 2840 | |||
| 2841 | /* callback functions */ | ||
| 2842 | |||
| 2843 | static void toolbar_inc_cb (GtkWidget *widget, | ||
| 2844 | gpointer data) | ||
| 2845 | { | ||
| 2846 | MainWindow *mainwin = (MainWindow *)data; | ||
| 2847 | |||
| 2848 | inc_mail_cb(mainwin, 0, NULL); | ||
| 2849 | } | ||
| 2850 | |||
| 2851 | static void toolbar_inc_all_cb (GtkWidget *widget, | ||
| 2852 | gpointer data) | ||
| 2853 | { | ||
| 2854 | MainWindow *mainwin = (MainWindow *)data; | ||
| 2855 | |||
| 2856 | inc_all_account_mail_cb(mainwin, 0, NULL); | ||
| 2857 | } | ||
| 2858 | |||
| 2859 | static void toolbar_rpop3_cb (GtkWidget *widget, | ||
| 2860 | gpointer data) | ||
| 2861 | { | ||
| 2862 | MainWindow *mainwin = (MainWindow *)data; | ||
| 2863 | |||
| 2864 | rpop3_cb(mainwin, 0, NULL); | ||
| 2865 | } | ||
| 2866 | |||
| 2867 | static void toolbar_send_cb (GtkWidget *widget, | ||
| 2868 | gpointer data) | ||
| 2869 | { | ||
| 2870 | MainWindow *mainwin = (MainWindow *)data; | ||
| 2871 | |||
| 2872 | send_queue_cb(mainwin, 0, NULL); | ||
| 2873 | } | ||
| 2874 | |||
| 2875 | static void toolbar_compose_cb (GtkWidget *widget, | ||
| 2876 | gpointer data) | ||
| 2877 | { | ||
| 2878 | MainWindow *mainwin = (MainWindow *)data; | ||
| 2879 | |||
| 2880 | compose_cb(mainwin, 0, NULL); | ||
| 2881 | } | ||
| 2882 | |||
| 2883 | static void toolbar_reply_cb (GtkWidget *widget, | ||
| 2884 | gpointer data) | ||
| 2885 | { | ||
| 2886 | MainWindow *mainwin = (MainWindow *)data; | ||
| 2887 | |||
| 2888 | if (prefs_common.default_reply_list) | ||
| 2889 | reply_cb(mainwin, COMPOSE_REPLY_TO_LIST, NULL); | ||
| 2890 | else | ||
| 2891 | reply_cb(mainwin, COMPOSE_REPLY, NULL); | ||
| 2892 | } | ||
| 2893 | |||
| 2894 | static void toolbar_reply_to_all_cb (GtkWidget *widget, | ||
| 2895 | gpointer data) | ||
| 2896 | { | ||
| 2897 | MainWindow *mainwin = (MainWindow *)data; | ||
| 2898 | |||
| 2899 | reply_cb(mainwin, COMPOSE_REPLY_TO_ALL, NULL); | ||
| 2900 | } | ||
| 2901 | |||
| 2902 | static void toolbar_forward_cb (GtkWidget *widget, | ||
| 2903 | gpointer data) | ||
| 2904 | { | ||
| 2905 | MainWindow *mainwin = (MainWindow *)data; | ||
| 2906 | |||
| 2907 | reply_cb(mainwin, COMPOSE_FORWARD, NULL); | ||
| 2908 | } | ||
| 2909 | |||
| 2910 | static void toolbar_delete_cb (GtkWidget *widget, | ||
| 2911 | gpointer data) | ||
| 2912 | { | ||
| 2913 | MainWindow *mainwin = (MainWindow *)data; | ||
| 2914 | |||
| 2915 | summary_delete(mainwin->summaryview); | ||
| 2916 | } | ||
| 2917 | |||
| 2918 | static void toolbar_junk_cb (GtkWidget *widget, | ||
| 2919 | gpointer data) | ||
| 2920 | { | ||
| 2921 | MainWindow *mainwin = (MainWindow *)data; | ||
| 2922 | |||
| 2923 | summary_junk(mainwin->summaryview); | ||
| 2924 | } | ||
| 2925 | |||
| 2926 | static void toolbar_notjunk_cb (GtkWidget *widget, | ||
| 2927 | gpointer data) | ||
| 2928 | { | ||
| 2929 | MainWindow *mainwin = (MainWindow *)data; | ||
| 2930 | |||
| 2931 | summary_not_junk(mainwin->summaryview); | ||
| 2932 | } | ||
| 2933 | |||
| 2934 | static void toolbar_exec_cb (GtkWidget *widget, | ||
| 2935 | gpointer data) | ||
| 2936 | { | ||
| 2937 | MainWindow *mainwin = (MainWindow *)data; | ||
| 2938 | |||
| 2939 | summary_execute(mainwin->summaryview); | ||
| 2940 | } | ||
| 2941 | |||
| 2942 | static void toolbar_next_unread_cb (GtkWidget *widget, | ||
| 2943 | gpointer data) | ||
| 2944 | { | ||
| 2945 | MainWindow *mainwin = (MainWindow *)data; | ||
| 2946 | |||
| 2947 | next_unread_cb(mainwin, 0, NULL); | ||
| 2948 | } | ||
| 2949 | |||
| 2950 | static void toolbar_prev_unread_cb(GtkWidget *widget, gpointer data) | ||
| 2951 | { | ||
| 2952 | MainWindow *mainwin = (MainWindow *)data; | ||
| 2953 | |||
| 2954 | prev_unread_cb(mainwin, 0, NULL); | ||
| 2955 | } | ||
| 2956 | |||
| 2957 | static void toolbar_address_cb(GtkWidget *widget, gpointer data) | ||
| 2958 | { | ||
| 2959 | MainWindow *mainwin = (MainWindow *)data; | ||
| 2960 | |||
| 2961 | addressbook_open_cb(mainwin, 0, NULL); | ||
| 2962 | } | ||
| 2963 | |||
| 2964 | static void toolbar_search_cb(GtkWidget *widget, gpointer data) | ||
| 2965 | { | ||
| 2966 | MainWindow *mainwin = (MainWindow *)data; | ||
| 2967 | |||
| 2968 | search_cb(mainwin, 1, NULL); | ||
| 2969 | } | ||
| 2970 | |||
| 2971 | static void toolbar_print_cb(GtkWidget *widget, gpointer data) | ||
| 2972 | { | ||
| 2973 | MainWindow *mainwin = (MainWindow *)data; | ||
| 2974 | |||
| 2975 | print_cb(mainwin, 0, NULL); | ||
| 2976 | } | ||
| 2977 | |||
| 2978 | static void toolbar_stop_cb(GtkWidget *widget, gpointer data) | ||
| 2979 | { | ||
| 2980 | MainWindow *mainwin = (MainWindow *)data; | ||
| 2981 | |||
| 2982 | inc_stop_cb(mainwin, 0, NULL); | ||
| 2983 | } | ||
| 2984 | |||
| 2985 | static void toolbar_prefs_common_cb(GtkWidget *widget, gpointer data) | ||
| 2986 | { | ||
| 2987 | MainWindow *mainwin = (MainWindow *)data; | ||
| 2988 | |||
| 2989 | prefs_common_open_cb(mainwin, 0, NULL); | ||
| 2990 | } | ||
| 2991 | |||
| 2992 | static void toolbar_prefs_account_cb(GtkWidget *widget, gpointer data) | ||
| 2993 | { | ||
| 2994 | MainWindow *mainwin = (MainWindow *)data; | ||
| 2995 | |||
| 2996 | prefs_account_open_cb(mainwin, 0, NULL); | ||
| 2997 | } | ||
| 2998 | |||
| 2999 | static void toolbar_toggle(GtkWidget *widget, gpointer data) | ||
| 3000 | { | ||
| 3001 | MainWindow *mainwin = (MainWindow *)data; | ||
| 3002 | ToolbarStyle style; | ||
| 3003 | |||
| 3004 | if (!gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM(widget))) | ||
| 3005 | return; | ||
| 3006 | |||
| 3007 | style = (ToolbarStyle)g_object_get_data(G_OBJECT(widget), MENU_VAL_ID); | ||
| 3008 | main_window_toolbar_toggle_menu_set_active(mainwin, style); | ||
| 3009 | } | ||
| 3010 | |||
| 3011 | static void toolbar_customize(GtkWidget *widget, gpointer data) | ||
| 3012 | { | ||
| 3013 | MainWindow *mainwin = (MainWindow *)data; | ||
| 3014 | gint *visible_items; | ||
| 3015 | GList *item_list = NULL; | ||
| 3016 | GtkWidget *toolbar; | ||
| 3017 | gint ret; | ||
| 3018 | const gchar *setting; | ||
| 3019 | |||
| 3020 | if (prefs_common.main_toolbar_setting && | ||
| 3021 | *prefs_common.main_toolbar_setting != '\0') | ||
| 3022 | setting = prefs_common.main_toolbar_setting; | ||
| 3023 | else | ||
| 3024 | setting = prefs_toolbar_get_default_main_setting_name_list(); | ||
| 3025 | visible_items = prefs_toolbar_get_id_list_from_name_list(setting); | ||
| 3026 | ret = prefs_toolbar_open(TOOLBAR_MAIN, visible_items, &item_list); | ||
| 3027 | g_free(visible_items); | ||
| 3028 | |||
| 3029 | if (ret == 0) { | ||
| 3030 | gtk_widget_destroy(mainwin->toolbar); | ||
| 3031 | toolbar = main_window_toolbar_create_from_list(mainwin, | ||
| 3032 | item_list); | ||
| 3033 | gtk_widget_set_size_request(toolbar, 300, -1); | ||
| 3034 | gtk_box_pack_start(GTK_BOX(mainwin->vbox), toolbar, | ||
| 3035 | FALSE, FALSE, 0); | ||
| 3036 | gtk_box_reorder_child(GTK_BOX(mainwin->vbox), toolbar, 1); | ||
| 3037 | mainwin->toolbar = toolbar; | ||
| 3038 | main_window_set_toolbar_sensitive(mainwin); | ||
| 3039 | main_window_set_toolbar_button_visibility(mainwin); | ||
| 3040 | g_free(prefs_common.main_toolbar_setting); | ||
| 3041 | prefs_common.main_toolbar_setting = | ||
| 3042 | prefs_toolbar_get_name_list_from_item_list(item_list); | ||
| 3043 | g_list_free(item_list); | ||
| 3044 | prefs_common_write_config(); | ||
| 3045 | |||
| 3046 | syl_plugin_signal_emit("main-window-toolbar-changed"); | ||
| 3047 | } | ||
| 3048 | } | ||
| 3049 | |||
| 3050 | static gboolean toolbar_button_pressed(GtkWidget *widget, GdkEventButton *event, | ||
| 3051 | gpointer data) | ||
| 3052 | { | ||
| 3053 | MainWindow *mainwin = (MainWindow *)data; | ||
| 3054 | GtkWidget *menu; | ||
| 3055 | GtkWidget *menuitem; | ||
| 3056 | |||
| 3057 | if (!event) return FALSE; | ||
| 3058 | if (event->button != 3) return FALSE; | ||
| 3059 | |||
| 3060 | menu = gtk_menu_new(); | ||
| 3061 | gtk_widget_show(menu); | ||
| 3062 | |||
| 3063 | #define SET_TOOLBAR_MENU(text, style, widget) \ | ||
| 3064 | { \ | ||
| 3065 | MENUITEM_ADD_RADIO(menu, menuitem, widget, text, style); \ | ||
| 3066 | if (prefs_common.toolbar_style == style) \ | ||
| 3067 | gtk_check_menu_item_set_active \ | ||
| 3068 | (GTK_CHECK_MENU_ITEM(menuitem), TRUE); \ | ||
| 3069 | g_signal_connect(G_OBJECT(menuitem), "activate", \ | ||
| 3070 | G_CALLBACK(toolbar_toggle), mainwin); \ | ||
| 3071 | } | ||
| 3072 | |||
| 3073 | SET_TOOLBAR_MENU(_("Icon _and text"), TOOLBAR_BOTH, NULL); | ||
| 3074 | SET_TOOLBAR_MENU(_("Text at the _right of icon"), TOOLBAR_BOTH_HORIZ, | ||
| 3075 | menuitem); | ||
| 3076 | SET_TOOLBAR_MENU(_("_Icon"), TOOLBAR_ICON, menuitem); | ||
| 3077 | SET_TOOLBAR_MENU(_("_Text"), TOOLBAR_TEXT, menuitem); | ||
| 3078 | SET_TOOLBAR_MENU(_("_None"), TOOLBAR_NONE, menuitem); | ||
| 3079 | MENUITEM_ADD(menu, menuitem, NULL, NULL); | ||
| 3080 | MENUITEM_ADD_WITH_MNEMONIC(menu, menuitem, _("_Customize toolbar..."), | ||
| 3081 | 0); | ||
| 3082 | g_signal_connect(G_OBJECT(menuitem), "activate", | ||
| 3083 | G_CALLBACK(toolbar_customize), mainwin); | ||
| 3084 | |||
| 3085 | g_signal_connect(G_OBJECT(menu), "selection_done", | ||
| 3086 | G_CALLBACK(gtk_widget_destroy), NULL); | ||
| 3087 | |||
| 3088 | gtk_menu_popup(GTK_MENU(menu), NULL, NULL, NULL, NULL, | ||
| 3089 | event->button, event->time); | ||
| 3090 | |||
| 3091 | return TRUE; | ||
| 3092 | } | ||
| 3093 | |||
| 3094 | static void online_switch_clicked(GtkWidget *widget, gpointer data) | ||
| 3095 | { | ||
| 3096 | MainWindow *mainwin = (MainWindow *)data; | ||
| 3097 | GtkWidget *menuitem; | ||
| 3098 | |||
| 3099 | debug_print("Toggle online mode: %d -> %d\n", prefs_common.online_mode, | ||
| 3100 | !prefs_common.online_mode); | ||
| 3101 | |||
| 3102 | menuitem = gtk_item_factory_get_item(mainwin->menu_factory, | ||
| 3103 | "/File/Work offline"); | ||
| 3104 | |||
| 3105 | if (prefs_common.online_mode == TRUE) { | ||
| 3106 | if (folder_remote_folder_active_session_exist()) { | ||
| 3107 | debug_print("Active session exist. Cancelling online switch.\n"); | ||
| 3108 | return; | ||
| 3109 | } | ||
| 3110 | |||
| 3111 | prefs_common.online_mode = FALSE; | ||
| 3112 | gtk_widget_hide(mainwin->online_pixmap); | ||
| 3113 | gtk_widget_show(mainwin->offline_pixmap); | ||
| 3114 | gtk_tooltips_set_tip | ||
| 3115 | (mainwin->online_tip, mainwin->online_switch, | ||
| 3116 | _("You are offline. Click the icon to go online."), | ||
| 3117 | NULL); | ||
| 3118 | gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), | ||
| 3119 | TRUE); | ||
| 3120 | inc_autocheck_timer_remove(); | ||
| 3121 | folder_remote_folder_destroy_all_sessions(); | ||
| 3122 | } else { | ||
| 3123 | prefs_common.online_mode = TRUE; | ||
| 3124 | gtk_widget_hide(mainwin->offline_pixmap); | ||
| 3125 | gtk_widget_show(mainwin->online_pixmap); | ||
| 3126 | gtk_tooltips_set_tip | ||
| 3127 | (mainwin->online_tip, mainwin->online_switch, | ||
| 3128 | _("You are online. Click the icon to go offline."), | ||
| 3129 | NULL); | ||
| 3130 | gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), | ||
| 3131 | FALSE); | ||
| 3132 | inc_autocheck_timer_set(); | ||
| 3133 | } | ||
| 3134 | } | ||
| 3135 | |||
| 3136 | static gboolean ac_label_button_pressed(GtkWidget *widget, | ||
| 3137 | GdkEventButton *event, gpointer data) | ||
| 3138 | { | ||
| 3139 | MainWindow *mainwin = (MainWindow *)data; | ||
| 3140 | |||
| 3141 | if (!event) return FALSE; | ||
| 3142 | |||
| 3143 | gtk_button_set_relief(GTK_BUTTON(widget), GTK_RELIEF_NORMAL); | ||
| 3144 | g_object_set_data(G_OBJECT(mainwin->ac_menu), "menu_button", widget); | ||
| 3145 | |||
| 3146 | gtk_menu_popup(GTK_MENU(mainwin->ac_menu), NULL, NULL, | ||
| 3147 | menu_button_position, widget, | ||
| 3148 | event->button, event->time); | ||
| 3149 | |||
| 3150 | return TRUE; | ||
| 3151 | } | ||
| 3152 | |||
| 3153 | static void ac_menu_popup_closed(GtkMenuShell *menu_shell, gpointer data) | ||
| 3154 | { | ||
| 3155 | MainWindow *mainwin = (MainWindow *)data; | ||
| 3156 | GtkWidget *button; | ||
| 3157 | |||
| 3158 | button = g_object_get_data(G_OBJECT(menu_shell), "menu_button"); | ||
| 3159 | if (!button) return; | ||
| 3160 | gtk_button_set_relief(GTK_BUTTON(button), GTK_RELIEF_NONE); | ||
| 3161 | g_object_set_data(G_OBJECT(mainwin->ac_menu), "menu_button", NULL); | ||
| 3162 | manage_window_focus_in(mainwin->window, NULL, NULL); | ||
| 3163 | } | ||
| 3164 | |||
| 3165 | static gboolean main_window_key_pressed(GtkWidget *widget, GdkEventKey *event, | ||
| 3166 | gpointer data) | ||
| 3167 | { | ||
| 3168 | MainWindow *mainwin = (MainWindow *)data; | ||
| 3169 | |||
| 3170 | if (!mainwin) | ||
| 3171 | return FALSE; | ||
| 3172 | |||
| 3173 | if (!GTK_WIDGET_HAS_FOCUS(mainwin->summaryview->qsearch->entry)) | ||
| 3174 | return FALSE; | ||
| 3175 | |||
| 3176 | /* g_print("keyval: %d, state: %d\n", event->keyval, event->state); */ | ||
| 3177 | if ((event->state & (GDK_MOD1_MASK|GDK_CONTROL_MASK)) != 0) | ||
| 3178 | return FALSE; | ||
| 3179 | if (event->keyval == GDK_Tab || event->keyval == GDK_KP_Tab || | ||
| 3180 | event->keyval == GDK_ISO_Left_Tab) | ||
| 3181 | return FALSE; | ||
| 3182 | |||
| 3183 | gtk_window_propagate_key_event(GTK_WINDOW(widget), event); | ||
| 3184 | |||
| 3185 | return TRUE; | ||
| 3186 | } | ||
| 3187 | |||
| 3188 | static gint main_window_close_cb(GtkWidget *widget, GdkEventAny *event, | ||
| 3189 | gpointer data) | ||
| 3190 | { | ||
| 3191 | MainWindow *mainwin = (MainWindow *)data; | ||
| 3192 | |||
| 3193 | if (mainwin->lock_count == 0) | ||
| 3194 | app_exit_cb(data, 0, widget); | ||
| 3195 | |||
| 3196 | return TRUE; | ||
| 3197 | } | ||
| 3198 | |||
| 3199 | static gint folder_window_close_cb(GtkWidget *widget, GdkEventAny *event, | ||
| 3200 | gpointer data) | ||
| 3201 | { | ||
| 3202 | MainWindow *mainwin = (MainWindow *)data; | ||
| 3203 | GtkWidget *menuitem; | ||
| 3204 | |||
| 3205 | menuitem = gtk_item_factory_get_item | ||
| 3206 | (mainwin->menu_factory, "/View/Show or hide/Folder tree"); | ||
| 3207 | gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), FALSE); | ||
| 3208 | |||
| 3209 | return TRUE; | ||
| 3210 | } | ||
| 3211 | |||
| 3212 | static gint message_window_close_cb(GtkWidget *widget, GdkEventAny *event, | ||
| 3213 | gpointer data) | ||
| 3214 | { | ||
| 3215 | MainWindow *mainwin = (MainWindow *)data; | ||
| 3216 | GtkWidget *menuitem; | ||
| 3217 | |||
| 3218 | menuitem = gtk_item_factory_get_item | ||
| 3219 | (mainwin->menu_factory, "/View/Show or hide/Message view"); | ||
| 3220 | gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), FALSE); | ||
| 3221 | |||
| 3222 | return TRUE; | ||
| 3223 | } | ||
| 3224 | |||
| 3225 | static void main_window_size_allocate_cb(GtkWidget *widget, | ||
| 3226 | GtkAllocation *allocation, | ||
| 3227 | gpointer data) | ||
| 3228 | { | ||
| 3229 | MainWindow *mainwin = (MainWindow *)data; | ||
| 3230 | |||
| 3231 | main_window_get_size(mainwin); | ||
| 3232 | } | ||
| 3233 | |||
| 3234 | static void folder_window_size_allocate_cb(GtkWidget *widget, | ||
| 3235 | GtkAllocation *allocation, | ||
| 3236 | gpointer data) | ||
| 3237 | { | ||
| 3238 | MainWindow *mainwin = (MainWindow *)data; | ||
| 3239 | |||
| 3240 | main_window_get_size(mainwin); | ||
| 3241 | } | ||
| 3242 | |||
| 3243 | static void message_window_size_allocate_cb(GtkWidget *widget, | ||
| 3244 | GtkAllocation *allocation, | ||
| 3245 | gpointer data) | ||
| 3246 | { | ||
| 3247 | MainWindow *mainwin = (MainWindow *)data; | ||
| 3248 | |||
| 3249 | main_window_get_size(mainwin); | ||
| 3250 | } | ||
| 3251 | |||
| 3252 | static gboolean main_window_window_state_cb(GtkWidget *widget, | ||
| 3253 | GdkEventWindowState *event, | ||
| 3254 | gpointer data) | ||
| 3255 | { | ||
| 3256 | MainWindow *mainwin = (MainWindow *)data; | ||
| 3257 | gboolean minimized = FALSE; | ||
| 3258 | |||
| 3259 | debug_print("main_window_window_state_cb\n"); | ||
| 3260 | |||
| 3261 | if ((event->changed_mask & GDK_WINDOW_STATE_MAXIMIZED) != 0) { | ||
| 3262 | if ((event->new_window_state & GDK_WINDOW_STATE_MAXIMIZED) != 0) { | ||
| 3263 | debug_print("main_window_window_state_cb: maximized\n"); | ||
| 3264 | prefs_common.mainwin_maximized = TRUE; | ||
| 3265 | } else { | ||
| 3266 | debug_print("main_window_window_state_cb: unmaximized\n"); | ||
| 3267 | #ifdef G_OS_WIN32 | ||
| 3268 | if ((event->changed_mask & GDK_WINDOW_STATE_ICONIFIED) != 0 && | ||
| 3269 | (event->new_window_state & GDK_WINDOW_STATE_ICONIFIED) != 0) { | ||
| 3270 | debug_print("main_window_window_state_cb: unmaximized by minimize\n"); | ||
| 3271 | /* don't change mainwin_maximized */ | ||
| 3272 | } else { | ||
| 3273 | prefs_common.mainwin_maximized = FALSE; | ||
| 3274 | } | ||
| 3275 | #else | ||
| 3276 | prefs_common.mainwin_maximized = FALSE; | ||
| 3277 | #endif | ||
| 3278 | } | ||
| 3279 | } | ||
| 3280 | if ((event->changed_mask & GDK_WINDOW_STATE_ICONIFIED) != 0) { | ||
| 3281 | if ((event->new_window_state & GDK_WINDOW_STATE_ICONIFIED) != 0) { | ||
| 3282 | debug_print("main_window_window_state_cb: iconified\n"); | ||
| 3283 | minimized = TRUE; | ||
| 3284 | mainwin->window_hidden = TRUE; | ||
| 3285 | } else { | ||
| 3286 | debug_print("main_window_window_state_cb: deiconified\n"); | ||
| 3287 | mainwin->window_hidden = FALSE; | ||
| 3288 | } | ||
| 3289 | } | ||
| 3290 | if ((event->changed_mask & GDK_WINDOW_STATE_WITHDRAWN) != 0) { | ||
| 3291 | if ((event->new_window_state & GDK_WINDOW_STATE_WITHDRAWN) != 0) { | ||
| 3292 | debug_print("main_window_window_state_cb: withdrawn\n"); | ||
| 3293 | mainwin->window_hidden = TRUE; | ||
| 3294 | } else { | ||
| 3295 | debug_print("main_window_window_state_cb: unwithdrawn\n"); | ||
| 3296 | mainwin->window_hidden = FALSE; | ||
| 3297 | } | ||
| 3298 | } | ||
| 3299 | |||
| 3300 | #ifdef G_OS_WIN32 | ||
| 3301 | if (minimized && | ||
| 3302 | prefs_common.show_trayicon && prefs_common.minimize_to_tray) { | ||
| 3303 | gtk_window_set_skip_taskbar_hint(GTK_WINDOW(widget), TRUE); | ||
| 3304 | debug_print("main_window_window_state_cb: hide window\n"); | ||
| 3305 | gtk_widget_hide(widget); | ||
| 3306 | #else | ||
| 3307 | if (mainwin->window_hidden && | ||
| 3308 | prefs_common.show_trayicon && prefs_common.minimize_to_tray) { | ||
| 3309 | gtk_window_set_skip_taskbar_hint(GTK_WINDOW(widget), TRUE); | ||
| 3310 | #endif | ||
| 3311 | } else if (!mainwin->window_hidden) { | ||
| 3312 | gtk_window_set_skip_taskbar_hint(GTK_WINDOW(widget), FALSE); | ||
| 3313 | #ifdef G_OS_WIN32 | ||
| 3314 | if (prefs_common.mainwin_maximized) | ||
| 3315 | gtk_window_maximize(GTK_WINDOW(widget)); | ||
| 3316 | #endif | ||
| 3317 | } | ||
| 3318 | |||
| 3319 | return FALSE; | ||
| 3320 | } | ||
| 3321 | |||
| 3322 | static gboolean main_window_visibility_notify_cb(GtkWidget *widget, | ||
| 3323 | GdkEventVisibility *event, | ||
| 3324 | gpointer data) | ||
| 3325 | { | ||
| 3326 | MainWindow *mainwin = (MainWindow *)data; | ||
| 3327 | |||
| 3328 | mainwin->window_obscured = | ||
| 3329 | (event->state == GDK_VISIBILITY_FULLY_OBSCURED || | ||
| 3330 | event->state == GDK_VISIBILITY_PARTIAL) ? TRUE : FALSE; | ||
| 3331 | |||
| 3332 | return FALSE; | ||
| 3333 | } | ||
| 3334 | |||
| 3335 | static void new_folder_cb(MainWindow *mainwin, guint action, | ||
| 3336 | GtkWidget *widget) | ||
| 3337 | { | ||
| 3338 | folderview_new_folder(mainwin->folderview); | ||
| 3339 | } | ||
| 3340 | |||
| 3341 | static void rename_folder_cb(MainWindow *mainwin, guint action, | ||
| 3342 | GtkWidget *widget) | ||
| 3343 | { | ||
| 3344 | folderview_rename_folder(mainwin->folderview); | ||
| 3345 | } | ||
| 3346 | |||
| 3347 | static void move_folder_cb(MainWindow *mainwin, guint action, GtkWidget *widget) | ||
| 3348 | { | ||
| 3349 | folderview_move_folder(mainwin->folderview); | ||
| 3350 | } | ||
| 3351 | |||
| 3352 | static void delete_folder_cb(MainWindow *mainwin, guint action, | ||
| 3353 | GtkWidget *widget) | ||
| 3354 | { | ||
| 3355 | folderview_delete_folder(mainwin->folderview); | ||
| 3356 | } | ||
| 3357 | |||
| 3358 | static void add_mailbox_cb(MainWindow *mainwin, guint action, | ||
| 3359 | GtkWidget *widget) | ||
| 3360 | { | ||
| 3361 | main_window_add_mailbox(mainwin); | ||
| 3362 | } | ||
| 3363 | |||
| 3364 | static void remove_mailbox_cb(MainWindow *mainwin, guint action, | ||
| 3365 | GtkWidget *widget) | ||
| 3366 | { | ||
| 3367 | folderview_remove_mailbox(mainwin->folderview); | ||
| 3368 | } | ||
| 3369 | |||
| 3370 | static void update_folderview_cb(MainWindow *mainwin, guint action, | ||
| 3371 | GtkWidget *widget) | ||
| 3372 | { | ||
| 3373 | if (action == 0) | ||
| 3374 | folderview_check_new_selected(mainwin->folderview); | ||
| 3375 | else | ||
| 3376 | folderview_check_new_all(); | ||
| 3377 | } | ||
| 3378 | |||
| 3379 | static void rebuild_tree_cb(MainWindow *mainwin, guint action, | ||
| 3380 | GtkWidget *widget) | ||
| 3381 | { | ||
| 3382 | folderview_rebuild_tree(mainwin->folderview); | ||
| 3383 | } | ||
| 3384 | |||
| 3385 | static void import_mail_cb(MainWindow *mainwin, guint action, | ||
| 3386 | GtkWidget *widget) | ||
| 3387 | { | ||
| 3388 | import_mail(mainwin->summaryview->folder_item); | ||
| 3389 | main_window_popup(mainwin); | ||
| 3390 | } | ||
| 3391 | |||
| 3392 | static void export_mail_cb(MainWindow *mainwin, guint action, | ||
| 3393 | GtkWidget *widget) | ||
| 3394 | { | ||
| 3395 | export_mail(mainwin->summaryview->folder_item); | ||
| 3396 | main_window_popup(mainwin); | ||
| 3397 | } | ||
| 3398 | |||
| 3399 | static void empty_trash_cb(MainWindow *mainwin, guint action, | ||
| 3400 | GtkWidget *widget) | ||
| 3401 | { | ||
| 3402 | main_window_empty_trash(mainwin, TRUE); | ||
| 3403 | } | ||
| 3404 | |||
| 3405 | static void save_as_cb(MainWindow *mainwin, guint action, GtkWidget *widget) | ||
| 3406 | { | ||
| 3407 | MessageView *messageview = mainwin->messageview; | ||
| 3408 | |||
| 3409 | if (messageview_get_selected_mime_part(messageview) && | ||
| 3410 | GTK_WIDGET_HAS_FOCUS(messageview->mimeview->treeview)) | ||
| 3411 | mimeview_save_as(messageview->mimeview); | ||
| 3412 | else | ||
| 3413 | summary_save_as(mainwin->summaryview); | ||
| 3414 | } | ||
| 3415 | |||
| 3416 | #if GTK_CHECK_VERSION(2, 10, 0) | ||
| 3417 | static void page_setup_cb(MainWindow *mainwin, guint action, GtkWidget *widget) | ||
| 3418 | { | ||
| 3419 | printing_page_setup_gtk(); | ||
| 3420 | } | ||
| 3421 | #endif | ||
| 3422 | |||
| 3423 | static void print_cb(MainWindow *mainwin, guint action, GtkWidget *widget) | ||
| 3424 | { | ||
| 3425 | summary_print(mainwin->summaryview); | ||
| 3426 | } | ||
| 3427 | |||
| 3428 | static void toggle_offline_cb(MainWindow *mainwin, guint action, | ||
| 3429 | GtkWidget *widget) | ||
| 3430 | { | ||
| 3431 | if (GTK_CHECK_MENU_ITEM(widget)->active && | ||
| 3432 | folder_remote_folder_active_session_exist()) { | ||
| 3433 | debug_print("Active session exist. Cancelling online switch.\n"); | ||
| 3434 | gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(widget), | ||
| 3435 | FALSE); | ||
| 3436 | return; | ||
| 3437 | } | ||
| 3438 | |||
| 3439 | main_window_toggle_online | ||
| 3440 | (mainwin, !GTK_CHECK_MENU_ITEM(widget)->active); | ||
| 3441 | } | ||
| 3442 | |||
| 3443 | static void app_exit_cb(MainWindow *mainwin, guint action, GtkWidget *widget) | ||
| 3444 | { | ||
| 3445 | if (prefs_common.confirm_on_exit) { | ||
| 3446 | if (alertpanel(_("Exit"), _("Exit this program?"), | ||
| 3447 | GTK_STOCK_OK, GTK_STOCK_CANCEL, NULL) | ||
| 3448 | != G_ALERTDEFAULT) | ||
| 3449 | return; | ||
| 3450 | manage_window_focus_in(mainwin->window, NULL, NULL); | ||
| 3451 | } | ||
| 3452 | |||
| 3453 | app_will_exit(FALSE); | ||
| 3454 | } | ||
| 3455 | |||
| 3456 | static void search_cb(MainWindow *mainwin, guint action, GtkWidget *widget) | ||
| 3457 | { | ||
| 3458 | if (action == 1) { | ||
| 3459 | FolderItem *item; | ||
| 3460 | |||
| 3461 | item = folderview_get_selected_item(mainwin->folderview); | ||
| 3462 | if (item && item->stype == F_VIRTUAL) | ||
| 3463 | prefs_search_folder_open(item); | ||
| 3464 | else | ||
| 3465 | query_search(item); | ||
| 3466 | } else if (action == 2) { | ||
| 3467 | if (!prefs_common.show_searchbar) { | ||
| 3468 | GtkWidget *menuitem; | ||
| 3469 | |||
| 3470 | menuitem = gtk_item_factory_get_item | ||
| 3471 | (mainwin->menu_factory, | ||
| 3472 | "/View/Show or hide/Search bar"); | ||
| 3473 | gtk_check_menu_item_set_active | ||
| 3474 | (GTK_CHECK_MENU_ITEM(menuitem), TRUE); | ||
| 3475 | } | ||
| 3476 | gtk_widget_grab_focus(mainwin->summaryview->qsearch->entry); | ||
| 3477 | } else | ||
| 3478 | message_search(mainwin->messageview); | ||
| 3479 | } | ||
| 3480 | |||
| 3481 | static void toggle_folder_cb(MainWindow *mainwin, guint action, | ||
| 3482 | GtkWidget *widget) | ||
| 3483 | { | ||
| 3484 | gboolean active; | ||
| 3485 | |||
| 3486 | active = GTK_CHECK_MENU_ITEM(widget)->active; | ||
| 3487 | |||
| 3488 | switch (mainwin->type) { | ||
| 3489 | case SEPARATE_NONE: | ||
| 3490 | case SEPARATE_MESSAGE: | ||
| 3491 | #if 0 | ||
| 3492 | if (active) | ||
| 3493 | gtk_widget_show(GTK_WIDGET_PTR(mainwin->folderview)); | ||
| 3494 | else | ||
| 3495 | gtk_widget_hide(GTK_WIDGET_PTR(mainwin->folderview)); | ||
| 3496 | #endif | ||
| 3497 | break; | ||
| 3498 | case SEPARATE_FOLDER: | ||
| 3499 | if (active) | ||
| 3500 | gtk_widget_show(mainwin->win.sep_folder.folderwin); | ||
| 3501 | else | ||
| 3502 | gtk_widget_hide(mainwin->win.sep_folder.folderwin); | ||
| 3503 | break; | ||
| 3504 | case SEPARATE_BOTH: | ||
| 3505 | if (active) | ||
| 3506 | gtk_widget_show(mainwin->win.sep_both.folderwin); | ||
| 3507 | else | ||
| 3508 | gtk_widget_hide(mainwin->win.sep_both.folderwin); | ||
| 3509 | break; | ||
| 3510 | } | ||
| 3511 | |||
| 3512 | prefs_common.folderview_visible = active; | ||
| 3513 | } | ||
| 3514 | |||
| 3515 | static void toggle_message_cb(MainWindow *mainwin, guint action, | ||
| 3516 | GtkWidget *widget) | ||
| 3517 | { | ||
| 3518 | gboolean active; | ||
| 3519 | |||
| 3520 | active = GTK_CHECK_MENU_ITEM(widget)->active; | ||
| 3521 | |||
| 3522 | if (active != messageview_is_visible(mainwin->messageview)) | ||
| 3523 | summary_toggle_view(mainwin->summaryview); | ||
| 3524 | } | ||
| 3525 | |||
| 3526 | static void toggle_toolbar_cb(MainWindow *mainwin, guint action, | ||
| 3527 | GtkWidget *widget) | ||
| 3528 | { | ||
| 3529 | mainwin->toolbar_style = (ToolbarStyle)action; | ||
| 3530 | prefs_common.toolbar_style = (ToolbarStyle)action; | ||
| 3531 | |||
| 3532 | main_window_set_toolbar_button_visibility(mainwin); | ||
| 3533 | } | ||
| 3534 | |||
| 3535 | static void toggle_searchbar_cb(MainWindow *mainwin, guint action, | ||
| 3536 | GtkWidget *widget) | ||
| 3537 | { | ||
| 3538 | if (GTK_CHECK_MENU_ITEM(widget)->active) { | ||
| 3539 | gtk_widget_show(mainwin->summaryview->qsearch->hbox); | ||
| 3540 | prefs_common.show_searchbar = TRUE; | ||
| 3541 | } else { | ||
| 3542 | gtk_widget_hide(mainwin->summaryview->qsearch->hbox); | ||
| 3543 | summary_qsearch_reset(mainwin->summaryview); | ||
| 3544 | prefs_common.show_searchbar = FALSE; | ||
| 3545 | } | ||
| 3546 | } | ||
| 3547 | |||
| 3548 | static void toggle_statusbar_cb(MainWindow *mainwin, guint action, | ||
| 3549 | GtkWidget *widget) | ||
| 3550 | { | ||
| 3551 | if (GTK_CHECK_MENU_ITEM(widget)->active) { | ||
| 3552 | gtk_widget_show(mainwin->statusbar); | ||
| 3553 | prefs_common.show_statusbar = TRUE; | ||
| 3554 | } else { | ||
| 3555 | gtk_widget_hide(mainwin->statusbar); | ||
| 3556 | prefs_common.show_statusbar = FALSE; | ||
| 3557 | } | ||
| 3558 | } | ||
| 3559 | |||
| 3560 | static void toolbar_customize_cb(MainWindow *mainwin, guint action, | ||
| 3561 | GtkWidget *widget) | ||
| 3562 | { | ||
| 3563 | toolbar_customize(widget, mainwin); | ||
| 3564 | } | ||
| 3565 | |||
| 3566 | static void change_layout_cb(MainWindow *mainwin, guint action, | ||
| 3567 | GtkWidget *widget) | ||
| 3568 | { | ||
| 3569 | LayoutType type = action; | ||
| 3570 | |||
| 3571 | if (GTK_CHECK_MENU_ITEM(widget)->active) | ||
| 3572 | main_window_change_layout(mainwin, type, mainwin->type); | ||
| 3573 | } | ||
| 3574 | |||
| 3575 | static void separate_widget_cb(MainWindow *mainwin, guint action, | ||
| 3576 | GtkWidget *widget) | ||
| 3577 | { | ||
| 3578 | SeparateType type; | ||
| 3579 | |||
| 3580 | if (GTK_CHECK_MENU_ITEM(widget)->active) | ||
| 3581 | type = mainwin->type | action; | ||
| 3582 | else | ||
| 3583 | type = mainwin->type & ~action; | ||
| 3584 | |||
| 3585 | main_window_change_layout(mainwin, prefs_common.layout_type, type); | ||
| 3586 | |||
| 3587 | prefs_common.sep_folder = (type & SEPARATE_FOLDER) != 0; | ||
| 3588 | prefs_common.sep_msg = (type & SEPARATE_MESSAGE) != 0; | ||
| 3589 | } | ||
| 3590 | |||
| 3591 | static void addressbook_open_cb(MainWindow *mainwin, guint action, | ||
| 3592 | GtkWidget *widget) | ||
| 3593 | { | ||
| 3594 | addressbook_open(NULL); | ||
| 3595 | } | ||
| 3596 | |||
| 3597 | static void log_window_show_cb(MainWindow *mainwin, guint action, | ||
| 3598 | GtkWidget *widget) | ||
| 3599 | { | ||
| 3600 | log_window_show(mainwin->logwin); | ||
| 3601 | } | ||
| 3602 | |||
| 3603 | static void inc_mail_cb(MainWindow *mainwin, guint action, GtkWidget *widget) | ||
| 3604 | { | ||
| 3605 | inc_mail(mainwin); | ||
| 3606 | } | ||
| 3607 | |||
| 3608 | static void inc_all_account_mail_cb(MainWindow *mainwin, guint action, | ||
| 3609 | GtkWidget *widget) | ||
| 3610 | { | ||
| 3611 | inc_all_account_mail(mainwin, FALSE); | ||
| 3612 | } | ||
| 3613 | |||
| 3614 | static void inc_stop_cb(MainWindow *mainwin, guint action, GtkWidget *widget) | ||
| 3615 | { | ||
| 3616 | inc_cancel_all(); | ||
| 3617 | } | ||
| 3618 | |||
| 3619 | static void rpop3_cb(MainWindow *mainwin, guint action, GtkWidget *widget) | ||
| 3620 | { | ||
| 3621 | rpop3_account(cur_account); | ||
| 3622 | } | ||
| 3623 | |||
| 3624 | static void send_queue_cb(MainWindow *mainwin, guint action, GtkWidget *widget) | ||
| 3625 | { | ||
| 3626 | main_window_send_queue(mainwin); | ||
| 3627 | } | ||
| 3628 | |||
| 3629 | static void compose_cb(MainWindow *mainwin, guint action, GtkWidget *widget) | ||
| 3630 | { | ||
| 3631 | PrefsAccount *ac = NULL; | ||
| 3632 | FolderItem *item = mainwin->summaryview->folder_item; | ||
| 3633 | |||
| 3634 | if (item) { | ||
| 3635 | ac = account_find_from_item(item); | ||
| 3636 | if (ac && ac->protocol == A_NNTP && | ||
| 3637 | FOLDER_TYPE(item->folder) == F_NEWS) { | ||
| 3638 | compose_new(ac, item, item->path, NULL); | ||
| 3639 | return; | ||
| 3640 | } | ||
| 3641 | } | ||
| 3642 | |||
| 3643 | compose_new(ac, item, NULL, NULL); | ||
| 3644 | } | ||
| 3645 | |||
| 3646 | static void reply_cb(MainWindow *mainwin, guint action, GtkWidget *widget) | ||
| 3647 | { | ||
| 3648 | summary_reply(mainwin->summaryview, (ComposeMode)action); | ||
| 3649 | } | ||
| 3650 | |||
| 3651 | static void move_to_cb(MainWindow *mainwin, guint action, GtkWidget *widget) | ||
| 3652 | { | ||
| 3653 | summary_move_to(mainwin->summaryview); | ||
| 3654 | } | ||
| 3655 | |||
| 3656 | static void copy_to_cb(MainWindow *mainwin, guint action, GtkWidget *widget) | ||
| 3657 | { | ||
| 3658 | summary_copy_to(mainwin->summaryview); | ||
| 3659 | } | ||
| 3660 | |||
| 3661 | static void delete_cb(MainWindow *mainwin, guint action, GtkWidget *widget) | ||
| 3662 | { | ||
| 3663 | summary_delete(mainwin->summaryview); | ||
| 3664 | } | ||
| 3665 | |||
| 3666 | static void open_msg_cb(MainWindow *mainwin, guint action, GtkWidget *widget) | ||
| 3667 | { | ||
| 3668 | summary_open_msg(mainwin->summaryview); | ||
| 3669 | } | ||
| 3670 | |||
| 3671 | static void view_source_cb(MainWindow *mainwin, guint action, | ||
| 3672 | GtkWidget *widget) | ||
| 3673 | { | ||
| 3674 | summary_view_source(mainwin->summaryview); | ||
| 3675 | } | ||
| 3676 | |||
| 3677 | static void show_all_header_cb(MainWindow *mainwin, guint action, | ||
| 3678 | GtkWidget *widget) | ||
| 3679 | { | ||
| 3680 | if (mainwin->menu_lock_count) return; | ||
| 3681 | summary_display_msg_selected(mainwin->summaryview, FALSE, | ||
| 3682 | GTK_CHECK_MENU_ITEM(widget)->active); | ||
| 3683 | } | ||
| 3684 | |||
| 3685 | static void mark_cb(MainWindow *mainwin, guint action, GtkWidget *widget) | ||
| 3686 | { | ||
| 3687 | summary_mark(mainwin->summaryview); | ||
| 3688 | } | ||
| 3689 | |||
| 3690 | static void unmark_cb(MainWindow *mainwin, guint action, GtkWidget *widget) | ||
| 3691 | { | ||
| 3692 | summary_unmark(mainwin->summaryview); | ||
| 3693 | } | ||
| 3694 | |||
| 3695 | static void mark_as_unread_cb(MainWindow *mainwin, guint action, | ||
| 3696 | GtkWidget *widget) | ||
| 3697 | { | ||
| 3698 | summary_mark_as_unread(mainwin->summaryview); | ||
| 3699 | } | ||
| 3700 | |||
| 3701 | static void mark_as_read_cb(MainWindow *mainwin, guint action, | ||
| 3702 | GtkWidget *widget) | ||
| 3703 | { | ||
| 3704 | summary_mark_as_read(mainwin->summaryview); | ||
| 3705 | } | ||
| 3706 | |||
| 3707 | static void mark_thread_as_read_cb(MainWindow *mainwin, guint action, | ||
| 3708 | GtkWidget *widget) | ||
| 3709 | { | ||
| 3710 | summary_mark_thread_as_read(mainwin->summaryview); | ||
| 3711 | } | ||
| 3712 | |||
| 3713 | static void mark_all_read_cb(MainWindow *mainwin, guint action, | ||
| 3714 | GtkWidget *widget) | ||
| 3715 | { | ||
| 3716 | summary_mark_all_read(mainwin->summaryview); | ||
| 3717 | } | ||
| 3718 | |||
| 3719 | static void junk_cb(MainWindow *mainwin, guint action, GtkWidget *widget) | ||
| 3720 | { | ||
| 3721 | if (action == 0) | ||
| 3722 | summary_junk(mainwin->summaryview); | ||
| 3723 | else | ||
| 3724 | summary_not_junk(mainwin->summaryview); | ||
| 3725 | } | ||
| 3726 | |||
| 3727 | static void reedit_cb(MainWindow *mainwin, guint action, GtkWidget *widget) | ||
| 3728 | { | ||
| 3729 | summary_reedit(mainwin->summaryview); | ||
| 3730 | } | ||
| 3731 | |||
| 3732 | static void add_address_cb(MainWindow *mainwin, guint action, | ||
| 3733 | GtkWidget *widget) | ||
| 3734 | { | ||
| 3735 | summary_add_address(mainwin->summaryview); | ||
| 3736 | } | ||
| 3737 | |||
| 3738 | static void set_charset_cb(MainWindow *mainwin, guint action, | ||
| 3739 | GtkWidget *widget) | ||
| 3740 | { | ||
| 3741 | const gchar *str; | ||
| 3742 | |||
| 3743 | if (GTK_CHECK_MENU_ITEM(widget)->active) { | ||
| 3744 | str = conv_get_charset_str((CharSet)action); | ||
| 3745 | g_free(prefs_common.force_charset); | ||
| 3746 | prefs_common.force_charset = str ? g_strdup(str) : NULL; | ||
| 3747 | |||
| 3748 | summary_redisplay_msg(mainwin->summaryview); | ||
| 3749 | |||
| 3750 | debug_print("forced charset: %s\n", | ||
| 3751 | str ? str : "Auto-Detect"); | ||
| 3752 | } | ||
| 3753 | } | ||
| 3754 | |||
| 3755 | static void thread_cb(MainWindow *mainwin, guint action, GtkWidget *widget) | ||
| 3756 | { | ||
| 3757 | if (mainwin->menu_lock_count) return; | ||
| 3758 | if (!mainwin->summaryview->folder_item) return; | ||
| 3759 | |||
| 3760 | if (GTK_CHECK_MENU_ITEM(widget)->active) | ||
| 3761 | summary_thread_build(mainwin->summaryview); | ||
| 3762 | else | ||
| 3763 | summary_unthread(mainwin->summaryview); | ||
| 3764 | } | ||
| 3765 | |||
| 3766 | static void expand_threads_cb(MainWindow *mainwin, guint action, | ||
| 3767 | GtkWidget *widget) | ||
| 3768 | { | ||
| 3769 | summary_expand_threads(mainwin->summaryview); | ||
| 3770 | } | ||
| 3771 | |||
| 3772 | static void collapse_threads_cb(MainWindow *mainwin, guint action, | ||
| 3773 | GtkWidget *widget) | ||
| 3774 | { | ||
| 3775 | summary_collapse_threads(mainwin->summaryview); | ||
| 3776 | } | ||
| 3777 | |||
| 3778 | static void set_display_item_cb(MainWindow *mainwin, guint action, | ||
| 3779 | GtkWidget *widget) | ||
| 3780 | { | ||
| 3781 | prefs_summary_column_open | ||
| 3782 | (FOLDER_ITEM_IS_SENT_FOLDER(mainwin->summaryview->folder_item)); | ||
| 3783 | } | ||
| 3784 | |||
| 3785 | static void sort_summary_cb(MainWindow *mainwin, guint action, | ||
| 3786 | GtkWidget *widget) | ||
| 3787 | { | ||
| 3788 | FolderItem *item = mainwin->summaryview->folder_item; | ||
| 3789 | GtkWidget *menuitem; | ||
| 3790 | |||
| 3791 | if (mainwin->menu_lock_count) return; | ||
| 3792 | |||
| 3793 | if (GTK_CHECK_MENU_ITEM(widget)->active && item) { | ||
| 3794 | menuitem = gtk_item_factory_get_item | ||
| 3795 | (mainwin->menu_factory, "/View/Sort/Ascending"); | ||
| 3796 | summary_sort(mainwin->summaryview, (FolderSortKey)action, | ||
| 3797 | GTK_CHECK_MENU_ITEM(menuitem)->active | ||
| 3798 | ? SORT_ASCENDING : SORT_DESCENDING); | ||
| 3799 | } | ||
| 3800 | } | ||
| 3801 | |||
| 3802 | static void sort_summary_type_cb(MainWindow *mainwin, guint action, | ||
| 3803 | GtkWidget *widget) | ||
| 3804 | { | ||
| 3805 | FolderItem *item = mainwin->summaryview->folder_item; | ||
| 3806 | |||
| 3807 | if (mainwin->menu_lock_count) return; | ||
| 3808 | |||
| 3809 | if (GTK_CHECK_MENU_ITEM(widget)->active && item) | ||
| 3810 | summary_sort(mainwin->summaryview, | ||
| 3811 | item->sort_key, (FolderSortType)action); | ||
| 3812 | } | ||
| 3813 | |||
| 3814 | static void attract_by_subject_cb(MainWindow *mainwin, guint action, | ||
| 3815 | GtkWidget *widget) | ||
| 3816 | { | ||
| 3817 | summary_attract_by_subject(mainwin->summaryview); | ||
| 3818 | } | ||
| 3819 | |||
| 3820 | static void delete_duplicated_cb(MainWindow *mainwin, guint action, | ||
| 3821 | GtkWidget *widget) | ||
| 3822 | { | ||
| 3823 | summary_delete_duplicated(mainwin->summaryview); | ||
| 3824 | } | ||
| 3825 | |||
| 3826 | static void concat_partial_cb(MainWindow *mainwin, guint action, | ||
| 3827 | GtkWidget *widget) | ||
| 3828 | { | ||
| 3829 | GSList *mlist; | ||
| 3830 | gchar *file; | ||
| 3831 | FolderItem *item; | ||
| 3832 | |||
| 3833 | if (summary_is_locked(mainwin->summaryview)) | ||
| 3834 | return; | ||
| 3835 | |||
| 3836 | item = mainwin->summaryview->folder_item; | ||
| 3837 | if (!item) | ||
| 3838 | return; | ||
| 3839 | mlist = summary_get_selected_msg_list(mainwin->summaryview); | ||
| 3840 | if (!mlist) | ||
| 3841 | return; | ||
| 3842 | |||
| 3843 | file = get_tmp_file(); | ||
| 3844 | if (procmsg_concat_partial_messages(mlist, file) == 0) { | ||
| 3845 | folder_item_add_msg(item, file, NULL, TRUE); | ||
| 3846 | summary_show_queued_msgs(mainwin->summaryview); | ||
| 3847 | } else { | ||
| 3848 | alertpanel_error | ||
| 3849 | (_("The selected messages could not be combined.")); | ||
| 3850 | } | ||
| 3851 | g_free(file); | ||
| 3852 | |||
| 3853 | g_slist_free(mlist); | ||
| 3854 | } | ||
| 3855 | |||
| 3856 | static void filter_cb(MainWindow *mainwin, guint action, GtkWidget *widget) | ||
| 3857 | { | ||
| 3858 | summary_filter(mainwin->summaryview, (gboolean)action); | ||
| 3859 | } | ||
| 3860 | |||
| 3861 | static void filter_junk_cb(MainWindow *mainwin, guint action, GtkWidget *widget) | ||
| 3862 | { | ||
| 3863 | summary_filter_junk(mainwin->summaryview, (gboolean)action); | ||
| 3864 | } | ||
| 3865 | |||
| 3866 | static void execute_summary_cb(MainWindow *mainwin, guint action, | ||
| 3867 | GtkWidget *widget) | ||
| 3868 | { | ||
| 3869 | summary_execute(mainwin->summaryview); | ||
| 3870 | } | ||
| 3871 | |||
| 3872 | static void update_summary_cb(MainWindow *mainwin, guint action, | ||
| 3873 | GtkWidget *widget) | ||
| 3874 | { | ||
| 3875 | if (!mainwin->summaryview->folder_item) return; | ||
| 3876 | |||
| 3877 | summary_show(mainwin->summaryview, mainwin->summaryview->folder_item, | ||
| 3878 | TRUE); | ||
| 3879 | } | ||
| 3880 | |||
| 3881 | static void open_config_folder_cb(MainWindow *mainwin, guint action, | ||
| 3882 | GtkWidget *widget) | ||
| 3883 | { | ||
| 3884 | execute_open_file(get_rc_dir(), NULL); | ||
| 3885 | } | ||
| 3886 | |||
| 3887 | static void open_attachments_folder_cb(MainWindow *mainwin, guint action, | ||
| 3888 | GtkWidget *widget) | ||
| 3889 | { | ||
| 3890 | execute_open_file(get_mime_tmp_dir(), NULL); | ||
| 3891 | } | ||
| 3892 | |||
| 3893 | static void prev_cb(MainWindow *mainwin, guint action, GtkWidget *widget) | ||
| 3894 | { | ||
| 3895 | MessageView *messageview = mainwin->messageview; | ||
| 3896 | |||
| 3897 | if (messageview_get_selected_mime_part(messageview) && | ||
| 3898 | GTK_WIDGET_HAS_FOCUS(messageview->mimeview->treeview) && | ||
| 3899 | mimeview_step(messageview->mimeview, GTK_SCROLL_STEP_BACKWARD)) | ||
| 3900 | return; | ||
| 3901 | |||
| 3902 | if (summary_step(mainwin->summaryview, GTK_SCROLL_STEP_BACKWARD)) | ||
| 3903 | summary_mark_displayed_read(mainwin->summaryview, NULL); | ||
| 3904 | } | ||
| 3905 | |||
| 3906 | static void next_cb(MainWindow *mainwin, guint action, GtkWidget *widget) | ||
| 3907 | { | ||
| 3908 | MessageView *messageview = mainwin->messageview; | ||
| 3909 | |||
| 3910 | if (messageview_get_selected_mime_part(messageview) && | ||
| 3911 | GTK_WIDGET_HAS_FOCUS(messageview->mimeview->treeview) && | ||
| 3912 | mimeview_step(messageview->mimeview, GTK_SCROLL_STEP_FORWARD)) | ||
| 3913 | return; | ||
| 3914 | |||
| 3915 | if (summary_step(mainwin->summaryview, GTK_SCROLL_STEP_FORWARD)) | ||
| 3916 | summary_mark_displayed_read(mainwin->summaryview, NULL); | ||
| 3917 | } | ||
| 3918 | |||
| 3919 | static void prev_unread_cb(MainWindow *mainwin, guint action, | ||
| 3920 | GtkWidget *widget) | ||
| 3921 | { | ||
| 3922 | summary_select_prev_unread(mainwin->summaryview); | ||
| 3923 | } | ||
| 3924 | |||
| 3925 | static void next_unread_cb(MainWindow *mainwin, guint action, | ||
| 3926 | GtkWidget *widget) | ||
| 3927 | { | ||
| 3928 | summary_select_next_unread(mainwin->summaryview); | ||
| 3929 | } | ||
| 3930 | |||
| 3931 | static void prev_new_cb(MainWindow *mainwin, guint action, GtkWidget *widget) | ||
| 3932 | { | ||
| 3933 | summary_select_prev_new(mainwin->summaryview); | ||
| 3934 | } | ||
| 3935 | |||
| 3936 | static void next_new_cb(MainWindow *mainwin, guint action, GtkWidget *widget) | ||
| 3937 | { | ||
| 3938 | summary_select_next_new(mainwin->summaryview); | ||
| 3939 | } | ||
| 3940 | |||
| 3941 | static void prev_marked_cb(MainWindow *mainwin, guint action, | ||
| 3942 | GtkWidget *widget) | ||
| 3943 | { | ||
| 3944 | summary_select_prev_marked(mainwin->summaryview); | ||
| 3945 | } | ||
| 3946 | |||
| 3947 | static void next_marked_cb(MainWindow *mainwin, guint action, | ||
| 3948 | GtkWidget *widget) | ||
| 3949 | { | ||
| 3950 | summary_select_next_marked(mainwin->summaryview); | ||
| 3951 | } | ||
| 3952 | |||
| 3953 | static void prev_labeled_cb(MainWindow *mainwin, guint action, | ||
| 3954 | GtkWidget *widget) | ||
| 3955 | { | ||
| 3956 | summary_select_prev_labeled(mainwin->summaryview); | ||
| 3957 | } | ||
| 3958 | |||
| 3959 | static void next_labeled_cb(MainWindow *mainwin, guint action, | ||
| 3960 | GtkWidget *widget) | ||
| 3961 | { | ||
| 3962 | summary_select_next_labeled(mainwin->summaryview); | ||
| 3963 | } | ||
| 3964 | |||
| 3965 | static void goto_folder_cb(MainWindow *mainwin, guint action, | ||
| 3966 | GtkWidget *widget) | ||
| 3967 | { | ||
| 3968 | FolderItem *to_folder; | ||
| 3969 | |||
| 3970 | to_folder = foldersel_folder_sel_full(NULL, FOLDER_SEL_ALL, NULL, | ||
| 3971 | _("Select folder to open")); | ||
| 3972 | |||
| 3973 | if (to_folder) | ||
| 3974 | folderview_select(mainwin->folderview, to_folder); | ||
| 3975 | } | ||
| 3976 | |||
| 3977 | static void copy_cb(MainWindow *mainwin, guint action, GtkWidget *widget) | ||
| 3978 | { | ||
| 3979 | messageview_copy_clipboard(mainwin->messageview); | ||
| 3980 | } | ||
| 3981 | |||
| 3982 | static void allsel_cb(MainWindow *mainwin, guint action, GtkWidget *widget) | ||
| 3983 | { | ||
| 3984 | MessageView *msgview = mainwin->messageview; | ||
| 3985 | |||
| 3986 | if (GTK_WIDGET_HAS_FOCUS(mainwin->summaryview->treeview)) | ||
| 3987 | summary_select_all(mainwin->summaryview); | ||
| 3988 | else if (GTK_WIDGET_HAS_FOCUS(mainwin->summaryview->qsearch->entry)) | ||
| 3989 | gtk_editable_select_region | ||
| 3990 | (GTK_EDITABLE(mainwin->summaryview->qsearch->entry), | ||
| 3991 | 0, -1); | ||
| 3992 | else if (messageview_is_visible(msgview) && | ||
| 3993 | (GTK_WIDGET_HAS_FOCUS(msgview->textview->text) || | ||
| 3994 | GTK_WIDGET_HAS_FOCUS(msgview->mimeview->textview->text))) | ||
| 3995 | messageview_select_all(msgview); | ||
| 3996 | } | ||
| 3997 | |||
| 3998 | static void select_thread_cb(MainWindow *mainwin, guint action, | ||
| 3999 | GtkWidget *widget) | ||
| 4000 | { | ||
| 4001 | summary_select_thread(mainwin->summaryview); | ||
| 4002 | } | ||
| 4003 | |||
| 4004 | static void create_filter_cb(MainWindow *mainwin, guint action, | ||
| 4005 | GtkWidget *widget) | ||
| 4006 | { | ||
| 4007 | summary_filter_open(mainwin->summaryview, (FilterCreateType)action); | ||
| 4008 | } | ||
| 4009 | |||
| 4010 | static void prefs_common_open_cb(MainWindow *mainwin, guint action, | ||
| 4011 | GtkWidget *widget) | ||
| 4012 | { | ||
| 4013 | prefs_common_open(); | ||
| 4014 | } | ||
| 4015 | |||
| 4016 | static void prefs_filter_open_cb(MainWindow *mainwin, guint action, | ||
| 4017 | GtkWidget *widget) | ||
| 4018 | { | ||
| 4019 | prefs_filter_open(NULL, NULL, NULL); | ||
| 4020 | } | ||
| 4021 | |||
| 4022 | static void prefs_template_open_cb(MainWindow *mainwin, guint action, | ||
| 4023 | GtkWidget *widget) | ||
| 4024 | { | ||
| 4025 | prefs_template_open(); | ||
| 4026 | } | ||
| 4027 | |||
| 4028 | static void plugin_manager_open_cb(MainWindow *mainwin, guint action, | ||
| 4029 | GtkWidget *widget) | ||
| 4030 | { | ||
| 4031 | plugin_manager_open(); | ||
| 4032 | } | ||
| 4033 | |||
| 4034 | #ifndef G_OS_WIN32 | ||
| 4035 | static void prefs_actions_open_cb(MainWindow *mainwin, guint action, | ||
| 4036 | GtkWidget *widget) | ||
| 4037 | { | ||
| 4038 | prefs_actions_open(mainwin); | ||
| 4039 | } | ||
| 4040 | #endif | ||
| 4041 | |||
| 4042 | static void prefs_account_open_cb(MainWindow *mainwin, guint action, | ||
| 4043 | GtkWidget *widget) | ||
| 4044 | { | ||
| 4045 | if (!cur_account) { | ||
| 4046 | new_account_cb(mainwin, 0, widget); | ||
| 4047 | } else { | ||
| 4048 | account_open(cur_account); | ||
| 4049 | } | ||
| 4050 | } | ||
| 4051 | |||
| 4052 | static void new_account_cb(MainWindow *mainwin, guint action, | ||
| 4053 | GtkWidget *widget) | ||
| 4054 | { | ||
| 4055 | PrefsAccount *ac; | ||
| 4056 | |||
| 4057 | if (compose_get_compose_list()) { | ||
| 4058 | alertpanel_notice(_("Some composing windows are open.\n" | ||
| 4059 | "Please close all the composing windows before editing the accounts.")); | ||
| 4060 | return; | ||
| 4061 | } | ||
| 4062 | |||
| 4063 | if ((ac = setup_account())) { | ||
| 4064 | account_set_menu(); | ||
| 4065 | main_window_reflect_prefs_all(); | ||
| 4066 | account_set_missing_folder(); | ||
| 4067 | folderview_set(mainwin->folderview); | ||
| 4068 | if (ac->folder) | ||
| 4069 | folder_write_list(); | ||
| 4070 | } | ||
| 4071 | } | ||
| 4072 | |||
| 4073 | static void account_selector_menu_cb(GtkMenuItem *menuitem, gpointer data) | ||
| 4074 | { | ||
| 4075 | cur_account = (PrefsAccount *)data; | ||
| 4076 | main_window_change_cur_account(); | ||
| 4077 | } | ||
| 4078 | |||
| 4079 | static void account_receive_menu_cb(GtkMenuItem *menuitem, gpointer data) | ||
| 4080 | { | ||
| 4081 | PrefsAccount *account = (PrefsAccount *)data; | ||
| 4082 | |||
| 4083 | inc_account_mail(main_window_get(), account); | ||
| 4084 | } | ||
| 4085 | |||
| 4086 | static void manual_open_cb(MainWindow *mainwin, guint action, | ||
| 4087 | GtkWidget *widget) | ||
| 4088 | { | ||
| 4089 | manual_open((ManualLang)action); | ||
| 4090 | } | ||
| 4091 | |||
| 4092 | static void faq_open_cb(MainWindow *mainwin, guint action, GtkWidget *widget) | ||
| 4093 | { | ||
| 4094 | faq_open((ManualLang)action); | ||
| 4095 | } | ||
| 4096 | |||
| 4097 | static GtkWidget *help_cmdline_window; | ||
| 4098 | |||
| 4099 | static void help_cmdline_ok(GtkWidget *button) | ||
| 4100 | { | ||
| 4101 | gtk_widget_destroy(gtk_widget_get_toplevel(button)); | ||
| 4102 | } | ||
| 4103 | |||
| 4104 | static gboolean help_cmdline_key_pressed(GtkWidget *widget, GdkEventKey *event, | ||
| 4105 | gpointer data) | ||
| 4106 | { | ||
| 4107 | if (event && event->keyval == GDK_Escape) { | ||
| 4108 | gtk_widget_destroy(widget); | ||
| 4109 | return TRUE; | ||
| 4110 | } | ||
| 4111 | return FALSE; | ||
| 4112 | } | ||
| 4113 | |||
| 4114 | static gboolean help_cmdline_deleted(GtkWidget *widget, GdkEventAny *event, | ||
| 4115 | gpointer data) | ||
| 4116 | { | ||
| 4117 | return FALSE; | ||
| 4118 | } | ||
| 4119 | |||
| 4120 | static void help_cmdline_destroyed(GtkWidget *widget, gpointer data) | ||
| 4121 | { | ||
| 4122 | help_cmdline_window = NULL; | ||
| 4123 | } | ||
| 4124 | |||
| 4125 | static void help_command_line_show(void) | ||
| 4126 | { | ||
| 4127 | GtkWidget *window; | ||
| 4128 | GtkWidget *vbox; | ||
| 4129 | GtkWidget *vbox2; | ||
| 4130 | GtkWidget *hbox; | ||
| 4131 | GtkWidget *label; | ||
| 4132 | GtkWidget *hbbox; | ||
| 4133 | GtkWidget *ok_btn; | ||
| 4134 | |||
| 4135 | if (help_cmdline_window) { | ||
| 4136 | gtk_window_present(GTK_WINDOW(help_cmdline_window)); | ||
| 4137 | return; | ||
| 4138 | } | ||
| 4139 | |||
| 4140 | window = gtk_window_new(GTK_WINDOW_TOPLEVEL); | ||
| 4141 | gtk_window_set_title(GTK_WINDOW(window), _("Command line options")); | ||
| 4142 | gtk_container_set_border_width(GTK_CONTAINER(window), 8); | ||
| 4143 | gtk_window_set_position(GTK_WINDOW(window), GTK_WIN_POS_CENTER); | ||
| 4144 | gtk_window_set_policy(GTK_WINDOW(window), FALSE, FALSE, FALSE); | ||
| 4145 | help_cmdline_window = window; | ||
| 4146 | |||
| 4147 | vbox = gtk_vbox_new(FALSE, 8); | ||
| 4148 | gtk_container_add(GTK_CONTAINER(window), vbox); | ||
| 4149 | |||
| 4150 | vbox2 = gtk_vbox_new(FALSE, 8); | ||
| 4151 | gtk_container_set_border_width(GTK_CONTAINER(vbox2), 8); | ||
| 4152 | gtk_box_pack_start(GTK_BOX(vbox), vbox2, FALSE, FALSE, 0); | ||
| 4153 | |||
| 4154 | label = gtk_label_new(_("Usage: sylpheed [OPTION]...")); | ||
| 4155 | gtk_box_pack_start(GTK_BOX(vbox2), label, FALSE, FALSE, 0); | ||
| 4156 | gtk_label_set_justify(GTK_LABEL(label), GTK_JUSTIFY_LEFT); | ||
| 4157 | gtk_misc_set_alignment(GTK_MISC(label), 0, 0.5); | ||
| 4158 | |||
| 4159 | hbox = gtk_hbox_new(FALSE, 16); | ||
| 4160 | gtk_box_pack_start(GTK_BOX(vbox2), hbox, FALSE, FALSE, 0); | ||
| 4161 | |||
| 4162 | label = gtk_label_new(_("--compose [address]\n" | ||
| 4163 | "--attach file1 [file2]...\n" | ||
| 4164 | "--receive\n" | ||
| 4165 | "--receive-all\n" | ||
| 4166 | "--send\n" | ||
| 4167 | "--status [folder]...\n" | ||
| 4168 | "--status-full [folder]...\n" | ||
| 4169 | "--open folderid/msgnum\n" | ||
| 4170 | "--open <file URL>\n" | ||
| 4171 | "--configdir dirname\n" | ||
| 4172 | "--exit\n" | ||
| 4173 | "--debug\n" | ||
| 4174 | "--safe-mode\n" | ||
| 4175 | "--help\n" | ||
| 4176 | "--version")); | ||
| 4177 | gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0); | ||
| 4178 | gtk_label_set_justify(GTK_LABEL(label), GTK_JUSTIFY_LEFT); | ||
| 4179 | gtk_misc_set_alignment(GTK_MISC(label), 0, 0.5); | ||
| 4180 | |||
| 4181 | label = gtk_label_new(_("open composition window\n" | ||
| 4182 | "open composition window with specified files attached\n" | ||
| 4183 | "receive new messages\n" | ||
| 4184 | "receive new messages of all accounts\n" | ||
| 4185 | "send all queued messages\n" | ||
| 4186 | "show the total number of messages\n" | ||
| 4187 | "show the status of each folder\n" | ||
| 4188 | "open message in new window\n" | ||
| 4189 | "open an rfc822 message file in a new window\n" | ||
| 4190 | "specify directory which stores configuration files\n" | ||
| 4191 | "exit Sylpheed\n" | ||
| 4192 | "debug mode\n" | ||
| 4193 | "safe mode\n" | ||
| 4194 | "display this help and exit\n" | ||
| 4195 | "output version information and exit")); | ||
| 4196 | gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0); | ||
| 4197 | gtk_label_set_justify(GTK_LABEL(label), GTK_JUSTIFY_LEFT); | ||
| 4198 | gtk_misc_set_alignment(GTK_MISC(label), 0, 0.5); | ||
| 4199 | |||
| 4200 | #ifdef G_OS_WIN32 | ||
| 4201 | label = gtk_label_new(_("Windows-only option:")); | ||
| 4202 | gtk_box_pack_start(GTK_BOX(vbox2), label, FALSE, FALSE, 0); | ||
| 4203 | gtk_label_set_justify(GTK_LABEL(label), GTK_JUSTIFY_LEFT); | ||
| 4204 | gtk_misc_set_alignment(GTK_MISC(label), 0, 0.5); | ||
| 4205 | |||
| 4206 | hbox = gtk_hbox_new(FALSE, 32); | ||
| 4207 | gtk_box_pack_start(GTK_BOX(vbox2), hbox, FALSE, FALSE, 0); | ||
| 4208 | |||
| 4209 | label = gtk_label_new(_("--ipcport portnum")); | ||
| 4210 | gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0); | ||
| 4211 | gtk_label_set_justify(GTK_LABEL(label), GTK_JUSTIFY_LEFT); | ||
| 4212 | gtk_misc_set_alignment(GTK_MISC(label), 0, 0.5); | ||
| 4213 | |||
| 4214 | label = gtk_label_new(_("specify port for IPC remote commands")); | ||
| 4215 | gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0); | ||
| 4216 | gtk_label_set_justify(GTK_LABEL(label), GTK_JUSTIFY_LEFT); | ||
| 4217 | gtk_misc_set_alignment(GTK_MISC(label), 0, 0.5); | ||
| 4218 | #endif | ||
| 4219 | |||
| 4220 | gtkut_stock_button_set_create(&hbbox, &ok_btn, GTK_STOCK_OK, | ||
| 4221 | NULL, NULL, NULL, NULL); | ||
| 4222 | gtk_box_pack_end(GTK_BOX(vbox), hbbox, FALSE, FALSE, 0); | ||
| 4223 | gtk_widget_grab_default(ok_btn); | ||
| 4224 | |||
| 4225 | g_signal_connect(G_OBJECT(ok_btn), "clicked", | ||
| 4226 | G_CALLBACK(help_cmdline_ok), NULL); | ||
| 4227 | g_signal_connect(G_OBJECT(window), "key_press_event", | ||
| 4228 | G_CALLBACK(help_cmdline_key_pressed), NULL); | ||
| 4229 | g_signal_connect(G_OBJECT(window), "delete_event", | ||
| 4230 | G_CALLBACK(help_cmdline_deleted), NULL); | ||
| 4231 | g_signal_connect(G_OBJECT(window), "destroy", | ||
| 4232 | G_CALLBACK(help_cmdline_destroyed), NULL); | ||
| 4233 | |||
| 4234 | gtk_widget_show_all(window); | ||
| 4235 | } | ||
| 4236 | |||
| 4237 | static void help_cmdline_cb(MainWindow *mainwin, guint action, | ||
| 4238 | GtkWidget *widget) | ||
| 4239 | { | ||
| 4240 | help_command_line_show(); | ||
| 4241 | } | ||
| 4242 | |||
| 4243 | #if USE_UPDATE_CHECK | ||
| 4244 | static void update_check_cb(MainWindow *mainwin, guint action, | ||
| 4245 | GtkWidget *widget) | ||
| 4246 | { | ||
| 4247 | update_check(TRUE); | ||
| 4248 | } | ||
| 4249 | |||
| 4250 | #ifdef USE_UPDATE_CHECK_PLUGIN | ||
| 4251 | static void update_check_plugin_cb(MainWindow *mainwin, guint action, | ||
| 4252 | GtkWidget *widget) | ||
| 4253 | { | ||
| 4254 | update_check_plugin(TRUE); | ||
| 4255 | } | ||
| 4256 | #endif | ||
| 4257 | #endif | ||
| 4258 | |||
| 4259 | static void scan_tree_func(Folder *folder, FolderItem *item, gpointer data) | ||
| 4260 | { | ||
| 4261 | MainWindow *mainwin = (MainWindow *)data; | ||
| 4262 | gchar *str; | ||
| 4263 | |||
| 4264 | if (item->path) | ||
| 4265 | str = g_strdup_printf(_("Scanning folder %s%c%s ..."), | ||
| 4266 | LOCAL_FOLDER(folder)->rootpath, | ||
| 4267 | G_DIR_SEPARATOR, | ||
| 4268 | item->path); | ||
| 4269 | else | ||
| 4270 | str = g_strdup_printf(_("Scanning folder %s ..."), | ||
| 4271 | LOCAL_FOLDER(folder)->rootpath); | ||
| 4272 | |||
| 4273 | STATUSBAR_PUSH(mainwin, str); | ||
| 4274 | STATUSBAR_POP(mainwin); | ||
| 4275 | g_free(str); | ||
| 4276 | } | ||
