aboutsummaryrefslogtreecommitdiffstats
path: root/shell/e-shell-view.c
blob: 34438e4556473498073171986bd43d9eaddf2c7f (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
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
/*
 * E-shell-view.c: Implements a Shell View of Evolution
 *
 * Authors:
 *   Miguel de Icaza (miguel@helixcode.com)
 *
 * (C) 2000 Helix Code, Inc.
 */
#include <config.h>
#include <gnome.h>
#include "shortcut-bar/e-shortcut-bar.h"
#include "e-util/e-util.h"
#include "e-shell-view.h"
#include "e-shell-view-menu.h"
#include "e-shell-shortcut.h"

#define PARENT_TYPE gnome_app_get_type ()

static GtkObjectClass *parent_class;

static void
esv_destroy (GtkObject *object)
{
    EShellView *eshell_view = E_SHELL_VIEW (object);

    e_shell_unregister_view (eshell_view->eshell, eshell_view);

    parent_class->destroy (object);
}

static void
e_shell_view_class_init (GtkObjectClass *object_class)
{
    object_class->destroy = esv_destroy;

    parent_class = gtk_type_class (PARENT_TYPE);
}

static void
e_shell_view_setup (EShellView *eshell_view)
{
    /*
     * FIXME, should load the config if (load_config)....
     */
    gtk_window_set_default_size (GTK_WINDOW (eshell_view), 600, 400);
}

static void
e_shell_view_setup_shortcut_display (EShellView *eshell_view)
{
    gtk_widget_push_visual (gdk_rgb_get_visual ());
    gtk_widget_push_colormap (gdk_rgb_get_cmap ());

    eshell_view->shortcut_hpaned = gtk_hpaned_new ();
    gtk_widget_show (eshell_view->shortcut_hpaned);
    
    eshell_view->shortcut_bar = e_shortcut_bar_new ();
    gtk_paned_set_position (GTK_PANED (eshell_view->shortcut_hpaned), 100);

    gtk_paned_pack1 (GTK_PANED (eshell_view->shortcut_hpaned),
             eshell_view->shortcut_bar, FALSE, TRUE);
    gtk_widget_show (eshell_view->shortcut_bar);

    gtk_widget_pop_visual ();
    gtk_widget_pop_colormap ();

    gnome_app_set_contents (GNOME_APP (eshell_view), eshell_view->shortcut_hpaned);

    gtk_signal_connect (
        GTK_OBJECT (eshell_view->shortcut_bar), "item_selected",
        GTK_SIGNAL_FUNC (shortcut_bar_item_selected), eshell_view);

}

static void
e_shell_view_load_group (EShell *eshell, EShellView *eshell_view, EShortcutGroup *esg)
{
    EShortcutBar *bar = E_SHORTCUT_BAR (eshell_view->shortcut_bar);
    int group_num, i;
    const int items = esg->shortcuts->len;

    group_num = e_shortcut_bar_add_group (bar, esg->title);
    if (esg->small_icons)
        e_shortcut_bar_set_view_type (bar, group_num, E_ICON_BAR_SMALL_ICONS);

    for (i = 0; i < items; i++){
        EShortcut *shortcut = E_SHORTCUT (g_array_index (esg->shortcuts, EShortcut *, i));
        EFolder *folder = shortcut->efolder;
        char *type = NULL;
        
        switch (folder->type){
        case E_FOLDER_MAIL:
            type = "folder:";
            break;
            
        case E_FOLDER_CONTACTS:
            type = "contacts:";
            break;
            
        case E_FOLDER_CALENDAR:
            type = "calendar:";
            break;
            
        case E_FOLDER_TASKS:
            type = "todo:";
            break;
            
        case E_FOLDER_OTHER:
            type = "file:";
            break;

        default:
            g_assert_not_reached ();
        }
        
        e_shortcut_bar_add_item (bar, group_num, type, folder->name);
    }
}

static void
e_shell_view_load_shortcut_bar (EShellView *eshell_view)
{
    EShell *eshell = eshell_view->eshell;
    const int groups = eshell->shortcut_groups->len;
    int i;
    
    for (i = 0; i < groups; i++){
        EShortcutGroup *esg;

        esg = g_array_index (eshell->shortcut_groups, EShortcutGroup *, i);

        e_shell_view_load_group (eshell, eshell_view, esg);
    }
}

GtkWidget *
e_shell_view_new (EShell *eshell, gboolean show_shortcut_bar)
{
    EShellView *eshell_view;

    eshell_view = gtk_type_new (e_shell_view_get_type ());

    gnome_app_construct (GNOME_APP (eshell_view), "Evolution", "Evolution");

    eshell_view->eshell = eshell;
    e_shell_view_setup (eshell_view);
    e_shell_view_setup_menus (eshell_view);

    if (show_shortcut_bar){
        e_shell_view_setup_shortcut_display (eshell_view);
        e_shell_view_load_shortcut_bar (eshell_view);
    } else {
        g_error ("Non-shortcut bar code not written yet");
    }

    e_shell_register_view (eshell, eshell_view);

    eshell_view->shortcut_displayed = show_shortcut_bar;
    
    return (GtkWidget *) eshell_view;
}

void
e_shell_view_set_view (EShellView *eshell_view, EFolder *efolder)
{
    if (efolder == NULL){
        printf ("Display executive summary");
    }  else {
        
    }
}

void
e_shell_view_display_shortcut_bar (EShellView *eshell_view, gboolean display)
{
    g_return_if_fail (eshell_view != NULL);
    g_return_if_fail (E_IS_SHELL_VIEW (eshell_view));

    g_error ("Switching code for the shortcut bar is not written yet");
}

E_MAKE_TYPE (e_shell_view, "EShellView", EShellView, e_shell_view_class_init, NULL, PARENT_TYPE);

void
e_shell_view_new_folder (EShellView *esv)
{
    g_return_if_fail (esv != NULL);
    g_return_if_fail (E_IS_SHELL_VIEW (esv));
}

void
e_shell_view_new_shortcut (EShellView *esv)
{
    g_return_if_fail (esv != NULL);
    g_return_if_fail (E_IS_SHELL_VIEW (esv));
}