aboutsummaryrefslogtreecommitdiffstats
path: root/COPYING
Commit message (Expand)AuthorAgeFilesLines
* Initial revisionBertrand Guiheneuf1999-04-181-0/+340
' href='#n3'>3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085
/*
 * e-mail-shell-view-actions.c
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2 of the License, or (at your option) version 3.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with the program; if not, see <http://www.gnu.org/licenses/>  
 *
 *
 * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com)
 *
 */

#include "e-mail-shell-view-private.h"

static void
action_mail_account_disable_cb (GtkAction *action,
                                EMailShellView *mail_shell_view)
{
    EMailShellSidebar *mail_shell_sidebar;
    EShellModule *shell_module;
    EShellView *shell_view;
    EMFolderTree *folder_tree;
    EAccountList *account_list;
    EAccount *account;
    gchar *folder_uri;

    shell_view = E_SHELL_VIEW (mail_shell_view);
    shell_module = e_shell_view_get_shell_module (shell_view);

    mail_shell_sidebar = mail_shell_view->priv->mail_shell_sidebar;
    folder_tree = e_mail_shell_sidebar_get_folder_tree (mail_shell_sidebar);
    folder_uri = em_folder_tree_get_selected_uri (folder_tree);
    g_return_if_fail (folder_uri != NULL);

    account = mail_config_get_account_by_source_url (folder_uri);
    g_return_if_fail (account != NULL);

    if (mail_config_has_proxies (account))
        mail_config_remove_account_proxies (account);

    account->enabled = !account->enabled;
    account_list = mail_config_get_accounts ();
    e_account_list_change (account_list, account);
    e_mail_shell_module_remove_store_by_uri (shell_module, folder_uri);

    if (account->parent_uid != NULL)
        mail_config_remove_account (account);

    mail_config_save_accounts ();

    g_free (folder_uri);
}

static void
action_mail_create_search_folder_cb (GtkAction *action,
                                     EMailShellView *mail_shell_view)
{
    /* FIXME */
    g_print ("Action: %s\n", gtk_action_get_name (GTK_ACTION (action)));
}

static void
action_mail_download_cb (GtkAction *action,
                         EMailShellView *mail_shell_view)
{
    /* FIXME */
    g_print ("Action: %s\n", gtk_action_get_name (GTK_ACTION (action)));
}

static void
action_mail_empty_trash_cb (GtkAction *action,
                            EMailShellView *mail_shell_view)
{
    EShellWindow *shell_window;
    EShellView *shell_view;

    shell_view = E_SHELL_VIEW (mail_shell_view);
    shell_window = e_shell_view_get_shell_window (shell_view);

    em_utils_empty_trash (GTK_WIDGET (shell_window));
}

static void
action_mail_flush_outbox_cb (GtkAction *action,
                             EMailShellView *mail_shell_view)
{
    mail_send ();
}

static void
action_mail_folder_copy_cb (GtkAction *action,
                            EMailShellView *mail_shell_view)
{
    EMailShellSidebar *mail_shell_sidebar;
    CamelFolderInfo *folder_info;
    EMFolderTree *folder_tree;

    mail_shell_sidebar = mail_shell_view->priv->mail_shell_sidebar;
    folder_tree = e_mail_shell_sidebar_get_folder_tree (mail_shell_sidebar);
    folder_info = em_folder_tree_get_selected_folder_info (folder_tree);
    g_return_if_fail (folder_info != NULL);

    /* XXX Leaking folder_info? */
    em_folder_utils_copy_folder (folder_info, FALSE);
}

static void
action_mail_folder_delete_cb (GtkAction *action,
                              EMailShellView *mail_shell_view)
{
    EMailShellSidebar *mail_shell_sidebar;
    EMFolderTree *folder_tree;
    CamelFolder *folder;

    mail_shell_sidebar = mail_shell_view->priv->mail_shell_sidebar;
    folder_tree = e_mail_shell_sidebar_get_folder_tree (mail_shell_sidebar);
    folder = em_folder_tree_get_selected_folder (folder_tree);
    g_return_if_fail (folder != NULL);

    em_folder_utils_delete_folder (folder);
}

