aboutsummaryrefslogtreecommitdiffstats
path: root/calendar/gui/dialogs
diff options
context:
space:
mode:
authorDamon Chaplin <damon@ximian.com>2001-08-15 09:13:37 +0800
committerDamon Chaplin <damon@src.gnome.org>2001-08-15 09:13:37 +0800
commit6684b4627d4767f6ea5d2969d70ae6f2cf863a79 (patch)
tree89d7a6fba9713ff48fe44ed4bad3ee94471030e6 /calendar/gui/dialogs
parent84f12a913e4a46c198a951dd2b10512fb87ce0a3 (diff)
downloadgsoc2013-evolution-6684b4627d4767f6ea5d2969d70ae6f2cf863a79.tar
gsoc2013-evolution-6684b4627d4767f6ea5d2969d70ae6f2cf863a79.tar.gz
gsoc2013-evolution-6684b4627d4767f6ea5d2969d70ae6f2cf863a79.tar.bz2
gsoc2013-evolution-6684b4627d4767f6ea5d2969d70ae6f2cf863a79.tar.lz
gsoc2013-evolution-6684b4627d4767f6ea5d2969d70ae6f2cf863a79.tar.xz
gsoc2013-evolution-6684b4627d4767f6ea5d2969d70ae6f2cf863a79.tar.zst
gsoc2013-evolution-6684b4627d4767f6ea5d2969d70ae6f2cf863a79.zip
added support for the Contacts field. Note that I'm not sure what we
2001-08-14 Damon Chaplin <damon@ximian.com> * gui/dialogs/task-page.c: * gui/dialogs/event-page.c: added support for the Contacts field. Note that I'm not sure what we should put in the iCalendar CONTACT properties. Currently we put "name <email>", but it isn't recognized as a contact when we reopen the dialog, so we may need more info here. Also we currently use a simple parser to parse the above format, and we should maybe use some camel function. * gui/dialogs/task-page.glade: * gui/dialogs/event-page.glade: replaced the GtkEntry fields for the Contacts with a GtkEventBox which we put the BonoboControl in at runtime. * gui/dialogs/meeting-page.c (invite_entry_changed): added FIXMEs since it doesn't seem to be freeing the EDestination stuff. JP? * gui/dialogs/comp-editor-util.c: added bunch of utility functions to handle the Contacts field in the main Event and Task pages. * gui/gnome-cal.c: added visible_start and visible_end fields, so we only emit the 'dates-shown-changed' signal when really necessary. Currently changing the folder title bar label results in a complete redraw of the Evolution window (silly GtkLabel queueing a resize), so we want to avoid that as much as possible. (gnome_calendar_new_appointment_for): only move the event's end time to the end of the day if it is not already 00:00:00. * gui/e-week-view-event-item.c: * gui/e-week-view.c: * gui/e-day-view.c: added support for double-clicking on an event to open it, and for double-clicking on the background to create a new event. There is still a minor problem to sort out, but it basically works. * cal-util/cal-component.c: added support for CONTACT properties, mainly by copying the code for COMMENT properties which are exactly the same type. * gui/e-day-view.c (e_day_view_realize): use the same color for the top canvas background as the shortcut bar, to make it look a little nicer (I think). Although we still have the theme problem with hard-coded colors. svn path=/trunk/; revision=12039
Diffstat (limited to 'calendar/gui/dialogs')
-rw-r--r--calendar/gui/dialogs/comp-editor-util.c248
-rw-r--r--calendar/gui/dialogs/comp-editor-util.h16
-rw-r--r--calendar/gui/dialogs/event-page.c103
-rw-r--r--calendar/gui/dialogs/event-page.glade13
-rw-r--r--calendar/gui/dialogs/meeting-page.c4
-rw-r--r--calendar/gui/dialogs/task-page.c105
-rw-r--r--calendar/gui/dialogs/task-page.glade15
7 files changed, 467 insertions, 37 deletions
diff --git a/calendar/gui/dialogs/comp-editor-util.c b/calendar/gui/dialogs/comp-editor-util.c
index 0e4384dca4..8ef7aebbab 100644
--- a/calendar/gui/dialogs/comp-editor-util.c
+++ b/calendar/gui/dialogs/comp-editor-util.c
@@ -23,11 +23,16 @@
#include <config.h>
#endif
+#include <ctype.h>
#include <string.h>
#include <ical.h>
#include <glib.h>
#include <libgnome/gnome-defs.h>
#include <libgnome/gnome-i18n.h>
+#include <liboaf/liboaf.h>
+#include <bonobo/bonobo-control.h>
+#include <bonobo/bonobo-widget.h>
+#include <e-destination.h>
#include <e-util/e-time-utils.h>
#include <cal-util/timeutil.h>
#include "../calendar-config.h"
@@ -224,3 +229,246 @@ comp_editor_get_current_time (GtkObject *object, gpointer data)
return tmp_tm;
}
+
+
+
+/*
+ * These are utility functions to handle the SelectNames control we use
+ * for the contacts field, and its related dialog.
+ */
+
+#define SELECT_NAMES_OAFID "OAFIID:GNOME_Evolution_Addressbook_SelectNames"
+
+GNOME_Evolution_Addressbook_SelectNames
+comp_editor_create_contacts_component (void)
+{
+ GNOME_Evolution_Addressbook_SelectNames corba_select_names;
+ CORBA_Environment ev;
+
+ CORBA_exception_init (&ev);
+ corba_select_names = oaf_activate_from_id (SELECT_NAMES_OAFID, 0,
+ NULL, &ev);
+
+ /* OAF seems to be broken -- it can return a CORBA_OBJECT_NIL without
+ raising an exception in `ev'. */
+ if (ev._major != CORBA_NO_EXCEPTION
+ || corba_select_names == CORBA_OBJECT_NIL) {
+ g_warning ("Cannot activate -- %s", SELECT_NAMES_OAFID);
+ CORBA_exception_free (&ev);
+ return CORBA_OBJECT_NIL;
+ }
+
+ CORBA_exception_free (&ev);
+
+ return corba_select_names;
+}
+
+
+GtkWidget *
+comp_editor_create_contacts_control (GNOME_Evolution_Addressbook_SelectNames corba_select_names)
+{
+ Bonobo_Control corba_control;
+ GtkWidget *control_widget;
+ CORBA_Environment ev;
+ char *name = _("Contacts");
+
+ CORBA_exception_init (&ev);
+
+ GNOME_Evolution_Addressbook_SelectNames_addSection (
+ corba_select_names, name, name, &ev);
+ if (ev._major != CORBA_NO_EXCEPTION) {
+ CORBA_exception_free (&ev);
+ return NULL;
+ }
+
+ corba_control =
+ GNOME_Evolution_Addressbook_SelectNames_getEntryBySection (
+ corba_select_names, name, &ev);
+
+ if (ev._major != CORBA_NO_EXCEPTION) {
+ CORBA_exception_free (&ev);
+ return NULL;
+ }
+
+ CORBA_exception_free (&ev);
+
+ control_widget = bonobo_widget_new_control_from_objref (
+ corba_control, CORBA_OBJECT_NIL);
+
+ gtk_widget_show (control_widget);
+
+ return control_widget;
+}
+
+
+Bonobo_EventSource_ListenerId
+comp_editor_connect_contacts_changed (GtkWidget *contacts_entry,
+ BonoboListenerCallbackFn changed_cb,
+ gpointer changed_cb_data)
+{
+ BonoboControlFrame *cf;
+ Bonobo_PropertyBag pb = CORBA_OBJECT_NIL;
+
+ cf = bonobo_widget_get_control_frame (BONOBO_WIDGET (contacts_entry));
+ pb = bonobo_control_frame_get_control_property_bag (cf, NULL);
+
+ return bonobo_event_source_client_add_listener (
+ pb, changed_cb,
+ "Bonobo/Property:change:entry_changed",
+ NULL, changed_cb_data);
+}
+
+
+void
+comp_editor_show_contacts_dialog (GNOME_Evolution_Addressbook_SelectNames corba_select_names)
+{
+ CORBA_Environment ev;
+
+ CORBA_exception_init (&ev);
+ GNOME_Evolution_Addressbook_SelectNames_activateDialog (
+ corba_select_names, _("Contacts"), &ev);
+ CORBA_exception_free (&ev);
+}
+
+
+/* A simple 'name <email>' parser.
+ FIXME: Should probably use camel functions or something. */
+static void
+parse_contact_string (const char *value, char **name, char **email)
+{
+ char *lbracket, *rbracket, *name_end, *tmp_name, *tmp_email;
+
+ if (!value) {
+ *name = g_strdup ("");
+ *email = g_strdup ("");
+ return;
+ }
+
+ lbracket = strchr (value, '<');
+ rbracket = strchr (value, '>');
+
+ if (!lbracket || !rbracket || rbracket < lbracket) {
+ *name = g_strdup (value);
+ *email = g_strdup ("");
+ return;
+ }
+
+ name_end = lbracket - 1;
+ while (name_end > value && isspace (*name_end))
+ name_end--;
+
+ tmp_name = g_malloc (name_end - value + 2);
+ strncpy (tmp_name, value, name_end - value + 1);
+ tmp_name[name_end - value + 1] = '\0';
+ *name = tmp_name;
+
+ tmp_email = g_malloc (rbracket - lbracket);
+ strncpy (tmp_email, lbracket + 1, rbracket - lbracket - 1);
+ tmp_email[rbracket - lbracket - 1] = '\0';
+ *email = tmp_email;
+
+ g_print ("Parsed: %s\n Name:'%s'\nEmail:'%s'\n",
+ value, *name, *email);
+}
+
+
+void
+comp_editor_contacts_to_widget (GtkWidget *contacts_entry,
+ CalComponent *comp)
+{
+ GPtrArray *dest_array;
+ EDestination *dest;
+ GSList *contact_list, *elem;
+ char *contacts_string;
+ int i;
+
+ cal_component_get_contact_list (comp, &contact_list);
+ dest_array = g_ptr_array_new ();
+ for (elem = contact_list; elem; elem = elem->next) {
+ CalComponentText *t = elem->data;
+ char *name, *email;
+
+ parse_contact_string (t->value, &name, &email);
+
+ dest = e_destination_new ();
+ e_destination_set_name (dest, name);
+ e_destination_set_email (dest, email);
+ g_ptr_array_add (dest_array, dest);
+ g_free (name);
+ g_free (email);
+ }
+ cal_component_free_text_list (contact_list);
+
+ /* we need destv to be NULL terminated */
+ g_ptr_array_add (dest_array, NULL);
+
+ contacts_string = e_destination_exportv ((EDestination**) dest_array->pdata);
+ g_print ("Destinations: %s\n", contacts_string);
+
+ bonobo_widget_set_property (BONOBO_WIDGET (contacts_entry),
+ "destinations", contacts_string, NULL);
+
+ g_free (contacts_string);
+
+ /* We free all dest_array except the last NULL we added. */
+ for (i = 0; i < dest_array->len - 1; i++) {
+ dest = g_ptr_array_index (dest_array, i);
+ gtk_object_unref (GTK_OBJECT (dest));
+ }
+ g_ptr_array_free (dest_array, TRUE);
+}
+
+
+void
+comp_editor_contacts_to_component (GtkWidget *contacts_entry,
+ CalComponent *comp)
+{
+ EDestination **contact_destv;
+ GSList *contact_list = NULL, *elem;
+ char *contacts_string = NULL;
+ CalComponentText *t;
+ const char *name, *email;
+ int i;
+
+ bonobo_widget_get_property (BONOBO_WIDGET (contacts_entry),
+ "destinations", &contacts_string, NULL);
+ g_print ("Contacts string: %s\n", contacts_string);
+
+ contact_destv = e_destination_importv (contacts_string);
+ if (contact_destv) {
+ for (i = 0; contact_destv[i] != NULL; i++) {
+ name = e_destination_get_name (contact_destv[i]);
+ email = e_destination_get_email (contact_destv[i]);
+
+ t = g_new0 (CalComponentText, 1);
+ t->altrep = NULL;
+
+ /* If both name and email are given, use the standard
+ 'name <email>' form, otherwise use just the name
+ or the email address.
+ FIXME: I'm not sure this is correct syntax etc. */
+ if (name && name[0] && email && email[0])
+ t->value = g_strdup_printf ("%s <%s>",
+ name, email);
+ else if (name && name[0])
+ t->value = g_strdup (name);
+ else
+ t->value = g_strdup (email);
+
+ contact_list = g_slist_prepend (contact_list, t);
+
+ gtk_object_unref (GTK_OBJECT (contact_destv[i]));
+ }
+ }
+ g_free (contact_destv);
+
+ contact_list = g_slist_reverse (contact_list);
+ cal_component_set_contact_list (comp, contact_list);
+
+ for (elem = contact_list; elem; elem = elem->next) {
+ t = elem->data;
+ g_free ((char*)t->value);
+ g_free (t);
+ }
+ g_slist_free (contact_list);
+}
diff --git a/calendar/gui/dialogs/comp-editor-util.h b/calendar/gui/dialogs/comp-editor-util.h
index 4e8e344731..45c45a72a3 100644
--- a/calendar/gui/dialogs/comp-editor-util.h
+++ b/calendar/gui/dialogs/comp-editor-util.h
@@ -23,6 +23,8 @@
#define _COMP_EDITOR_UTIL_H_
#include <gtk/gtkwidget.h>
+#include <bonobo/bonobo-control.h>
+#include "Evolution-Addressbook-SelectNames.h"
#include "comp-editor-page.h"
void comp_editor_dates (CompEditorPageDates *date, CalComponent *comp);
@@ -32,4 +34,18 @@ GtkWidget *comp_editor_new_date_edit (gboolean show_date, gboolean show_time);
struct tm comp_editor_get_current_time (GtkObject *object, gpointer data);
+
+GNOME_Evolution_Addressbook_SelectNames comp_editor_create_contacts_component (void);
+GtkWidget * comp_editor_create_contacts_control (GNOME_Evolution_Addressbook_SelectNames corba_select_names);
+Bonobo_EventSource_ListenerId comp_editor_connect_contacts_changed (GtkWidget *contacts_entry,
+ BonoboListenerCallbackFn changed_cb,
+ gpointer changed_cb_data);
+void comp_editor_show_contacts_dialog (GNOME_Evolution_Addressbook_SelectNames corba_select_names);
+
+void comp_editor_contacts_to_widget (GtkWidget *contacts_entry,
+ CalComponent *comp);
+void comp_editor_contacts_to_component (GtkWidget *contacts_entry,
+ CalComponent *comp);
+
+
#endif
diff --git a/calendar/gui/dialogs/event-page.c b/calendar/gui/dialogs/event-page.c
index bae084d526..a3947b1cba 100644
--- a/calendar/gui/dialogs/event-page.c
+++ b/calendar/gui/dialogs/event-page.c
@@ -69,7 +69,7 @@ struct _EventPagePrivate {
GtkWidget *show_time_as_busy;
GtkWidget *contacts_btn;
- GtkWidget *contacts;
+ GtkWidget *contacts_box;
GtkWidget *categories_btn;
GtkWidget *categories;
@@ -80,6 +80,11 @@ struct _EventPagePrivate {
start timezone is then changed, we updated the end timezone to the
same value, since 99% of events start and end in one timezone. */
gboolean sync_timezones;
+
+ /* The Corba component for selecting contacts, and the entry field
+ which we place in the dialog. */
+ GNOME_Evolution_Addressbook_SelectNames corba_select_names;
+ GtkWidget *contacts_entry;
};
@@ -178,12 +183,15 @@ event_page_init (EventPage *epage)
priv->show_time_as_free = NULL;
priv->show_time_as_busy = NULL;
priv->contacts_btn = NULL;
- priv->contacts = NULL;
+ priv->contacts_box = NULL;
priv->categories_btn = NULL;
priv->categories = NULL;
priv->updating = FALSE;
priv->sync_timezones = FALSE;
+
+ priv->corba_select_names = CORBA_OBJECT_NIL;
+ priv->contacts_entry = NULL;
}
/* Destroy handler for the event page */
@@ -199,6 +207,14 @@ event_page_destroy (GtkObject *object)
epage = EVENT_PAGE (object);
priv = epage->priv;
+ if (priv->corba_select_names != CORBA_OBJECT_NIL) {
+ CORBA_Environment ev;
+
+ CORBA_exception_init (&ev);
+ CORBA_Object_release (priv->corba_select_names, &ev);
+ CORBA_exception_free (&ev);
+ }
+
if (priv->xml) {
gtk_object_unref (GTK_OBJECT (priv->xml));
priv->xml = NULL;
@@ -324,6 +340,27 @@ clear_widgets (EventPage *epage)
e_dialog_editable_set (priv->categories, NULL);
}
+
+static void
+contacts_changed_cb (BonoboListener *listener,
+ char *event_name,
+ CORBA_any *arg,
+ CORBA_Environment *ev,
+ gpointer data)
+{
+ EventPage *epage;
+ EventPagePrivate *priv;
+
+ epage = EVENT_PAGE (data);
+ priv = epage->priv;
+
+ g_print ("In contacts_changed_cb\n");
+
+ if (!priv->updating)
+ comp_editor_page_notify_changed (COMP_EDITOR_PAGE (epage));
+}
+
+
/* fill_widgets handler for the event page */
static void
event_page_fill_widgets (CompEditorPage *page, CalComponent *comp)
@@ -488,6 +525,17 @@ event_page_fill_widgets (CompEditorPage *page, CalComponent *comp)
cal_component_get_categories (comp, &categories);
e_dialog_editable_set (priv->categories, categories);
+ /* Contacts */
+ comp_editor_contacts_to_widget (priv->contacts_entry, comp);
+
+ /* We connect the contacts changed signal here, as we have to be a bit
+ more careful with it due to the use or Corba. The priv->updating
+ flag won't work as we won't get the changed event immediately.
+ FIXME: Unfortunately this doesn't work either. We never get the
+ changed event now. */
+ comp_editor_connect_contacts_changed (priv->contacts_entry,
+ contacts_changed_cb, epage);
+
priv->updating = FALSE;
}
@@ -612,6 +660,10 @@ event_page_fill_component (CompEditorPage *page, CalComponent *comp)
transparency = e_dialog_radio_get (priv->show_time_as_free,
transparency_map);
cal_component_set_transparency (comp, transparency);
+
+ /* Contacts */
+
+ comp_editor_contacts_to_component (priv->contacts_entry, comp);
}
/* set_summary handler for the event page */
@@ -672,7 +724,7 @@ get_widgets (EventPage *epage)
priv->show_time_as_busy = GW ("show-time-as-busy");
priv->contacts_btn = GW ("contacts-button");
- priv->contacts = GW ("contacts");
+ priv->contacts_box = GW ("contacts-box");
priv->categories_btn = GW ("categories-button");
priv->categories = GW ("categories");
@@ -692,7 +744,7 @@ get_widgets (EventPage *epage)
&& priv->show_time_as_free
&& priv->show_time_as_busy
&& priv->contacts_btn
- && priv->contacts
+ && priv->contacts_box
&& priv->categories_btn
&& priv->categories);
}
@@ -989,6 +1041,22 @@ all_day_event_toggled_cb (GtkWidget *toggle, gpointer data)
&dates);
}
+/* Callback used when the contacts button is clicked; we must bring up the
+ * contact list dialog.
+ */
+static void
+contacts_clicked_cb (GtkWidget *button, gpointer data)
+{
+ EventPage *epage;
+ EventPagePrivate *priv;
+
+ epage = EVENT_PAGE (data);
+ priv = epage->priv;
+
+ g_print ("In contacts_clicked_cb\n");
+ comp_editor_show_contacts_dialog (priv->corba_select_names);
+}
+
/* Callback used when the categories button is clicked; we must bring up the
* category list dialog.
*/
@@ -1021,7 +1089,7 @@ field_changed_cb (GtkWidget *widget, gpointer data)
}
/* Hooks the widget signals */
-static void
+static gboolean
init_widgets (EventPage *epage)
{
EventPagePrivate *priv;
@@ -1058,6 +1126,10 @@ init_widgets (EventPage *epage)
gtk_signal_connect (GTK_OBJECT (priv->all_day_event), "toggled",
GTK_SIGNAL_FUNC (all_day_event_toggled_cb), epage);
+ /* Contacts button */
+ gtk_signal_connect (GTK_OBJECT (priv->contacts_btn), "clicked",
+ GTK_SIGNAL_FUNC (contacts_clicked_cb), epage);
+
/* Categories button */
gtk_signal_connect (GTK_OBJECT (priv->categories_btn), "clicked",
GTK_SIGNAL_FUNC (categories_clicked_cb), epage);
@@ -1098,10 +1170,19 @@ init_widgets (EventPage *epage)
gtk_signal_connect (GTK_OBJECT (priv->categories), "changed",
GTK_SIGNAL_FUNC (field_changed_cb), epage);
- /* FIXME: we do not support these fields yet, so we disable them */
+ /* Create the contacts entry, a corba control from the address book. */
+ priv->corba_select_names = comp_editor_create_contacts_component ();
+ if (priv->corba_select_names == CORBA_OBJECT_NIL)
+ return FALSE;
- gtk_widget_set_sensitive (priv->contacts_btn, FALSE);
- gtk_widget_set_sensitive (priv->contacts, FALSE);
+ priv->contacts_entry = comp_editor_create_contacts_control (priv->corba_select_names);
+ if (priv->contacts_entry == NULL)
+ return FALSE;
+
+ gtk_container_add (GTK_CONTAINER (priv->contacts_box),
+ priv->contacts_entry);
+
+ return TRUE;
}
@@ -1136,7 +1217,11 @@ event_page_construct (EventPage *epage)
return NULL;
}
- init_widgets (epage);
+ if (!init_widgets (epage)) {
+ g_message ("event_page_construct(): "
+ "Could not initialize the widgets!");
+ return NULL;
+ }
return epage;
}
diff --git a/calendar/gui/dialogs/event-page.glade b/calendar/gui/dialogs/event-page.glade
index 380b99302f..0c3abcfc5f 100644
--- a/calendar/gui/dialogs/event-page.glade
+++ b/calendar/gui/dialogs/event-page.glade
@@ -487,18 +487,17 @@
</widget>
<widget>
- <class>GtkEntry</class>
- <name>contacts</name>
- <can_focus>True</can_focus>
- <editable>True</editable>
- <text_visible>True</text_visible>
- <text_max_length>0</text_max_length>
- <text></text>
+ <class>GtkEventBox</class>
+ <name>contacts-box</name>
<child>
<padding>0</padding>
<expand>True</expand>
<fill>True</fill>
</child>
+
+ <widget>
+ <class>Placeholder</class>
+ </widget>
</widget>
<widget>
diff --git a/calendar/gui/dialogs/meeting-page.c b/calendar/gui/dialogs/meeting-page.c
index 161ae07255..529ea63c6e 100644
--- a/calendar/gui/dialogs/meeting-page.c
+++ b/calendar/gui/dialogs/meeting-page.c
@@ -810,8 +810,12 @@ invite_entry_changed (BonoboListener *listener,
row_cnt = row_count (priv->model, mpage) - 1;
e_table_model_row_inserted (priv->model, row_cnt);
}
+
+ /* FIXME: Should you unref destv[i], JP?? - Damon */
+
}
+ /* FIXME: Should you g_free() destv, JP?? - Damon */
}
static void
diff --git a/calendar/gui/dialogs/task-page.c b/calendar/gui/dialogs/task-page.c
index d2f4a557c2..f6ad6da413 100644
--- a/calendar/gui/dialogs/task-page.c
+++ b/calendar/gui/dialogs/task-page.c
@@ -66,12 +66,17 @@ struct _TaskPagePrivate {
GtkWidget *classification_confidential;
GtkWidget *contacts_btn;
- GtkWidget *contacts;
+ GtkWidget *contacts_box;
GtkWidget *categories_btn;
GtkWidget *categories;
gboolean updating;
+
+ /* The Corba component for selecting contacts, and the entry field
+ which we place in the dialog. */
+ GNOME_Evolution_Addressbook_SelectNames corba_select_names;
+ GtkWidget *contacts_entry;
};
static const int classification_map[] = {
@@ -174,11 +179,14 @@ task_page_init (TaskPage *tpage)
priv->classification_private = NULL;
priv->classification_confidential = NULL;
priv->contacts_btn = NULL;
- priv->contacts = NULL;
+ priv->contacts_box = NULL;
priv->categories_btn = NULL;
priv->categories = NULL;
priv->updating = FALSE;
+
+ priv->corba_select_names = CORBA_OBJECT_NIL;
+ priv->contacts_entry = NULL;
}
/* Destroy handler for the task page */
@@ -194,6 +202,14 @@ task_page_destroy (GtkObject *object)
tpage = TASK_PAGE (object);
priv = tpage->priv;
+ if (priv->corba_select_names != CORBA_OBJECT_NIL) {
+ CORBA_Environment ev;
+
+ CORBA_exception_init (&ev);
+ CORBA_Object_release (priv->corba_select_names, &ev);
+ CORBA_exception_free (&ev);
+ }
+
if (priv->xml) {
gtk_object_unref (GTK_OBJECT (priv->xml));
priv->xml = NULL;
@@ -265,6 +281,23 @@ classification_get (GtkWidget *widget)
return e_dialog_radio_get (widget, classification_map);
}
+static void
+contacts_changed_cb (BonoboListener *listener,
+ char *event_name,
+ CORBA_any *arg,
+ CORBA_Environment *ev,
+ gpointer data)
+{
+ TaskPage *tpage;
+ TaskPagePrivate *priv;
+
+ tpage = TASK_PAGE (data);
+ priv = tpage->priv;
+
+ if (!priv->updating)
+ comp_editor_page_notify_changed (COMP_EDITOR_PAGE (tpage));
+}
+
/* fill_widgets handler for the task page */
static void
task_page_fill_widgets (CompEditorPage *page, CalComponent *comp)
@@ -384,6 +417,19 @@ task_page_fill_widgets (CompEditorPage *page, CalComponent *comp)
cal_component_get_categories (comp, &categories);
e_dialog_editable_set (priv->categories, categories);
+
+ /* Contacts */
+ comp_editor_contacts_to_widget (priv->contacts_entry, comp);
+
+ /* We connect the contacts changed signal here, as we have to be a bit
+ more careful with it due to the use or Corba. The priv->updating
+ flag won't work as we won't get the changed event immediately.
+ FIXME: Unfortunately this doesn't work either. We never get the
+ changed event now. */
+ comp_editor_connect_contacts_changed (priv->contacts_entry,
+ contacts_changed_cb, tpage);
+
+
priv->updating = FALSE;
}
@@ -491,6 +537,9 @@ task_page_fill_component (CompEditorPage *page, CalComponent *comp)
if (cat)
g_free (cat);
+
+ /* Contacts */
+ comp_editor_contacts_to_component (priv->contacts_entry, comp);
}
/* set_summary handler for the task page */
@@ -558,7 +607,7 @@ get_widgets (TaskPage *tpage)
priv->classification_confidential = GW ("classification-confidential");
priv->contacts_btn = GW ("contacts-button");
- priv->contacts = GW ("contacts");
+ priv->contacts_box = GW ("contacts-box");
priv->categories_btn = GW ("categories-button");
priv->categories = GW ("categories");
@@ -575,7 +624,7 @@ get_widgets (TaskPage *tpage)
&& priv->classification_confidential
&& priv->description
&& priv->contacts_btn
- && priv->contacts
+ && priv->contacts_box
&& priv->categories_btn
&& priv->categories);
}
@@ -649,6 +698,22 @@ date_changed_cb (EDateEdit *dedit, gpointer data)
&dates);
}
+/* Callback used when the contacts button is clicked; we must bring up the
+ * contact list dialog.
+ */
+static void
+contacts_clicked_cb (GtkWidget *button, gpointer data)
+{
+ TaskPage *tpage;
+ TaskPagePrivate *priv;
+
+ tpage = TASK_PAGE (data);
+ priv = tpage->priv;
+
+ g_print ("In contacts_clicked_cb\n");
+ comp_editor_show_contacts_dialog (priv->corba_select_names);
+}
+
/* Callback used when the categories button is clicked; we must bring up the
* category list dialog.
*/
@@ -681,7 +746,7 @@ field_changed_cb (GtkWidget *widget, gpointer data)
}
/* Hooks the widget signals */
-static void
+static gboolean
init_widgets (TaskPage *tpage)
{
TaskPagePrivate *priv;
@@ -732,19 +797,31 @@ init_widgets (TaskPage *tpage)
field gets set whenever a field is changed. */
gtk_signal_connect (GTK_OBJECT (priv->description), "changed",
GTK_SIGNAL_FUNC (field_changed_cb), tpage);
- gtk_signal_connect (GTK_OBJECT (priv->contacts), "changed",
- GTK_SIGNAL_FUNC (field_changed_cb), tpage);
gtk_signal_connect (GTK_OBJECT (priv->categories), "changed",
GTK_SIGNAL_FUNC (field_changed_cb), tpage);
- /* Button clicks */
+ /* Contacts button */
+ gtk_signal_connect (GTK_OBJECT (priv->contacts_btn), "clicked",
+ GTK_SIGNAL_FUNC (contacts_clicked_cb), tpage);
+
+ /* Categories button */
gtk_signal_connect (GTK_OBJECT (priv->categories_btn), "clicked",
GTK_SIGNAL_FUNC (categories_clicked_cb), tpage);
- /* FIXME: we do not support these fields yet, so we disable them */
- gtk_widget_set_sensitive (priv->contacts_btn, FALSE);
- gtk_widget_set_sensitive (priv->contacts, FALSE);
+ /* Create the contacts entry, a corba control from the address book. */
+ priv->corba_select_names = comp_editor_create_contacts_component ();
+ if (priv->corba_select_names == CORBA_OBJECT_NIL)
+ return FALSE;
+
+ priv->contacts_entry = comp_editor_create_contacts_control (priv->corba_select_names);
+ if (priv->contacts_entry == NULL)
+ return FALSE;
+
+ gtk_container_add (GTK_CONTAINER (priv->contacts_box),
+ priv->contacts_entry);
+
+ return TRUE;
}
@@ -779,7 +856,11 @@ task_page_construct (TaskPage *tpage)
return NULL;
}
- init_widgets (tpage);
+ if (!init_widgets (tpage)) {
+ g_message ("event_page_construct(): "
+ "Could not initialize the widgets!");
+ return NULL;
+ }
return tpage;
}
diff --git a/calendar/gui/dialogs/task-page.glade b/calendar/gui/dialogs/task-page.glade
index 7c4a53c098..10e0180eff 100644
--- a/calendar/gui/dialogs/task-page.glade
+++ b/calendar/gui/dialogs/task-page.glade
@@ -410,7 +410,6 @@
<class>GtkButton</class>
<name>contacts-button</name>
<can_focus>True</can_focus>
- <relief>GTK_RELIEF_NORMAL</relief>
<child>
<padding>0</padding>
<expand>False</expand>
@@ -431,25 +430,23 @@
</widget>
<widget>
- <class>GtkEntry</class>
- <name>contacts</name>
- <can_focus>True</can_focus>
- <editable>True</editable>
- <text_visible>True</text_visible>
- <text_max_length>0</text_max_length>
- <text></text>
+ <class>GtkEventBox</class>
+ <name>contacts-box</name>
<child>
<padding>0</padding>
<expand>True</expand>
<fill>True</fill>
</child>
+
+ <widget>
+ <class>Placeholder</class>
+ </widget>
</widget>
<widget>
<class>GtkButton</class>
<name>categories-button</name>
<can_focus>True</can_focus>
- <relief>GTK_RELIEF_NORMAL</relief>
<child>
<padding>0</padding>
<expand>False</expand>