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
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
|
/* Evolution calendar - Meeting editor dialog
*
* Copyright (C) 2000 Helix Code, Inc.
*
* Authors: Jesse Pavel <jpavel@helixcode.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* 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.
*/
#include <config.h>
#include <gnome.h>
#include <glade/glade.h>
#include <icaltypes.h>
#include "e-meeting-edit.h"
#define E_MEETING_GLADE_XML "e-meeting-dialog.glade"
#define E_MEETING_DEBUG
/* These are the widgets to be used in the GUI. */
static GladeXML *xml;
static GtkWidget *meeting_window;
static GtkWidget *attendee_list;
static GtkWidget *address_entry;
static GtkWidget *add_dialog;
static gint selected_row;
static gboolean
window_delete_cb (GtkWidget *widget,
GdkEvent *event,
gpointer data)
{
#ifdef E_MEETING_DEBUG
g_print ("e-meeting-edit.c: The main window received a delete event.\n");
#endif
return (FALSE);
}
static void
window_destroy_cb (GtkWidget *widget,
gpointer data)
{
#ifdef E_MEETING_DEBUG
g_print ("e-meeting-edit.c: The main window received a destroy event.\n");
#endif
gtk_main_quit ();
return;
}
static void
add_button_clicked_cb (GtkWidget *widget, gpointer data)
{
gint button_num;
#ifdef E_MEETING_DEBUG
g_print ("e-meeting-edit.c: the add button was clicked.\n");
#endif
if (add_dialog == NULL || address_entry == NULL) {
add_dialog = glade_xml_get_widget (xml, "add_dialog");
address_entry = glade_xml_get_widget (xml, "address_entry");
gnome_dialog_set_close (GNOME_DIALOG (add_dialog), TRUE);
gnome_dialog_editable_enters (GNOME_DIALOG (add_dialog), GTK_EDITABLE (address_entry));
gnome_dialog_close_hides (GNOME_DIALOG (add_dialog), TRUE);
gnome_dialog_set_default (GNOME_DIALOG (add_dialog), 0);
}
g_return_if_fail (add_dialog != NULL);
g_return_if_fail (address_entry != NULL);
gtk_widget_show (add_dialog);
button_num = gnome_dialog_run (GNOME_DIALOG (add_dialog));
if (button_num == 0) {
/* The user pressed Okay--let's add it to our list. */
gchar temp_stat[] = "Needs action";
gchar *address;
gchar * row_text[2];
address = gtk_entry_get_text (GTK_ENTRY (address_entry));
row_text[0] = address;
row_text[1] = temp_stat;
gtk_clist_append (GTK_CLIST (attendee_list), row_text);
}
gtk_entry_set_text (GTK_ENTRY (address_entry), "");
}
static void
delete_button_clicked_cb (GtkWidget *widget, gpointer data)
{
if (selected_row < 0) {
GtkWidget *dialog;
dialog = gnome_warning_dialog_parented ("You must select an entry to delete.",
GTK_WINDOW (add_dialog));
gnome_dialog_run (GNOME_DIALOG(dialog));
}
else {
gtk_clist_remove (GTK_CLIST (attendee_list), selected_row);
selected_row = -1;
}
}
static void
edit_button_clicked_cb (GtkWidget *widget, gpointer data)
{
if (selected_row < 0) {
GtkWidget *dialog;
dialog = gnome_warning_dialog_parented ("You must select an entry to edit.",
GTK_WINDOW (add_dialog));
gnome_dialog_run (GNOME_DIALOG(dialog));
return;
}
else {
gchar *text[2];
gint cntr;
gint button_num;
for (cntr = 0; cntr < 2; cntr++) {
gtk_clist_get_text (GTK_CLIST (attendee_list),
selected_row,
cntr,
&text[cntr]);
}
if (add_dialog == NULL || address_entry == NULL) {
add_dialog = glade_xml_get_widget (xml, "add_dialog");
address_entry = glade_xml_get_widget (xml, "address_entry");
gnome_dialog_set_close (GNOME_DIALOG (add_dialog), TRUE);
gnome_dialog_editable_enters (GNOME_DIALOG (add_dialog), GTK_EDITABLE (address_entry));
gnome_dialog_close_hides (GNOME_DIALOG (add_dialog), TRUE);
gnome_dialog_set_default (GNOME_DIALOG (add_dialog), 0);
}
gtk_entry_set_text (GTK_ENTRY (address_entry), text[0]);
gtk_widget_show (add_dialog);
button_num = gnome_dialog_run (GNOME_DIALOG (add_dialog));
if (button_num == 0) {
gchar *new_text;
new_text = gtk_entry_get_text (GTK_ENTRY (address_entry));
gtk_clist_set_text (GTK_CLIST (attendee_list),
selected_row,
0,
new_text);
}
gtk_entry_set_text (GTK_ENTRY (address_entry), "");
}
}
static void list_row_select_cb (GtkWidget *widget,
gint row,
gint column,
GdkEventButton *event,
gpointer data)
{
selected_row = row;
}
static void
reset_widgets (void)
{
xml = NULL;
meeting_window = NULL;
attendee_list = NULL;
address_entry = NULL;
add_dialog = NULL;
selected_row = -1;
}
void
e_meeting_edit (CalComponent *comp, CalClient *client)
{
GtkWidget *add_button, *delete_button, *edit_button;
reset_widgets ();
xml = glade_xml_new (EVOLUTION_GLADEDIR "/" E_MEETING_GLADE_XML, NULL);
meeting_window = glade_xml_get_widget (xml, "meeting_window");
attendee_list = glade_xml_get_widget (xml, "attendee_list");
gtk_clist_set_column_justification (GTK_CLIST (attendee_list), 1, GTK_JUSTIFY_CENTER);
gtk_signal_connect (GTK_OBJECT (meeting_window), "delete_event",
GTK_SIGNAL_FUNC (window_delete_cb), NULL);
gtk_signal_connect_after (GTK_OBJECT (meeting_window), "delete_event",
GTK_SIGNAL_FUNC (window_destroy_cb), NULL);
gtk_signal_connect (GTK_OBJECT (meeting_window), "destroy_event",
GTK_SIGNAL_FUNC (window_destroy_cb), NULL);
gtk_signal_connect (GTK_OBJECT (attendee_list), "select_row",
GTK_SIGNAL_FUNC (list_row_select_cb), NULL);
add_button = glade_xml_get_widget (xml, "add_button");
delete_button = glade_xml_get_widget (xml, "delete_button");
edit_button = glade_xml_get_widget (xml, "edit_button");
gtk_signal_connect (GTK_OBJECT (add_button), "clicked",
GTK_SIGNAL_FUNC (add_button_clicked_cb), NULL);
gtk_signal_connect (GTK_OBJECT (delete_button), "clicked",
GTK_SIGNAL_FUNC (delete_button_clicked_cb), NULL);
gtk_signal_connect (GTK_OBJECT (edit_button), "clicked",
GTK_SIGNAL_FUNC (edit_button_clicked_cb), NULL);
gtk_widget_show (meeting_window);
gtk_main ();
#ifdef E_MEETING_DEBUG
g_print ("e-meeting-edit.c: We've terminated the subsidiary gtk_main().\n");
#endif
if (meeting_window != NULL)
gtk_widget_destroy (meeting_window);
if (add_dialog != NULL)
gtk_widget_destroy (add_dialog);
gtk_object_destroy (GTK_OBJECT (xml));
}
|