aboutsummaryrefslogtreecommitdiffstats
path: root/calendar/gui/dialogs/event-page.c
diff options
context:
space:
mode:
authorSuman Manjunath <msuman@novell.com>2007-08-13 18:40:23 +0800
committerChenthill Palanisamy <pchen@src.gnome.org>2007-08-13 18:40:23 +0800
commit98087d1543dff4c0f1cf70b88c634ebe3bcbb656 (patch)
treefd6998b832ed6bb60398da9872e5b8922694baa5 /calendar/gui/dialogs/event-page.c
parent7701d36a65aba3e183fe30e6a0818c5405eb1f46 (diff)
downloadgsoc2013-evolution-98087d1543dff4c0f1cf70b88c634ebe3bcbb656.tar
gsoc2013-evolution-98087d1543dff4c0f1cf70b88c634ebe3bcbb656.tar.gz
gsoc2013-evolution-98087d1543dff4c0f1cf70b88c634ebe3bcbb656.tar.bz2
gsoc2013-evolution-98087d1543dff4c0f1cf70b88c634ebe3bcbb656.tar.lz
gsoc2013-evolution-98087d1543dff4c0f1cf70b88c634ebe3bcbb656.tar.xz
gsoc2013-evolution-98087d1543dff4c0f1cf70b88c634ebe3bcbb656.tar.zst
gsoc2013-evolution-98087d1543dff4c0f1cf70b88c634ebe3bcbb656.zip
reviewed by: Chenthill Palanisamy <pchenthill@novell.com>
2007-08-13 Suman Manjunath <msuman@novell.com> reviewed by: Chenthill Palanisamy <pchenthill@novell.com> * gui/dialogs/event-page.c: (event_page_init), (sensitize_widgets), (get_current_account), (event_page_fill_widgets), (event_page_fill_component), (existing_attendee), (event_page_set_info_string), (get_widgets), (source_changed_cb), (init_widgets), (event_page_select_organizer), (event_page_construct): * gui/dialogs/event-page.glade: * gui/dialogs/memo-page.c: (memo_page_init), * (sensitize_widgets), (memo_page_fill_widgets), (get_current_account), (memo_page_fill_component), (memo_page_set_info_string), (get_widgets), (source_changed_cb), (init_widgets), (memo_page_select_organizer), (memo_page_construct): * gui/dialogs/memo-page.glade: * gui/dialogs/task-page.c: (task_page_init), * (sensitize_widgets), (get_current_account), (task_page_fill_widgets), (task_page_fill_component), (existing_attendee), (task_page_set_info_string), (get_widgets), (source_changed_cb), (init_widgets), (task_page_select_organizer), (task_page_construct): * gui/dialogs/task-page.glade: Add a label on the top to show * information string for calendar, task and memo editors. It would be shown while operating on subscribed user's folder items. * gui/itip-utils.c: (itip_send_comp), (reply_to_calendar_comp): * A utility function sanitize_component has been removed. The sentby parameter is set in the event pages. --This line, and those below, will be ignored-- M calendar/gui/dialogs/task-page.glade M calendar/gui/dialogs/task-page.c M calendar/gui/dialogs/task-page.h M calendar/gui/dialogs/event-page.glade M calendar/gui/dialogs/memo-page.glade M calendar/gui/dialogs/event-page.c M calendar/gui/dialogs/event-page.h M calendar/gui/dialogs/memo-page.c M calendar/gui/dialogs/memo-page.h M calendar/gui/itip-utils.c M calendar/ChangeLog svn path=/trunk/; revision=33996
Diffstat (limited to 'calendar/gui/dialogs/event-page.c')
-rw-r--r--calendar/gui/dialogs/event-page.c222
1 files changed, 188 insertions, 34 deletions
diff --git a/calendar/gui/dialogs/event-page.c b/calendar/gui/dialogs/event-page.c
index de1048c793..d9c16556e3 100644
--- a/calendar/gui/dialogs/event-page.c
+++ b/calendar/gui/dialogs/event-page.c
@@ -70,6 +70,11 @@ struct _EventPagePrivate {
GtkWidget *main;
BonoboUIComponent *uic;
+ /* Generic informative messages placeholder */
+ GtkWidget *info_hbox;
+ GtkWidget *info_icon;
+ GtkWidget *info_string;
+
GtkWidget *summary;
GtkWidget *summary_label;
GtkWidget *location;
@@ -177,6 +182,9 @@ static void hour_sel_changed ( GtkSpinButton *widget, EventPage *epage);
static void minute_sel_changed ( GtkSpinButton *widget, EventPage *epage);
static void hour_minute_changed ( EventPage *epage);
static void update_end_time_selector( EventPage *epage);
+static void event_page_select_organizer (EventPage *epage, const char *backend_address);
+static void set_subscriber_info_string (EventPage *epage, const char *backend_address);
+
G_DEFINE_TYPE (EventPage, event_page, TYPE_COMP_EDITOR_PAGE);
/* Class initialization function for the event page */
@@ -236,6 +244,10 @@ event_page_init (EventPage *epage)
priv->categories = NULL;
priv->sod = NULL;
+ priv->info_hbox = NULL;
+ priv->info_icon = NULL;
+ priv->info_string = NULL;
+
priv->deleted_attendees = g_ptr_array_new ();
priv->comp = NULL;
@@ -576,7 +588,6 @@ clear_widgets (EventPage *epage)
e_dialog_editable_set (priv->categories, NULL);
gtk_entry_set_text (GTK_ENTRY (GTK_COMBO (priv->organizer)->entry), priv->default_address);
-
}
static gboolean
@@ -821,6 +832,11 @@ sensitize_widgets (EventPage *epage)
gtk_box_pack_start ((GtkBox *)priv->status_icons, priv->alarm_icon, FALSE, FALSE, 6);
}
+ /* The list of organizers is set to be non-editable. Otherwise any
+ * change in the displayed list causes an 'Account not found' error.
+ */
+ gtk_editable_set_editable (GTK_EDITABLE (GTK_COMBO (priv->organizer)->entry), FALSE);
+
gtk_editable_set_editable (GTK_EDITABLE (priv->summary), !read_only);
gtk_editable_set_editable (GTK_EDITABLE (priv->location), sensitize);
gtk_widget_set_sensitive (priv->alarm_box, custom);
@@ -952,7 +968,7 @@ get_current_account (EventPage *epage)
EAccount *a = (EAccount *)e_iterator_get(it);
char *full = g_strdup_printf("%s <%s>", a->id->name, a->id->address);
- if (!strcmp (full, str)) {
+ if (!g_ascii_strcasecmp (full, str)) {
g_free (full);
g_object_unref (it);
@@ -978,6 +994,7 @@ event_page_fill_widgets (CompEditorPage *page, ECalComponent *comp)
ECalComponentDateTime start_date, end_date;
const char *location, *uid = NULL;
const char *categories;
+ gchar *backend_addr = NULL;
ESource *source;
GSList *l;
gboolean validated = TRUE;
@@ -1026,11 +1043,17 @@ event_page_fill_widgets (CompEditorPage *page, ECalComponent *comp)
}
e_cal_component_free_text_list (l);
+ e_cal_get_cal_address (COMP_EDITOR_PAGE (epage)->client, &backend_addr, NULL);
+ set_subscriber_info_string (epage, backend_addr);
+
if (priv->is_meeting) {
ECalComponentOrganizer organizer;
-
+
priv->user_add = itip_get_comp_attendee (comp, COMP_EDITOR_PAGE (epage)->client);
+ /* Organizer strings */
+ event_page_select_organizer (epage, backend_addr);
+
/* If there is an existing organizer show it properly */
if (e_cal_component_has_organizer (comp)) {
e_cal_component_get_organizer (comp, &organizer);
@@ -1039,7 +1062,7 @@ event_page_fill_widgets (CompEditorPage *page, ECalComponent *comp)
gchar *string;
GList *list = NULL;
- if (itip_organizer_is_user (comp, page->client)) {
+ if (itip_organizer_is_user (comp, page->client) || itip_sentby_is_user (comp)) {
if (e_cal_get_static_capability (
page->client,
CAL_STATIC_CAPABILITY_ORGANIZER_NOT_EMAIL_ADDRESS))
@@ -1079,20 +1102,31 @@ event_page_fill_widgets (CompEditorPage *page, ECalComponent *comp)
if (a != NULL) {
/* Reuse earlier declared *page, or rename this to avoid confusion? */
CompEditorPage *page = (CompEditorPage *) epage;
+
priv->ia = e_meeting_store_add_attendee_with_defaults (priv->model);
g_object_ref (priv->ia);
- e_meeting_attendee_set_address (priv->ia, g_strdup_printf ("MAILTO:%s", a->id->address));
- e_meeting_attendee_set_cn (priv->ia, g_strdup (a->id->name));
+ if (!(backend_addr && *backend_addr) || !g_ascii_strcasecmp (backend_addr, a->id->address)) {
+ e_meeting_attendee_set_address (priv->ia, g_strdup_printf ("MAILTO:%s", a->id->address));
+ e_meeting_attendee_set_cn (priv->ia, g_strdup (a->id->name));
+ } else {
+ e_meeting_attendee_set_address (priv->ia, g_strdup_printf ("MAILTO:%s", backend_addr));
+ e_meeting_attendee_set_sentby (priv->ia, g_strdup_printf ("MAILTO:%s", a->id->address));
+ }
+
if (page->client && e_cal_get_organizer_must_accept (page->client))
e_meeting_attendee_set_status (priv->ia, ICAL_PARTSTAT_NEEDSACTION);
else
e_meeting_attendee_set_status (priv->ia, ICAL_PARTSTAT_ACCEPTED);
e_meeting_list_view_add_attendee_to_name_selector (E_MEETING_LIST_VIEW (priv->list_view), priv->ia);
}
+
}
}
+ if (backend_addr)
+ g_free (backend_addr);
+
/* Start and end times */
e_cal_component_get_dtstart (comp, &start_date);
e_cal_component_get_dtend (comp, &end_date);
@@ -1452,13 +1486,18 @@ event_page_fill_component (CompEditorPage *page, ECalComponent *comp)
e_cal_component_add_alarm (comp, ca);
}
}
-
+
if (priv->is_meeting) {
ECalComponentOrganizer organizer = {NULL, NULL, NULL, NULL};
if (!priv->existing) {
EAccount *a;
- gchar *addr = NULL;
+ gchar *backend_addr, *org_addr = NULL, *sentby = NULL;
+
+ e_cal_get_cal_address (priv->client, &backend_addr, NULL);
+
+ /* FIXME need not set Organizer strings here */
+ event_page_select_organizer (epage, backend_addr);
/* Find the identity for the organizer or sentby field */
a = get_current_account (epage);
@@ -1476,13 +1515,23 @@ event_page_fill_component (CompEditorPage *page, ECalComponent *comp)
return FALSE;
}
- addr = g_strdup_printf ("MAILTO:%s", a->id->address);
+ if (!backend_addr || !g_ascii_strcasecmp (backend_addr, a->id->address)) {
+ org_addr = g_strdup_printf ("MAILTO:%s", a->id->address);
+ organizer.value = org_addr;
+ organizer.cn = a->id->name;
+ } else {
+ gchar *sentby = NULL;
+ org_addr = g_strdup_printf ("MAILTO:%s", backend_addr);
+ sentby = g_strdup_printf ("MAILTO:%s", a->id->address);
+ organizer.value = org_addr;
+ organizer.sentby = sentby;
+ }
- organizer.value = addr;
- organizer.cn = a->id->name;
e_cal_component_set_organizer (comp, &organizer);
- g_free (addr);
+ g_free (backend_addr);
+ g_free (org_addr);
+ g_free (sentby);
}
if (e_meeting_store_count_actual_attendees (priv->model) < 1) {
@@ -1710,19 +1759,27 @@ existing_attendee (EMeetingAttendee *ia, ECalComponent *comp)
{
GSList *attendees, *l;
const gchar *ia_address;
+ const gchar *ia_sentby = NULL;
ia_address = itip_strip_mailto (e_meeting_attendee_get_address (ia));
if (!ia_address)
return FALSE;
+ if (e_meeting_attendee_is_set_sentby (ia))
+ ia_sentby = itip_strip_mailto (e_meeting_attendee_get_sentby (ia));
+
e_cal_component_get_attendee_list (comp, &attendees);
for (l = attendees; l; l = l->next) {
ECalComponentAttendee *attendee = l->data;
const char *address;
+ const char *sentby = NULL;
address = itip_strip_mailto (attendee->value);
- if (address && !g_ascii_strcasecmp (ia_address, address)) {
+ if (attendee->sentby)
+ sentby = itip_strip_mailto (attendee->sentby);
+
+ if ((address && !g_ascii_strcasecmp (ia_address, address)) || (sentby && !g_ascii_strcasecmp (ia_sentby, sentby))) {
e_cal_component_free_attendee_list (attendees);
return TRUE;
}
@@ -2169,6 +2226,23 @@ event_page_set_show_categories (EventPage *epage, gboolean state)
}
}
+/*If the msg has some value set, the icon should always be set */
+void
+event_page_set_info_string (EventPage *epage, const gchar *icon, const gchar *msg)
+{
+ EventPagePrivate *priv;
+
+ priv = epage->priv;
+
+ gtk_image_set_from_stock (GTK_IMAGE (priv->info_icon), icon, GTK_ICON_SIZE_BUTTON);
+ gtk_label_set_text (GTK_LABEL(priv->info_string), msg);
+
+ if (msg && icon)
+ gtk_widget_show (priv->info_hbox);
+ else
+ gtk_widget_hide (priv->info_hbox);
+}
+
/* Gets the widgets from the XML file and returns if they are all available. */
static gboolean
get_widgets (EventPage *epage)
@@ -2224,6 +2298,10 @@ get_widgets (EventPage *epage)
priv->location = GW ("location");
priv->location_label = GW ("location-label");
+ priv->info_hbox = GW ("generic-info");
+ priv->info_icon = GW ("generic-info-image");
+ priv->info_string = GW ("generic-info-msgs");
+
priv->invite = GW ("invite");
priv->add = GW ("add-attendee");
priv->remove = GW ("remove-attendee");
@@ -2649,6 +2727,22 @@ source_changed_cb (GtkWidget *widget, ESource *source, gpointer data)
else
event_page_hide_options (epage);
+ if (client) {
+ gchar *backend_addr = NULL;
+
+ e_cal_get_cal_address(client, &backend_addr, NULL);
+
+ if (backend_addr && *backend_addr) {
+
+ if (priv->is_meeting)
+ event_page_select_organizer (epage, backend_addr);
+
+ set_subscriber_info_string (epage, backend_addr);
+ }
+
+ g_free (backend_addr);
+ }
+
sensitize_widgets (epage);
alarm_list_dialog_set_client (priv->alarm_list_dlg_widget, client);
@@ -2656,6 +2750,24 @@ source_changed_cb (GtkWidget *widget, ESource *source, gpointer data)
}
}
+
+static void
+set_subscriber_info_string (EventPage *epage, const char *backend_address)
+{
+ ECal *client = COMP_EDITOR_PAGE (epage)->client;
+ ESource *source;
+
+ source = e_cal_get_source (client);
+
+ if (e_source_get_property (source, "subscriber"))
+ /* Translators: This string is used when we are creating an Event
+ (meeting or appointment) on behalf of some other user */
+ event_page_set_info_string (epage, GTK_STOCK_DIALOG_INFO,
+ g_strdup_printf(_("You are acting on behalf of %s"), backend_address));
+ else
+ event_page_set_info_string (epage, NULL, NULL);
+}
+
static void
alarm_changed_cb (GtkWidget *widget, gpointer data)
{
@@ -2831,6 +2943,9 @@ init_widgets (EventPage *epage)
(EDateEditGetTimeCallback) comp_editor_get_current_time,
epage, NULL);
+ /* Generic informative messages */
+ gtk_widget_hide (priv->info_hbox);
+
/* Summary */
g_signal_connect((priv->summary), "changed",
G_CALLBACK (summary_changed_cb), epage);
@@ -3021,6 +3136,65 @@ init_widgets (EventPage *epage)
+static void
+event_page_select_organizer (EventPage *epage, const char *backend_address)
+{
+ EventPagePrivate *priv;
+ EIterator *it;
+ EAccount *def_account;
+ EAccount *a;
+ gboolean subscribed_cal = FALSE;
+ ESource *source = NULL;
+ const char *user_addr = NULL;
+
+ priv = epage->priv;
+ if (COMP_EDITOR_PAGE (epage)->client)
+ source = e_cal_get_source (COMP_EDITOR_PAGE (epage)->client);
+ if (source)
+ user_addr = e_source_get_property (source, "subscriber");
+
+ if (user_addr)
+ subscribed_cal = TRUE;
+ else
+ user_addr = backend_address;
+
+ /*FIXME find the organizer using the address strings which is set in org combo box */
+ def_account = itip_addresses_get_default();
+ for (it = e_list_get_iterator((EList *)priv->accounts);
+ e_iterator_is_valid(it);
+ e_iterator_next(it)) {
+ gchar *full = NULL;
+
+ a = (EAccount *)e_iterator_get(it);
+ full = g_strdup_printf("%s <%s>", a->id->name, a->id->address);
+
+ /* Note that the address specified by the backend gets
+ * precedence over the default mail address.
+ */
+ if (user_addr && !g_ascii_strcasecmp (user_addr, a->id->address)) {
+ if (priv->default_address)
+ g_free (priv->default_address);
+
+ priv->default_address = full;
+ } else if (a == def_account && !priv->default_address)
+ priv->default_address = full;
+
+ }
+ g_object_unref(it);
+
+ if (priv->default_address) {
+ if (!priv->comp || !e_cal_component_has_organizer (priv->comp)) {
+ gtk_entry_set_text (GTK_ENTRY (GTK_COMBO (priv->organizer)->entry), priv->default_address);
+ /* FIXME: Use accessor functions to access private members of a GtkCombo widget */
+ gtk_widget_set_sensitive (GTK_WIDGET (GTK_COMBO (priv->organizer)->button), TRUE);
+ }
+ if (subscribed_cal)
+ /* FIXME: Use accessor functions to access private members of a GtkCombo widget */
+ gtk_widget_set_sensitive (GTK_WIDGET (GTK_COMBO (priv->organizer)->button), FALSE);
+ } else
+ g_warning ("No potential organizers!");
+}
+
/**
* event_page_construct:
* @epage: An event page.
@@ -3034,7 +3208,6 @@ EventPage *
event_page_construct (EventPage *epage, EMeetingStore *model, ECal *client)
{
EventPagePrivate *priv;
- char *backend_address = NULL;
EIterator *it;
EAccount *def_account;
GList *address_strings = NULL, *l;
@@ -3064,38 +3237,19 @@ event_page_construct (EventPage *epage, EMeetingStore *model, ECal *client)
return NULL;
}
- /* Address information */
- if (!e_cal_get_cal_address (client, &backend_address, NULL))
- return NULL;
-
priv->accounts = itip_addresses_get ();
def_account = itip_addresses_get_default();
for (it = e_list_get_iterator((EList *)priv->accounts);
e_iterator_is_valid(it);
e_iterator_next(it)) {
- char *full;
+ gchar *full = NULL;
a = (EAccount *)e_iterator_get(it);
full = g_strdup_printf("%s <%s>", a->id->name, a->id->address);
address_strings = g_list_append(address_strings, full);
-
- /* Note that the address specified by the backend gets
- * precedence over the default mail address.
- */
- if (backend_address && !strcmp (backend_address, a->id->address)) {
- if (priv->default_address)
- g_free (priv->default_address);
-
- priv->default_address = g_strdup (full);
- } else if (a == def_account && !priv->default_address) {
- priv->default_address = g_strdup (full);
- }
}
- if (backend_address)
- g_free (backend_address);
-
g_object_unref(it);
if (address_strings)