aboutsummaryrefslogblamecommitdiffstats
path: root/mail/e-mail-shell-view-actions.c
blob: 83131c2a927db4b08020921759688864f5e1e57d (plain) (tree)
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930
1931
1932
1933
1934
1935
1936
1937
1938
1939
1940
1941
1942
1943
1944
1945
1946
1947
1948
1949
1950
1951
1952
1953
1954
1955
1956
1957
1958
1959
1960
1961
1962
1963
1964
1965
1966
1967
1968
1969
1970
1971
1972
1973
1974
1975
1976
1977
1978
1979
1980
1981
1982
1983
1984
1985
1986
1987
1988
1989
1990
1991
1992
1993
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
2027
2028
2029
2030
2031
2032
2033
2034
2035
2036
2037
2038
2039
2040
2041
2042
2043
2044
2045
2186
2187
2188
2189
2190
2191
2192
2193
2194
2195
2196
2197
2198
2199
2200
2201
2202
2203
2204
2205
2206
2207
2208
2209
2210
2211
2212
2213
2214
2215
2216
2217
2218
2219
2220
2221
2222
2223
2224
2225
2226
2227
2228
2229
2230
2231
2232
2233
2234
2235
2236
2237
2238
2239
2240
2241
2242
2243
2244
2245
2246
2247
2248
2249
2250
2251
2252
2253
2254
2255
2256
2257
2258
2259
2260
2261
2262
2263
2264
2265
2266
2267
2268
2269
2270
2271
2272
2273
2274
2275
2276
2277
2278
2279
2280
2281
2282
2283
2284
2285
2286
2287
2288
2289
2290
2291
2292
2293
2294
2295
2296
2297
2298
2299
2300
2301
2302
2303
2304
2305
2306
2307
2308
2309
2310
2311
2312
2313
2314
2315
2316
2317
2318
2319
2320
2321
2322
2323
2324
2325
2326
2327
2328
2329
2330
2331
2332
2333
2334
2335
2336
2337
2338
2339
2340
2341
2342
2343
2344
2345
2346
2347
2348
2349
2350
2351
2352
2353
2354
2355
2356
2357
2358
2359
2360
2361
2362
2363
2364
2365
2366
2367
2368
2369
2370
2371
2372
2373
2374
2375
2376
2377
2378
2379
2380
2381
2382
2383
2384
2385
2386
2387
2388
2389
2390
2391
2392
2393
2394
2395
2396
2397
2398
2399
2400
2401
2402
2403
2404
2405
2406
2407
2408
2409
2410
2411
2412
2413
2414
2415
2416
2417
2418
2419
2420
2421
2422
2423
2424
2425
2426
2427
2428
2429
2430
2431
2432
2433
2434
2435
2436
2437
2438
2439
2440
2441
2442
2443
2444
2445
2446
2447
2448
2449
2450
2451
2452
2453
2454
2455
2456
2457
2458
2459
2460
2461
2462
2463
2464
2465
2466
2467
2468
2469
2470
2471
2472
2473
2474
2475
2476
2477
2478
2479
2480
2481
2482
2483
2484
2485
2486
2487
2488
2489
2490
2491
2492
2493
2494






















                                                                               


                                                                          

                                             
                                                           
 































                                                                                





                                                           








                                                                              





                                                               









                                                                                





                                                               






                                                                               





                                                     























































                                                                                





























                                                                            






                                                                  





                                                                       

                                                       





                                                                     

                                                       





                                                                 

                                                       





                                                                  

                                                       





                                                              









                                                                                













                                                                            



















                                                                                





                                                               



















                                                                                





                                                                  















                                                                                


           


                                                             
                     


           


                                                            










                                                                                





                                                              









                                                                                





                                                               













                                                                                













                                                                            










                                                                                





                                                           










                                                                                





                                                                  




















                                                                                





                                                               









                                                                                





                                                              









                                                                                













                                                                            






                                                                                





                                                                        






                                                                                





                                                        


















                                                                                





                                                                 


















                                                                                





                                                               


















                                                                                





                                                               


















                                                                                













                                                                            









                                                                                





                                                              









                                                                                





                                                            






                                                                              





                                                               










                                                                                





                                                          














                                                                                





                                                             













                                                                                





                                                          










                                                                                





                                                                 










                                                                                





                                                            















                                                                                





                                                             

















                                                                                





                                                            














                                                                                













                                                                            






                                                                                





                                                     























































                                                                                





                                                     












                                                                                





                                                               












                                                                                





                                                            






                                                                                





                                                            












                                                                                



















                                                                       












                                                                                





                                                                   












                                                                                





                                                                












                                                                                





                                                      








                                                                                





                                                              








                                                                                





                                                         


















                                                                                





                                                          






                                                                                





                                                           






                                                                                





                                                           


















                                                                                





                                                             






                                                                                





                                                        















                                                                                





                                                                                

                                                        





                                                                              

                                                        





                                                                          

                                                        





                                                                           

                                                        





















                                                                            






                                                                                













                                                                            
                           





                                                                     






                                                                                





                                                                   






                                                                                













                                                                            






                                                                  





                                                                     
                                                      





                                                                    











                                                                  





                                                         










                                                                                


           







































                                                                               


                                                         






                                                                              





                                                        






                                                                              





                                                         






                                                                              














































                                                                           





                                                             




































































































                                                                             






                                                     
















































































































































































































































































































































































































































                                                                               
                                  










                                                                      


































                                                                       





















































































                                                    






                                           




















































































































































































































































































































                                                                         



                                                                   



                                                                   
                                                        
                                                       




                                                                   














                                                                  
/*
 * 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"

/* Remembers the previously selected folder when transferring messages. */
static gchar *default_xfer_messages_uri;

static void
action_mail_add_sender_cb (GtkAction *action,
                           EMailShellView *mail_shell_view)
{
    EMailShellContent *mail_shell_content;
    EMFolderView *folder_view;
    EShellWindow *shell_window;
    EShellView *shell_view;
    CamelMessageInfo *info;
    GPtrArray *uids;
    const gchar *address;

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

    mail_shell_content = mail_shell_view->priv->mail_shell_content;
    folder_view = e_mail_shell_content_get_folder_view (mail_shell_content);

    uids = message_list_get_selected (folder_view->list);

    if (uids->len != 1)
        goto exit;

    info = camel_folder_get_message_info (
        folder_view->folder, uids->pdata[0]);
    if (info == NULL)
        goto exit;

    address = camel_message_info_from (info);
    if (address == NULL || *address == '\0')
        goto exit;

    em_utils_add_address (GTK_WIDGET (shell_window), address);

exit:
    em_utils_uids_free (uids);
}

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

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

    em_format_html_display_set_caret_mode (format, active);
}

