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
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
|
/* Evolution calendar - Main page of the task editor dialog
*
* Copyright (C) 2001 Ximian, Inc.
*
* Authors: Federico Mena-Quintero <federico@ximian.com>
* Miguel de Icaza <miguel@ximian.com>
* Seth Alves <alves@hungry.com>
* JP Rosevear <jpr@ximian.com>
*
* 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.
*/
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
#include <glib.h>
#include <gtk/gtksignal.h>
#include <gtk/gtktogglebutton.h>
#include <gtk/gtkvbox.h>
#include <gtk/gtkwindow.h>
#include <libgnome/gnome-defs.h>
#include <libgnome/gnome-i18n.h>
#include <glade/glade.h>
#include <libgnomeui/gnome-stock.h>
#include <gal/e-table/e-cell-combo.h>
#include <gal/e-table/e-cell-text.h>
#include <gal/e-table/e-table-simple.h>
#include <gal/e-table/e-table-scrolled.h>
#include <gal/widgets/e-unicode.h>
#include <gal/widgets/e-popup-menu.h>
#include <gal/widgets/e-gui-utils.h>
#include <widgets/misc/e-dateedit.h>
#include <e-util/e-dialog-widgets.h>
#include "../component-factory.h"
#include "../e-meeting-attendee.h"
#include "../e-meeting-model.h"
#include "../itip-utils.h"
#include "comp-editor-util.h"
#include "e-delegate-dialog.h"
#include "meeting-page.h"
enum columns {
MEETING_ATTENDEE_COL,
MEETING_MEMBER_COL,
MEETING_TYPE_COL,
MEETING_ROLE_COL,
MEETING_RSVP_COL,
MEETING_DELTO_COL,
MEETING_DELFROM_COL,
MEETING_STATUS_COL,
MEETING_CN_COL,
MEETING_LANG_COL,
MEETING_COLUMN_COUNT
};
/* Private part of the MeetingPage structure */
struct _MeetingPagePrivate {
/* Lists of attendees */
GPtrArray *deleted_attendees;
/* To use in case of cancellation */
CalComponent *comp;
/* List of identities */
GList *addresses;
GList *address_strings;
gchar *default_address;
/* Glade XML data */
GladeXML *xml;
/* Widgets from the Glade file */
GtkWidget *main;
GtkWidget *organizer_table;
GtkWidget *organizer;
GtkWidget *organizer_lbl;
GtkWidget *other_organizer;
GtkWidget *other_organizer_lbl;
GtkWidget *other_organizer_btn;
GtkWidget *existing_organizer_table;
GtkWidget *existing_organizer;
GtkWidget *existing_organizer_btn;
GtkWidget *invite;
/* E Table stuff */
EMeetingModel *model;
ETableScrolled *etable;
gint row;
/* For handling who the organizer is */
gboolean other;
gboolean existing;
gboolean updating;
};
static void meeting_page_class_init (MeetingPageClass *class);
static void meeting_page_init (MeetingPage *mpage);
static void meeting_page_destroy (GtkObject *object);
static GtkWidget *meeting_page_get_widget (CompEditorPage *page);
static void meeting_page_focus_main_widget (CompEditorPage *page);
static void meeting_page_fill_widgets (CompEditorPage *page, CalComponent *comp);
static gboolean meeting_page_fill_component (CompEditorPage *page, CalComponent *comp);
static gint right_click_cb (ETable *etable, gint row, gint col, GdkEvent *event, gpointer data);
static CompEditorPageClass *parent_class = NULL;
/**
* meeting_page_get_type:
*
* Registers the #MeetingPage class if necessary, and returns the type ID
* associated to it.
*
* Return value: The type ID of the #MeetingPage class.
**/
GtkType
meeting_page_get_type (void)
{
static GtkType meeting_page_type;
if (!meeting_page_type) {
static const GtkTypeInfo meeting_page_info = {
"MeetingPage",
sizeof (MeetingPage),
sizeof (MeetingPageClass),
(GtkClassInitFunc) meeting_page_class_init,
(GtkObjectInitFunc) meeting_page_init,
NULL, /* reserved_1 */
NULL, /* reserved_2 */
(GtkClassInitFunc) NULL
};
meeting_page_type =
gtk_type_unique (TYPE_COMP_EDITOR_PAGE,
&meeting_page_info);
}
return meeting_page_type;
}
/* Class initialization function for the task page */
static void
meeting_page_class_init (MeetingPageClass *class)
{
CompEditorPageClass *editor_page_class;
GtkObjectClass *object_class;
editor_page_class = (CompEditorPageClass *) class;
object_class = (GtkObjectClass *) class;
parent_class = gtk_type_class (TYPE_COMP_EDITOR_PAGE);
editor_page_class->get_widget = meeting_page_get_widget;
editor_page_class->focus_main_widget = meeting_page_focus_main_widget;
editor_page_class->fill_widgets = meeting_page_fill_widgets;
editor_page_class->fill_component = meeting_page_fill_component;
editor_page_class->set_summary = NULL;
editor_page_class->set_dates = NULL;
object_class->destroy = meeting_page_destroy;
}
/* Object initialization function for the task page */
static void
meeting_page_init (MeetingPage *mpage)
{
MeetingPagePrivate *priv;
priv = g_new0 (MeetingPagePrivate, 1);
mpage->priv = priv;
priv->deleted_attendees = g_ptr_array_new ();
priv->comp = NULL;
priv->xml = NULL;
priv->main = NULL;
priv->invite = NULL;
priv->model = NULL;
priv->etable = NULL;
priv->updating = FALSE;
}
static void
set_attendees (CalComponent *comp, const GPtrArray *attendees)
{
GSList *comp_attendees = NULL, *l;
int i;
for (i = 0; i < attendees->len; i++) {
EMeetingAttendee *ia = g_ptr_array_index (attendees, i);
CalComponentAttendee *ca;
ca = e_meeting_attendee_as_cal_component_attendee (ia);
comp_attendees = g_slist_prepend (comp_attendees, ca);
}
comp_attendees = g_slist_reverse (comp_attendees);
cal_component_set_attendee_list (comp, comp_attendees);
for (l = comp_attendees; l != NULL; l = l->next)
g_free (l->data);
g_slist_free (comp_attendees);
}
static void
cleanup_attendees (GPtrArray *attendees)
{
int i;
for (i = 0; i < attendees->len; i++)
gtk_object_unref (GTK_OBJECT (g_ptr_array_index (attendees, i)));
}
/* Destroy handler for the task page */
static void
meeting_page_destroy (GtkObject *object)
{
MeetingPage *mpage;
MeetingPagePrivate *priv;
ETable *real_table;
g_return_if_fail (object != NULL);
g_return_if_fail (IS_MEETING_PAGE (object));
mpage = MEETING_PAGE (object);
priv = mpage->priv;
if (priv->comp != NULL)
gtk_object_unref (GTK_OBJECT (priv->comp));
cleanup_attendees (priv->deleted_attendees);
g_ptr_array_free (priv->deleted_attendees, FALSE);
itip_addresses_free (priv->addresses);
g_list_free (priv->address_strings);
gtk_object_unref (GTK_OBJECT (priv->model));
if (priv->xml) {
gtk_object_unref (GTK_OBJECT (priv->xml));
priv->xml = NULL;
}
g_free (priv);
mpage->priv = NULL;
if (GTK_OBJECT_CLASS (parent_class)->destroy)
(* GTK_OBJECT_CLASS (parent_class)->destroy) (object);
}
/* get_widget handler for the task page */
static GtkWidget *
meeting_page_get_widget (CompEditorPage *page)
{
MeetingPage *mpage;
MeetingPagePrivate *priv;
mpage = MEETING_PAGE (page);
priv = mpage->priv;
return priv->main;
}
/* focus_main_widget handler for the task page */
static void
meeting_page_focus_main_widget (CompEditorPage *page)
{
MeetingPage *mpage;
MeetingPagePrivate *priv;
mpage = MEETING_PAGE (page);
priv = mpage->priv;
gtk_widget_grab_focus (priv->organizer);
}
/* Fills the widgets with default values */
static void
clear_widgets (MeetingPage *mpage)
{
MeetingPagePrivate *priv;
priv = mpage->priv;
gtk_entry_set_text (GTK_ENTRY (GTK_COMBO (priv->organizer)->entry), "");
gtk_entry_set_text (GTK_ENTRY (priv->other_organizer), "");
gtk_label_set_text (GTK_LABEL (priv->existing_organizer), _("None"));
gtk_widget_show (priv->organizer_table);
gtk_widget_hide (priv->existing_organizer_table);
gtk_widget_hide (priv->other_organizer_lbl);
gtk_widget_hide (priv->other_organizer);
priv->existing = FALSE;
priv->other = FALSE;
}
/* fill_widgets handler for the meeting page */
static void
meeting_page_fill_widgets (CompEditorPage *page, CalComponent *comp)
{
MeetingPage *mpage;
MeetingPagePrivate *priv;
CalComponentOrganizer organizer;
GList *l;
mpage = MEETING_PAGE (page);
priv = mpage->priv;
priv->updating = TRUE;
/* Clean out old data */
if (priv->comp != NULL)
gtk_object_unref (GTK_OBJECT (priv->comp));
priv->comp = NULL;
cleanup_attendees (priv->deleted_attendees);
/* Clean the screen */
clear_widgets (mpage);
/* Component for cancellation */
priv->comp = cal_component_clone (comp);
/* Organizer */
cal_component_get_organizer (comp, &organizer);
priv->addresses = itip_addresses_get ();
for (l = priv->addresses; l != NULL; l = l->next) {
ItipAddress *a = l->data;
priv->address_strings = g_list_append (priv->address_strings, a->full);
if (a->default_address)
priv->default_address = a->full;
}
gtk_combo_set_popdown_strings (GTK_COMBO (priv->organizer), priv->address_strings);
if (organizer.value != NULL) {
const gchar *strip = itip_strip_mailto (organizer.value);
gchar *s, *string;
gtk_widget_hide (priv->organizer_table);
gtk_widget_show (priv->existing_organizer_table);
gtk_widget_hide (priv->invite);
if (organizer.cn != NULL)
string = g_strdup_printf ("%s <%s>", organizer.cn, strip);
else
string = g_strdup (strip);
s = e_utf8_to_gtk_string (priv->existing_organizer, string);
gtk_label_set_text (GTK_LABEL (priv->existing_organizer), s);
g_free (s);
g_free (string);
priv->existing = TRUE;
} else {
gtk_widget_hide (priv->other_organizer_lbl);
gtk_widget_hide (priv->other_organizer);
e_dialog_editable_set (GTK_COMBO (priv->organizer)->entry, priv->default_address);
}
priv->updating = FALSE;
}
/* fill_component handler for the meeting page */
static gboolean
meeting_page_fill_component (CompEditorPage *page, CalComponent *comp)
{
MeetingPage *mpage;
MeetingPagePrivate *priv;
CalComponentOrganizer organizer = {NULL, NULL, NULL, NULL};
mpage = MEETING_PAGE (page);
priv = mpage->priv;
if (!priv->existing) {
gchar *addr = NULL, *cn = NULL;
GList *l;
if (priv->other) {
addr = e_dialog_editable_get (priv->other_organizer);
} else {
gchar *str = e_dialog_editable_get (GTK_COMBO (priv->organizer)->entry);
for (l = priv->addresses; l != NULL; l = l->next) {
ItipAddress *a = l->data;
if (!strcmp (a->full, str)) {
addr = g_strdup (a->address);
cn = g_strdup (a->name);
}
}
g_free (str);
}
if (addr == NULL || strlen (addr) == 0) {
e_notice (NULL, GNOME_MESSAGE_BOX_ERROR,
_("An organizer is required."));
g_free (addr);
g_free (cn);
return FALSE;
} else {
gchar *tmp;
tmp = addr;
addr = g_strdup_printf ("MAILTO:%s", addr);
g_free (tmp);
}
organizer.value = addr;
organizer.cn = cn;
cal_component_set_organizer (comp, &organizer);
g_free (addr);
g_free (cn);
}
if (e_meeting_model_count_attendees (priv->model) < 1) {
e_notice (NULL, GNOME_MESSAGE_BOX_ERROR,
"Atleast one attendee is required.");
return FALSE;
}
set_attendees (comp, e_meeting_model_get_attendees (priv->model));
return TRUE;
}
/* Gets the widgets from the XML file and returns if they are all available. */
static gboolean
get_widgets (MeetingPage *mpage)
{
CompEditorPage *page = COMP_EDITOR_PAGE (mpage);
MeetingPagePrivate *priv;
GSList *accel_groups;
GtkWidget *toplevel;
priv = mpage->priv;
#define GW(name) glade_xml_get_widget (priv->xml, name)
priv->main = GW ("meeting-page");
if (!priv->main)
return FALSE;
/* Get the GtkAccelGroup from the toplevel window, so we can install
it when the notebook page is mapped. */
toplevel = gtk_widget_get_toplevel (priv->main);
accel_groups = gtk_accel_groups_from_object (GTK_OBJECT (toplevel));
if (accel_groups) {
page->accel_group = accel_groups->data;
gtk_accel_group_ref (page->accel_group);
}
gtk_widget_ref (priv->main);
gtk_widget_unparent (priv->main);
priv->organizer_table = GW ("organizer-table");
priv->organizer = GW ("organizer");
priv->organizer_lbl = GW ("organizer-label");
priv->other_organizer = GW ("other-organizer");
priv->other_organizer_lbl = GW ("other-organizer-label");
priv->other_organizer_btn = GW ("other-organizer-button");
priv->existing_organizer_table = GW ("existing-organizer-table");
priv->existing_organizer = GW ("existing-organizer");
priv->existing_organizer_btn = GW ("existing-organizer-button");
priv->invite = GW ("invite");
#undef GW
return (priv->invite
&& priv->organizer_table
&& priv->organizer
&& priv->organizer_lbl
&& priv->other_organizer
&& priv->other_organizer_lbl
&& priv->other_organizer_btn
&& priv->existing_organizer_table
&& priv->existing_organizer
&& priv->existing_organizer_btn);
}
/* This is called when any field is changed; it notifies upstream. */
static void
field_changed_cb (GtkWidget *widget, gpointer data)
{
MeetingPage *mpage;
MeetingPagePrivate *priv;
mpage = MEETING_PAGE (data);
priv = mpage->priv;
if (!priv->updating)
comp_editor_page_notify_changed (COMP_EDITOR_PAGE (mpage));
}
/* Function called to make the organizer other than the user */
static void
other_clicked_cb (GtkWidget *widget, gpointer data)
{
MeetingPage *mpage;
MeetingPagePrivate *priv;
mpage = MEETING_PAGE (data);
priv = mpage->priv;
gtk_widget_hide (priv->organizer_lbl);
gtk_widget_hide (priv->organizer);
gtk_widget_hide (priv->other_organizer_btn);
gtk_widget_show (priv->other_organizer_lbl);
gtk_widget_show (priv->other_organizer);
priv->other = TRUE;
}
/* Function called to change the organizer */
static void
change_clicked_cb (GtkWidget *widget, gpointer data)
{
MeetingPage *mpage;
MeetingPagePrivate *priv;
mpage = MEETING_PAGE (data);
priv = mpage->priv;
gtk_widget_show (priv->organizer_table);
gtk_widget_hide (priv->existing_organizer_table);
gtk_widget_show (priv->invite);
gtk_combo_set_popdown_strings (GTK_COMBO (priv->organizer), priv->address_strings);
e_dialog_editable_set (GTK_COMBO (priv->organizer)->entry, priv->default_address);
priv->existing = FALSE;
}
/* Function called to invite more people */
static void
invite_cb (GtkWidget *widget, gpointer data)
{
MeetingPage *mpage;
MeetingPagePrivate *priv;
mpage = MEETING_PAGE (data);
priv = mpage->priv;
e_meeting_model_invite_others_dialog (priv->model);
}
/* Hooks the widget signals */
static void
init_widgets (MeetingPage *mpage)
{
MeetingPagePrivate *priv;
priv = mpage->priv;
/* Organizer */
gtk_signal_connect (GTK_OBJECT (GTK_COMBO (priv->organizer)->entry), "changed",
GTK_SIGNAL_FUNC (field_changed_cb), mpage);
gtk_signal_connect (GTK_OBJECT (priv->other_organizer_btn), "clicked",
GTK_SIGNAL_FUNC (other_clicked_cb), mpage);
gtk_signal_connect (GTK_OBJECT (priv->existing_organizer_btn), "clicked",
GTK_SIGNAL_FUNC (change_clicked_cb), mpage);
/* Invite button */
gtk_signal_connect (GTK_OBJECT (priv->invite), "clicked",
GTK_SIGNAL_FUNC (invite_cb), mpage);
}
static void
popup_delegate_cb (GtkWidget *widget, gpointer data)
{
MeetingPage *mpage = MEETING_PAGE (data);
MeetingPagePrivate *priv;
EDelegateDialog *edd;
GtkWidget *dialog;
EMeetingAttendee *ia;
char *address = NULL, *name = NULL;
priv = mpage->priv;
ia = e_meeting_model_find_attendee_at_row (priv->model, priv->row);
/* Show dialog. */
edd = e_delegate_dialog_new (NULL, itip_strip_mailto (e_meeting_attendee_get_delto (ia)));
dialog = e_delegate_dialog_get_toplevel (edd);
if (gnome_dialog_run_and_close (GNOME_DIALOG (dialog)) == 0){
EMeetingAttendee *ic;
name = e_delegate_dialog_get_delegate_name (edd);
address = e_delegate_dialog_get_delegate (edd);
/* Make sure we can add the new delegatee person */
if (e_meeting_model_find_attendee (priv->model, address, NULL) != NULL) {
e_notice (NULL, GNOME_MESSAGE_BOX_ERROR,
_("That person is already attending the meeting!"));
goto cleanup;
}
/* Update information for attendee */
if (e_meeting_attendee_is_set_delto (ia)) {
EMeetingAttendee *ib;
ib = e_meeting_model_find_attendee (priv->model, itip_strip_mailto (e_meeting_attendee_get_delto (ia)), NULL);
if (ib != NULL) {
gtk_object_ref (GTK_OBJECT (ib));
g_ptr_array_add (priv->deleted_attendees, ib);
e_meeting_model_remove_attendee (priv->model, ib);
}
}
e_meeting_attendee_set_delto (ia, g_strdup_printf ("MAILTO:%s", address));
/* Construct delegatee information */
ic = e_meeting_model_add_attendee_with_defaults (priv->model);
e_meeting_attendee_set_address (ic, g_strdup_printf ("MAILTO:%s", address));
e_meeting_attendee_set_delfrom (ic, g_strdup (e_meeting_attendee_get_address (ia)));
e_meeting_attendee_set_cn (ic, g_strdup (name));
}
cleanup:
g_free (name);
g_free (address);
gtk_object_unref (GTK_OBJECT (edd));
}
static void
popup_delete_cb (GtkWidget *widget, gpointer data)
{
MeetingPage *mpage = MEETING_PAGE (data);
MeetingPagePrivate *priv;
EMeetingAttendee *ia;
int pos = 0;
priv = mpage->priv;
ia = e_meeting_model_find_attendee_at_row (priv->model, priv->row);
/* If this was a delegatee, no longer delegate */
if (e_meeting_attendee_is_set_delfrom (ia)) {
EMeetingAttendee *ib;
ib = e_meeting_model_find_attendee (priv->model, e_meeting_attendee_get_delfrom (ia), &pos);
if (ib != NULL)
e_meeting_attendee_set_delto (ib, NULL);
}
/* Handle deleting all attendees in the delegation chain */
while (ia != NULL) {
EMeetingAttendee *ib = NULL;
gtk_object_ref (GTK_OBJECT (ia));
g_ptr_array_add (priv->deleted_attendees, ia);
e_meeting_model_remove_attendee (priv->model, ia);
if (e_meeting_attendee_get_delto (ia) != NULL)
ib = e_meeting_model_find_attendee (priv->model, e_meeting_attendee_get_delto (ia), NULL);
ia = ib;
}
}
enum {
CAN_DELEGATE = 2,
CAN_DELETE = 4
};
static EPopupMenu context_menu[] = {
{ N_("_Delegate To..."), NULL,
GTK_SIGNAL_FUNC (popup_delegate_cb),NULL, CAN_DELEGATE },
E_POPUP_SEPARATOR,
{ N_("_Delete"), GNOME_STOCK_MENU_TRASH,
GTK_SIGNAL_FUNC (popup_delete_cb), NULL, CAN_DELETE },
E_POPUP_TERMINATOR
};
/* handle context menu over message-list */
static gint
right_click_cb (ETable *etable, gint row, gint col, GdkEvent *event, gpointer data)
{
MeetingPage *mpage = MEETING_PAGE (data);
MeetingPagePrivate *priv;
GtkMenu *menu;
int enable_mask = 0, hide_mask = 0;
priv = mpage->priv;
priv->row = row;
menu = e_popup_menu_create (context_menu, enable_mask, hide_mask, data);
e_auto_kill_popup_menu_on_hide (menu);
gtk_menu_popup (menu, NULL, NULL, NULL, NULL,
event->button.button, event->button.time);
return TRUE;
}
/**
* meeting_page_construct:
* @mpage: An task details page.
*
* Constructs an task page by loading its Glade data.
*
* Return value: The same object as @mpage, or NULL if the widgets could not
* be created.
**/
MeetingPage *
meeting_page_construct (MeetingPage *mpage, EMeetingModel *emm)
{
MeetingPagePrivate *priv;
ETable *real_table;
gchar *filename;
priv = mpage->priv;
priv->xml = glade_xml_new (EVOLUTION_GLADEDIR
"/meeting-page.glade", NULL);
if (!priv->xml) {
g_message ("meeting_page_construct(): "
"Could not load the Glade XML file!");
return NULL;
}
if (!get_widgets (mpage)) {
g_message ("meeting_page_construct(): "
"Could not find all widgets in the XML file!");
return NULL;
}
/* The etable displaying attendees and their status */
gtk_object_ref (GTK_OBJECT (emm));
priv->model = emm;
filename = g_strdup_printf ("%s/config/et-header-meeting-page", evolution_dir);
priv->etable = e_meeting_model_etable_from_model (priv->model,
EVOLUTION_ETSPECDIR "/meeting-page.etspec",
filename);
g_free (filename);
real_table = e_table_scrolled_get_table (priv->etable);
gtk_signal_connect (GTK_OBJECT (real_table),
"right_click", GTK_SIGNAL_FUNC (right_click_cb), mpage);
gtk_widget_show (GTK_WIDGET (priv->etable));
gtk_box_pack_start (GTK_BOX (priv->main), GTK_WIDGET (priv->etable), TRUE, TRUE, 2);
/* Init the widget signals */
init_widgets (mpage);
return mpage;
}
/**
* meeting_page_new:
*
* Creates a new task details page.
*
* Return value: A newly-created task details page, or NULL if the page could
* not be created.
**/
MeetingPage *
meeting_page_new (EMeetingModel *emm)
{
MeetingPage *mpage;
mpage = gtk_type_new (TYPE_MEETING_PAGE);
if (!meeting_page_construct (mpage, emm)) {
gtk_object_unref (GTK_OBJECT (mpage));
return NULL;
}
return mpage;
}
/**
* meeting_page_get_cancel_comp:
* @mpage:
*
*
*
* Return value:
**/
CalComponent *
meeting_page_get_cancel_comp (MeetingPage *mpage)
{
MeetingPagePrivate *priv;
g_return_val_if_fail (mpage != NULL, NULL);
g_return_val_if_fail (IS_MEETING_PAGE (mpage), NULL);
priv = mpage->priv;
if (priv->deleted_attendees->len == 0)
return NULL;
set_attendees (priv->comp, priv->deleted_attendees);
return cal_component_clone (priv->comp);
}
|