aboutsummaryrefslogtreecommitdiffstats
path: root/mail/e-mail-shell-view-private.c
blob: ebbde76d03bf7b4ae88c9ff38d0a2c330435e1d9 (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
/*
 * 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_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;
    EShellView *shell_view;
    EShellContent *shell_content;
    EShellSidebar *shell_sidebar;

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

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