static void
action_mail_folder_expunge_cb (GtkAction *action,
                               EMailShellView *mail_shell_view)
{
    EMailReader *reader;
    MessageList *message_list;
    EShellWindow *shell_window;
    EShellView *shell_view;

    shell_view = E_SHELL_VIEW (mail_shell_view);
    shell_window = e_shell_view_get_shell_window (shell_view);

    reader = E_MAIL_READER (mail_shell_view->priv->mail_shell_content);
    message_list = e_mail_reader_get_message_list (reader);
    g_return_if_fail (message_list->folder != NULL);

    em_utils_expunge_folder (
        GTK_WIDGET (shell_window), message_list->folder);
}

static void
action_mail_folder_mark_all_as_read_cb (GtkAction *action,
                                        EMailShellView *mail_shell_view)
{
    EMailReader *reader;
    MessageList *message_list;
    EShellWindow *shell_window;
    EShellView *shell_view;
    CamelFolder *folder;
    GtkWindow *parent;
    GPtrArray *uids;
    const gchar *key;
    const gchar *prompt;
    guint ii;

    shell_view = E_SHELL_VIEW (mail_shell_view);
    shell_window = e_shell_view_get_shell_window (shell_view);
    parent = GTK_WINDOW (shell_window);

    reader = E_MAIL_READER (mail_shell_view->priv->mail_shell_content);
    message_list = e_mail_reader_get_message_list (reader);
    folder = message_list->folder;
    g_return_if_fail (folder != NULL);

    key = "/apps/evolution/mail/prompts/mark_all_read";
    prompt = "mail:ask-mark-all-read";

    if (!em_utils_prompt_user (parent, key, prompt, NULL))
        return;

    uids = message_list_get_uids (message_list);

    camel_folder_freeze (folder);
    for (ii = 0; ii < uids->len; ii++)
        camel_folder_set_message_flags (
            folder, uids->pdata[ii],
            CAMEL_MESSAGE_SEEN, CAMEL_MESSAGE_SEEN);
    camel_folder_thaw (folder);

    message_list_free_uids (message_list, uids);
}

static void
action_mail_folder_move_cb (GtkAction *action,
                            EMailShellView *mail_shell_view)
{
    EMailShellSidebar *mail_shell_sidebar;
    CamelFolderInfo *folder_info;
    EMFolderTree *folder_tree;

    mail_shell_sidebar = mail_shell_view->priv->mail_shell_sidebar;
    folder_tree = e_mail_shell_sidebar_get_folder_tree (mail_shell_sidebar);
    folder_info = em_folder_tree_get_selected_folder_info (folder_tree);
    g_return_if_fail (folder_info != NULL);

    /* XXX Leaking folder_info? */
    em_folder_utils_copy_folder (folder_info, TRUE);
}

static void
action_mail_folder_new_cb (GtkAction *action,
                           EMailShellView *mail_shell_view)
{
    EMailShellSidebar *mail_shell_sidebar;
    CamelFolderInfo *folder_info;
    EMFolderTree *folder_tree;

    mail_shell_sidebar = mail_shell_view->priv->mail_shell_sidebar;
    folder_tree = e_mail_shell_sidebar_get_folder_tree (mail_shell_sidebar);
    folder_info = em_folder_tree_get_selected_folder_info (folder_tree);
    g_return_if_fail (folder_info != NULL);

    em_folder_utils_create_folder (folder_info, folder_tree);
    camel_folder_info_free (folder_info);
}

static void
action_mail_folder_properties_cb (GtkAction *action,
                                  EMailShellView *mail_shell_view)
{
    EMailShellSidebar *mail_shell_sidebar;
    EMFolderTree *folder_tree;
    EShellView *shell_view;
    GtkTreeSelection *selection;
    GtkTreeView *tree_view;
    GtkTreeModel *model;
    GtkTreeIter iter;
    gchar *uri;

    shell_view = E_SHELL_VIEW (mail_shell_view);
    mail_shell_sidebar = mail_shell_view->priv->mail_shell_sidebar;
    folder_tree = e_mail_shell_sidebar_get_folder_tree (mail_shell_sidebar);

    tree_view = GTK_TREE_VIEW (folder_tree);
    selection = gtk_tree_view_get_selection (tree_view);
    if (!gtk_tree_selection_get_selected (selection, &model, &iter))
        return;

    gtk_tree_model_get (model, &iter, COL_STRING_URI, &uri, -1);
    em_folder_properties_show (shell_view, NULL, uri);
    g_free (uri);
}