static void
action_mail_check_for_junk_cb (GtkAction *action,
                               EMailShellView *mail_shell_view)
{
    EMailShellContent *mail_shell_content;
    EMFolderView *folder_view;
    GPtrArray *uids;

    mail_shell_content = mail_shell_view->priv->mail_shell_content;
    folder_view = e_mail_shell_content_get_folder_view (mail_shell_content);

    uids = message_list_get_selected (folder_view->list);

    mail_filter_junk (folder_view->folder, uids);
}

static void
action_mail_clipboard_copy_cb (GtkAction *action,
                               EMailShellView *mail_shell_view)
{
    EMailShellContent *mail_shell_content;
    GtkWidget *preview;

    mail_shell_content = mail_shell_view->priv->mail_shell_content;
    preview = e_mail_shell_content_get_preview_widget (mail_shell_content);

    gtk_html_copy (GTK_HTML (preview));
}

static void
action_mail_copy_cb (GtkAction *action,
                     EMailShellView *mail_shell_view)
{
    EMailShellContent *mail_shell_content;
    EShellModule *shell_module;
    EShellView *shell_view;
    EMFolderTreeModel *model;
    EMFolderView *folder_view;
    GtkWidget *folder_tree;
    GtkWidget *dialog;
    GPtrArray *selected;
    const gchar *uri;

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

    mail_shell_content = mail_shell_view->priv->mail_shell_content;
    folder_view = e_mail_shell_content_get_folder_view (mail_shell_content);
    selected = message_list_get_selected (folder_view->list);

    folder_tree = em_folder_tree_new_with_model (model);

    em_folder_tree_set_excluded (
        EM_FOLDER_TREE (folder_tree),
        EMFT_EXCLUDE_NOSELECT | EMFT_EXCLUDE_VIRTUAL |
        EMFT_EXCLUDE_VTRASH);

    dialog = em_folder_selector_new (
        EM_FOLDER_TREE (folder_tree),
        EM_FOLDER_SELECTOR_CAN_CREATE,
        _("Select Folder"), NULL, _("C_opy"));

    if (default_xfer_messages_uri != NULL)
        em_folder_selector_set_selected (
            EM_FOLDER_SELECTOR (dialog),
            default_xfer_messages_uri);

    if (gtk_dialog_run (GTK_DIALOG (dialog)) != GTK_RESPONSE_OK)
        goto exit;

    uri = em_folder_selector_get_selected_uri (
        EM_FOLDER_SELECTOR (dialog));

    g_free (default_xfer_messages_uri);
    default_xfer_messages_uri = g_strdup (uri);

    if (uri != NULL) {
        mail_transfer_messages (
            folder_view->folder, selected,
            FALSE, uri, 0, NULL, NULL);
        selected = NULL;
    }

exit:
    if (selected != NULL)
        em_utils_uids_free (selected);

    gtk_widget_destroy (dialog);
}

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_delete_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_filter_on_mailing_list_cb (GtkAction *action,
                                       EMailShellView *mail_shell_view)
{
    e_mail_shell_view_create_filter_from_selected (
        mail_shell_view, AUTO_MLIST);
}

static void
action_mail_filter_on_recipients_cb (GtkAction *action,
                                     EMailShellView *mail_shell_view)
{
    e_mail_shell_view_create_filter_from_selected (
        mail_shell_view, AUTO_TO);
}

static void
action_mail_filter_on_sender_cb (GtkAction *action,
                                 EMailShellView *mail_shell_view)
{
    e_mail_shell_view_create_filter_from_selected (
        mail_shell_view, AUTO_FROM);
}

static void
action_mail_filter_on_subject_cb (GtkAction *action,
                                  EMailShellView *mail_shell_view)
{
    e_mail_shell_view_create_filter_from_selected (
        mail_shell_view, AUTO_SUBJECT);
}

static void
action_mail_filters_apply_cb (GtkAction *action,
                              EMailShellView *mail_shell_view)
{
    EMailShellContent *mail_shell_content;
    EMFolderView *folder_view;
    GPtrArray *uids;

    mail_shell_content = mail_shell_view->priv->mail_shell_content;
    folder_view = e_mail_shell_content_get_folder_view (mail_shell_content);

    uids = message_list_get_selected (folder_view->list);

    mail_filter_on_demand (folder_view->folder, uids);
}

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

static void
action_mail_flag_clear_cb (GtkAction *action,
                           EMailShellView *mail_shell_view)
{
    EMailShellContent *mail_shell_content;
    EMFormatHTMLDisplay *format;
    EMFolderView *folder_view;
    EShellWindow *shell_window;
    EShellView *shell_view;
    GPtrArray *uids;

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

    mail_shell_content = mail_shell_view->priv->mail_shell_content;
    folder_view = e_mail_shell_content_get_folder_view (mail_shell_content);
    format = e_mail_shell_content_get_preview_format (mail_shell_content);

    uids = message_list_get_selected (folder_view->list);

    em_utils_flag_for_followup_clear (
        GTK_WIDGET (shell_window), folder_view->folder, uids);

    em_format_redraw ((EMFormat *) format);
}

static void
action_mail_flag_completed_cb (GtkAction *action,
                               EMailShellView *mail_shell_view)
{
    EMailShellContent *mail_shell_content;
    EMFormatHTMLDisplay *format;
    EMFolderView *folder_view;
    EShellWindow *shell_window;
    EShellView *shell_view;
    GPtrArray *uids;

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

    mail_shell_content = mail_shell_view->priv->mail_shell_content;
    folder_view = e_mail_shell_content_get_folder_view (mail_shell_content);
    format = e_mail_shell_content_get_preview_format (mail_shell_content);

    uids = message_list_get_selected (folder_view->list);

    em_utils_flag_for_followup_completed (
        GTK_WIDGET (shell_window), folder_view->folder, uids);

    em_format_redraw ((EMFormat *) format);
}

static void
action_mail_flag_for_followup_cb (GtkAction *action,
                                  EMailShellView *mail_shell_view)
{
    EMailShellContent *mail_shell_content;
    EMFolderView *folder_view;
    EShellWindow *shell_window;
    EShellView *shell_view;
    GPtrArray *uids;

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

    mail_shell_content = mail_shell_view->priv->mail_shell_content;
    folder_view = e_mail_shell_content_get_folder_view (mail_shell_content);

    uids = message_list_get_selected (folder_view->list);

    em_utils_flag_for_followup (
        GTK_WIDGET (shell_window), folder_view->folder, uids);
}

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)
{
    EMailShellContent *mail_shell_content;
    EMFolderView *folder_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);

    mail_shell_content = mail_shell_view->priv->mail_shell_content;
    folder_view = e_mail_shell_content_get_folder_view (mail_shell_content);
    g_return_if_fail (folder_view->folder != NULL);

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

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

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);
}

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

static void
action_mail_folder_select_thread_cb (GtkAction *action,
                                     EMailShellView *mail_shell_view)
{
    EMailShellContent *mail_shell_content;
    EMFolderView *folder_view;

    mail_shell_content = mail_shell_view->priv->mail_shell_content;
    folder_view = e_mail_shell_content_get_folder_view (mail_shell_content);

    message_list_select_thread (folder_view->list);
}

