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
|
/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */
/* e-shell-config-offline.c - Configuration page for offline synchronization.
*
* Copyright (C) 2002 Ximian, Inc.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of version 2 of the GNU General Public
* License as published by the Free Software Foundation.
*
* 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
* General Public License for more details.
*
* You should have received a copy of the GNU General Public
* License along with this program; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*
* Author: Ettore Perazzoli <ettore@ximian.com>
*/
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
#include "e-shell-config-offline.h"
#include "evolution-config-control.h"
#include "e-storage-set-view.h"
#include "Evolution.h"
#include <bonobo-conf/Bonobo_Config.h>
#include <bonobo/bonobo-exception.h>
#include <gal/widgets/e-scroll-frame.h>
#include <gtk/gtkwidget.h>
struct _PageData {
EShell *shell;
GtkWidget *storage_set_view;
EvolutionConfigControl *config_control;
};
typedef struct _PageData PageData;
/* Callbacks. */
static void
config_control_destroy_callback (GtkObject *object,
void *data)
{
PageData *page_data;
page_data = (PageData *) data;
gtk_widget_destroy (page_data->storage_set_view);
g_free (page_data);
}
static void
config_control_apply_callback (EvolutionConfigControl *config_control,
void *data)
{
CORBA_Environment ev;
CORBA_sequence_CORBA_string *paths;
CORBA_any any;
PageData *page_data;
GList *checked_paths;
GList *p;
int i;
page_data = (PageData *) data;
checked_paths = e_storage_set_view_get_checkboxes_list (E_STORAGE_SET_VIEW (page_data->storage_set_view));
paths = CORBA_sequence_CORBA_string__alloc ();
paths->_maximum = paths->_length = g_list_length (checked_paths);
paths->_buffer = CORBA_sequence_CORBA_string_allocbuf (paths->_maximum);
for (p = checked_paths, i = 0; p != NULL; p = p->next, i ++)
paths->_buffer[i] = CORBA_string_dup ((const char *) p->data);
any._type = TC_CORBA_sequence_CORBA_string;
any._value = paths;
CORBA_exception_init (&ev);
Bonobo_ConfigDatabase_setValue (e_shell_get_config_db (page_data->shell),
"/OfflineFolders/paths", &any, &ev);
if (BONOBO_EX (&ev))
g_warning ("Cannot set /OfflineFolders/paths from ConfigDatabase -- %s", BONOBO_EX_ID (&ev));
CORBA_exception_free (&ev);
g_list_free (checked_paths);
}
static void
storage_set_view_checkboxes_changed_callback (EStorageSetView *storage_set_view,
void *data)
{
PageData *page_data;
page_data = (PageData *) data;
evolution_config_control_changed (page_data->config_control);
}
/* Construction. */
static void
init_storage_set_view_status_from_config (EStorageSetView *storage_set_view,
EShell *shell)
{
Bonobo_ConfigDatabase config_db;
CORBA_Environment ev;
CORBA_any *any;
CORBA_sequence_CORBA_string *sequence;
GList *list;
int i;
config_db = e_shell_get_config_db (shell);
g_assert (config_db != CORBA_OBJECT_NIL);
CORBA_exception_init (&ev);
any = Bonobo_ConfigDatabase_getValue (config_db, "/OfflineFolders/paths", "", &ev);
if (BONOBO_EX (&ev)) {
g_warning ("Cannot get /OfflineFolders/paths from ConfigDatabase -- %s", BONOBO_EX_ID (&ev));
CORBA_exception_free (&ev);
return;
}
if (! CORBA_TypeCode_equal (any->_type, TC_CORBA_sequence_CORBA_string, &ev) || BONOBO_EX (&ev)) {
g_warning ("/OfflineFolders/Paths in ConfigDatabase is not the expected type");
CORBA_free (any);
CORBA_exception_free (&ev);
return;
}
sequence = (CORBA_sequence_CORBA_string *) any->_value;
list = NULL;
for (i = 0; i < sequence->_length; i ++)
list = g_list_prepend (list, sequence->_buffer[i]);
e_storage_set_view_set_checkboxes_list (storage_set_view, list);
g_list_free (list);
CORBA_free (any);
CORBA_exception_free (&ev);
}
BonoboObject *
e_shell_config_offline_create_control (EShell *shell)
{
PageData *page_data;
GtkWidget *scroll_frame;
g_return_val_if_fail (E_IS_SHELL (shell), NULL);
page_data = g_new (PageData, 1);
page_data->shell = shell;
page_data->storage_set_view = e_storage_set_new_view (e_shell_get_storage_set (shell), NULL);
e_storage_set_view_set_show_checkboxes (E_STORAGE_SET_VIEW (page_data->storage_set_view), TRUE);
gtk_widget_show (page_data->storage_set_view);
init_storage_set_view_status_from_config (E_STORAGE_SET_VIEW (page_data->storage_set_view), shell);
gtk_signal_connect (GTK_OBJECT (page_data->storage_set_view), "checkboxes_changed",
GTK_SIGNAL_FUNC (storage_set_view_checkboxes_changed_callback), page_data);
scroll_frame = e_scroll_frame_new (NULL, NULL);
e_scroll_frame_set_shadow_type (E_SCROLL_FRAME (scroll_frame), GTK_SHADOW_IN);
e_scroll_frame_set_policy (E_SCROLL_FRAME (scroll_frame),
GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
gtk_container_add (GTK_CONTAINER (scroll_frame), page_data->storage_set_view);
gtk_widget_show (scroll_frame);
page_data->config_control = evolution_config_control_new (scroll_frame);
gtk_signal_connect (GTK_OBJECT (page_data->config_control), "destroy",
GTK_SIGNAL_FUNC (config_control_destroy_callback), page_data);
gtk_signal_connect (GTK_OBJECT (page_data->config_control), "apply",
GTK_SIGNAL_FUNC (config_control_apply_callback), page_data);
return BONOBO_OBJECT (page_data->config_control);
}
|