static void
action_mail_folder_refresh_cb (GtkAction *action,
                               EMailShellView *mail_shell_view)
{
    EMailShellSidebar *mail_shell_sidebar;
    EMFolderTree *folder_tree;
    CamelFolder *folder;

    mail_shell_sidebar = mail_shell_view->priv->mail_shell_sidebar;
    folder_tree = e_mail_shell_sidebar_get_folder_tree (mail_shell_sidebar);
    folder = em_folder_tree_get_selected_folder (folder_tree);
    g_return_if_fail (folder != NULL);

    mail_refresh_folder (folder, NULL, NULL);
}

static void
action_mail_folder_rename_cb (GtkAction *action,
                              EMailShellView *mail_shell_view)
{
    EMailShellSidebar *mail_shell_sidebar;
    EMFolderTree *folder_tree;
    CamelFolder *folder;

    mail_shell_sidebar = mail_shell_view->priv->mail_shell_sidebar;
    folder_tree = e_mail_shell_sidebar_get_folder_tree (mail_shell_sidebar);
    folder = em_folder_tree_get_selected_folder (folder_tree);
    g_return_if_fail (folder != NULL);

    em_folder_utils_rename_folder (folder);
}

/* Helper for action_mail_folder_select_all_cb() */
static gboolean
action_mail_folder_select_all_timeout_cb (MessageList *message_list)
{
    message_list_select_all (message_list);
    gtk_widget_grab_focus (GTK_WIDGET (message_list));

    return FALSE;
}

static void
action_mail_folder_select_all_cb (GtkAction *action,
                                  EMailShellView *mail_shell_view)
{
    EMailReader *reader;
    MessageList *message_list;
    EShellWindow *shell_window;
    EShellView *shell_view;

    shell_view = E_SHELL_VIEW (mail_shell_view);
    shell_window = e_shell_view_get_shell_window (shell_view);

    reader = E_MAIL_READER (mail_shell_view->priv->mail_shell_content);
    message_list = e_mail_reader_get_message_list (reader);

    if (message_list->threaded) {
        gtk_action_activate (ACTION (MAIL_THREADS_EXPAND_ALL));

        /* XXX The timeout below is added so that the execution
         *     thread to expand all conversation threads would
         *     have completed.  The timeout 505 is just to ensure
         *     that the value is a small delta more than the
         *     timeout value in mail_regen_list(). */
        g_timeout_add (
            505, (GSourceFunc)
            action_mail_folder_select_all_timeout_cb,
            message_list);
    } else
        /* If there is no threading, just select all immediately. */
        action_mail_folder_select_all_timeout_cb (message_list);
}

static void
action_mail_folder_select_thread_cb (GtkAction *action,
                                     EMailShellView *mail_shell_view)
{
    MessageList *message_list;
    EMailReader *reader;

    reader = E_MAIL_READER (mail_shell_view->priv->mail_shell_content);
    message_list = e_mail_reader_get_message_list (reader);

    message_list_select_thread (message_list);
}

static void
action_mail_folder_select_subthread_cb (GtkAction *action,
                                        EMailShellView *mail_shell_view)
{
    MessageList *message_list;
    EMailReader *reader;

    reader = E_MAIL_READER (mail_shell_view->priv->mail_shell_content);
    message_list = e_mail_reader_get_message_list (reader);

    message_list_select_subthread (message_list);
}

static void
action_mail_hide_deleted_cb (GtkToggleAction *action,
                             EMailShellView *mail_shell_view)
{
    /* FIXME */
    g_print ("Action: %s\n", gtk_action_get_name (GTK_ACTION (action)));
}

static void
action_mail_hide_read_cb (GtkAction *action,
                          EMailShellView *mail_shell_view)
{
    MessageList *message_list;
    EMailReader *reader;

    reader = E_MAIL_READER (mail_shell_view->priv->mail_shell_content);
    message_list = e_mail_reader_get_message_list (reader);

    message_list_hide_add (
        message_list,
        "(match-all (system-flag \"seen\"))",
        ML_HIDE_SAME, ML_HIDE_SAME);
}

static void
action_mail_hide_selected_cb (GtkAction *action,
                              EMailShellView *mail_shell_view)
{
    MessageList *message_list;
    EMailReader *reader;
    GPtrArray *uids;

    reader = E_MAIL_READER (mail_shell_view->priv->mail_shell_content);
    message_list = e_mail_reader_get_message_list (reader);

    uids = message_list_get_selected (message_list);
    message_list_hide_uids (message_list, uids);
    message_list_free_uids (message_list, uids);
}

