From 96a9eafc7290ef276d2f0559d20cc2f1057c4231 Mon Sep 17 00:00:00 2001 From: JP Rosevear Date: Tue, 24 Jul 2001 22:35:57 +0000 Subject: stip the delto and delfrom (popup_delegate_cb): show a delegate dialog and 2001-07-24 JP Rosevear * gui/dialogs/meeting-page.c (value_at): stip the delto and delfrom (popup_delegate_cb): show a delegate dialog and add the new delegatee and update the delegator (add_section): listen for changes in a more direct manner (get_select_name_dialog): add_section now takes a limit argument * gui/dialogs/e-delegate-dialog.[hc]: New dialog to query the user for a person to delegate to * gui/dialogs/Makefile.am: build/install new files * gui/Makefile.am: add ldadd line for ebook svn path=/trunk/; revision=11364 --- calendar/ChangeLog | 16 ++ calendar/gui/Makefile.am | 5 +- calendar/gui/dialogs/Makefile.am | 5 + calendar/gui/dialogs/e-delegate-dialog.c | 351 +++++++++++++++++++++++++++ calendar/gui/dialogs/e-delegate-dialog.glade | 120 +++++++++ calendar/gui/dialogs/e-delegate-dialog.h | 70 ++++++ calendar/gui/dialogs/meeting-page.c | 134 +++++++--- 7 files changed, 662 insertions(+), 39 deletions(-) create mode 100644 calendar/gui/dialogs/e-delegate-dialog.c create mode 100644 calendar/gui/dialogs/e-delegate-dialog.glade create mode 100644 calendar/gui/dialogs/e-delegate-dialog.h diff --git a/calendar/ChangeLog b/calendar/ChangeLog index dde15e6a39..b44a5c884c 100644 --- a/calendar/ChangeLog +++ b/calendar/ChangeLog @@ -1,3 +1,19 @@ +2001-07-24 JP Rosevear + + * gui/dialogs/meeting-page.c (value_at): stip the delto and + delfrom + (popup_delegate_cb): show a delegate dialog and add the new + delegatee and update the delegator + (add_section): listen for changes in a more direct manner + (get_select_name_dialog): add_section now takes a limit argument + + * gui/dialogs/e-delegate-dialog.[hc]: New dialog to query the user + for a person to delegate to + + * gui/dialogs/Makefile.am: build/install new files + + * gui/Makefile.am: add ldadd line for ebook + 2001-07-21 Damon Chaplin * gui/e-week-view-event-item.c (e_week_view_event_item_draw): fixed diff --git a/calendar/gui/Makefile.am b/calendar/gui/Makefile.am index 4d22893263..0aa57aeda8 100644 --- a/calendar/gui/Makefile.am +++ b/calendar/gui/Makefile.am @@ -137,9 +137,12 @@ evolution_calendar_LDADD = \ $(top_builddir)/libical/src/libical/libical.la \ $(top_builddir)/libwombat/libwombat.la \ $(top_builddir)/widgets/meeting-time-sel/libevolutionmtsel.a \ + $(top_builddir)/addressbook/backend/ebook/libebook.la \ + $(top_builddir)/libversit/libversit.la \ + $(top_builddir)/e-util/ename/libename.la \ dialogs/libcal-dialogs.a \ $(top_builddir)/widgets/misc/libemiscwidgets.a \ - $(EXTRA_GNOME_LIBS) \ + $(EXTRA_GNOME_LIBS) \ $(BONOBO_HTML_GNOME_LIBS) \ $(GNOME_VFS_LIBS) \ $(BONOBO_CONF_LIBS) \ diff --git a/calendar/gui/dialogs/Makefile.am b/calendar/gui/dialogs/Makefile.am index f9c95f3341..a56cf18d76 100644 --- a/calendar/gui/dialogs/Makefile.am +++ b/calendar/gui/dialogs/Makefile.am @@ -25,6 +25,8 @@ INCLUDES = \ -I$(top_builddir)/libical/src/libical \ -I$(top_builddir)/shell \ -I$(top_srcdir)/shell \ + -I$(top_srcdir)/addressbook/backend/ebook \ + -I$(top_builddir)/addressbook/backend/ebook \ -I$(includedir) \ $(EXTRA_GNOME_CFLAGS) \ -DEVOLUTION_DATADIR=\""$(datadir)"\" \ @@ -55,6 +57,8 @@ libcal_dialogs_a_SOURCES = \ comp-editor-util.h \ delete-comp.c \ delete-comp.h \ + e-delegate-dialog.c \ + e-delegate-dialog.h \ e-timezone-dialog.c \ e-timezone-dialog.h \ event-editor.c \ @@ -81,6 +85,7 @@ glade_DATA = \ alarm-options.glade \ alarm-page.glade \ cal-prefs-dialog.glade \ + e-delegate-dialog.glade \ e-timezone-dialog.glade \ event-page.glade \ meeting-page.glade \ diff --git a/calendar/gui/dialogs/e-delegate-dialog.c b/calendar/gui/dialogs/e-delegate-dialog.c new file mode 100644 index 0000000000..beb93d5dc8 --- /dev/null +++ b/calendar/gui/dialogs/e-delegate-dialog.c @@ -0,0 +1,351 @@ +/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ +/* Evolution calendar - Delegate selector dialog + * + * Copyright (C) 2001 Ximian, Inc. + * + * Authors: Damon Chaplin + * + * 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 +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "Evolution-Addressbook-SelectNames.h" +#include "e-delegate-dialog.h" + +struct _EDelegateDialogPrivate { + char *name; + char *address; + + /* Glade XML data */ + GladeXML *xml; + + /* Widgets from the Glade file */ + GtkWidget *app; + GtkWidget *hbox; + GtkWidget *addressbook; + + GNOME_Evolution_Addressbook_SelectNames corba_select_names; + GtkWidget *entry; +}; + +#define SELECT_NAMES_OAFID "OAFIID:GNOME_Evolution_Addressbook_SelectNames" +static const char *section_name = "Delegate To"; + +static void e_delegate_dialog_class_init (EDelegateDialogClass *class); +static void e_delegate_dialog_init (EDelegateDialog *edd); +static void e_delegate_dialog_destroy (GtkObject *object); + +static gboolean get_widgets (EDelegateDialog *edd); +static void addressbook_clicked_cb (GtkWidget *widget, gpointer data); + +static GtkObjectClass *parent_class; + + +GtkType +e_delegate_dialog_get_type (void) +{ + static GtkType e_delegate_dialog_type = 0; + + if (!e_delegate_dialog_type) { + static const GtkTypeInfo e_delegate_dialog_info = { + "EDelegateDialog", + sizeof (EDelegateDialog), + sizeof (EDelegateDialogClass), + (GtkClassInitFunc) e_delegate_dialog_class_init, + (GtkObjectInitFunc) e_delegate_dialog_init, + NULL, /* reserved_1 */ + NULL, /* reserved_2 */ + (GtkClassInitFunc) NULL + }; + + e_delegate_dialog_type = gtk_type_unique (GTK_TYPE_OBJECT, + &e_delegate_dialog_info); + } + + return e_delegate_dialog_type; +} + +/* Class initialization function for the event editor */ +static void +e_delegate_dialog_class_init (EDelegateDialogClass *class) +{ + GtkObjectClass *object_class; + + object_class = (GtkObjectClass *) class; + + parent_class = gtk_type_class (GTK_TYPE_OBJECT); + + object_class->destroy = e_delegate_dialog_destroy; +} + +/* Object initialization function for the event editor */ +static void +e_delegate_dialog_init (EDelegateDialog *edd) +{ + EDelegateDialogPrivate *priv; + + priv = g_new0 (EDelegateDialogPrivate, 1); + edd->priv = priv; + + priv->address = NULL; +} + +/* Destroy handler for the event editor */ +static void +e_delegate_dialog_destroy (GtkObject *object) +{ + EDelegateDialog *edd; + EDelegateDialogPrivate *priv; + GtkWidget *dialog; + + g_return_if_fail (object != NULL); + g_return_if_fail (E_IS_DELEGATE_DIALOG (object)); + + edd = E_DELEGATE_DIALOG (object); + priv = edd->priv; + + /* Destroy the actual dialog. */ + dialog = e_delegate_dialog_get_toplevel (edd); + gtk_widget_destroy (dialog); + + g_free (priv->address); + priv->address = NULL; + + g_free (priv); + edd->priv = NULL; + + if (GTK_OBJECT_CLASS (parent_class)->destroy) + (* GTK_OBJECT_CLASS (parent_class)->destroy) (object); +} + + +EDelegateDialog * +e_delegate_dialog_construct (EDelegateDialog *edd) +{ + EDelegateDialogPrivate *priv; + Bonobo_Control corba_control; + CORBA_Environment ev; + + g_return_val_if_fail (edd != NULL, NULL); + g_return_val_if_fail (E_IS_DELEGATE_DIALOG (edd), NULL); + + priv = edd->priv; + + /* Load the content widgets */ + + priv->xml = glade_xml_new (EVOLUTION_GLADEDIR "/e-delegate-dialog.glade", + NULL); + if (!priv->xml) { + g_message ("e_delegate_dialog_construct(): Could not load the Glade XML file!"); + goto error; + } + + if (!get_widgets (edd)) { + g_message ("e_delegate_dialog_construct(): Could not find all widgets in the XML file!"); + goto error; + } + + CORBA_exception_init (&ev); + + priv->corba_select_names = oaf_activate_from_id (SELECT_NAMES_OAFID, 0, NULL, &ev); + GNOME_Evolution_Addressbook_SelectNames_addSectionWithLimit (priv->corba_select_names, + section_name, + section_name, + 1, &ev); + + if (BONOBO_EX (&ev)) { + g_message ("e_delegate_dialog_construct(): Unable to add section!"); + goto error; + } + + corba_control = GNOME_Evolution_Addressbook_SelectNames_getEntryBySection (priv->corba_select_names, + section_name, &ev); + + if (BONOBO_EX (&ev)) { + g_message ("e_delegate_dialog_construct(): Unable to get addressbook entry!"); + goto error; + } + + CORBA_exception_free (&ev); + + priv->entry = bonobo_widget_new_control_from_objref (corba_control, CORBA_OBJECT_NIL); + gtk_widget_show (priv->entry); + gtk_box_pack_start (GTK_BOX (priv->hbox), priv->entry, TRUE, TRUE, 0); + + + gtk_signal_connect (GTK_OBJECT (priv->addressbook), "clicked", + GTK_SIGNAL_FUNC (addressbook_clicked_cb), edd); + + return edd; + + error: + + gtk_object_unref (GTK_OBJECT (edd)); + return NULL; +} + +static gboolean +get_widgets (EDelegateDialog *edd) +{ + EDelegateDialogPrivate *priv; + + priv = edd->priv; + +#define GW(name) glade_xml_get_widget (priv->xml, name) + + priv->app = GW ("delegate-dialog"); + priv->hbox = GW ("delegate-hbox"); + priv->addressbook = GW ("addressbook"); + + return (priv->app + && priv->hbox + && priv->addressbook); +} + +static void +addressbook_clicked_cb (GtkWidget *widget, gpointer data) +{ + EDelegateDialog *edd = data; + EDelegateDialogPrivate *priv; + CORBA_Environment ev; + + priv = edd->priv; + + CORBA_exception_init (&ev); + + GNOME_Evolution_Addressbook_SelectNames_activateDialog (priv->corba_select_names, section_name, &ev); + + CORBA_exception_free (&ev); +} + + +/** + * e_delegate_dialog_new: + * + * Creates a new event editor dialog. + * + * Return value: A newly-created event editor dialog, or NULL if the event + * editor could not be created. + **/ +EDelegateDialog * +e_delegate_dialog_new (void) +{ + EDelegateDialog *edd; + + edd = E_DELEGATE_DIALOG (gtk_type_new (E_TYPE_DELEGATE_DIALOG)); + return e_delegate_dialog_construct (E_DELEGATE_DIALOG (edd)); +} + +char * +e_delegate_dialog_get_delegate (EDelegateDialog *edd) +{ + EDelegateDialogPrivate *priv; + EDestination **destv; + char *string = NULL; + + g_return_val_if_fail (edd != NULL, NULL); + g_return_val_if_fail (E_IS_DELEGATE_DIALOG (edd), NULL); + + priv = edd->priv; + + bonobo_widget_get_property (BONOBO_WIDGET (priv->entry), "text", &string, NULL); + destv = e_destination_importv (string); + + g_message ("importv: [%s]", string); + + if (destv && destv[0] != NULL) { + g_free (priv->address); + priv->address = g_strdup (e_destination_get_email (destv[0])); + g_free (destv); + } + + g_free (string); + + return g_strdup (priv->address); +} + + +char * +e_delegate_dialog_get_delegate_name (EDelegateDialog *edd) +{ + EDelegateDialogPrivate *priv; + EDestination **destv; + char *string = NULL; + + g_return_val_if_fail (edd != NULL, NULL); + g_return_val_if_fail (E_IS_DELEGATE_DIALOG (edd), NULL); + + priv = edd->priv; + + bonobo_widget_get_property (BONOBO_WIDGET (priv->entry), "text", &string, NULL); + destv = e_destination_importv (string); + + g_message ("importv: [%s]", string); + + if (destv && destv[0] != NULL) { + g_free (priv->name); + priv->name = g_strdup (e_destination_get_name (destv[0])); + g_free (destv); + } + + g_free (string); + + return g_strdup (priv->name); +} + +void +e_delegate_dialog_set_delegate (EDelegateDialog *edd, + const char *address) +{ + EDelegateDialogPrivate *priv; + + g_return_if_fail (edd != NULL); + g_return_if_fail (E_IS_DELEGATE_DIALOG (edd)); + + priv = edd->priv; + + if (priv->address) + g_free (priv->address); + + priv->address = g_strdup (address); +} + + +GtkWidget* +e_delegate_dialog_get_toplevel (EDelegateDialog *edd) +{ + EDelegateDialogPrivate *priv; + + g_return_val_if_fail (edd != NULL, NULL); + g_return_val_if_fail (E_IS_DELEGATE_DIALOG (edd), NULL); + + priv = edd->priv; + + return priv->app; +} + diff --git a/calendar/gui/dialogs/e-delegate-dialog.glade b/calendar/gui/dialogs/e-delegate-dialog.glade new file mode 100644 index 0000000000..394c191682 --- /dev/null +++ b/calendar/gui/dialogs/e-delegate-dialog.glade @@ -0,0 +1,120 @@ + + + + + timezone-dialog + timezone-dialog + + src + pixmaps + C + True + True + + + + GnomeDialog + delegate-dialog + False + Enter Delegate + GTK_WINDOW_TOPLEVEL + GTK_WIN_POS_NONE + False + False + True + False + True + True + + + GtkVBox + GnomeDialog:vbox + dialog-vbox1 + False + 8 + + 4 + True + True + + + + GtkHButtonBox + GnomeDialog:action_area + dialog-action_area1 + GTK_BUTTONBOX_END + 8 + 85 + 27 + 7 + 0 + + 0 + False + True + GTK_PACK_END + + + + GtkButton + ok-button + True + True + True + GNOME_STOCK_BUTTON_OK + + + + GtkButton + cancel-button + True + True + GNOME_STOCK_BUTTON_CANCEL + + + + + GtkHBox + delegate-hbox + False + 4 + + 0 + False + False + + + + GtkLabel + label3 + + GTK_JUSTIFY_CENTER + False + 0.5 + 0.5 + 0 + 0 + + 0 + False + False + + + + + GtkButton + addressbook + True + + + 0 + False + False + GTK_PACK_END + + + + + + + diff --git a/calendar/gui/dialogs/e-delegate-dialog.h b/calendar/gui/dialogs/e-delegate-dialog.h new file mode 100644 index 0000000000..971751828b --- /dev/null +++ b/calendar/gui/dialogs/e-delegate-dialog.h @@ -0,0 +1,70 @@ +/* Evolution calendar - Delegate selector dialog + * + * Copyright (C) 2001 Ximian, Inc. + * + * Authors: JP Rosevear + * + * 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. + */ + +#ifndef __E_DELEGATE_DIALOG_H__ +#define __E_DELEGATE_DIALOG_H__ + +#include +#include + + + +#define E_TYPE_DELEGATE_DIALOG (e_delegate_dialog_get_type ()) +#define E_DELEGATE_DIALOG(obj) (GTK_CHECK_CAST ((obj), E_TYPE_DELEGATE_DIALOG, EDelegateDialog)) +#define E_DELEGATE_DIALOG_CLASS(klass) (GTK_CHECK_CLASS_CAST ((klass), E_TYPE_DELEGATE_DIALOG, \ + EDelegateDialogClass)) +#define E_IS_DELEGATE_DIALOG(obj) (GTK_CHECK_TYPE ((obj), E_TYPE_DELEGATE_DIALOG)) +#define E_IS_DELEGATE_DIALOG_CLASS(klass) (GTK_CHECK_CLASS_TYPE ((klass), E_TYPE_DELEGATE_DIALOG)) + + +typedef struct _EDelegateDialog EDelegateDialog; +typedef struct _EDelegateDialogClass EDelegateDialogClass; +typedef struct _EDelegateDialogPrivate EDelegateDialogPrivate; + +struct _EDelegateDialog { + GtkObject object; + + /* Private data */ + EDelegateDialogPrivate *priv; +}; + +struct _EDelegateDialogClass { + GtkObjectClass parent_class; +}; + + +GtkType e_delegate_dialog_get_type (void); +EDelegateDialog* e_delegate_dialog_construct (EDelegateDialog *etd); + +EDelegateDialog* e_delegate_dialog_new (void); + +char* e_delegate_dialog_get_delegate (EDelegateDialog *etd); + +char* e_delegate_dialog_get_delegate_name (EDelegateDialog *etd); + +void e_delegate_dialog_set_delegate (EDelegateDialog *etd, + const char *address); + +GtkWidget* e_delegate_dialog_get_toplevel (EDelegateDialog *etd); + + + +#endif /* __E_DELEGATE_DIALOG_H__ */ diff --git a/calendar/gui/dialogs/meeting-page.c b/calendar/gui/dialogs/meeting-page.c index 3b7b9e72a9..99c5cf37c6 100644 --- a/calendar/gui/dialogs/meeting-page.c +++ b/calendar/gui/dialogs/meeting-page.c @@ -27,15 +27,17 @@ #endif #include -#include -#include -#include #include #include #include #include #include #include +#include +#include +#include +#include +#include #include #include #include @@ -50,6 +52,7 @@ #include "../component-factory.h" #include "../itip-utils.h" #include "comp-editor-util.h" +#include "e-delegate-dialog.h" #include "meeting-page.h" @@ -123,8 +126,6 @@ struct _MeetingPagePrivate { /* For handling the invite button */ GNOME_Evolution_Addressbook_SelectNames corba_select_names; - - }; @@ -361,17 +362,17 @@ meeting_page_fill_widgets (CompEditorPage *page, CalComponent *comp) CalComponentAttendee *att = l->data; struct attendee *attendee = g_new0 (struct attendee, 1); - attendee->address = g_strdup (att->value); - attendee->member = g_strdup (att->member); + attendee->address = att->value ? g_strdup (att->value) : g_strdup (""); + attendee->member = att->member ? g_strdup (att->member) : g_strdup (""); attendee->cutype= att->cutype; attendee->role = att->role; attendee->status = att->status; attendee->rsvp = att->rsvp; - attendee->delto = g_strdup (att->delto); - attendee->delfrom = g_strdup (att->delfrom); - attendee->sentby = g_strdup (att->sentby); - attendee->cn = g_strdup (att->cn); - attendee->language = g_strdup (att->language); + attendee->delto = att->delto ? g_strdup (att->delto) : g_strdup (""); + attendee->delfrom = att->delto ? g_strdup (att->delfrom) : g_strdup (""); + attendee->sentby = att->sentby ? g_strdup (att->sentby) : g_strdup (""); + attendee->cn = att->cn ? g_strdup (att->cn) : g_strdup (""); + attendee->language = att->language ? g_strdup (att->language) : g_strdup (""); priv->attendees = g_slist_prepend (priv->attendees, attendee); @@ -452,7 +453,7 @@ meeting_page_fill_component (CompEditorPage *page, CalComponent *comp) att->rsvp = attendee->rsvp; att->delto = (attendee->delto && *attendee->delto) ? attendee->delto : NULL; att->delfrom = (attendee->delfrom && *attendee->delfrom) ? attendee->delfrom : NULL; - att->sentby = attendee->sentby; + att->sentby = (attendee->sentby && *attendee->sentby) ? attendee->sentby : NULL; att->cn = (attendee->cn && *attendee->cn) ? attendee->cn : NULL; att->language = (attendee->language && *attendee->language) ? attendee->language : NULL; @@ -515,19 +516,21 @@ invite_entry_changed (BonoboListener *listener, CORBA_Environment *ev, gpointer user_data) { - g_message ("event: \"%s\", section \"%s\"", event_name, BONOBO_ARG_GET_STRING (arg)); + g_message ("event: \"%s\", section \"%s\"", event_name, BONOBO_ARG_GET_STRING (arg)); } static void -add_section (GNOME_Evolution_Addressbook_SelectNames corba_select_names, const char *name) +add_section (GNOME_Evolution_Addressbook_SelectNames corba_select_names, const char *name, int limit) { Bonobo_Control corba_control; CORBA_Environment ev; - GtkWidget *control_widget; - BonoboControlFrame *cf; - Bonobo_PropertyBag pb = CORBA_OBJECT_NIL; + CORBA_exception_init (&ev); + if (limit != 0) + GNOME_Evolution_Addressbook_SelectNames_addSectionWithLimit (corba_select_names, + name, name, limit, &ev); + else GNOME_Evolution_Addressbook_SelectNames_addSection (corba_select_names, name, name, &ev); @@ -542,18 +545,10 @@ add_section (GNOME_Evolution_Addressbook_SelectNames corba_select_names, const c CORBA_exception_free (&ev); -#if 0 - control_widget = bonobo_widget_new_control_from_objref ( - corba_control, CORBA_OBJECT_NIL); - - cf = bonobo_widget_get_control_frame (BONOBO_WIDGET (control_widget)); - pb = bonobo_control_frame_get_control_property_bag (cf, NULL); - - bonobo_event_source_client_add_listener ( - pb, invite_entry_changed, - "Bonobo/Property:change:entry_changed", - NULL, NULL); -#endif + bonobo_event_source_client_add_listener (corba_control, + invite_entry_changed, + "changed:working_copy", + NULL, NULL); } static gboolean @@ -571,9 +566,9 @@ get_select_name_dialog (MeetingPage *mpage) priv->corba_select_names = oaf_activate_from_id (SELECT_NAMES_OAFID, 0, NULL, &ev); - add_section (priv->corba_select_names, "Required Participants"); - add_section (priv->corba_select_names, "Optional Participants"); - add_section (priv->corba_select_names, "Non-Participants"); + add_section (priv->corba_select_names, "Required Participants", 0); + add_section (priv->corba_select_names, "Optional Participants", 0); + add_section (priv->corba_select_names, "Non-Participants", 0); bonobo_event_source_client_add_listener (priv->corba_select_names, invite_entry_changed, @@ -854,7 +849,7 @@ append_row (ETableModel *etm, ETableModel *model, int row, void *data) attendee = g_new0 (struct attendee, 1); - attendee->address = g_strdup_printf ("MAILTO:%s", e_table_model_value_at (model, MEETING_ATTENDEE_COL, row)); + attendee->address = g_strdup_printf ("MAILTO:%s", (char *) e_table_model_value_at (model, MEETING_ATTENDEE_COL, row)); attendee->member = g_strdup (e_table_model_value_at (model, MEETING_MEMBER_COL, row)); attendee->cutype = text_to_type (e_table_model_value_at (model, MEETING_TYPE_COL, row)); attendee->role = text_to_role (e_table_model_value_at (model, MEETING_ROLE_COL, row)); @@ -898,9 +893,9 @@ value_at (ETableModel *etm, int col, int row, void *data) case MEETING_RSVP_COL: return boolean_to_text (attendee->rsvp); case MEETING_DELTO_COL: - return attendee->delto; + return itip_strip_mailto (attendee->delto); case MEETING_DELFROM_COL: - return attendee->delfrom; + return itip_strip_mailto (attendee->delfrom); case MEETING_STATUS_COL: return partstat_to_text (attendee->status); case MEETING_CN_COL: @@ -928,7 +923,7 @@ set_value_at (ETableModel *etm, int col, int row, const void *val, void *data) case MEETING_ATTENDEE_COL: if (attendee->address) g_free (attendee->address); - attendee->address = g_strdup_printf ("MAILTO:%s", val); + attendee->address = g_strdup_printf ("MAILTO:%s", (char *) val); break; case MEETING_MEMBER_COL: if (attendee->member) @@ -1170,10 +1165,72 @@ popup_delegate_cb (GtkWidget *widget, gpointer data) { MeetingPage *mpage = MEETING_PAGE (data); MeetingPagePrivate *priv; + EDelegateDialog *edd; + GtkWidget *dialog; + char *address = NULL, *name = NULL; + gint row_cnt; priv = mpage->priv; - e_table_model_row_changed (priv->model, priv->row); + /* Show dialog. */ + edd = e_delegate_dialog_new (); + dialog = e_delegate_dialog_get_toplevel (edd); + + if (gnome_dialog_run_and_close (GNOME_DIALOG (dialog)) == 0){ + struct attendee *a; + char *str; + GSList *l; + + name = e_delegate_dialog_get_delegate_name (edd); + address = e_delegate_dialog_get_delegate (edd); + + for (l = priv->attendees; l != NULL; l = l->next) { + a = l->data; + + if (a->address != NULL && !g_strcasecmp (itip_strip_mailto (a->address), address)) { + GtkWidget *dlg = gnome_error_dialog ("That person is already attending the meeting!"); + gnome_dialog_run_and_close (GNOME_DIALOG (dlg)); + goto cleanup; + } + } + + a = g_slist_nth_data (priv->attendees, priv->row); + if (a->delto) + g_free (a->delto); + a->delto = g_strdup_printf ("MAILTO:%s", address); + + a = g_new0 (struct attendee, 1); + + a->address = g_strdup_printf ("MAILTO:%s", address); + a->member = init_value (NULL, MEETING_MEMBER_COL, mpage); + str = init_value (NULL, MEETING_TYPE_COL, mpage); + a->cutype = text_to_type (str); + g_free (str); + str = init_value (NULL, MEETING_ROLE_COL, mpage); + a->role = text_to_role (str); + g_free (str); + str = init_value (NULL, MEETING_RSVP_COL, mpage); + a->rsvp = text_to_boolean (str); + g_free (str); + a->delto = init_value (NULL, MEETING_DELTO_COL, mpage); + a->delfrom = g_strdup_printf ("MAILTO:%s", (char *) value_at (NULL, MEETING_ATTENDEE_COL, priv->row, mpage)); + str = init_value (NULL, MEETING_STATUS_COL, mpage); + a->status = text_to_partstat (str); + g_free (str); + a->cn = name ? g_strdup (name) : g_strdup (""); + a->language = init_value (NULL, MEETING_LANG_COL, mpage); + + priv->attendees = g_slist_append (priv->attendees, a); + + row_cnt = row_count (priv->model, mpage) - 1; + e_table_model_row_changed (priv->model, priv->row); + e_table_model_row_inserted (priv->model, row_cnt); + } + + cleanup: + g_free (name); + g_free (address); + gtk_object_unref (GTK_OBJECT (edd)); } static void @@ -1294,3 +1351,4 @@ meeting_page_new (void) return mpage; } + -- cgit v1.2.3