aboutsummaryrefslogtreecommitdiffstats
path: root/mail/e-mail-shell-view-private.c
blob: 9287ed777e2686f3cde06a58e4d36145e28cc8be (plain) (blame)
1
2
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
/*
 * e-mail-shell-view-private.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"

#include <widgets/menus/gal-view-factory-etable.h>

static void
mail_shell_view_folder_tree_popup_event_cb (EShellView *shell_view,
                                            GdkEventButton *event)
{
    const gchar *widget_path;

    widget_path = "/mail-folder-popup";
    e_shell_view_show_popup_menu (shell_view, widget_path, event);
}

static void
mail_shell_view_load_view_collection (EShellViewClass *shell_view_class)
{
    GalViewCollection *collection;
    GalViewFactory *factory;
    ETableSpecification *spec;
    const gchar *base_dir;
    gchar *filename;

    collection = shell_view_class->view_collection;

    base_dir = EVOLUTION_ETSPECDIR;
    spec = e_table_specification_new ();
    filename = g_build_filename (base_dir, ETSPEC_FILENAME, NULL);
    if (!e_table_specification_load_from_file (spec, filename))
        g_critical ("Unable to load ETable specification file "
                "for mail");
    g_free (filename);

    factory = gal_view_factory_etable_new (spec);
    gal_view_collection_add_factory (collection, factory);
    g_object_unref (factory);
    g_object_unref (spec);

    gal_view_collection_load (collection);
}

static void
mail_shell_view_notify_view_id_cb (EMailShellView *mail_shell_view)
{
    EMailShellContent *mail_shell_content;
    GalViewInstance *view_instance;
    const gchar *view_id;

    mail_shell_content = mail_shell_view->priv->mail_shell_content;
    view_instance = NULL;  /* FIXME */
    view_id = e_shell_view_get_view_id (E_SHELL_VIEW (mail_shell_view));

    /* A NULL view ID implies we're in a custom view.  But you can
     * only get to a custom view via the "Define Views" dialog, which
     * would have already modified the view instance appropriately.
     * Furthermore, there's no way to refer to a custom view by ID
     * anyway, since custom views have no IDs. */
    if (view_id == NULL)
        return;

    gal_view_instance_set_current_view_id (view_instance, view_id);
}

void
e_mail_shell_view_private_init (EMailShellView *mail_shell_view,
                                EShellViewClass *shell_view_class)
{
    EMailShellViewPrivate *priv = mail_shell_view->priv;

    priv->mail_actions = gtk_action_group_new ("mail");
    priv->filter_actions = gtk_action_group_new ("mail-filter");

    if (!gal_view_collection_loaded (shell_view_class->view_collection))
        mail_shell_view_load_view_collection (shell_view_class);

    g_signal_connect (
        mail_shell_view, "notify::view-id",
        G_CALLBACK (mail_shell_view_notify_view_id_cb), NULL);
}

void
e_mail_shell_view_private_constructed (EMailShellView *mail_shell_view)
{
    EMailShellViewPrivate *priv = mail_shell_view->priv;
    EMailShellSidebar *mail_shell_sidebar;
    EShellView *shell_view;
    EShellContent *shell_content;
    EShellSidebar *shell_sidebar;
    EMFolderTree *folder_tree;

    shell_view = E_SHELL_VIEW (mail_shell_view);
    shell_content = e_shell_view_get_shell_content (shell_view);
    shell_sidebar = e_shell_view_get_shell_sidebar (shell_view);

    /* Cache these to avoid lots of awkward casting. */
    priv->mail_shell_content = g_object_ref (shell_content);
    priv->mail_shell_sidebar = g_object_ref (shell_content);

    mail_shell_sidebar = E_MAIL_SHELL_SIDEBAR (shell_sidebar);
    folder_tree = e_mail_shell_sidebar_get_folder_tree (mail_shell_sidebar);

    g_signal_connect_swapped (
        folder_tree, "popup-event",
        G_CALLBACK (mail_shell_view_folder_tree_popup_event_cb),
        mail_shell_view);

    e_mail_shell_view_actions_init (mail_shell_view);
}

void
e_mail_shell_view_private_dispose (EMailShellView *mail_shell_view)
{
    EMailShellViewPrivate *priv = mail_shell_view->priv;

    DISPOSE (priv->mail_actions);
    DISPOSE (priv->filter_actions);

    DISPOSE (priv->mail_shell_content);
    DISPOSE (priv->mail_shell_sidebar);
}

void
e_mail_shell_view_private_finalize (EMailShellView *mail_shell_view)
{
}