static void
action_mail_preview_cb (GtkToggleAction *action,
                        EMailShellView *mail_shell_view)
{
    EMailShellContent *mail_shell_content;
    gboolean active;

    mail_shell_content = mail_shell_view->priv->mail_shell_content;
    active = gtk_toggle_action_get_active (action);

    e_mail_shell_content_set_preview_visible (mail_shell_content, active);
}

static void
action_mail_show_hidden_cb (GtkAction *action,
                            EMailShellView *mail_shell_view)
{
    MessageList *message_list;
    EMailReader *reader;

    reader = E_MAIL_READER (mail_shell_view->priv->mail_shell_content);
    message_list = e_mail_reader_get_message_list (reader);

    message_list_hide_clear (message_list);
}

static void
action_mail_stop_cb (GtkAction *action,
                     EMailShellView *mail_shell_view)
{
    mail_cancel_all ();
}

static void
action_mail_threads_collapse_all_cb (GtkAction *action,
                                     EMailShellView *mail_shell_view)
{
    MessageList *message_list;
    EMailReader *reader;

    reader = E_MAIL_READER (mail_shell_view->priv->mail_shell_content);
    message_list = e_mail_reader_get_message_list (reader);

    message_list_set_threaded_collapse_all (message_list);
}

static void
action_mail_threads_expand_all_cb (GtkAction *action,
                                   EMailShellView *mail_shell_view)
{
    MessageList *message_list;
    EMailReader *reader;

    reader = E_MAIL_READER (mail_shell_view->priv->mail_shell_content);
    message_list = e_mail_reader_get_message_list (reader);

    message_list_set_threaded_expand_all (message_list);
}

static void
action_mail_threads_group_by_cb (GtkToggleAction *action,
                                 EMailShellView *mail_shell_view)
{
    EMailShellContent *mail_shell_content;
    MessageList *message_list;
    EMailReader *reader;
    gboolean active;

    mail_shell_content = mail_shell_view->priv->mail_shell_content;
    active = gtk_toggle_action_get_active (action);

    reader = E_MAIL_READER (mail_shell_content);
    message_list = e_mail_reader_get_message_list (reader);

    message_list_set_threaded (message_list, active);
}

static void
action_mail_tools_filters_cb (GtkAction *action,
                              EMailShellView *mail_shell_view)
{
    EShellWindow *shell_window;
    EShellView *shell_view;

    shell_view = E_SHELL_VIEW (mail_shell_view);
    shell_window = e_shell_view_get_shell_window (shell_view);

    em_utils_edit_filters (GTK_WIDGET (shell_window));
}

static void
action_mail_tools_search_folders_cb (GtkAction *action,
                                     EMailShellView *mail_shell_view)
{
    vfolder_edit (E_SHELL_VIEW (mail_shell_view));
}

static void
action_mail_tools_subscriptions_cb (GtkAction *action,
                                    EMailShellView *mail_shell_view)
{
    EShellWindow *shell_window;
    EShellView *shell_view;
    GtkWidget *dialog;

    shell_view = E_SHELL_VIEW (mail_shell_view);
    shell_window = e_shell_view_get_shell_window (shell_view);

    dialog = em_subscribe_editor_new ();
    gtk_window_set_transient_for (
        GTK_WINDOW (dialog), GTK_WINDOW (shell_window));
    gtk_dialog_run (GTK_DIALOG (dialog));
    /* XXX Dialog destroys itself. */
}

static void
action_mail_view_cb (GtkRadioAction *action,
                     GtkRadioAction *current,
                     EMailShellView *mail_shell_view)
{
    EMailShellContent *mail_shell_content;
    gboolean vertical_view;

    mail_shell_content = mail_shell_view->priv->mail_shell_content;
    vertical_view = (gtk_radio_action_get_current_value (action) == 1);

    e_mail_shell_content_set_vertical_view (
        mail_shell_content, vertical_view);
}

