diff options
author | Chenthill Palanisamy <pchen@src.gnome.org> | 2007-07-09 04:27:28 +0800 |
---|---|---|
committer | Chenthill Palanisamy <pchen@src.gnome.org> | 2007-07-09 04:27:28 +0800 |
commit | a11e7afc54918cc11c8dc476f52d8380351808bc (patch) | |
tree | 0127fe80ad6d8c51feaea0c40094d0fd7d6ced47 | |
parent | e18a34da15866a9a2b201b3077991db69a2dc8d2 (diff) | |
download | gsoc2013-evolution-a11e7afc54918cc11c8dc476f52d8380351808bc.tar.gz gsoc2013-evolution-a11e7afc54918cc11c8dc476f52d8380351808bc.tar.zst gsoc2013-evolution-a11e7afc54918cc11c8dc476f52d8380351808bc.zip |
Fixes #300584
svn path=/trunk/; revision=33772
-rw-r--r-- | calendar/ChangeLog | 13 | ||||
-rw-r--r-- | calendar/gui/e-calendar-view.c | 72 | ||||
-rw-r--r-- | calendar/gui/e-calendar-view.h | 2 | ||||
-rw-r--r-- | calendar/gui/e-day-view.c | 9 | ||||
-rw-r--r-- | calendar/gui/e-week-view.c | 18 |
5 files changed, 104 insertions, 10 deletions
diff --git a/calendar/ChangeLog b/calendar/ChangeLog index dc17a13311..df6d9bb77b 100644 --- a/calendar/ChangeLog +++ b/calendar/ChangeLog @@ -1,5 +1,18 @@ 2007-07-09 Milan Crha <mcrha@redhat.com> + ** Fix for bug #300584 + + * gui/e-calendar-view.h: Added public helper + function e_calendar_view_get_icalcomponent_summary + * gui/e-calendar-view.c: (e_calendar_view_get_icalcomponent_summary), + (icalcomp_contains_category), (e_calendar_view_get_tooltips): + Implementing helper functions and added year number also into tooltip. + * gui/e-day-view.c: (e_day_view_update_long_event_label): + * gui/e-week-view.c: (e_week_view_reshape_event_span), + (cancel_editing): Using e_calendar_view_get_icalcomponent_summary. + +2007-07-09 Milan Crha <mcrha@redhat.com> + ** Fix for bug #438613 and #329594 * gui/dialogs/event-page.c: (sensitize_widgets): diff --git a/calendar/gui/e-calendar-view.c b/calendar/gui/e-calendar-view.c index 243f6f9974..524b94c913 100644 --- a/calendar/gui/e-calendar-view.c +++ b/calendar/gui/e-calendar-view.c @@ -2107,6 +2107,7 @@ e_calendar_view_get_tooltips (ECalendarViewEventData *data) ECalComponent *newcomp = e_cal_component_new (); icaltimezone *zone, *default_zone; ECal *client = NULL; + gboolean free_text = FALSE; /* Delete any stray tooltip if left */ if (widget) @@ -2123,7 +2124,7 @@ e_calendar_view_get_tooltips (ECalendarViewEventData *data) box = gtk_vbox_new (FALSE, 0); - str = icalcomponent_get_summary (pevent->comp_data->icalcomp); + str = e_calendar_view_get_icalcomponent_summary (pevent->comp_data->client, pevent->comp_data->icalcomp, &free_text); if (!(str && *str)) { g_object_unref (newcomp); @@ -2137,7 +2138,12 @@ e_calendar_view_get_tooltips (ECalendarViewEventData *data) label = gtk_label_new (NULL); gtk_label_set_line_wrap ((GtkLabel *)label, TRUE); gtk_label_set_markup ((GtkLabel *)label, tmp); - + + if (free_text) { + g_free ((char*)str); + str = NULL; + } + hbox = gtk_hbox_new (FALSE, 0); gtk_box_pack_start ((GtkBox *)hbox, label, FALSE, FALSE, 0); ebox = gtk_event_box_new (); @@ -2240,7 +2246,67 @@ e_calendar_view_get_tooltips (ECalendarViewEventData *data) return FALSE; } - + +static gboolean +icalcomp_contains_category (icalcomponent *icalcomp, const gchar *category) +{ + icalproperty *property; + + g_return_val_if_fail (icalcomp != NULL && category != NULL, FALSE); + + for (property = icalcomponent_get_first_property (icalcomp, ICAL_CATEGORIES_PROPERTY); + property != NULL; + property = icalcomponent_get_next_property (icalcomp, ICAL_CATEGORIES_PROPERTY)) { + const char *value = icalproperty_get_value_as_string (property); + + if (value && strcmp (category, value) == 0){ + return TRUE; + } + } + + return FALSE; +} + +/* e_calendar_view_get_icalcomponent_summary returns summary of calcomp, + * and for type of birthday or anniversary it append number of years since + * beginning. In this case, the free_text is set to TRUE and caller need + * to g_free returned string, otherwise free_text is set to FALSE and + * returned value is owned by calcomp. + */ + +const gchar * +e_calendar_view_get_icalcomponent_summary (ECal *ecal, icalcomponent *icalcomp, gboolean *free_text) +{ + const gchar *summary; + + g_return_val_if_fail (icalcomp != NULL && free_text != NULL, NULL); + + *free_text = FALSE; + summary = icalcomponent_get_summary (icalcomp); + + if (icalcomp_contains_category (icalcomp, _("Birthday")) || + icalcomp_contains_category (icalcomp, _("Anniversary"))) { + struct icaltimetype dtstart, dtnow; + icalcomponent *item_icalcomp = NULL; + + if (e_cal_get_object (ecal, + icalcomponent_get_uid (icalcomp), + icalcomponent_get_relcalid (icalcomp), + &item_icalcomp, + NULL)) { + dtstart = icalcomponent_get_dtstart (item_icalcomp); + dtnow = icalcomponent_get_dtstart (icalcomp); + + if (dtnow.year - dtstart.year > 0) { + summary = g_strdup_printf ("%s (%d)", summary ? summary : "", dtnow.year - dtstart.year); + *free_text = summary != NULL; + } + } + } + + return summary; +} + #ifdef ENABLE_CAIRO void draw_curved_rectangle (cairo_t *cr, double x0, double y0, diff --git a/calendar/gui/e-calendar-view.h b/calendar/gui/e-calendar-view.h index 8f074869c8..81c6081cea 100644 --- a/calendar/gui/e-calendar-view.h +++ b/calendar/gui/e-calendar-view.h @@ -170,6 +170,8 @@ 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); + #ifdef ENABLE_CAIRO void draw_curved_rectangle (cairo_t *cr, double x0, diff --git a/calendar/gui/e-day-view.c b/calendar/gui/e-day-view.c index 0768d02106..b3c14d56d8 100644 --- a/calendar/gui/e-day-view.c +++ b/calendar/gui/e-day-view.c @@ -2508,6 +2508,7 @@ e_day_view_update_long_event_label (EDayView *day_view, { EDayViewEvent *event; const gchar *summary; + gboolean free_text = FALSE; event = &g_array_index (day_view->long_events, EDayViewEvent, event_num); @@ -2516,11 +2517,15 @@ e_day_view_update_long_event_label (EDayView *day_view, if (!event->canvas_item) return; - summary = icalcomponent_get_summary (event->comp_data->icalcomp); + summary = e_calendar_view_get_icalcomponent_summary (event->comp_data->client, event->comp_data->icalcomp, &free_text); + gnome_canvas_item_set (event->canvas_item, "text", summary ? summary : "", NULL); - + + if (free_text) + g_free ((gchar*)summary); + /* if (e_cal_get_static_capability (event->comp_data->client, CAL_STATIC_CAPABILITY_HAS_UNACCEPTED_MEETING) && e_cal_util_component_has_attendee (event->comp_data->icalcomp)) set_text_as_bold (event); */ diff --git a/calendar/gui/e-week-view.c b/calendar/gui/e-week-view.c index c52882a5e7..df3950c49b 100644 --- a/calendar/gui/e-week-view.c +++ b/calendar/gui/e-week-view.c @@ -2722,15 +2722,16 @@ e_week_view_reshape_event_span (EWeekView *week_view, /* Create the text item if necessary. */ if (!span->text_item) { - ECalComponentText cal_text; + const gchar *summary; GtkWidget *widget; GdkColor color; + gboolean free_text = FALSE; widget = (GtkWidget *)week_view; color = e_week_view_get_text_color (week_view, event, widget); - - e_cal_component_get_summary (comp, &cal_text); + summary = e_calendar_view_get_icalcomponent_summary (event->comp_data->client, event->comp_data->icalcomp, &free_text); + span->text_item = gnome_canvas_item_new (GNOME_CANVAS_GROUP (GNOME_CANVAS (week_view->main_canvas)->root), e_text_get_type (), @@ -2738,12 +2739,15 @@ e_week_view_reshape_event_span (EWeekView *week_view, "clip", TRUE, "max_lines", 1, "editable", TRUE, - "text", cal_text.value ? cal_text.value : "", + "text", summary ? summary : "", "use_ellipsis", TRUE, "fill_color_gdk", &color, "im_context", E_CANVAS (week_view->main_canvas)->im_context, NULL); + if (free_text) + g_free ((gchar*)summary); + /* Uncomment once the pango fix is in if (e_cal_get_static_capability (event->comp_data->client, CAL_STATIC_CAPABILITY_HAS_UNACCEPTED_MEETING) && e_cal_util_component_has_attendee (event->comp_data->icalcomp)) { @@ -2993,6 +2997,7 @@ cancel_editing (EWeekView *week_view) EWeekViewEvent *event; EWeekViewEventSpan *span; const gchar *summary; + gboolean free_text = FALSE; event_num = week_view->editing_event_num; span_num = week_view->editing_span_num; @@ -3004,9 +3009,12 @@ cancel_editing (EWeekView *week_view) /* Reset the text to what was in the component */ - summary = icalcomponent_get_summary (event->comp_data->icalcomp); + summary = e_calendar_view_get_icalcomponent_summary (event->comp_data->client, event->comp_data->icalcomp, &free_text); g_object_set (G_OBJECT (span->text_item), "text", summary ? summary : "", NULL); + if (free_text) + g_free ((gchar*)summary); + /* Stop editing */ e_week_view_stop_editing_event (week_view); } |