diff options
author | JP Rosevear <jpr@ximian.com> | 2001-10-19 05:34:04 +0800 |
---|---|---|
committer | JP Rosevear <jpr@src.gnome.org> | 2001-10-19 05:34:04 +0800 |
commit | f6dfb498619f36e5038b305318c2db657362ca79 (patch) | |
tree | 7d027ced62345ed9ac8f94adfe651861a300697c /calendar/gui/e-meeting-model.c | |
parent | d4fd9c55c7f5d5b7ad3f0bf1c4a2481023f7bceb (diff) | |
download | gsoc2013-evolution-f6dfb498619f36e5038b305318c2db657362ca79.tar.gz gsoc2013-evolution-f6dfb498619f36e5038b305318c2db657362ca79.tar.zst gsoc2013-evolution-f6dfb498619f36e5038b305318c2db657362ca79.zip |
call the invite others dialog in the model
2001-10-18 JP Rosevear <jpr@ximian.com>
* gui/e-meeting-time-sel.c
(e_meeting_time_selector_on_invite_others_button_clicked): call
the invite others dialog in the model
* gui/e-meeting-attendee.c (e_meeting_attendee_get_atype): pick
attendee type based on role and cutype
* gui/e-meeting-attendee.h: remove proto
* gui/Makefile.am: compile select names idl
* gui/e-meeting-model.h: new proto
* gui/dialogs/meeting-page.c: remove invite others dialogs bits
from here
* gui/e-meeting-model.c (e_meeting_model_invite_others_dialog):
and put them here
* gui/dialogs/Makefile.am: compile corba bits in parent dir
* gui/dialogs/comp-editor-util.h: reflect above in includes
* gui/dialogs/e-delegate-dialog.c: ditto
* gui/dialogs/schedule-page.c: ditto and clean includes
svn path=/trunk/; revision=13775
Diffstat (limited to 'calendar/gui/e-meeting-model.c')
-rw-r--r-- | calendar/gui/e-meeting-model.c | 165 |
1 files changed, 164 insertions, 1 deletions
diff --git a/calendar/gui/e-meeting-model.c b/calendar/gui/e-meeting-model.c index 273a25672a..472c12ce4e 100644 --- a/calendar/gui/e-meeting-model.c +++ b/calendar/gui/e-meeting-model.c @@ -26,6 +26,10 @@ #endif #include <glib.h> +#include <liboaf/liboaf.h> +#include <bonobo/bonobo-control.h> +#include <bonobo/bonobo-widget.h> +#include <bonobo/bonobo-exception.h> #include <libgnome/gnome-defs.h> #include <libgnome/gnome-i18n.h> #include <libgnome/gnome-util.h> @@ -38,14 +42,18 @@ #include <e-card-cursor.h> #include <e-card.h> #include <e-card-simple.h> +#include <e-destination.h> #include <cal-util/cal-component.h> #include <cal-util/cal-util.h> #include <cal-util/timeutil.h> +#include "Evolution-Addressbook-SelectNames.h" #include "calendar-config.h" #include "itip-utils.h" #include "e-meeting-attendee.h" #include "e-meeting-model.h" +#define SELECT_NAMES_OAFID "OAFIID:GNOME_Evolution_Addressbook_SelectNames" + enum columns { ITIP_ADDRESS_COL, ITIP_MEMBER_COL, @@ -74,6 +82,9 @@ struct _EMeetingModelPrivate GList *refresh_data; gint refresh_count; gboolean refreshing; + + /* For invite others dialogs */ + GNOME_Evolution_Addressbook_SelectNames corba_select_names; }; #define BUF_SIZE 1024 @@ -99,10 +110,14 @@ static void init (EMeetingModel *model); static void destroy (GtkObject *obj); static void attendee_changed_cb (EMeetingAttendee *ia, gpointer data); +static void invite_entry_changed_cb (BonoboListener *listener, + char *event_name, + CORBA_any *arg, + CORBA_Environment *ev, + gpointer data); static ETableModelClass *parent_class = NULL; - GtkType e_meeting_model_get_type (void) { @@ -1311,6 +1326,154 @@ e_meeting_model_etable_from_model (EMeetingModel *im, const gchar *spec_file, co } static void +add_section (GNOME_Evolution_Addressbook_SelectNames corba_select_names, const char *name, int limit) +{ + CORBA_Environment ev; + + 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); + + CORBA_exception_free (&ev); +} + +static gboolean +get_select_name_dialog (EMeetingModel *im) +{ + EMeetingModelPrivate *priv; + const char *sections[] = {_("Chair Persons"), + _("Required Participants"), + _("Optional Participants"), + _("Non-Participants")}; + CORBA_Environment ev; + + priv = im->priv; + + if (priv->corba_select_names != CORBA_OBJECT_NIL) { + Bonobo_Control corba_control; + GtkWidget *control_widget; + int i; + + CORBA_exception_init (&ev); + for (i = 0; i < 4; i++) { + corba_control = GNOME_Evolution_Addressbook_SelectNames_getEntryBySection (priv->corba_select_names, sections[i], &ev); + if (BONOBO_EX (&ev)) { + CORBA_exception_free (&ev); + return FALSE; + } + + control_widget = bonobo_widget_new_control_from_objref (corba_control, CORBA_OBJECT_NIL); + + bonobo_widget_set_property (BONOBO_WIDGET (control_widget), "text", "", NULL); + } + CORBA_exception_free (&ev); + + return TRUE; + } + + CORBA_exception_init (&ev); + + priv->corba_select_names = oaf_activate_from_id (SELECT_NAMES_OAFID, 0, NULL, &ev); + + add_section (priv->corba_select_names, sections[0], 0); + add_section (priv->corba_select_names, sections[1], 0); + add_section (priv->corba_select_names, sections[2], 0); + add_section (priv->corba_select_names, sections[3], 0); + + bonobo_event_source_client_add_listener (priv->corba_select_names, + invite_entry_changed_cb, + "GNOME/Evolution:changed:model", + NULL, im); + + if (BONOBO_EX (&ev)) { + CORBA_exception_free (&ev); + return FALSE; + } + + CORBA_exception_free (&ev); + + return TRUE; +} + +void +e_meeting_model_invite_others_dialog (EMeetingModel *im) +{ + EMeetingModelPrivate *priv; + CORBA_Environment ev; + + priv = im->priv; + + if (!get_select_name_dialog (im)) + return; + + CORBA_exception_init (&ev); + + GNOME_Evolution_Addressbook_SelectNames_activateDialog ( + priv->corba_select_names, _("Required Participants"), &ev); + + CORBA_exception_free (&ev); +} + +static void +invite_entry_changed_cb (BonoboListener *listener, + char *event_name, + CORBA_any *arg, + CORBA_Environment *ev, + gpointer data) +{ + EMeetingModel *im = data; + EMeetingModelPrivate *priv; + Bonobo_Control corba_control; + GtkWidget *control_widget; + EDestination **destv; + char *string = NULL, *section; + int i; + + priv = im->priv; + + section = BONOBO_ARG_GET_STRING (arg); + + g_message ("event: \"%s\", section \"%s\"", event_name, section); + + corba_control = GNOME_Evolution_Addressbook_SelectNames_getEntryBySection (priv->corba_select_names, section, ev); + control_widget = bonobo_widget_new_control_from_objref (corba_control, CORBA_OBJECT_NIL); + + bonobo_widget_get_property (BONOBO_WIDGET (control_widget), "destinations", &string, NULL); + destv = e_destination_importv (string); + if (destv == NULL) + return; + + for (i = 0; destv[i] != NULL; i++) { + EMeetingAttendee *ia; + const char *name, *address; + + name = e_destination_get_name (destv[i]); + address = e_destination_get_email (destv[i]); + + if (e_meeting_model_find_attendee (im, address, NULL) == NULL) { + ia = e_meeting_model_add_attendee_with_defaults (im); + + e_meeting_attendee_set_address (ia, g_strdup_printf ("MAILTO:%s", address)); + if (!strcmp (section, _("Chair Persons"))) + e_meeting_attendee_set_role (ia, ICAL_ROLE_CHAIR); + else if (!strcmp (section, _("Required Participants"))) + e_meeting_attendee_set_role (ia, ICAL_ROLE_REQPARTICIPANT); + else if (!strcmp (section, _("Optional Participants"))) + e_meeting_attendee_set_role (ia, ICAL_ROLE_OPTPARTICIPANT); + else if (!strcmp (section, _("Non-Participants"))) + e_meeting_attendee_set_role (ia, ICAL_ROLE_NONPARTICIPANT); + e_meeting_attendee_set_cn (ia, g_strdup (name)); + } + } + e_destination_freev (destv); +} + +static void attendee_changed_cb (EMeetingAttendee *ia, gpointer data) { EMeetingModel *im = E_MEETING_MODEL (data); |