static void
action_mail_folder_select_subthread_cb (GtkAction *action,
                                        EMailShellView *mail_shell_view)
{
    EMailShellContent *mail_shell_content;
    EMFolderView *folder_view;

    mail_shell_content = mail_shell_view->priv->mail_shell_content;
    folder_view = e_mail_shell_content_get_folder_view (mail_shell_content);

    message_list_select_subthread (folder_view->list);
}

static void
action_mail_forward_cb (GtkAction *action,
                        EMailShellView *mail_shell_view)
{
    EMailShellContent *mail_shell_content;
    EMFolderView *folder_view;
    EShellWindow *shell_window;
    EShellView *shell_view;
    GPtrArray *uids;

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

    mail_shell_content = mail_shell_view->priv->mail_shell_content;
    folder_view = e_mail_shell_content_get_folder_view (mail_shell_content);

    if (!em_utils_check_user_can_send_mail (GTK_WIDGET (shell_window)))
        return;

    uids = message_list_get_selected (folder_view->list);

    em_utils_forward_messages (
        folder_view->folder, uids, folder_view->folder_uri);
}

static void
action_mail_forward_attached_cb (GtkAction *action,
                                 EMailShellView *mail_shell_view)
{
    EMailShellContent *mail_shell_content;
    EMFolderView *folder_view;
    EShellWindow *shell_window;
    EShellView *shell_view;
    GPtrArray *uids;

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

    mail_shell_content = mail_shell_view->priv->mail_shell_content;
    folder_view = e_mail_shell_content_get_folder_view (mail_shell_content);

    if (!em_utils_check_user_can_send_mail (GTK_WIDGET (shell_window)))
        return;

    uids = message_list_get_selected (folder_view->list);

    em_utils_forward_attached (
        folder_view->folder, uids, folder_view->folder_uri);
}

static void
action_mail_forward_inline_cb (GtkAction *action,
                               EMailShellView *mail_shell_view)
{
    EMailShellContent *mail_shell_content;
    EMFolderView *folder_view;
    EShellWindow *shell_window;
    EShellView *shell_view;
    GPtrArray *uids;

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

    mail_shell_content = mail_shell_view->priv->mail_shell_content;
    folder_view = e_mail_shell_content_get_folder_view (mail_shell_content);

    if (!em_utils_check_user_can_send_mail (GTK_WIDGET (shell_window)))
        return;

    uids = message_list_get_selected (folder_view->list);

    em_utils_forward_inline (
        folder_view->folder, uids, folder_view->folder_uri);
}

static void
action_mail_forward_quoted_cb (GtkAction *action,
                               EMailShellView *mail_shell_view)
{
    EMailShellContent *mail_shell_content;
    EMFolderView *folder_view;
    EShellWindow *shell_window;
    EShellView *shell_view;
    GPtrArray *uids;

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

    mail_shell_content = mail_shell_view->priv->mail_shell_content;
    folder_view = e_mail_shell_content_get_folder_view (mail_shell_content);

    if (!em_utils_check_user_can_send_mail (GTK_WIDGET (shell_window)))
        return;

    uids = message_list_get_selected (folder_view->list);

    em_utils_forward_quoted (
        folder_view->folder, uids, folder_view->folder_uri);
}

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)
{
    EMailShellContent *mail_shell_content;
    EMFolderView *folder_view;

    mail_shell_content = mail_shell_view->priv->mail_shell_content;
    folder_view = e_mail_shell_content_get_folder_view (mail_shell_content);

    message_list_hide_add (
        folder_view->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)
{
    EMailShellContent *mail_shell_content;
    EMFolderView *folder_view;
    GPtrArray *uids;

    mail_shell_content = mail_shell_view->priv->mail_shell_content;
    folder_view = e_mail_shell_content_get_folder_view (mail_shell_content);

    uids = message_list_get_selected (folder_view->list);
    message_list_hide_uids (folder_view->list, uids);
    message_list_free_uids (folder_view->list, uids);
}

static void
action_mail_load_images_cb (GtkAction *action,
                            EMailShellView *mail_shell_view)
{
    EMailShellContent *mail_shell_content;
    EMFormatHTMLDisplay *format;

    mail_shell_content = mail_shell_view->priv->mail_shell_content;
    format = e_mail_shell_content_get_preview_format (mail_shell_content);

    em_format_html_load_http ((EMFormatHTML *) format);
}

static void
action_mail_mark_important_cb (GtkAction *action,
                               EMailShellView *mail_shell_view)
{
    EMailShellContent *mail_shell_content;
    EMFolderView *folder_view;
    guint32 mask, set;

    mail_shell_content = mail_shell_view->priv->mail_shell_content;
    folder_view = e_mail_shell_content_get_folder_view (mail_shell_content);

    mask = CAMEL_MESSAGE_FLAGGED | CAMEL_MESSAGE_DELETED;
    set = CAMEL_MESSAGE_FLAGGED;

    em_folder_view_mark_selected (folder_view, mask, set);
}

static void
action_mail_mark_junk_cb (GtkAction *action,
                          EMailShellView *mail_shell_view)
{
    EMailShellContent *mail_shell_content;
    EMFolderView *folder_view;
    guint32 mask, set;
    gint count;

    mail_shell_content = mail_shell_view->priv->mail_shell_content;
    folder_view = e_mail_shell_content_get_folder_view (mail_shell_content);

    mask = CAMEL_MESSAGE_SEEN | CAMEL_MESSAGE_JUNK |
        CAMEL_MESSAGE_NOTJUNK | CAMEL_MESSAGE_JUNK_LEARN;
    set = CAMEL_MESSAGE_SEEN | CAMEL_MESSAGE_JUNK |
        CAMEL_MESSAGE_JUNK_LEARN;

    count = em_folder_view_mark_selected (folder_view, mask, set);
    em_folder_view_select_next_message (folder_view, count, TRUE);
}

static void
action_mail_mark_notjunk_cb (GtkAction *action,
                             EMailShellView *mail_shell_view)
{
    EMailShellContent *mail_shell_content;
    EMFolderView *folder_view;
    guint32 mask, set;
    gint count;

    mail_shell_content = mail_shell_view->priv->mail_shell_content;
    folder_view = e_mail_shell_content_get_folder_view (mail_shell_content);

    mask = CAMEL_MESSAGE_JUNK | CAMEL_MESSAGE_NOTJUNK |
        CAMEL_MESSAGE_JUNK_LEARN;
    set = CAMEL_MESSAGE_NOTJUNK | CAMEL_MESSAGE_JUNK_LEARN;

    count = em_folder_view_mark_selected (folder_view, mask, set);
    em_folder_view_select_next_message (folder_view, count, TRUE);
}

static void
action_mail_mark_read_cb (GtkAction *action,
                          EMailShellView *mail_shell_view)
{
    EMailShellContent *mail_shell_content;
    EMFolderView *folder_view;
    guint32 mask, set;

    mail_shell_content = mail_shell_view->priv->mail_shell_content;
    folder_view = e_mail_shell_content_get_folder_view (mail_shell_content);

    mask = CAMEL_MESSAGE_SEEN;
    set = CAMEL_MESSAGE_SEEN;

    em_folder_view_mark_selected (folder_view, mask, set);
}

static void
action_mail_mark_unimportant_cb (GtkAction *action,
                                 EMailShellView *mail_shell_view)
{
    EMailShellContent *mail_shell_content;
    EMFolderView *folder_view;
    guint32 mask, set;

    mail_shell_content = mail_shell_view->priv->mail_shell_content;
    folder_view = e_mail_shell_content_get_folder_view (mail_shell_content);

    mask = CAMEL_MESSAGE_FLAGGED;
    set = 0;

    em_folder_view_mark_selected (folder_view, mask, set);
}

static void
action_mail_mark_unread_cb (GtkAction *action,
                            EMailShellView *mail_shell_view)
{
    EMailShellContent *mail_shell_content;
    EMFolderView *folder_view;
    guint32 mask, set;

    mail_shell_content = mail_shell_view->priv->mail_shell_content;
    folder_view = e_mail_shell_content_get_folder_view (mail_shell_content);

    mask = CAMEL_MESSAGE_SEEN | CAMEL_MESSAGE_DELETED;
    set = 0;

    em_folder_view_mark_selected (folder_view, mask, set);

    if (folder_view->list->seen_id != 0) {
        g_source_remove (folder_view->list->seen_id);
        folder_view->list->seen_id = 0;
    }
}

static void
action_mail_message_edit_cb (GtkAction *action,
                             EMailShellView *mail_shell_view)
{
    EMailShellContent *mail_shell_content;
    EMFolderView *folder_view;
    EShellWindow *shell_window;
    EShellView *shell_view;
    GPtrArray *uids;

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

    mail_shell_content = mail_shell_view->priv->mail_shell_content;
    folder_view = e_mail_shell_content_get_folder_view (mail_shell_content);

    if (!em_utils_check_user_can_send_mail (GTK_WIDGET (shell_window)))
        return;

    uids = message_list_get_selected (folder_view->list);

    em_utils_edit_messages (folder_view->folder, uids, FALSE);
}

static void
action_mail_message_new_cb (GtkAction *action,
                            EMailShellView *mail_shell_view)
{
    EMailShellContent *mail_shell_content;
    EMFolderView *folder_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);

    mail_shell_content = mail_shell_view->priv->mail_shell_content;
    folder_view = e_mail_shell_content_get_folder_view (mail_shell_content);

    if (!em_utils_check_user_can_send_mail (GTK_WIDGET (shell_window)))
        return;

    em_utils_compose_new_message (folder_view->folder_uri);
}

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