static GtkActionEntry mail_entries[] = {

    { "mail-account-disable",
      NULL,
      N_("_Disable Account"),
      NULL,
      N_("Disable this account"),
      G_CALLBACK (action_mail_account_disable_cb) },

    { "mail-create-search-folder",
      NULL,
      N_("C_reate Search Folder From Search..."),
      NULL,
      NULL,  /* XXX Add a tooltip! */
      G_CALLBACK (action_mail_create_search_folder_cb) },

    { "mail-download",
      NULL,
      N_("_Download Messages for Offline Usage"),
      NULL,
      N_("Download messages of accounts and folders marked for offline"),
      G_CALLBACK (action_mail_download_cb) },

    { "mail-empty-trash",
      NULL,
      N_("Empty _Trash"),
      NULL,
      N_("Permanently remove all the deleted messages from all folders"),
      G_CALLBACK (action_mail_empty_trash_cb) },

    { "mail-flush-outbox",
      "mail-send",
      N_("Fl_ush Outbox"),
      NULL,
      NULL,  /* XXX Add a tooltip! */
      G_CALLBACK (action_mail_flush_outbox_cb) },

    { "mail-folder-copy",
      "folder-copy",
      N_("_Copy Folder To..."),
      NULL,
      N_("Copy the selected folder into another folder"),
      G_CALLBACK (action_mail_folder_copy_cb) },

    { "mail-folder-delete",
      GTK_STOCK_DELETE,
      NULL,
      NULL,
      N_("Permanently remove this folder"),
      G_CALLBACK (action_mail_folder_delete_cb) },

    { "mail-folder-expunge",
      NULL,
      N_("E_xpunge"),
      "<Control>e",
      N_("Permanently remove all deleted messages from this folder"),
      G_CALLBACK (action_mail_folder_expunge_cb) },

    { "mail-folder-mark-all-as-read",
      "mail-read",
      N_("Mar_k All Messages as Read"),
      NULL,
      N_("Mark all messages in the folder as read"),
      G_CALLBACK (action_mail_folder_mark_all_as_read_cb) },

    { "mail-folder-move",
      "folder-move",
      N_("_Move Folder To..."),
      NULL,
      N_("Move the selected folder into another folder"),
      G_CALLBACK (action_mail_folder_move_cb) },

    { "mail-folder-new",
      "folder-new",
      N_("_New..."),
      NULL,
      N_("Create a new folder for storing mail"),
      G_CALLBACK (action_mail_folder_new_cb) },

    { "mail-folder-properties",
      GTK_STOCK_PROPERTIES,
      NULL,
      NULL,
      N_("Change the properties of this folder"),
      G_CALLBACK (action_mail_folder_properties_cb) },

    { "mail-folder-refresh",
      GTK_STOCK_REFRESH,
      NULL,
      "F5",
      N_("Refresh the folder"),
      G_CALLBACK (action_mail_folder_refresh_cb) },

    { "mail-folder-rename",
      NULL,
      N_("_Rename..."),
      "F2",
      N_("Change the name of this folder"),
      G_CALLBACK (action_mail_folder_rename_cb) },

    { "mail-folder-select-all",
      NULL,
      N_("Select _All Messages"),
      "<Control>a",
      N_("Select all visible messages"),
      G_CALLBACK (action_mail_folder_select_all_cb) },

    { "mail-folder-select-thread",
      NULL,
      N_("Select Message _Thread"),
      "<Control>h",
      N_("Select all messages in the same thread as the selected message"),
      G_CALLBACK (action_mail_folder_select_thread_cb) },

    { "mail-folder-select-subthread",
      NULL,
      N_("Select Message S_ubthread"),
      "<Shift><Control>h",
      N_("Select all replies to the currently selected message"),
      G_CALLBACK (action_mail_folder_select_subthread_cb) },

    { "mail-hide-read",
      NULL,
      N_("Hide _Read Messages"),
      NULL,
      N_("Temporarily hide all messages that have already been read"),
      G_CALLBACK (action_mail_hide_read_cb) },

    { "mail-hide-selected",
      NULL,
      N_("Hide S_elected Messages"),
      NULL,
      N_("Temporarily hide the selected messages"),
      G_CALLBACK (action_mail_hide_selected_cb) },

    { "mail-show-hidden",
      NULL,
      N_("Show Hidde_n Messages"),
      NULL,
      N_("Show messages that have been temporarily hidden"),
      G_CALLBACK (action_mail_show_hidden_cb) },

    { "mail-stop",
      GTK_STOCK_STOP,
      N_("Cancel"),
      NULL,
      N_("Cancel the current mail operation"),
      G_CALLBACK (action_mail_stop_cb) },

    { "mail-threads-collapse-all",
      NULL,
      N_("Collapse All _Threads"),
      "<Shift><Control>b",
      N_("Collapse all message threads"),
      G_CALLBACK (action_mail_threads_collapse_all_cb) },

    { "mail-threads-expand-all",
      NULL,
      N_("E_xpand All Threads"),
      NULL,
      N_("Expand all message threads"),
      G_CALLBACK (action_mail_threads_expand_all_cb) },

    { "mail-tools-filters",
      NULL,
      N_("_Message Filters"),
      NULL,
      N_("Create or edit rules for filtering new mail"),
      G_CALLBACK (action_mail_tools_filters_cb) },

    { "mail-tools-search-folders",
      NULL,
      N_("Search F_olders"),
      NULL,
      N_("Create or edit search folder definitions"),
      G_CALLBACK (action_mail_tools_search_folders_cb) },

    { "mail-tools-subscriptions",
      NULL,
      N_("_Subscriptions..."),
      NULL,
      N_("Subscribe or unsubscribe to folders on remote servers"),
      G_CALLBACK (action_mail_tools_subscriptions_cb) },

    /*** Menus ***/

    { "mail-folder-menu",
      NULL,
      N_("F_older"),
      NULL,
      NULL,
      NULL },

    { "mail-preview-menu",
      NULL,
      N_("_Preview"),
      NULL,
      NULL,
      NULL }
};

