aboutsummaryrefslogtreecommitdiffstats
path: root/calendar/gui/e-meeting-list-view.c
diff options
context:
space:
mode:
authorJP Rosevear <jpr@novell.com>2005-02-23 09:28:20 +0800
committerJP Rosevear <jpr@src.gnome.org>2005-02-23 09:28:20 +0800
commitb04efc12fa2842852129e25a6a64767c1bbd28f5 (patch)
treefd2ebf29cfc9f494408d65e42b1e2a8e071370bd /calendar/gui/e-meeting-list-view.c
parent7c9fac1f90c71124eda269acd2b87b7149f9002c (diff)
downloadgsoc2013-evolution-b04efc12fa2842852129e25a6a64767c1bbd28f5.tar.gz
gsoc2013-evolution-b04efc12fa2842852129e25a6a64767c1bbd28f5.tar.zst
gsoc2013-evolution-b04efc12fa2842852129e25a6a64767c1bbd28f5.zip
Fixes #63866, #67714, #62089, #47747, #61495
2005-02-21 JP Rosevear <jpr@novell.com> Fixes #63866, #67714, #62089, #47747, #61495 * gui/e-select-names-renderer.h: update signal * gui/e-select-names-renderer.c (e_select_names_renderer_editing_done): emit the cancelled signal properly and don't update if it was cancelled (e_select_names_renderer_focus_out_event): if the cell loses focus the editing is done (e_select_names_renderer_start_editing): listen for focus out event, and only set the address if appropriate (e_select_names_renderer_get_property): handle name/email props (e_select_names_renderer_set_property): ditto (e_select_names_renderer_finalize): free name/email (e_select_names_renderer_class_init): install name/email props; cell_edited returns lists now * gui/e-select-names-editable.h: update protos * gui/e-select-names-editable.c: don't really override any of the gtkentry editable cell routines since we directly inherit from ENameSelectorEntry (e_select_names_editable_get_emails): get all the email addresses (e_select_names_editable_get_names): get all the names (e_select_names_editable_set_address): set the destination correctly for editing * gui/e-meeting-list-view.c (attendee_edited_cb): handle a blank entry by removing it and don't allow an entry that already exists to be entered (attendee_editing_canceled_cb): if the item editing is cancelled and it has no name or email address, remove it (process_section): if the contact has multiple addresses (ie a mailing list), expand the entries * gui/e-calendar-marshal.list: add new marshaller svn path=/trunk/; revision=28851
Diffstat (limited to 'calendar/gui/e-meeting-list-view.c')
-rw-r--r--calendar/gui/e-meeting-list-view.c169
1 files changed, 130 insertions, 39 deletions
diff --git a/calendar/gui/e-meeting-list-view.c b/calendar/gui/e-meeting-list-view.c
index a3965da4af..f411b1be2d 100644
--- a/calendar/gui/e-meeting-list-view.c
+++ b/calendar/gui/e-meeting-list-view.c
@@ -192,12 +192,85 @@ value_edited (GtkTreeView *view, gint col, const gchar *path, const gchar *text)
}
static void
-attendee_edited_cb (GtkCellRenderer *renderer, const gchar *path, const gchar *address, const gchar *name, GtkTreeView *view)
+attendee_edited_cb (GtkCellRenderer *renderer, const gchar *path, GList *addresses, GList *names, GtkTreeView *view)
{
- value_edited (view, E_MEETING_STORE_ADDRESS_COL, path, address);
- value_edited (view, E_MEETING_STORE_CN_COL, path, name);
+ EMeetingStore *model = E_MEETING_STORE (gtk_tree_view_get_model (view));
+ GtkTreePath *treepath = gtk_tree_path_new_from_string (path);
+ int row = gtk_tree_path_get_indices (treepath)[0];
+ EMeetingAttendee *existing_attendee;
+
+ existing_attendee = e_meeting_store_find_attendee_at_row (model, row);
+
+ if (g_list_length (addresses) > 1) {
+ EMeetingAttendee *attendee;
+ GList *l, *m;
+
+ for (l = addresses, m = names; l && m; l = l->next, m = m->next) {
+ char *name = m->data, *email = l->data;
+
+ if (!((name && *name) || (email && *email)))
+ continue;
+
+ if (e_meeting_store_find_attendee (model, email, NULL) != NULL)
+ continue;
+
+ attendee = e_meeting_store_add_attendee_with_defaults (model);
+ e_meeting_attendee_set_address (attendee, g_strdup (l->data));
+ e_meeting_attendee_set_cn (attendee, g_strdup (m->data));
+ if (existing_attendee) {
+ /* FIXME Should we copy anything else? */
+ e_meeting_attendee_set_cutype (attendee, e_meeting_attendee_get_cutype (existing_attendee));
+ e_meeting_attendee_set_role (attendee, e_meeting_attendee_get_role (existing_attendee));
+ e_meeting_attendee_set_rsvp (attendee, e_meeting_attendee_get_rsvp (existing_attendee));
+ e_meeting_attendee_set_status (attendee, e_meeting_attendee_get_status (existing_attendee));
+ }
+ }
+
+ if (existing_attendee)
+ e_meeting_store_remove_attendee (model, existing_attendee);
+
+ } else if (g_list_length (addresses) == 1) {
+ char *name = names->data, *email = addresses->data;
+
+ if (!((name && *name) || (email && *email)) || e_meeting_store_find_attendee (model, email, NULL) != NULL) {
+ if (existing_attendee)
+ e_meeting_store_remove_attendee (model, existing_attendee);
+ } else {
+ value_edited (view, E_MEETING_STORE_ADDRESS_COL, path, email);
+ value_edited (view, E_MEETING_STORE_CN_COL, path, name);
+ }
+ } else {
+ if (existing_attendee)
+ e_meeting_store_remove_attendee (model, existing_attendee);
+ }
+
+ gtk_tree_path_free (treepath);
+}
+
+static void
+attendee_editing_canceled_cb (GtkCellRenderer *renderer, GtkTreeView *view)
+{
+ EMeetingStore *model = E_MEETING_STORE (gtk_tree_view_get_model (view));
+ GtkTreePath *path;
+ EMeetingAttendee *existing_attendee;
+ int row;
+
+ /* This is for newly added attendees when the editing is cancelled */
+ gtk_tree_view_get_cursor (view, &path, NULL);
+ if (!path)
+ return;
+
+ row = gtk_tree_path_get_indices (path)[0];
+ existing_attendee = e_meeting_store_find_attendee_at_row (model, row);
+ if (existing_attendee) {
+ if (!e_meeting_attendee_is_set_cn (existing_attendee) && !e_meeting_attendee_is_set_address (existing_attendee))
+ e_meeting_store_remove_attendee (model, existing_attendee);
+ }
+
+ gtk_tree_path_free (path);
}
+
static void
type_edited_cb (GtkCellRenderer *renderer, const gchar *path, const gchar *text, GtkTreeView *view)
{
@@ -226,7 +299,7 @@ static void
build_table (GtkTreeView *view)
{
GtkCellRenderer *renderer;
-
+
gtk_tree_view_set_headers_visible (view, TRUE);
gtk_tree_view_set_rules_hint (view, TRUE);
@@ -234,10 +307,12 @@ build_table (GtkTreeView *view)
g_object_set (G_OBJECT (renderer), "editable", TRUE, NULL);
gtk_tree_view_insert_column_with_attributes (view, -1, _("Attendee"), renderer,
"text", E_MEETING_STORE_ATTENDEE_COL,
- "address", E_MEETING_STORE_ADDRESS_COL,
+ "name", E_MEETING_STORE_CN_COL,
+ "email", E_MEETING_STORE_ADDRESS_COL,
"underline", E_MEETING_STORE_ATTENDEE_UNDERLINE_COL,
NULL);
g_signal_connect (renderer, "cell_edited", G_CALLBACK (attendee_edited_cb), view);
+ g_signal_connect (renderer, "editing-canceled", G_CALLBACK (attendee_editing_canceled_cb), view);
renderer = e_cell_renderer_combo_new ();
g_object_set (G_OBJECT (renderer), "list", get_type_strings (), "editable", TRUE, NULL);
@@ -331,46 +406,62 @@ process_section (EMeetingListView *view, GList *destinations, icalparameter_role
priv = view->priv;
for (l = destinations; l; l = g_list_next (l)) {
EDestination *destination = l->data;
- const char *name, *attendee = NULL;
- char *attr = NULL;
-
- name = e_destination_get_name (destination);
-
- /* Get the field as attendee from the backend */
- if (e_cal_get_ldap_attribute (e_meeting_store_get_e_cal (priv->store),
- &attr, NULL)) {
- /* FIXME this should be more general */
- if (!g_ascii_strcasecmp (attr, "icscalendar")) {
- EContact *contact;
-
- /* FIXME: this does not work, have to use first
- e_destination_use_contact() */
- contact = e_destination_get_contact (destination);
- if (contact) {
- attendee = e_contact_get (contact, E_CONTACT_FREEBUSY_URL);
- if (!attendee)
- attendee = e_contact_get (contact, E_CONTACT_CALENDAR_URI);
+ const GList *list_dests, *l;
+ GList card_dest;
+
+ if (e_destination_is_evolution_list (destination)) {
+ list_dests = e_destination_list_get_dests (destination);
+ } else {
+ card_dest.next = NULL;
+ card_dest.prev = NULL;
+ card_dest.data = destination;
+ list_dests = &card_dest;
+ }
+
+ for (l = list_dests; l; l = l->next) {
+ EDestination *dest = l->data;
+ const char *name, *attendee = NULL;
+ char *attr = NULL;
+
+ name = e_destination_get_name (dest);
+
+ /* Get the field as attendee from the backend */
+ if (e_cal_get_ldap_attribute (e_meeting_store_get_e_cal (priv->store),
+ &attr, NULL)) {
+ /* FIXME this should be more general */
+ if (!g_ascii_strcasecmp (attr, "icscalendar")) {
+ EContact *contact;
+
+ /* FIXME: this does not work, have to use first
+ e_destination_use_contact() */
+ contact = e_destination_get_contact (dest);
+ if (contact) {
+ attendee = e_contact_get (contact, E_CONTACT_FREEBUSY_URL);
+ if (!attendee)
+ attendee = e_contact_get (contact, E_CONTACT_CALENDAR_URI);
+ }
}
}
- }
- /* If we couldn't get the attendee prior, get the email address as the default */
- if (attendee == NULL || *attendee == '\0') {
- attendee = e_destination_get_email (destination);
- }
+ /* If we couldn't get the attendee prior, get the email address as the default */
+ if (attendee == NULL || *attendee == '\0') {
+ attendee = e_destination_get_email (dest);
+ }
- if (attendee == NULL || *attendee == '\0')
- continue;
+ if (attendee == NULL || *attendee == '\0')
+ continue;
- if (e_meeting_store_find_attendee (priv->store, attendee, NULL) == NULL) {
- EMeetingAttendee *ia = e_meeting_store_add_attendee_with_defaults (priv->store);
-
- e_meeting_attendee_set_address (ia, g_strdup_printf ("MAILTO:%s", attendee));
- e_meeting_attendee_set_role (ia, role);
- if (role == ICAL_ROLE_NONPARTICIPANT)
- e_meeting_attendee_set_cutype (ia, ICAL_CUTYPE_RESOURCE);
- e_meeting_attendee_set_cn (ia, g_strdup (name));
+ if (e_meeting_store_find_attendee (priv->store, attendee, NULL) == NULL) {
+ EMeetingAttendee *ia = e_meeting_store_add_attendee_with_defaults (priv->store);
+
+ e_meeting_attendee_set_address (ia, g_strdup_printf ("MAILTO:%s", attendee));
+ e_meeting_attendee_set_role (ia, role);
+ if (role == ICAL_ROLE_NONPARTICIPANT)
+ e_meeting_attendee_set_cutype (ia, ICAL_CUTYPE_RESOURCE);
+ e_meeting_attendee_set_cn (ia, g_strdup (name));
+ }
}
+
}
}