static void
action_mail_message_post_cb (GtkAction *action,
                             EMailShellView *mail_shell_view)
{
    EMailShellContent *mail_shell_content;
    EMFolderView *folder_view;

    mail_shell_content = mail_shell_view->priv->mail_shell_content;
    folder_view = e_mail_shell_content_get_folder_view (mail_shell_content);

    em_utils_post_to_folder (folder_view->folder);
}

static void
action_mail_move_cb (GtkAction *action,
                     EMailShellView *mail_shell_view)
{
    EMailShellContent *mail_shell_content;
    EShellModule *shell_module;
    EShellView *shell_view;
    EMFolderTreeModel *model;
    EMFolderView *folder_view;
    GtkWidget *folder_tree;
    GtkWidget *dialog;
    GPtrArray *selected;
    const gchar *uri;

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

    mail_shell_content = mail_shell_view->priv->mail_shell_content;
    folder_view = e_mail_shell_content_get_folder_view (mail_shell_content);
    selected = message_list_get_selected (folder_view->list);

    folder_tree = em_folder_tree_new_with_model (model);

    em_folder_tree_set_excluded (
        EM_FOLDER_TREE (folder_tree),
        EMFT_EXCLUDE_NOSELECT | EMFT_EXCLUDE_VIRTUAL |
        EMFT_EXCLUDE_VTRASH);

    dialog = em_folder_selector_new (
        EM_FOLDER_TREE (folder_tree),
        EM_FOLDER_SELECTOR_CAN_CREATE,
        _("Select Folder"), NULL, _("_Move"));

    if (default_xfer_messages_uri != NULL)
        em_folder_selector_set_selected (
            EM_FOLDER_SELECTOR (dialog),
            default_xfer_messages_uri);

    if (gtk_dialog_run (GTK_DIALOG (dialog)) != GTK_RESPONSE_OK)
        goto exit;

    uri = em_folder_selector_get_selected_uri (
        EM_FOLDER_SELECTOR (dialog));

    g_free (default_xfer_messages_uri);
    default_xfer_messages_uri = g_strdup (uri);

    if (uri != NULL) {
        mail_transfer_messages (
            folder_view->folder, selected,
            TRUE, uri, 0, NULL, NULL);
        selected = NULL;
    }

exit:
    if (selected != NULL)
        em_utils_uids_free (selected);

    gtk_widget_destroy (dialog);
}

static void
action_mail_next_cb (GtkAction *action,
                     EMailShellView *mail_shell_view)
{
    EMailShellContent *mail_shell_content;
    MessageListSelectDirection direction;
    EMFolderView *folder_view;
    guint32 flags, mask;

    mail_shell_content = mail_shell_view->priv->mail_shell_content;
    folder_view = e_mail_shell_content_get_folder_view (mail_shell_content);

    direction = MESSAGE_LIST_SELECT_NEXT;
    flags = 0;
    mask = 0;

    message_list_select (folder_view->list, direction, flags, mask);
}

static void
action_mail_next_important_cb (GtkAction *action,
                               EMailShellView *mail_shell_view)
{
    EMailShellContent *mail_shell_content;
    MessageListSelectDirection direction;
    EMFolderView *folder_view;
    guint32 flags, mask;

    mail_shell_content = mail_shell_view->priv->mail_shell_content;
    folder_view = e_mail_shell_content_get_folder_view (mail_shell_content);

    direction = MESSAGE_LIST_SELECT_NEXT | MESSAGE_LIST_SELECT_WRAP;
    flags = CAMEL_MESSAGE_FLAGGED;
    mask = CAMEL_MESSAGE_FLAGGED;

    message_list_select (folder_view->list, direction, flags, mask);
}

static void
action_mail_next_thread_cb (GtkAction *action,
                            EMailShellView *mail_shell_view)
{
    EMailShellContent *mail_shell_content;
    EMFolderView *folder_view;

    mail_shell_content = mail_shell_view->priv->mail_shell_content;
    folder_view = e_mail_shell_content_get_folder_view (mail_shell_content);

    message_list_select_next_thread (folder_view->list);
}