static EPopupActionEntry mail_popup_entries[] = {

    { "mail-popup-account-disable",
      NULL,
      "mail-account-disable" },

    { "mail-popup-empty-trash",
      NULL,
      "mail-empty-trash" },

    { "mail-popup-flush-outbox",
      NULL,
      "mail-flush-outbox" },

    { "mail-popup-folder-copy",
      NULL,
      "mail-folder-copy" },

    { "mail-popup-folder-delete",
      NULL,
      "mail-folder-delete" },

    { "mail-popup-folder-move",
      NULL,
      "mail-folder-move" },

    { "mail-popup-folder-new",
      N_("_New Folder..."),
      "mail-folder-new" },

    { "mail-popup-folder-properties",
      NULL,
      "mail-folder-properties" },

    { "mail-popup-folder-refresh",
      NULL,
      "mail-folder-refresh" },

    { "mail-popup-folder-rename",
      NULL,
      "mail-folder-rename" }
};

static GtkToggleActionEntry mail_toggle_entries[] = {

    { "mail-hide-deleted",
      NULL,
      N_("Hide _Deleted Messages"),
      NULL,
      N_("Hide deleted messages rather than displaying "
         "them with a line through them"),
      G_CALLBACK (action_mail_hide_deleted_cb),
      TRUE },

    { "mail-preview",
      NULL,
      N_("Show Message _Preview"),
      "<Control>m",
      N_("Show message preview pane"),
      G_CALLBACK (action_mail_preview_cb),
      TRUE },

    { "mail-threads-group-by",
      NULL,
      N_("_Group By Threads"),
      "<Control>t",
      N_("Threaded message list"),
      G_CALLBACK (action_mail_threads_group_by_cb),
      FALSE }
};

static GtkRadioActionEntry mail_view_entries[] = {

    /* This action represents the initial active mail view.
     * It should not be visible in the UI, nor should it be
     * possible to switch to it from another shell view. */
    { "mail-view-internal",
      NULL,
      NULL,
      NULL,
      NULL,
      -1 },

    { "mail-view-classic",
      NULL,
      N_("_Classic View"),
      NULL,
      N_("Show message preview below the message list"),
      0 },

    { "mail-view-vertical",
      NULL,
      N_("_Vertical View"),
      NULL,
      N_("Show message preview alongside the message list"),
      1 }
};

