diff options
author | Milan Crha <mcrha@redhat.com> | 2008-11-11 20:43:43 +0800 |
---|---|---|
committer | Milan Crha <mcrha@src.gnome.org> | 2008-11-11 20:43:43 +0800 |
commit | 3447262d1b4219296c79ecb27216f932c49568bd (patch) | |
tree | 64750995b1a33850b22cf67faef3b0cbd2c3fc36 /calendar/gui | |
parent | ddda77f14467ec33ea50acd04e98b9086b1b62f6 (diff) | |
download | gsoc2013-evolution-3447262d1b4219296c79ecb27216f932c49568bd.tar.gz gsoc2013-evolution-3447262d1b4219296c79ecb27216f932c49568bd.tar.zst gsoc2013-evolution-3447262d1b4219296c79ecb27216f932c49568bd.zip |
** Fix for bug #559604
2008-11-11 Milan Crha <mcrha@redhat.com>
** Fix for bug #559604
* gui/e-calendar-view.h: (e_calendar_view_get_attendees_status_info):
* gui/e-calendar-view.c: (e_calendar_view_get_attendees_status_info),
(e_calendar_view_get_tooltips):
* gui/e-calendar-table.c: (query_tooltip_cb):
Show attendees' status in the tooltip if available.
svn path=/trunk/; revision=36773
Diffstat (limited to 'calendar/gui')
-rw-r--r-- | calendar/gui/e-calendar-table.c | 10 | ||||
-rw-r--r-- | calendar/gui/e-calendar-view.c | 89 | ||||
-rw-r--r-- | calendar/gui/e-calendar-view.h | 1 |
3 files changed, 100 insertions, 0 deletions
diff --git a/calendar/gui/e-calendar-table.c b/calendar/gui/e-calendar-table.c index 25442abd57..7f3ebfcf60 100644 --- a/calendar/gui/e-calendar-table.c +++ b/calendar/gui/e-calendar-table.c @@ -432,6 +432,16 @@ query_tooltip_cb (GtkWidget *widget, gint x, gint y, gboolean keyboard_mode, Gtk e_cal_component_free_datetime (&dtstart); e_cal_component_free_datetime (&dtdue); + tmp = e_calendar_view_get_attendees_status_info (new_comp); + if (tmp) { + l = gtk_label_new (tmp); + gtk_misc_set_alignment (GTK_MISC (l), 0.0, 0.5); + gtk_box_pack_start (GTK_BOX (w), l, FALSE, FALSE, 0); + + g_free (tmp); + tmp = NULL; + } + tmp2 = g_string_new (""); e_cal_component_get_description_list (new_comp, &desc); for (len = 0, p = desc; p != NULL; p = p->next) { diff --git a/calendar/gui/e-calendar-view.c b/calendar/gui/e-calendar-view.c index b1c5819c35..d54c2808ec 100644 --- a/calendar/gui/e-calendar-view.c +++ b/calendar/gui/e-calendar-view.c @@ -2131,6 +2131,83 @@ e_calendar_view_move_tip (GtkWidget *widget, int x, int y) gtk_widget_show (widget); } +/** + * Returns information about attendees in the component. If no attendees, then returns NULL. + * The information is like "Status: Accepted: X Declined: Y ...". + * Free returned pointer with g_free. + **/ +char * +e_calendar_view_get_attendees_status_info (ECalComponent *comp) +{ + struct _values { + icalparameter_partstat status; + const char *caption; + int count; + } values[] = { + { ICAL_PARTSTAT_ACCEPTED, N_("Accepted"), 0 }, + { ICAL_PARTSTAT_DECLINED, N_("Declined"), 0 }, + { ICAL_PARTSTAT_TENTATIVE, N_("Tentative"), 0 }, + { ICAL_PARTSTAT_DELEGATED, N_("Delegated"), 0 }, + { ICAL_PARTSTAT_NEEDSACTION, N_("Needs action"), 0 }, + { ICAL_PARTSTAT_NONE, N_("Other"), 0 }, + { ICAL_PARTSTAT_X, NULL, -1 } + }; + + GSList *attendees = NULL, *a; + gboolean have = FALSE; + char *res = NULL; + int i; + + if (!comp || !e_cal_component_has_attendees (comp)) + return NULL; + + e_cal_component_get_attendee_list (comp, &attendees); + + for (a = attendees; a; a = a->next) { + ECalComponentAttendee *att = a->data; + + if (att && att->cutype == ICAL_CUTYPE_INDIVIDUAL && + (att->role == ICAL_ROLE_CHAIR || + att->role == ICAL_ROLE_REQPARTICIPANT || + att->role == ICAL_ROLE_OPTPARTICIPANT)) { + have = TRUE; + + for (i = 0; values[i].count != -1; i++) { + if (att->status == values[i].status || values[i].status == ICAL_PARTSTAT_NONE) { + values[i].count++; + break; + } + } + } + } + + if (have) { + GString *str = g_string_new (""); + + for (i = 0; values[i].count != -1; i++) { + if (values[i].count > 0) { + if (str->str && *str->str) + g_string_append (str, " "); + + g_string_append_printf (str, "%s: %d", _(values[i].caption), values[i].count); + } + } + + g_string_prepend (str, ": "); + + /* To Translators: 'Status' here means the state of the attendees, the resulting string will be in a form: + Status: Accepted: X Declined: Y ... */ + g_string_prepend (str, _("Status")); + + res = g_string_free (str, FALSE); + } + + if (attendees) + e_cal_component_free_attendee_list (attendees); + + return res; +} + /* * It is expected to show the tooltips in this below format * @@ -2138,6 +2215,7 @@ e_calendar_view_move_tip (GtkWidget *widget, int x, int y) * Organiser: NameOfTheUser<email@ofuser.com> * Location: PlaceOfTheMeeting * Time : DateAndTime (xx Minutes) + * Status: Accepted: X Declined: Y ... */ gboolean @@ -2276,6 +2354,17 @@ e_calendar_view_get_tooltips (ECalendarViewEventData *data) g_free (tmp2); g_free (tmp1); + tmp = e_calendar_view_get_attendees_status_info (newcomp); + if (tmp) { + hbox = gtk_hbox_new (FALSE, 0); + gtk_box_pack_start ((GtkBox *)hbox, gtk_label_new (tmp), FALSE, FALSE, 0); + ebox = gtk_event_box_new (); + gtk_container_add ((GtkContainer *)ebox, hbox); + gtk_box_pack_start ((GtkBox *)box, ebox, FALSE, FALSE, 0); + + g_free (tmp); + } + pevent->tooltip = gtk_window_new (GTK_WINDOW_POPUP); frame = gtk_frame_new (NULL); gtk_frame_set_shadow_type ((GtkFrame *)frame, GTK_SHADOW_IN); diff --git a/calendar/gui/e-calendar-view.h b/calendar/gui/e-calendar-view.h index 8f8eddf53f..320d911d24 100644 --- a/calendar/gui/e-calendar-view.h +++ b/calendar/gui/e-calendar-view.h @@ -175,6 +175,7 @@ gboolean e_calendar_view_get_tooltips (ECalendarViewEventData *data); void e_calendar_view_move_tip (GtkWidget *widget, int x, int y); const gchar *e_calendar_view_get_icalcomponent_summary (ECal *ecal, icalcomponent *icalcomp, gboolean *free_text); +char *e_calendar_view_get_attendees_status_info (ECalComponent *comp); void draw_curved_rectangle (cairo_t *cr, double x0, |