static void
action_mail_next_unread_cb (GtkAction *action,
                            EMailShellView *mail_shell_view)
{
    EMailShellContent *mail_shell_content;
    MessageListSelectDirection direction;
    EMFolderView *folder_view;
    guint32 flags, mask;

    mail_shell_content = mail_shell_view->priv->mail_shell_content;
    folder_view = e_mail_shell_content_get_folder_view (mail_shell_content);

    direction = MESSAGE_LIST_SELECT_NEXT | MESSAGE_LIST_SELECT_WRAP;
    flags = 0;
    mask = CAMEL_MESSAGE_SEEN;

    message_list_select (folder_view->list, direction, flags, mask);
}

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

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

    e_mail_shell_content_set_preview_visible (
        mail_shell_content, preview_visible);
}

static void
action_mail_previous_cb (GtkAction *action,
                         EMailShellView *mail_shell_view)
{
    EMailShellContent *mail_shell_content;
    MessageListSelectDirection direction;
    EMFolderView *folder_view;
    guint32 flags, mask;

    mail_shell_content = mail_shell_view->priv->mail_shell_content;
    folder_view = e_mail_shell_content_get_folder_view (mail_shell_content);

    direction = MESSAGE_LIST_SELECT_PREVIOUS;
    flags = 0;
    mask = 0;

    message_list_select (folder_view->list, direction, flags, mask);
}

static void
action_mail_previous_important_cb (GtkAction *action,
                                   EMailShellView *mail_shell_view)
{
    EMailShellContent *mail_shell_content;
    MessageListSelectDirection direction;
    EMFolderView *folder_view;
    guint32 flags, mask;

    mail_shell_content = mail_shell_view->priv->mail_shell_content;
    folder_view = e_mail_shell_content_get_folder_view (mail_shell_content);

    direction = MESSAGE_LIST_SELECT_PREVIOUS | MESSAGE_LIST_SELECT_WRAP;
    flags = CAMEL_MESSAGE_FLAGGED;
    mask = CAMEL_MESSAGE_FLAGGED;

    message_list_select (folder_view->list, direction, flags, mask);
}

static void
action_mail_previous_unread_cb (GtkAction *action,
                                EMailShellView *mail_shell_view)
{
    EMailShellContent *mail_shell_content;
    MessageListSelectDirection direction;
    EMFolderView *folder_view;
    guint32 flags, mask;

    mail_shell_content = mail_shell_view->priv->mail_shell_content;
    folder_view = e_mail_shell_content_get_folder_view (mail_shell_content);

    direction = MESSAGE_LIST_SELECT_PREVIOUS | MESSAGE_LIST_SELECT_WRAP;
    flags = 0;
    mask = CAMEL_MESSAGE_SEEN;

    message_list_select (folder_view->list, direction, flags, mask);
}

static void
action_mail_print_cb (GtkAction *action,
                      EMailShellView *mail_shell_view)
{
    EMailShellContent *mail_shell_content;
    GtkPrintOperationAction print_action;
    EMFolderView *folder_view;

    mail_shell_content = mail_shell_view->priv->mail_shell_content;
    folder_view = e_mail_shell_content_get_folder_view (mail_shell_content);

    print_action = GTK_PRINT_OPERATION_ACTION_PRINT_DIALOG;
    em_folder_view_print (folder_view, print_action);
}

static void
action_mail_print_preview_cb (GtkAction *action,
                              EMailShellView *mail_shell_view)
{
    EMailShellContent *mail_shell_content;
    GtkPrintOperationAction print_action;
    EMFolderView *folder_view;

    mail_shell_content = mail_shell_view->priv->mail_shell_content;
    folder_view = e_mail_shell_content_get_folder_view (mail_shell_content);

    print_action = GTK_PRINT_OPERATION_ACTION_PREVIEW;
    em_folder_view_print (folder_view, print_action);
}

static void
action_mail_redirect_cb (GtkAction *action,
                         EMailShellView *mail_shell_view)
{
    EMailShellContent *mail_shell_content;
    EMFolderView *folder_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);

    mail_shell_content = mail_shell_view->priv->mail_shell_content;
    folder_view = e_mail_shell_content_get_folder_view (mail_shell_content);

    if (folder_view->list->cursor_uid == NULL)
        return;

    if (!em_utils_check_user_can_send_mail (GTK_WIDGET (shell_window)))
        return;

    em_utils_redirect_message_by_uid (
        folder_view->folder, folder_view->list->cursor_uid);
}

static void
action_mail_reply_all_cb (GtkAction *action,
                          EMailShellView *mail_shell_view)
{
    EMailShellContent *mail_shell_content;
    EMFolderView *folder_view;

    mail_shell_content = mail_shell_view->priv->mail_shell_content;
    folder_view = e_mail_shell_content_get_folder_view (mail_shell_content);

    em_folder_view_message_reply (folder_view, REPLY_MODE_ALL);
}

static void
action_mail_reply_list_cb (GtkAction *action,
                           EMailShellView *mail_shell_view)
{
    EMailShellContent *mail_shell_content;
    EMFolderView *folder_view;

    mail_shell_content = mail_shell_view->priv->mail_shell_content;
    folder_view = e_mail_shell_content_get_folder_view (mail_shell_content);

    em_folder_view_message_reply (folder_view, REPLY_MODE_LIST);
}

static void
action_mail_reply_post_cb (GtkAction *action,
                           EMailShellView *mail_shell_view)
{
    EMailShellContent *mail_shell_content;
    EMFolderView *folder_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);

    mail_shell_content = mail_shell_view->priv->mail_shell_content;
    folder_view = e_mail_shell_content_get_folder_view (mail_shell_content);

    if (folder_view->list->cursor_uid == NULL)
        return;

    if (!em_utils_check_user_can_send_mail (GTK_WIDGET (shell_window)))
        return;

    em_utils_post_reply_to_message_by_uid (
        folder_view->folder, folder_view->list->cursor_uid);
}

static void
action_mail_reply_sender_cb (GtkAction *action,
                             EMailShellView *mail_shell_view)
{
    EMailShellContent *mail_shell_content;
    EMFolderView *folder_view;

    mail_shell_content = mail_shell_view->priv->mail_shell_content;
    folder_view = e_mail_shell_content_get_folder_view (mail_shell_content);

    em_folder_view_message_reply (folder_view, REPLY_MODE_SENDER);
}

static void
action_mail_save_as_cb (GtkAction *action,
                        EMailShellView *mail_shell_view)
{
    EMailShellContent *mail_shell_content;
    EMFolderView *folder_view;
    EShellWindow *shell_window;
    EShellView *shell_view;
    GPtrArray *uids;

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

    mail_shell_content = mail_shell_view->priv->mail_shell_content;
    folder_view = e_mail_shell_content_get_folder_view (mail_shell_content);

    uids = message_list_get_selected (folder_view->list);

    em_utils_save_messages (
        GTK_WIDGET (shell_window), folder_view->folder, uids);
}

static void
action_mail_search_folder_from_mailing_list_cb (GtkAction *action,
                                                EMailShellView *mail_shell_view)
{
    e_mail_shell_view_create_vfolder_from_selected (
        mail_shell_view, AUTO_MLIST);
}