static GtkRadioActionEntry mail_filter_entries[] = {

    { "mail-filter-all-messages",
      NULL,
      N_("All Messages"),
      NULL,
      NULL,  /* XXX Add a tooltip! */
      MAIL_FILTER_ALL_MESSAGES },

    { "mail-filter-important-messages",
      "emblem-important",
      N_("Important Messages"),
      NULL,
      NULL,  /* XXX Add a tooltip! */
      MAIL_FILTER_IMPORTANT_MESSAGES },

    { "mail-filter-label-important",
      NULL,
      N_("Important"),
      NULL,
      NULL,  /* XXX Add a tooltip! */
      MAIL_FILTER_LABEL_IMPORTANT },

    { "mail-filter-label-later",
      NULL,
      N_("Later"),
      NULL,
      NULL,  /* XXX Add a tooltip! */
      MAIL_FILTER_LABEL_LATER },

    { "mail-filter-label-personal",
      NULL,
      N_("Personal"),
      NULL,
      NULL,  /* XXX Add a tooltip! */
      MAIL_FILTER_LABEL_PERSONAL },

    { "mail-filter-label-to-do",
      NULL,
      N_("To Do"),
      NULL,
      NULL,  /* XXX Add a tooltip! */
      MAIL_FILTER_LABEL_TO_DO },

    { "mail-filter-label-work",
      NULL,
      N_("Work"),
      NULL,
      NULL,  /* XXX Add a tooltip! */
      MAIL_FILTER_LABEL_WORK },

    { "mail-filter-last-5-days-messages",
      NULL,
      N_("Last 5 Days' Messages"),
      NULL,
      NULL,  /* XXX Add a tooltip! */
      MAIL_FILTER_LAST_5_DAYS_MESSAGES },

    { "mail-filter-messages-not-junk",
      "mail-mark-notjunk",
      N_("Messages Not Junk"),
      NULL,
      NULL,  /* XXX Add a tooltip! */
      MAIL_FILTER_MESSAGES_NOT_JUNK },

    { "mail-filter-messages-with-attachments",
      "mail-attachment",
      N_("Messages with Attachments"),
      NULL,
      NULL,  /* XXX Add a tooltip! */
      MAIL_FILTER_MESSAGES_WITH_ATTACHMENTS },

    { "mail-filter-no-label",
      NULL,
      N_("No Label"),
      NULL,
      NULL,  /* XXX Add a tooltip! */
      MAIL_FILTER_NO_LABEL },

    { "mail-filter-read-messages",
      "mail-read",
      N_("Read Messages"),
      NULL,
      NULL,  /* XXX Add a tooltip! */
      MAIL_FILTER_READ_MESSAGES },

    { "mail-filter-recent-messages",
      NULL,
      N_("Recent Messages"),
      NULL,
      NULL,  /* XXX Add a tooltip! */
      MAIL_FILTER_RECENT_MESSAGES },

    { "mail-filter-unread-messages",
      "mail-unread",
      N_("Unread Messages"),
      NULL,
      NULL,  /* XXX Add a tooltip! */
      MAIL_FILTER_UNREAD_MESSAGES }
};

static GtkRadioActionEntry mail_search_entries[] = {

    { "mail-search-body-contains",
      NULL,
      N_("Body contains"),
      NULL,
      NULL,  /* XXX Add a tooltip! */
      MAIL_SEARCH_BODY_CONTAINS },

    { "mail-search-message-contains",
      NULL,
      N_("Message contains"),
      NULL,
      NULL,  /* XXX Add a tooltip! */
      MAIL_SEARCH_MESSAGE_CONTAINS },

    { "mail-search-recipients-contain",
      NULL,
      N_("Recipients contain"),
      NULL,
      NULL,  /* XXX Add a tooltip! */
      MAIL_SEARCH_RECIPIENTS_CONTAIN },

    { "mail-search-sender-contains",
      NULL,
      N_("Sender contains"),
      NULL,
      NULL,  /* XXX Add a tooltip! */
      MAIL_SEARCH_SENDER_CONTAINS },

    { "mail-search-subject-contains",
      NULL,
      N_("Subject contains"),
      NULL,
      NULL,  /* XXX Add a tooltip! */
      MAIL_SEARCH_SUBJECT_CONTAINS },

    { "mail-search-subject-or-recipients-contains",
      NULL,
      N_("Subject or Recipients contains"),
      NULL,
      NULL,  /* XXX Add a tooltip! */
      MAIL_SEARCH_SUBJECT_OR_RECIPIENTS_CONTAINS },

    { "mail-search-subject-or-sender-contains",
      NULL,
      N_("Subject or Sender contains"),
      NULL,
      NULL,  /* XXX Add a tooltip! */
      MAIL_SEARCH_SUBJECT_OR_SENDER_CONTAINS }
};