static void
action_mail_search_folder_from_recipients_cb (GtkAction *action,
                                              EMailShellView *mail_shell_view)
{
    e_mail_shell_view_create_vfolder_from_selected (
        mail_shell_view, AUTO_TO);
}

static void
action_mail_search_folder_from_sender_cb (GtkAction *action,
                                          EMailShellView *mail_shell_view)
{
    e_mail_shell_view_create_vfolder_from_selected (
        mail_shell_view, AUTO_FROM);
}

static void
action_mail_search_folder_from_subject_cb (GtkAction *action,
                                           EMailShellView *mail_shell_view)
{
    e_mail_shell_view_create_vfolder_from_selected (
        mail_shell_view, AUTO_SUBJECT);
}

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

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

static void
action_mail_show_hidden_cb (GtkAction *action,
                            EMailShellView *mail_shell_view)
{
    EMailShellContent *mail_shell_content;
    EMFolderView *folder_view;

    mail_shell_content = mail_shell_view->priv->mail_shell_content;
    folder_view = e_mail_shell_content_get_folder_view (mail_shell_content);

    message_list_hide_clear (folder_view->list);
}

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

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)
{
    EMailShellContent *mail_shell_content;
    EMFolderView *folder_view;

    mail_shell_content = mail_shell_view->priv->mail_shell_content;
    folder_view = e_mail_shell_content_get_folder_view (mail_shell_content);

    message_list_set_threaded_collapse_all (folder_view->list);
}

static void
action_mail_threads_expand_all_cb (GtkAction *action,
                                   EMailShellView *mail_shell_view)
{
    EMailShellContent *mail_shell_content;
    EMFolderView *folder_view;

    mail_shell_content = mail_shell_view->priv->mail_shell_content;
    folder_view = e_mail_shell_content_get_folder_view (mail_shell_content);

    message_list_set_threaded_expand_all (folder_view->list);
}

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

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_undelete_cb (GtkAction *action,
                         EMailShellView *mail_shell_view)
{
    EMailShellContent *mail_shell_content;
    EMFolderView *folder_view;
    guint32 mask, set;

    mail_shell_content = mail_shell_view->priv->mail_shell_content;
    folder_view = e_mail_shell_content_get_folder_view (mail_shell_content);

    mask = CAMEL_MESSAGE_DELETED;
    set = 0;

    em_folder_view_mark_selected (folder_view, mask, set);
}

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

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

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

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

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

static void
action_mail_zoom_100_cb (GtkAction *action,
                         EMailShellView *mail_shell_view)
{
    EMailShellContent *mail_shell_content;
    EMFormatHTMLDisplay *format;

    mail_shell_content = mail_shell_view->priv->mail_shell_content;
    format = e_mail_shell_content_get_preview_format (mail_shell_content);

    em_format_html_display_zoom_reset (format);
}

static void
action_mail_zoom_in_cb (GtkAction *action,
                        EMailShellView *mail_shell_view)
{
    EMailShellContent *mail_shell_content;
    EMFormatHTMLDisplay *format;

    mail_shell_content = mail_shell_view->priv->mail_shell_content;
    format = e_mail_shell_content_get_preview_format (mail_shell_content);

    em_format_html_display_zoom_in (format);
}