static GtkRadioActionEntry mail_scope_entries[] = {

    { "mail-scope-all-accounts",
      NULL,
      N_("All Accounts"),
      NULL,
      NULL,  /* XXX Add a tooltip! */
      MAIL_SCOPE_ALL_ACCOUNTS },

    { "mail-scope-current-account",
      NULL,
      N_("Current Account"),
      NULL,
      NULL,  /* XXX Add a tooltip! */
      MAIL_SCOPE_CURRENT_ACCOUNT },

    { "mail-scope-current-folder",
      NULL,
      N_("Current Folder"),
      NULL,
      NULL,  /* XXX Add a tooltip! */
      MAIL_SCOPE_CURRENT_FOLDER },

    { "mail-scope-current-message",
      NULL,
      N_("Current Message"),
      NULL,
      NULL,  /* XXX Add a tooltip! */
      MAIL_SCOPE_CURRENT_MESSAGE }
};

void
e_mail_shell_view_actions_init (EMailShellView *mail_shell_view)
{
    EShellView *shell_view;
    EShellWindow *shell_window;
    GtkActionGroup *action_group;
    GtkUIManager *ui_manager;
    GConfBridge *bridge;
    GObject *object;
    GObject *src_object;
    GObject *dst_object;
    const gchar *domain;
    const gchar *key;

    shell_view = E_SHELL_VIEW (mail_shell_view);
    shell_window = e_shell_view_get_shell_window (shell_view);
    ui_manager = e_shell_window_get_ui_manager (shell_window);
    domain = GETTEXT_PACKAGE;

    action_group = mail_shell_view->priv->mail_actions;
    gtk_action_group_set_translation_domain (action_group, domain);
    gtk_action_group_add_actions (
        action_group, mail_entries,
        G_N_ELEMENTS (mail_entries), mail_shell_view);
    e_action_group_add_popup_actions (
        action_group, mail_popup_entries,
        G_N_ELEMENTS (mail_popup_entries));
    gtk_action_group_add_toggle_actions (
        action_group, mail_toggle_entries,
        G_N_ELEMENTS (mail_toggle_entries), mail_shell_view);
    gtk_action_group_add_radio_actions (
        action_group, mail_view_entries,
        G_N_ELEMENTS (mail_view_entries), -1,
        G_CALLBACK (action_mail_view_cb), mail_shell_view);
    gtk_action_group_add_radio_actions (
        action_group, mail_search_entries,
        G_N_ELEMENTS (mail_search_entries),
        MAIL_SEARCH_SUBJECT_OR_SENDER_CONTAINS,
        NULL, NULL);
    gtk_action_group_add_radio_actions (
        action_group, mail_scope_entries,
        G_N_ELEMENTS (mail_scope_entries),
        MAIL_SCOPE_CURRENT_FOLDER,
        NULL, NULL);
    gtk_ui_manager_insert_action_group (ui_manager, action_group, 0);

    /* Bind GObject properties for GConf keys. */

    bridge = gconf_bridge_get ();

    object = G_OBJECT (ACTION (MAIL_PREVIEW));
    key = "/apps/evolution/mail/display/show_preview";
    gconf_bridge_bind_property (bridge, key, object, "active");

    object = G_OBJECT (ACTION (MAIL_THREADS_GROUP_BY));
    key = "/apps/evolution/mail/display/thread_list";
    gconf_bridge_bind_property (bridge, key, object, "active");

    object = G_OBJECT (ACTION (MAIL_VIEW_VERTICAL));
    key = "/apps/evolution/mail/display/layout";
    gconf_bridge_bind_property (bridge, key, object, "current-value");

    /* Fine tuning. */

    src_object = G_OBJECT (ACTION (MAIL_THREADS_GROUP_BY));

    dst_object = G_OBJECT (ACTION (MAIL_FOLDER_SELECT_THREAD));
    e_binding_new (src_object, "active", dst_object, "sensitive");

    dst_object = G_OBJECT (ACTION (MAIL_FOLDER_SELECT_SUBTHREAD));
    e_binding_new (src_object, "active", dst_object, "sensitive");

    dst_object = G_OBJECT (ACTION (MAIL_THREADS_COLLAPSE_ALL));
    e_binding_new (src_object, "active", dst_object, "sensitive");

    dst_object = G_OBJECT (ACTION (MAIL_THREADS_EXPAND_ALL));
    e_binding_new (src_object, "active", dst_object, "sensitive");
}