static void
action_mail_zoom_out_cb (GtkAction *action,
                         EMailShellView *mail_shell_view)
{
    EMailShellContent *mail_shell_content;
    EMFormatHTMLDisplay *format;

    mail_shell_content = mail_shell_view->priv->mail_shell_content;
    format = e_mail_shell_content_get_preview_format (mail_shell_content);

    em_format_html_display_zoom_out (format);
}

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-add-sender",
      NULL,
      N_("A_dd Sender to Address Book"),
      NULL,
      N_("Add sender to address book"),
      G_CALLBACK (action_mail_add_sender_cb) },

    { "mail-check-for-junk",
      "mail-mark-junk",
      N_("Check for _Junk"),
      NULL,
      N_("Filter the selected messages for junk status"),
      G_CALLBACK (action_mail_check_for_junk_cb) },

    { "mail-clipboard-copy",
      GTK_STOCK_COPY,
      NULL,
      NULL,
      N_("Copy selected messages to the clipboard"),
      G_CALLBACK (action_mail_clipboard_copy_cb) },

    { "mail-copy",
      "mail-copy",
      N_("_Copy to Folder"),
      "<Shift><Control>y",
      N_("Copy selected messages to another folder"),
      G_CALLBACK (action_mail_copy_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-delete",
      "user-trash",
      N_("_Delete Message"),
      "<Control>d",
      N_("Mark the selected messages for deletion"),
      G_CALLBACK (action_mail_delete_cb) },

    /* XXX Work around one-accelerator-per-action limit. */
    { "mail-delete-1",
      NULL,
      NULL,
      "Delete",
      NULL,
      G_CALLBACK (action_mail_delete_cb) },

    /* XXX Work around one-accelerator-per-action limit. */
    { "mail-delete-2",
      NULL,
      NULL,
      "KP_Delete",
      NULL,
      G_CALLBACK (action_mail_delete_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-filter-on-mailing-list",
      NULL,
      N_("Filter on Mailing _List..."),
      NULL,
      N_("Create a rule to filter messages to this mailing list"),
      G_CALLBACK (action_mail_filter_on_mailing_list_cb) },

    { "mail-filter-on-recipients",
      NULL,
      N_("Filter on _Recipients..."),
      NULL,
      N_("Create a rule to filter messages to these recipients"),
      G_CALLBACK (action_mail_filter_on_recipients_cb) },

    { "mail-filter-on-sender",
      NULL,
      N_("Filter on Se_nder..."),
      NULL,
      N_("Create a rule to filter messages from this sender"),
      G_CALLBACK (action_mail_filter_on_sender_cb) },

    { "mail-filter-on-subject",
      NULL,
      N_("Filter on _Subject..."),
      NULL,
      N_("Create a rule to filter messages with this subject"),
      G_CALLBACK (action_mail_filter_on_subject_cb) },

    { "mail-filters-apply",
      "stock_mail-filters-apply",
      N_("A_pply filters"),
      "<Control>y",
      N_("Apply filter rules to the selected messages"),
      G_CALLBACK (action_mail_filters_apply_cb) },

    { "mail-find",
      GTK_STOCK_FIND,
      N_("_Find in Message..."),
      "<Shift><Control>f",
      N_("Search for text in the body of the displayed message"),
      G_CALLBACK (action_mail_find_cb) },

    { "mail-flag-clear",
      NULL,
      N_("_Clear Flag"),
      NULL,
      N_("Remove the follow-up flag from the selected messages"),
      G_CALLBACK (action_mail_flag_clear_cb) },

    { "mail-flag-completed",
      NULL,
      N_("_Flag Completed"),
      NULL,
      N_("Set the follow-up flag to completed on the selected messages"),
      G_CALLBACK (action_mail_flag_completed_cb) },

    { "mail-flag-for-followup",
      "stock_mail-flag-for-followup",
      N_("Follow _Up..."),
      "<Shift><Control>g",
      N_("Flag the selected messages for follow-up"),
      G_CALLBACK (action_mail_flag_for_followup_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-forward",
      "mail-forward",
      N_("_Forward"),
      "<Control>f",
      N_("Forward the selected message to someone"),
      G_CALLBACK (action_mail_forward_cb) },

    { "mail-forward-attached",
      NULL,
      N_("_Attached"),
      NULL,
      N_("Forward the selected message to someone as an attachment"),
      G_CALLBACK (action_mail_forward_attached_cb) },

    { "mail-forward-inline",
      NULL,
      N_("_Inline"),
      NULL,
      N_("Forward the selected message in the body of a new message"),
      G_CALLBACK (action_mail_forward_inline_cb) },

    { "mail-forward-quoted",
      NULL,
      N_("_Quoted"),
      NULL,
      N_("Forward the selected message quoted like a reply"),
      G_CALLBACK (action_mail_forward_quoted_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-load-images",
      "image-x-generic",
      N_("_Load Images"),
      "<Control>i",
      N_("Force images in HTML mail to be loaded"),
      G_CALLBACK (action_mail_load_images_cb) },

    { "mail-mark-important",
      "mail-mark-important",
      N_("_Important"),
      NULL,
      N_("Mark the selected messages as important"),
      G_CALLBACK (action_mail_mark_important_cb) },

    { "mail-mark-junk",
      "mail-mark-junk",
      N_("_Junk"),
      "<Control>j",
      N_("Mark the selected messages as junk"),
      G_CALLBACK (action_mail_mark_junk_cb) },

    { "mail-mark-notjunk",
      "mail-mark-notjunk",
      N_("_Not Junk"),
      "<Shift><Control>j",
      N_("Mark the selected messages as not being junk"),
      G_CALLBACK (action_mail_mark_notjunk_cb) },

    { "mail-mark-read",
      "mail-mark-read",
      N_("_Read"),
      "<Control>k",
      N_("Mark the selected messages as having been read"),
      G_CALLBACK (action_mail_mark_read_cb) },

    { "mail-mark-unimportant",
      NULL,
      N_("Uni_mportant"),
      NULL,
      N_("Mark the selected messages as unimportant"),
      G_CALLBACK (action_mail_mark_unimportant_cb) },

    { "mail-mark-unread",
      "mail-mark-unread",
      N_("_Unread"),
      "<Shift><Control>k",
      N_("Mark the selected messages as not having been read"),
      G_CALLBACK (action_mail_mark_unread_cb) },

    { "mail-message-edit",
      NULL,
      N_("_Edit as New Message..."),
      NULL,
      N_("Open the selected messages in the composer for editing"),
      G_CALLBACK (action_mail_message_edit_cb) },

    { "mail-message-new",
      "mail-message-new",
      N_("Compose _New Message"),
      "<Shift><Control>m",
      N_("Open a window for composing a mail message"),
      G_CALLBACK (action_mail_message_new_cb) },

    { "mail-message-open",
      NULL,
      N_("_Open in New Window"),
      "<Control>o",
      N_("Open the selected messages in a new window"),
      G_CALLBACK (action_mail_message_open_cb) },

    { "mail-message-post",
      NULL,
      N_("Pos_t New Message to Folder"),
      NULL,
      N_("Post a message to a public folder"),
      G_CALLBACK (action_mail_message_post_cb) },

    { "mail-move",
      "mail-move",
      N_("_Move to Folder"),
      "<Shift><Control>v",
      N_("Move selected messages to another folder"),
      G_CALLBACK (action_mail_move_cb) },

    { "mail-next",
      GTK_STOCK_GO_FORWARD,
      N_("_Next Message"),
      "<Control>Page_Down",
      N_("Display the next message"),
      G_CALLBACK (action_mail_next_cb) },

    { "mail-next-important",
      NULL,
      N_("Next _Important Message"),
      NULL,
      N_("Display the next important message"),
      G_CALLBACK (action_mail_next_important_cb) },

    { "mail-next-thread",
      NULL,
      N_("Next _Thread"),
      NULL,
      N_("Display the next thread"),
      G_CALLBACK (action_mail_next_thread_cb) },

    { "mail-next-unread",
      NULL,
      N_("Next _Unread Message"),
      "<Control>bracketright",
      N_("Display the next unread message"),
      G_CALLBACK (action_mail_next_unread_cb) },

    /* XXX Work around one-accelerator-per-action limit. */
    { "mail-next-unread-1",
      NULL,
      NULL,
      "period",
      NULL,
      G_CALLBACK (action_mail_next_unread_cb) },

    /* XXX Work around one-accelerator-per-action limit. */
    { "mail-next-unread-2",
      NULL,
      NULL,
      "<Control>period",
      NULL,
      G_CALLBACK (action_mail_next_unread_cb) },

    { "mail-previous",
      GTK_STOCK_GO_BACK,
      N_("_Previous Message"),
      "<Control>Page_Up",
      N_("Display the previous message"),
      G_CALLBACK (action_mail_previous_cb) },

    { "mail-previous-important",
      NULL,
      N_("Pr_evious Important Message"),
      NULL,
      N_("Display the previous important message"),
      G_CALLBACK (action_mail_previous_important_cb) },

    { "mail-previous-unread",
      NULL,
      N_("P_revious Unread Message"),
      "<Control>bracketleft",
      N_("Display the previous unread message"),
      G_CALLBACK (action_mail_previous_unread_cb) },

    /* XXX Work around one-accelerator-per-action limit. */
    { "mail-previous-unread-1",
      NULL,
      NULL,
      "comma",
      NULL,
      G_CALLBACK (action_mail_previous_unread_cb) },

    /* XXX Work around one-accelerator-per-action limit. */
    { "mail-previous-unread-2",
      NULL,
      NULL,
      "<Control>comma",
      NULL,
      G_CALLBACK (action_mail_previous_unread_cb) },

    { "mail-print",
      GTK_STOCK_PRINT,
      NULL,
      NULL,
      N_("Print this message"),
      G_CALLBACK (action_mail_print_cb) },

    { "mail-print-preview",
      GTK_STOCK_PRINT_PREVIEW,
      NULL,
      NULL,
      N_("Preview the message to be printed"),
      G_CALLBACK (action_mail_print_preview_cb) },

    { "mail-redirect",
      NULL,
      N_("Re_direct"),
      NULL,
      N_("Redirect (bounce) the selected message to someone"),
      G_CALLBACK (action_mail_redirect_cb) },

    { "mail-reply-all",
      "mail-reply-all",
      N_("Reply to _All"),
      "<Shift><Control>r",
      N_("Compose a reply to all the recipients of the selected message"),
      G_CALLBACK (action_mail_reply_all_cb) },

    { "mail-reply-list",
      NULL,
      N_("Reply to _List"),
      "<Control>l",
      N_("Compose a reply to the mailing list of the selected message"),
      G_CALLBACK (action_mail_reply_list_cb) },

    { "mail-reply-post",
      NULL,
      N_("Post a Repl_y"),
      NULL,
      N_("Post a reply to a message in a public folder"),
      G_CALLBACK (action_mail_reply_post_cb) },

    { "mail-reply-sender",
      "mail-reply-sender",
      N_("_Reply to Sender"),
      "<Control>r",
      N_("Compose a reply to the sender of the selected message"),
      G_CALLBACK (action_mail_reply_sender_cb) },

    { "mail-save-as",
      GTK_STOCK_SAVE_AS,
      N_("_Save As mbox..."),
      NULL,
      N_("Save selected message as an mbox file"),
      G_CALLBACK (action_mail_save_as_cb) },

    { "mail-search-folder-from-mailing-list",
      NULL,
      N_("Search Folder from Mailing _List..."),
      NULL,
      N_("Create a search folder for this mailing list"),
      G_CALLBACK (action_mail_search_folder_from_mailing_list_cb) },

    { "mail-search-folder-from-recipients",
      NULL,
      N_("Search Folder from Recipien_ts..."),
      NULL,
      N_("Create a search folder for these recipients"),
      G_CALLBACK (action_mail_search_folder_from_recipients_cb) },

    { "mail-search-folder-from-sender",
      NULL,
      N_("Search Folder from Sen_der..."),
      NULL,
      N_("Create a search folder for this sender"),
      G_CALLBACK (action_mail_search_folder_from_sender_cb) },

    { "mail-search-folder-from-subject",
      NULL,
      N_("Search Folder from S_ubject..."),
      NULL,
      N_("Create a search folder for this subject"),
      G_CALLBACK (action_mail_search_folder_from_subject_cb) },

    { "mail-select-all",
      NULL,
      N_("Select _All Text"),
      "<Shift><Control>x",
      N_("Select all the text in a message"),
      G_CALLBACK (action_mail_select_all_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-show-source",
      NULL,
      N_("_Message Source"),
      "<Control>u",
      N_("Show the raw email source of the message"),
      G_CALLBACK (action_mail_show_source_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) },

    { "mail-undelete",
      NULL,
      N_("_Undelete Message"),
      "<Shift><Control>d",
      N_("Undelete the selected messages"),
      G_CALLBACK (action_mail_undelete_cb) },

    { "mail-uri-call-to",
      NULL,
      N_("C_all To..."),
      NULL,
      NULL,  /* XXX Add a tooltip! */
      G_CALLBACK (action_mail_uri_call_to_cb) },

    { "mail-uri-copy",
      GTK_STOCK_COPY,
      N_("_Copy Link Location"),
      NULL,
      NULL,  /* XXX Add a tooltip! */
      G_CALLBACK (action_mail_uri_copy_cb) },

    { "mail-uri-copy-address",
      GTK_STOCK_COPY,
      N_("Copy _Email Address"),
      NULL,
      NULL,  /* XXX Add a tooltip! */
      G_CALLBACK (action_mail_uri_copy_address_cb) },

    { "mail-uri-to-search-folder-recipient",
      NULL,
      N_("_To This Address"),
      NULL,
      NULL,  /* XXX Add a tooltip! */
      G_CALLBACK (action_mail_uri_to_search_folder_recipient_cb) },

    { "mail-uri-to-search-folder-sender",
      NULL,
      N_("_From This Address"),
      NULL,
      NULL,  /* XXX Add a tooltip! */
      G_CALLBACK (action_mail_uri_to_search_folder_sender_cb) },

    { "mail-zoom-100",
      GTK_STOCK_ZOOM_100,
      N_("_Normal Size"),
      "<Control>0",
      N_("Reset the text to its original size"),
      G_CALLBACK (action_mail_zoom_100_cb) },

    { "mail-zoom-in",
      GTK_STOCK_ZOOM_IN,
      N_("_Zoom In"),
      "<Control>plus",
      N_("Increase the text size"),
      G_CALLBACK (action_mail_zoom_in_cb) },

    { "mail-zoom-out",
      GTK_STOCK_ZOOM_OUT,
      N_("Zoom _Out"),
      "<Control>minus",
      N_("Decreate the text size"),
      G_CALLBACK (action_mail_zoom_out_cb) },

    /*** Menus ***/

    { "mail-create-rule-menu",
      NULL,
      N_("Create R_ule"),
      NULL,
      NULL,
      NULL },

    { "mail-encoding-menu",
      NULL,
      N_("Ch_aracter Encoding"),
      NULL,
      NULL,
      NULL },

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

    { "mail-forward-as-menu",
      NULL,
      N_("F_orward As..."),
      NULL,
      NULL,
      NULL },

    { "mail-goto-menu",
      GTK_STOCK_JUMP_TO,
      N_("_Go To"),
      NULL,
      NULL,
      NULL },

    { "mail-label-menu",
      NULL,
      N_("_Label"),
      NULL,
      NULL,
      NULL },

    { "mail-mark-as-menu",
      NULL,
      N_("Mar_k As"),
      NULL,
      NULL,
      NULL },

    { "mail-message-menu",
      NULL,
      N_("_Message"),
      NULL,
      NULL,
      NULL },

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

    { "mail-uri-to-search-folder-menu",
      NULL,
      N_("Create _Search Folder"),
      NULL,
      NULL,
      NULL },

    { "mail-zoom-menu",
      NULL,
      N_("_Zoom"),
      NULL,
      NULL,
      NULL }
};

static GtkToggleActionEntry mail_toggle_entries[] = {

    { "mail-caret-mode",
      NULL,
      N_("_Caret Mode"),
      "F7",
      N_("Show a blinking cursor in the body of displayed messages"),
      G_CALLBACK (action_mail_caret_mode_cb),
      FALSE },

    { "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-show-all-headers",
      NULL,
      N_("All Message _Headers"),
      NULL,
      N_("Show messages with all email headers"),
      G_CALLBACK (action_mail_show_all_headers_cb),
      FALSE },

    { "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;
    GtkAction *action;
    GObject *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);
    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_CARET_MODE));
    key = "/apps/evolution/mail/display/caret_mode";
    gconf_bridge_bind_property (bridge, key, object, "active");

    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_VIEW_VERTICAL));
    key = "/apps/evolution/mail/display/show_wide";
    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");

    /* Fine tuning. */

    action = ACTION (MAIL_DELETE);
    g_object_set (action, "short-label", _("Delete"), NULL);

    action = ACTION (MAIL_NEXT);
    g_object_set (action, "short-label", _("Next"), NULL);

    action = ACTION (MAIL_PREVIOUS);
    g_object_set (action, "short-label", _("Previous"), NULL);

    action = ACTION (MAIL_REPLY_SENDER);
    g_object_set (action, "short-label", _("Reply"), NULL);
}