aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--calendar/ChangeLog19
-rw-r--r--calendar/gui/e-day-view-main-item.c529
-rw-r--r--calendar/gui/e-day-view.c213
-rw-r--r--widgets/ChangeLog5
-rw-r--r--widgets/table/e-cell-text.c60
-rw-r--r--widgets/text/e-text.c69
6 files changed, 553 insertions, 342 deletions
diff --git a/calendar/ChangeLog b/calendar/ChangeLog
index 49f7b11489..2035ec90ed 100644
--- a/calendar/ChangeLog
+++ b/calendar/ChangeLog
@@ -1,3 +1,22 @@
+2006-07-10 Rajeev ramanathan <rajeevramanathan_2004@yahoo.co.in>
+
+ * gui/e-day-view.c:(e_day_view_update_event_label)
+ Added code for Day/Work Week view item, top border showing time
+ (e_day_view_realize), (e_day_view_on_event_click),
+ (e_day_view_on_long_event_click), (e_day_view_reshape_resize_long_event_rect),
+ (e_day_view_reshape_resize_rect_item),(e_day_view_on_top_canvas_motion),
+ (e_day_view_finish_resize),(e_day_view_abort_resize),
+ (e_day_view_reshape_main_canvas_resize_bar):
+ Added code for Resize Transparency with Cairo drawing.
+
+ (e_day_view_on_text_item_event):
+ Fixed crashes because of tooltip during editing and resize.
+
+ * gui/e-day-view-main-canvas.c:
+ (e_day_view_main_item_draw_day_event):
+ Added code for Time displayed on resizing events and for Shadow
+ Effect for item selection
+
2006-07-10 Chenthill Palanisamy <pchenthill@novell.com>
Fixes #332911
diff --git a/calendar/gui/e-day-view-main-item.c b/calendar/gui/e-day-view-main-item.c
index c4261ce948..3286194e0c 100644
--- a/calendar/gui/e-day-view-main-item.c
+++ b/calendar/gui/e-day-view-main-item.c
@@ -1263,6 +1263,13 @@ e_day_view_main_item_draw_day_event (EDayViewMainItem *dvmitem,
gfloat alpha;
gboolean gradient;
gdouble cc = 65535.0;
+ gdouble date_fraction;
+ gboolean short_event, resize_flag = FALSE;
+ gchar *end_time, *end_suffix;
+ gint end_hour, end_display_hour, end_minute, end_suffix_width;
+ int scroll_flag = 0;
+ gint row_y;
+
day_view = dvmitem->day_view;
cr = gdk_cairo_create (drawable);
@@ -1286,7 +1293,7 @@ e_day_view_main_item_draw_day_event (EDayViewMainItem *dvmitem,
return;
/* Get the position of the event. If it is not shown skip it.*/
- if (!e_day_view_get_event_position (day_view, day, event_num,
+ if (!e_day_view_get_event_position (day_view, day, event_num,
&item_x, &item_y,
&item_w, &item_h))
return;
@@ -1319,6 +1326,144 @@ e_day_view_main_item_draw_day_event (EDayViewMainItem *dvmitem,
}
}
+ /* Draw shadow around the event when selected */
+ if (day_view->editing_event_day == day
+ && day_view->editing_event_num == event_num && (GTK_WIDGET_HAS_FOCUS (day_view->main_canvas)))
+ {
+// item_x -= 1;
+// item_y -= 2;
+
+ /* Vertical Line */
+ cairo_save (cr);
+ pat = cairo_pattern_create_linear (item_x + item_w - E_DAY_VIEW_BAR_WIDTH + 6.5, item_y + 13.75,
+ item_x + item_w - E_DAY_VIEW_BAR_WIDTH + 13.75, item_y + 13.75);
+ cairo_pattern_add_color_stop_rgba (pat, 0, 0, 0, 0, 1);
+ cairo_pattern_add_color_stop_rgba (pat, 0.7, 0, 0, 0, 0.2);
+ cairo_pattern_add_color_stop_rgba (pat, 1, 1, 1, 1, 0.3);
+ cairo_set_source (cr, pat);
+ cairo_rectangle (cr, item_x + item_w - E_DAY_VIEW_BAR_WIDTH + 6.5, item_y + 14.75, 7.0, item_h - 22.0);
+ cairo_fill (cr);
+ cairo_pattern_destroy (pat);
+
+ /* Arc at the right */
+ pat = cairo_pattern_create_radial (item_x + item_w - E_DAY_VIEW_BAR_WIDTH + 3, item_y + 13.5, 5.0,
+ item_x + item_w - E_DAY_VIEW_BAR_WIDTH + 5, item_y + 13.5, 12.0);
+ cairo_pattern_add_color_stop_rgba (pat, 1, 1, 1, 1, 0.3);
+ cairo_pattern_add_color_stop_rgba (pat, 0.25, 0, 0, 0, 0.2);
+ cairo_pattern_add_color_stop_rgba (pat, 0, 0, 0, 0, 1);
+ cairo_set_source (cr, pat);
+ cairo_arc (cr, item_x + item_w - E_DAY_VIEW_BAR_WIDTH + 5, item_y + 13.5, 8.0, 11 * M_PI / 8, M_PI / 8);
+ cairo_fill (cr);
+ cairo_pattern_destroy (pat);
+
+ cairo_set_source_rgb (cr, 0, 0, 0);
+ cairo_set_line_width (cr, 1.25);
+ cairo_move_to (cr, item_x + item_w - E_DAY_VIEW_BAR_WIDTH + 5, item_y + 9.5);
+ cairo_line_to (cr, item_x + item_w - E_DAY_VIEW_BAR_WIDTH + 9.5, item_y + 15);
+ cairo_stroke (cr);
+
+ /* Horizontal line */
+ pat = cairo_pattern_create_linear (item_x + E_DAY_VIEW_BAR_WIDTH + 15, item_y + item_h,
+ item_x + E_DAY_VIEW_BAR_WIDTH + 15, item_y + item_h + 7);
+ cairo_pattern_add_color_stop_rgba (pat, 0, 0, 0, 0, 1);
+ cairo_pattern_add_color_stop_rgba (pat, 0.7, 0, 0, 0, 0.2);
+ cairo_pattern_add_color_stop_rgba (pat, 1, 1, 1, 1, 0.3);
+ cairo_set_source (cr, pat);
+ cairo_rectangle (cr, item_x + E_DAY_VIEW_BAR_WIDTH + 16.5, item_y + item_h, item_w - 31.5, 7.0);
+ cairo_fill (cr);
+ cairo_pattern_destroy (pat);
+
+ /* Bottom arc */
+ pat = cairo_pattern_create_radial (item_x + E_DAY_VIEW_BAR_WIDTH + 12.5, item_y + item_h - 5, 5.0,
+ item_x + E_DAY_VIEW_BAR_WIDTH + 12.5, item_y + item_h - 5, 12.0);
+ cairo_pattern_add_color_stop_rgba (pat, 1, 1, 1, 1, 0.3);
+ cairo_pattern_add_color_stop_rgba (pat, 0.7, 0, 0, 0, 0.2);
+ cairo_pattern_add_color_stop_rgba (pat, 0, 0, 0, 0, 1);
+ cairo_set_source (cr, pat);
+ cairo_arc (cr, item_x + E_DAY_VIEW_BAR_WIDTH + 13, item_y + item_h - 5, 12.0, 3 * M_PI / 8, 9 * M_PI / 8);
+ cairo_fill (cr);
+ cairo_pattern_destroy (pat);
+
+ cairo_set_source_rgba (cr, 0, 0, 0, 0.5);
+ cairo_set_line_width (cr, 2);
+ cairo_move_to (cr, item_x + E_DAY_VIEW_BAR_WIDTH + 14, item_y + item_h + 2);
+ cairo_line_to (cr, item_x + E_DAY_VIEW_BAR_WIDTH + 15.5, item_y + item_h + 3);
+ cairo_stroke (cr);
+ cairo_set_source_rgba (cr, 0, 0, 0, 0.27);
+ cairo_move_to (cr, item_x + E_DAY_VIEW_BAR_WIDTH + 15, item_y + item_h + 3.5);
+ cairo_line_to (cr, item_x + E_DAY_VIEW_BAR_WIDTH + 17, item_y + item_h + 3.5);
+ cairo_stroke (cr);
+
+ /* Arc in middle */
+ pat = cairo_pattern_create_radial (item_x + item_w - E_DAY_VIEW_BAR_WIDTH + 1, item_y + item_h - 4.5, 1.0,
+ item_x + item_w - E_DAY_VIEW_BAR_WIDTH + 1, item_y + item_h - 4.5, 12.0);
+ cairo_pattern_add_color_stop_rgba (pat, 1, 1, 1, 1, 0.3);
+ cairo_pattern_add_color_stop_rgba (pat, 0.8, 0, 0, 0, 0.2);
+ cairo_pattern_add_color_stop_rgba (pat, 0, 0, 0, 0, 1);
+ cairo_set_source (cr, pat);
+ cairo_arc (cr, item_x + item_w - E_DAY_VIEW_BAR_WIDTH + 1, item_y + item_h - 4.5, 12.0, 15 * M_PI / 8, 5 * M_PI / 8);
+ cairo_fill (cr);
+ cairo_pattern_destroy (pat);
+
+ cairo_set_source_rgba (cr, 0, 0, 0, 0.27);
+ cairo_move_to (cr, item_x + item_w - E_DAY_VIEW_BAR_WIDTH - 1, item_y + item_h + 3);
+ cairo_line_to (cr, item_x + item_w - E_DAY_VIEW_BAR_WIDTH , item_y + item_h + 3);
+ cairo_stroke (cr);
+
+ cairo_set_source_rgba (cr, 0, 0, 0, 0.27);
+ cairo_move_to (cr, item_x + item_w - E_DAY_VIEW_BAR_WIDTH + 9, item_y + item_h - 6);
+ cairo_line_to (cr, item_x + item_w - E_DAY_VIEW_BAR_WIDTH + 10, item_y + item_h - 6);
+ cairo_stroke (cr);
+
+
+ cairo_restore (cr);
+
+ /* Black border */
+ cairo_save (cr);
+ x0 = item_x + E_DAY_VIEW_BAR_WIDTH + 9;
+ y0 = item_y + 10;
+ rect_width = MAX (item_w - E_DAY_VIEW_BAR_WIDTH - 7, 0);
+ rect_height = item_h - 7;
+
+ radius = 20;
+
+ draw_curved_rectangle (cr, x0, y0, rect_width, rect_height, radius);
+
+ cairo_set_source_rgb (cr, 0, 0, 0);
+ cairo_fill (cr);
+ cairo_restore (cr);
+
+ /* Extra Grid lines when clicked */
+ cairo_save (cr);
+
+ x0 = item_x + E_DAY_VIEW_BAR_WIDTH + 1;
+ y0 = item_y + 2;
+ rect_width = MAX (item_w - E_DAY_VIEW_BAR_WIDTH - 3, 0);
+ rect_height = item_h - 4.;
+
+ radius = 16;
+
+ draw_curved_rectangle (cr, x0, y0, rect_width, rect_height, radius);
+
+ cairo_set_source_rgb (cr, 1, 1, 1);
+ cairo_fill (cr);
+
+ gdk_cairo_set_source_color (cr,
+ &day_view->colors[E_DAY_VIEW_COLOR_BG_GRID]);
+
+ for (row_y = y0;
+ row_y < rect_height + y0;
+ row_y += day_view->row_height) {
+ if (row_y >= 0 && row_y < rect_height + y0) {
+ cairo_set_line_width (cr, 0.7);
+ cairo_move_to (cr, item_x + E_DAY_VIEW_BAR_WIDTH + 1 , row_y);
+ cairo_line_to (cr, item_x + item_w -2, row_y);
+ cairo_stroke (cr);
+ }
+ }
+ cairo_restore (cr);
+ }
+
/* Draw the background of the event with white to play with transparency */
cairo_save (cr);
@@ -1365,11 +1510,25 @@ e_day_view_main_item_draw_day_event (EDayViewMainItem *dvmitem,
draw_curved_rectangle (cr, x0, y0, rect_width, rect_height, radius);
+ date_fraction = rect_height / day_view->row_height;
+ short_event = (((event->end_minute - event->start_minute)/day_view->mins_per_row) >= 2) ? FALSE : TRUE ;
+
+ if (day_view->editing_event_day == day
+ && day_view->editing_event_num == event_num)
+ short_event = TRUE;
+
if (gradient) {
- pat = cairo_pattern_create_linear (item_x + E_DAY_VIEW_BAR_WIDTH + 1.75, item_y + 2.75,
- item_x + E_DAY_VIEW_BAR_WIDTH + 1.75, item_y + item_h - 2.75);
- cairo_pattern_add_color_stop_rgba (pat, 1, red/cc, green/cc, blue/cc, 0.8);
- cairo_pattern_add_color_stop_rgba (pat, 0, red/cc, green/cc, blue/cc, 0.4);
+ pat = cairo_pattern_create_linear (item_x + E_DAY_VIEW_BAR_WIDTH + 1.75, item_y + 7.75,
+ item_x + E_DAY_VIEW_BAR_WIDTH + 1.75, item_y + item_h - 7.75);
+ if (!short_event) {
+ cairo_pattern_add_color_stop_rgba (pat, 1, red/cc, green/cc, blue/cc, 0.8);
+ cairo_pattern_add_color_stop_rgba (pat, 1/(date_fraction + (rect_height/18)), red/cc, green/cc, blue/cc, 0.8);
+ cairo_pattern_add_color_stop_rgba (pat, 1/(date_fraction + (rect_height/18)), red/cc, green/cc, blue/cc, 0.4);
+ cairo_pattern_add_color_stop_rgba (pat, 1, red/cc, green/cc, blue/cc, 0.8);
+ } else {
+ cairo_pattern_add_color_stop_rgba (pat, 1, red/cc, green/cc, blue/cc, 0.8);
+ cairo_pattern_add_color_stop_rgba (pat, 0, red/cc, green/cc, blue/cc, 0.4);
+ }
cairo_set_source (cr, pat);
cairo_fill_preserve (cr);
cairo_pattern_destroy (pat);
@@ -1401,14 +1560,56 @@ e_day_view_main_item_draw_day_event (EDayViewMainItem *dvmitem,
bar_y1 = event->start_minute * day_view->row_height / day_view->mins_per_row - y;
bar_y2 = event->end_minute * day_view->row_height / day_view->mins_per_row - y;
+ scroll_flag = bar_y2;
+
/* When an item is being resized, we fill the bar up to the new row. */
if (day_view->resize_drag_pos != E_CALENDAR_VIEW_POS_NONE
&& day_view->resize_event_day == day
&& day_view->resize_event_num == event_num) {
+ resize_flag = TRUE;
+
if (day_view->resize_drag_pos == E_CALENDAR_VIEW_POS_TOP_EDGE)
bar_y1 = item_y + 1;
- else if (day_view->resize_drag_pos == E_CALENDAR_VIEW_POS_BOTTOM_EDGE)
+
+ else if (day_view->resize_drag_pos == E_CALENDAR_VIEW_POS_BOTTOM_EDGE) {
bar_y2 = item_y + item_h - 1;
+
+ end_minute = event->end_minute;
+
+ end_hour = end_minute / 60;
+ end_minute = end_minute % 60;
+
+ e_day_view_convert_time_to_display (day_view, end_hour,
+ &end_display_hour,
+ &end_suffix,
+ &end_suffix_width);
+
+ cairo_save (cr);
+ if (e_calendar_view_get_use_24_hour_format (E_CALENDAR_VIEW (day_view))) {
+ cairo_translate (cr, item_x + item_w - E_DAY_VIEW_BAR_WIDTH - 32, item_y + item_h - 8);
+ end_time = g_strdup_printf ("%2i:%02i",
+ end_display_hour, end_minute);
+
+ } else {
+ cairo_translate (cr, item_x + item_w - E_DAY_VIEW_BAR_WIDTH - 48, item_y + item_h - 8);
+ end_time = g_strdup_printf ("%2i:%02i%s",
+ end_display_hour, end_minute,
+ end_suffix);
+ }
+
+ cairo_set_font_size (cr, 14);
+ if ((red/cc > 0.7) || (green/cc > 0.7) || (blue/cc > 0.7 ))
+ cairo_set_source_rgb (cr, 0, 0, 0);
+ else
+ cairo_set_source_rgb (cr, 1, 1, 1);
+ cairo_show_text (cr, end_time);
+ cairo_restore (cr);
+
+ if (scroll_flag < bar_y2)
+ event->end_minute += day_view->mins_per_row;
+ else
+ event->end_minute -= day_view->mins_per_row;
+ }
}
comp = e_cal_component_new ();
@@ -1445,196 +1646,180 @@ e_day_view_main_item_draw_day_event (EDayViewMainItem *dvmitem,
gdk_cairo_set_source_color (cr,
&day_view->colors[E_DAY_VIEW_COLOR_EVENT_VBAR]);
-#if 0
- /* Draw the horizontal bars above and beneath the event if it
- is currently being edited. */
- if (day_view->editing_event_day == day
- && day_view->editing_event_num == event_num) {
- cairo_save (cr);
- cairo_rectangle (cr, item_x, item_y - E_DAY_VIEW_BAR_HEIGHT,
- item_w, E_DAY_VIEW_BAR_HEIGHT);
- cairo_fill (cr);
- cairo_restore (cr);
-
- cairo_save (cr);
- cairo_rectangle (cr, item_x, item_y + item_h,
- item_w, E_DAY_VIEW_BAR_HEIGHT);
- cairo_fill (cr);
- cairo_restore (cr);
- }
-#endif
-
/* Draw the reminder & recurrence icons, if needed. */
- num_icons = 0;
- draw_reminder_icon = FALSE;
- draw_recurrence_icon = FALSE;
- draw_timezone_icon = FALSE;
- draw_meeting_icon = FALSE;
- draw_attach_icon = FALSE;
- icon_x = item_x + E_DAY_VIEW_BAR_WIDTH + E_DAY_VIEW_ICON_X_PAD;
- icon_y = item_y + E_DAY_VIEW_EVENT_BORDER_HEIGHT
- + E_DAY_VIEW_ICON_Y_PAD;
-
- if (e_cal_component_has_alarms (comp)) {
- draw_reminder_icon = TRUE;
- num_icons++;
- }
-
- if (e_cal_component_has_recurrences (comp) || e_cal_component_is_instance (comp)) {
- draw_recurrence_icon = TRUE;
- num_icons++;
- }
- if (e_cal_component_has_attachments (comp)) {
- draw_attach_icon = TRUE;
- num_icons++;
- }
- /* If the DTSTART or DTEND are in a different timezone to our current
- timezone, we display the timezone icon. */
- if (event->different_timezone) {
- draw_timezone_icon = TRUE;
- num_icons++;
- }
-
- if (e_cal_component_has_organizer (comp)) {
- draw_meeting_icon = TRUE;
- num_icons++;
- }
-
- e_cal_component_get_categories_list (comp, &categories_list);
- for (elem = categories_list; elem; elem = elem->next) {
- char *category;
- GdkPixmap *pixmap = NULL;
- GdkBitmap *mask = NULL;
-
- category = (char *) elem->data;
- if (e_categories_config_get_icon_for (category, &pixmap, &mask))
+ if (!resize_flag) {
+ num_icons = 0;
+ draw_reminder_icon = FALSE;
+ draw_recurrence_icon = FALSE;
+ draw_timezone_icon = FALSE;
+ draw_meeting_icon = FALSE;
+ draw_attach_icon = FALSE;
+ icon_x = item_x + E_DAY_VIEW_BAR_WIDTH + E_DAY_VIEW_ICON_X_PAD;
+ icon_y = item_y + E_DAY_VIEW_EVENT_BORDER_HEIGHT
+ + E_DAY_VIEW_ICON_Y_PAD;
+
+ if (e_cal_component_has_alarms (comp)) {
+ draw_reminder_icon = TRUE;
num_icons++;
- }
-
- if (num_icons != 0) {
- if (item_h >= (E_DAY_VIEW_ICON_HEIGHT + E_DAY_VIEW_ICON_Y_PAD)
- * num_icons) {
- icon_x_inc = 0;
- icon_y_inc = E_DAY_VIEW_ICON_HEIGHT
- + E_DAY_VIEW_ICON_Y_PAD;
- } else {
- icon_x_inc = E_DAY_VIEW_ICON_WIDTH
- + E_DAY_VIEW_ICON_X_PAD;
- icon_y_inc = 0;
- }
-
- if (draw_reminder_icon) {
- max_icon_w = item_x + item_w - icon_x
- - E_DAY_VIEW_EVENT_BORDER_WIDTH;
- max_icon_h = item_y + item_h - icon_y
- - E_DAY_VIEW_EVENT_BORDER_HEIGHT;
-
- cairo_save (cr);
- gdk_cairo_set_source_pixbuf (cr, day_view->reminder_icon, icon_x, icon_y);
- cairo_paint (cr);
- cairo_restore (cr);
-
- icon_x += icon_x_inc;
- icon_y += icon_y_inc;
}
- if (draw_recurrence_icon) {
- max_icon_w = item_x + item_w - icon_x
- - E_DAY_VIEW_EVENT_BORDER_WIDTH;
- max_icon_h = item_y + item_h - icon_y
- - E_DAY_VIEW_EVENT_BORDER_HEIGHT;
-
- cairo_save (cr);
- gdk_cairo_set_source_pixbuf (cr, day_view->recurrence_icon, icon_x, icon_y);
- cairo_paint (cr);
- cairo_restore (cr);
-
- icon_x += icon_x_inc;
- icon_y += icon_y_inc;
+ if (e_cal_component_has_recurrences (comp) || e_cal_component_is_instance (comp)) {
+ draw_recurrence_icon = TRUE;
+ num_icons++;
}
- if (draw_attach_icon) {
- max_icon_w = item_x + item_w - icon_x
- - E_DAY_VIEW_EVENT_BORDER_WIDTH;
- max_icon_h = item_y + item_h - icon_y
- - E_DAY_VIEW_EVENT_BORDER_HEIGHT;
-
- cairo_save (cr);
- gdk_cairo_set_source_pixbuf (cr, day_view->attach_icon, icon_x, icon_y);
- cairo_paint (cr);
- cairo_restore (cr);
- icon_x += icon_x_inc;
- icon_y += icon_y_inc;
+ if (e_cal_component_has_attachments (comp)) {
+ draw_attach_icon = TRUE;
+ num_icons++;
}
- if (draw_timezone_icon) {
- max_icon_w = item_x + item_w - icon_x
- - E_DAY_VIEW_EVENT_BORDER_WIDTH;
- max_icon_h = item_y + item_h - icon_y
- - E_DAY_VIEW_EVENT_BORDER_HEIGHT;
-
- cairo_save (cr);
- gdk_cairo_set_source_pixbuf (cr, day_view->timezone_icon, icon_x, icon_y);
- cairo_paint (cr);
- cairo_restore (cr);
-
- icon_x += icon_x_inc;
- icon_y += icon_y_inc;
+ /* If the DTSTART or DTEND are in a different timezone to our current
+ timezone, we display the timezone icon. */
+ if (event->different_timezone) {
+ draw_timezone_icon = TRUE;
+ num_icons++;
}
-
- if (draw_meeting_icon) {
- max_icon_w = item_x + item_w - icon_x
- - E_DAY_VIEW_EVENT_BORDER_WIDTH;
- max_icon_h = item_y + item_h - icon_y
- - E_DAY_VIEW_EVENT_BORDER_HEIGHT;
-
- cairo_save (cr);
- gdk_cairo_set_source_pixbuf (cr, day_view->meeting_icon, icon_x, icon_y);
- cairo_paint (cr);
- cairo_restore (cr);
-
- icon_x += icon_x_inc;
- icon_y += icon_y_inc;
+ if (e_cal_component_has_organizer (comp)) {
+ draw_meeting_icon = TRUE;
+ num_icons++;
}
- /* draw categories icons */
+ e_cal_component_get_categories_list (comp, &categories_list);
for (elem = categories_list; elem; elem = elem->next) {
char *category;
GdkPixmap *pixmap = NULL;
GdkBitmap *mask = NULL;
category = (char *) elem->data;
- if (!e_categories_config_get_icon_for (category, &pixmap, &mask))
- continue;
+ if (e_categories_config_get_icon_for (category, &pixmap, &mask))
+ num_icons++;
+ }
- max_icon_w = item_x + item_w - icon_x
- - E_DAY_VIEW_EVENT_BORDER_WIDTH;
- max_icon_h = item_y + item_h - icon_y
- - E_DAY_VIEW_EVENT_BORDER_HEIGHT;
+ if (num_icons != 0) {
+ if (item_h >= (E_DAY_VIEW_ICON_HEIGHT + E_DAY_VIEW_ICON_Y_PAD)
+ * num_icons) {
+ icon_x_inc = 0;
+ icon_y_inc = E_DAY_VIEW_ICON_HEIGHT
+ + E_DAY_VIEW_ICON_Y_PAD;
+ } else {
+ icon_x_inc = E_DAY_VIEW_ICON_WIDTH
+ + E_DAY_VIEW_ICON_X_PAD;
+ icon_y_inc = 0;
+ }
- gdk_gc_set_clip_origin (gc, icon_x, icon_y);
- if (mask != NULL)
- gdk_gc_set_clip_mask (gc, mask);
- gdk_draw_pixmap (drawable, gc,
- pixmap,
- 0, 0, icon_x, icon_y,
- MIN (E_DAY_VIEW_ICON_WIDTH,
- max_icon_w),
- MIN (E_DAY_VIEW_ICON_HEIGHT,
- max_icon_h));
+ if (draw_reminder_icon) {
+ max_icon_w = item_x + item_w - icon_x
+ - E_DAY_VIEW_EVENT_BORDER_WIDTH;
+ max_icon_h = item_y + item_h - icon_y
+ - E_DAY_VIEW_EVENT_BORDER_HEIGHT;
- gdk_pixmap_unref (pixmap);
- if (mask != NULL)
- gdk_bitmap_unref (mask);
+ cairo_save (cr);
+ gdk_cairo_set_source_pixbuf (cr, day_view->reminder_icon, icon_x, icon_y);
+ cairo_paint (cr);
+ cairo_restore (cr);
+
+ icon_x += icon_x_inc;
+ icon_y += icon_y_inc;
+ }
+
+ if (draw_recurrence_icon) {
+ max_icon_w = item_x + item_w - icon_x
+ - E_DAY_VIEW_EVENT_BORDER_WIDTH;
+ max_icon_h = item_y + item_h - icon_y
+ - E_DAY_VIEW_EVENT_BORDER_HEIGHT;
+
+ cairo_save (cr);
+ gdk_cairo_set_source_pixbuf (cr, day_view->recurrence_icon, icon_x, icon_y);
+ cairo_paint (cr);
+ cairo_restore (cr);
+
+ icon_x += icon_x_inc;
+ icon_y += icon_y_inc;
+ }
+ if (draw_attach_icon) {
+ max_icon_w = item_x + item_w - icon_x
+ - E_DAY_VIEW_EVENT_BORDER_WIDTH;
+ max_icon_h = item_y + item_h - icon_y
+ - E_DAY_VIEW_EVENT_BORDER_HEIGHT;
- icon_x += icon_x_inc;
- icon_y += icon_y_inc;
- }
+ cairo_save (cr);
+ gdk_cairo_set_source_pixbuf (cr, day_view->attach_icon, icon_x, icon_y);
+ cairo_paint (cr);
+ cairo_restore (cr);
+ icon_x += icon_x_inc;
+ icon_y += icon_y_inc;
+ }
+ if (draw_timezone_icon) {
+ max_icon_w = item_x + item_w - icon_x
+ - E_DAY_VIEW_EVENT_BORDER_WIDTH;
+ max_icon_h = item_y + item_h - icon_y
+ - E_DAY_VIEW_EVENT_BORDER_HEIGHT;
+
+ cairo_save (cr);
+ gdk_cairo_set_source_pixbuf (cr, day_view->timezone_icon, icon_x, icon_y);
+ cairo_paint (cr);
+ cairo_restore (cr);
+
+ icon_x += icon_x_inc;
+ icon_y += icon_y_inc;
+ }
+
+
+ if (draw_meeting_icon) {
+ max_icon_w = item_x + item_w - icon_x
+ - E_DAY_VIEW_EVENT_BORDER_WIDTH;
+ max_icon_h = item_y + item_h - icon_y
+ - E_DAY_VIEW_EVENT_BORDER_HEIGHT;
+
+ cairo_save (cr);
+ gdk_cairo_set_source_pixbuf (cr, day_view->meeting_icon, icon_x, icon_y);
+ cairo_paint (cr);
+ cairo_restore (cr);
+
+ icon_x += icon_x_inc;
+ icon_y += icon_y_inc;
+ }
+
+ /* draw categories icons */
+ for (elem = categories_list; elem; elem = elem->next) {
+ char *category;
+ GdkPixmap *pixmap = NULL;
+ GdkBitmap *mask = NULL;
+
+ category = (char *) elem->data;
+ if (!e_categories_config_get_icon_for (category, &pixmap, &mask))
+ continue;
+
+ max_icon_w = item_x + item_w - icon_x
+ - E_DAY_VIEW_EVENT_BORDER_WIDTH;
+ max_icon_h = item_y + item_h - icon_y
+ - E_DAY_VIEW_EVENT_BORDER_HEIGHT;
+
+ gdk_gc_set_clip_origin (gc, icon_x, icon_y);
+ if (mask != NULL)
+ gdk_gc_set_clip_mask (gc, mask);
+ gdk_draw_pixmap (drawable, gc,
+ pixmap,
+ 0, 0, icon_x, icon_y,
+ MIN (E_DAY_VIEW_ICON_WIDTH,
+ max_icon_w),
+ MIN (E_DAY_VIEW_ICON_HEIGHT,
+ max_icon_h));
+
+ gdk_pixmap_unref (pixmap);
+ if (mask != NULL)
+ gdk_bitmap_unref (mask);
+
+ icon_x += icon_x_inc;
+ icon_y += icon_y_inc;
+ }
- gdk_gc_set_clip_mask (gc, NULL);
- }
+ gdk_gc_set_clip_mask (gc, NULL);
+ }
/* free memory */
e_cal_component_free_categories_list (categories_list);
+ }
+
g_object_unref (comp);
cairo_destroy (cr);
}
diff --git a/calendar/gui/e-day-view.c b/calendar/gui/e-day-view.c
index fa80114970..8e066fe41d 100644
--- a/calendar/gui/e-day-view.c
+++ b/calendar/gui/e-day-view.c
@@ -783,13 +783,6 @@ e_day_view_init (EDayView *day_view)
"EDayViewTopItem::day_view", day_view,
NULL);
- day_view->resize_long_event_rect_item =
- gnome_canvas_item_new (canvas_group,
- gnome_canvas_rect_get_type(),
- "width_pixels", 1,
- NULL);
- gnome_canvas_item_hide (day_view->resize_long_event_rect_item);
-
day_view->drag_long_event_rect_item =
gnome_canvas_item_new (canvas_group,
gnome_canvas_rect_get_type (),
@@ -863,35 +856,6 @@ e_day_view_init (EDayView *day_view)
"EDayViewMainItem::day_view", day_view,
NULL);
- day_view->resize_rect_item =
- gnome_canvas_item_new (canvas_group,
- gnome_canvas_rect_get_type(),
- "width_pixels", 1,
- NULL);
- gnome_canvas_item_hide (day_view->resize_rect_item);
-
- day_view->resize_bar_item =
- gnome_canvas_item_new (canvas_group,
- gnome_canvas_rect_get_type(),
- "width_pixels", 1,
- NULL);
- gnome_canvas_item_hide (day_view->resize_bar_item);
-
- day_view->main_canvas_top_resize_bar_item =
- gnome_canvas_item_new (canvas_group,
- gnome_canvas_rect_get_type (),
- "width_pixels", 1,
- NULL);
- gnome_canvas_item_hide (day_view->main_canvas_top_resize_bar_item);
-
- day_view->main_canvas_bottom_resize_bar_item =
- gnome_canvas_item_new (canvas_group,
- gnome_canvas_rect_get_type (),
- "width_pixels", 1,
- NULL);
- gnome_canvas_item_hide (day_view->main_canvas_bottom_resize_bar_item);
-
-
day_view->drag_rect_item =
gnome_canvas_item_new (canvas_group,
gnome_canvas_rect_get_type (),
@@ -1102,38 +1066,11 @@ e_day_view_realize (GtkWidget *widget)
/* Set the canvas item colors. */
- gnome_canvas_item_set (day_view->resize_long_event_rect_item,
- "fill_color_gdk", &day_view->colors[E_DAY_VIEW_COLOR_EVENT_BACKGROUND],
- "outline_color_gdk", &day_view->colors[E_DAY_VIEW_COLOR_EVENT_BORDER],
- NULL);
-
gnome_canvas_item_set (day_view->drag_long_event_rect_item,
"fill_color_gdk", &day_view->colors[E_DAY_VIEW_COLOR_EVENT_BACKGROUND],
"outline_color_gdk", &day_view->colors[E_DAY_VIEW_COLOR_EVENT_BORDER],
NULL);
-
- gnome_canvas_item_set (day_view->resize_rect_item,
- "fill_color_gdk", &day_view->colors[E_DAY_VIEW_COLOR_EVENT_BACKGROUND],
- "outline_color_gdk", &day_view->colors[E_DAY_VIEW_COLOR_EVENT_BORDER],
- NULL);
-
- gnome_canvas_item_set (day_view->resize_bar_item,
- "fill_color_gdk", &day_view->colors[E_DAY_VIEW_COLOR_EVENT_VBAR],
- "outline_color_gdk", &day_view->colors[E_DAY_VIEW_COLOR_EVENT_BORDER],
- NULL);
-
- gnome_canvas_item_set (day_view->main_canvas_top_resize_bar_item,
- "fill_color_gdk", &day_view->colors[E_DAY_VIEW_COLOR_EVENT_VBAR],
- "outline_color_gdk", &day_view->colors[E_DAY_VIEW_COLOR_EVENT_BORDER],
- NULL);
-
- gnome_canvas_item_set (day_view->main_canvas_bottom_resize_bar_item,
- "fill_color_gdk", &day_view->colors[E_DAY_VIEW_COLOR_EVENT_VBAR],
- "outline_color_gdk", &day_view->colors[E_DAY_VIEW_COLOR_EVENT_BORDER],
- NULL);
-
-
gnome_canvas_item_set (day_view->drag_rect_item,
"fill_color_gdk", &day_view->colors[E_DAY_VIEW_COLOR_EVENT_BACKGROUND],
"outline_color_gdk", &day_view->colors[E_DAY_VIEW_COLOR_EVENT_BORDER],
@@ -1271,14 +1208,6 @@ e_day_view_style_set (GtkWidget *widget,
NULL);
}
}
- gnome_canvas_item_set (day_view->main_canvas_top_resize_bar_item,
- "fill_color_gdk", &day_view->colors[E_DAY_VIEW_COLOR_EVENT_VBAR],
- "outline_color_gdk", &day_view->colors[E_DAY_VIEW_COLOR_EVENT_BORDER],
- NULL);
- gnome_canvas_item_set (day_view->main_canvas_bottom_resize_bar_item,
- "fill_color_gdk", &day_view->colors[E_DAY_VIEW_COLOR_EVENT_VBAR],
- "outline_color_gdk", &day_view->colors[E_DAY_VIEW_COLOR_EVENT_BORDER],
- NULL);
/* Set up Pango prerequisites */
font_desc = gtk_widget_get_style (widget)->font_desc;
@@ -1793,8 +1722,8 @@ e_day_view_update_event_label (EDayView *day_view,
gint event_num)
{
EDayViewEvent *event;
- char *text, *start_suffix, *end_suffix;
- gboolean free_text = FALSE, editing_event = FALSE;
+ char *text, *start_suffix, *end_suffix, *mode;
+ gboolean free_text = FALSE, editing_event = FALSE, show_span = FALSE, format_time;
gint offset;
gint start_hour, start_display_hour, start_minute, start_suffix_width;
gint end_hour, end_display_hour, end_minute, end_suffix_width;
@@ -1813,21 +1742,32 @@ e_day_view_update_event_label (EDayView *day_view,
&& day_view->editing_event_num == event_num)
editing_event = TRUE;
- if (!editing_event
- && (event->start_minute % day_view->mins_per_row != 0
- || (day_view->show_event_end_times
- && event->end_minute % day_view->mins_per_row != 0))) {
- offset = day_view->first_hour_shown * 60
- + day_view->first_minute_shown;
+ if (!editing_event) {
+ if (event->start_minute % day_view->mins_per_row != 0
+ || (day_view->show_event_end_times
+ && event->end_minute % day_view->mins_per_row != 0)) {
+ offset = day_view->first_hour_shown * 60
+ + day_view->first_minute_shown;
+ show_span = TRUE;
+ } else {
+ offset = 0;
+ }
start_minute = offset + event->start_minute;
end_minute = offset + event->end_minute;
+ format_time = (((end_minute - start_minute)/day_view->mins_per_row) >= 2) ? TRUE : FALSE;
+
start_hour = start_minute / 60;
start_minute = start_minute % 60;
end_hour = end_minute / 60;
end_minute = end_minute % 60;
+ if (format_time)
+ mode = "\n";
+ else
+ mode = "";
+
e_day_view_convert_time_to_display (day_view, start_hour,
&start_display_hour,
&start_suffix,
@@ -1838,41 +1778,48 @@ e_day_view_update_event_label (EDayView *day_view,
&end_suffix_width);
if (e_calendar_view_get_use_24_hour_format (E_CALENDAR_VIEW (day_view))) {
- if (day_view->show_event_end_times) {
+ if (day_view->show_event_end_times && show_span) {
/* 24 hour format with end time. */
text = g_strdup_printf
- ("%2i:%02i-%2i:%02i %s",
+ ("%2i:%02i-%2i:%02i %s %s",
start_display_hour, start_minute,
- end_display_hour, end_minute,
+ end_display_hour, end_minute, mode,
text);
} else {
+ free_text = TRUE;
+ if (format_time) {
/* 24 hour format without end time. */
text = g_strdup_printf
- ("%2i:%02i %s",
- start_display_hour, start_minute,
+ ("%2i:%02i %s %s",
+ start_display_hour, start_minute, mode,
text);
+ free_text = FALSE;
+ }
}
} else {
- if (day_view->show_event_end_times) {
+ if (day_view->show_event_end_times && offset != 0) {
/* 12 hour format with end time. */
text = g_strdup_printf
- ("%2i:%02i%s-%2i:%02i%s %s",
- start_display_hour, start_minute,
+ ("%2i:%02i%s-%2i:%02i%s %s %s",
+ start_display_hour, start_minute,
start_suffix,
- end_display_hour, end_minute,
+ end_display_hour, end_minute, mode,
end_suffix,
text);
} else {
/* 12 hour format without end time. */
text = g_strdup_printf
- ("%2i:%02i%s %s",
+ ("%2i:%02i%s %s %s",
start_display_hour, start_minute,
- start_suffix,
+ start_suffix, mode,
text);
}
}
- free_text = TRUE;
+ if (free_text)
+ free_text = FALSE;
+ else
+ free_text = TRUE;
}
gnome_canvas_item_set (event->canvas_item,
@@ -1887,7 +1834,6 @@ e_day_view_update_event_label (EDayView *day_view,
g_free (text);
}
-
static void
e_day_view_update_long_event_label (EDayView *day_view,
gint event_num)
@@ -2746,7 +2692,6 @@ e_day_view_convert_time_to_position (EDayView *day_view,
return offset * day_view->row_height / day_view->mins_per_row;
}
-
static gboolean
e_day_view_on_top_canvas_button_press (GtkWidget *widget,
GdkEventButton *event,
@@ -3049,6 +2994,7 @@ e_day_view_on_event_button_press (EDayView *day_view,
} else if (event->type == GDK_2BUTTON_PRESS) {
e_day_view_on_event_double_click (day_view, day,
event_num);
+
gtk_signal_emit_stop_by_name (GTK_OBJECT (day_view->main_canvas),
"button_press_event");
return TRUE;
@@ -3121,9 +3067,6 @@ e_day_view_on_long_event_click (EDayView *day_view,
/* Create the edit rect if necessary. */
e_day_view_reshape_resize_long_event_rect_item (day_view);
- /* Make sure the text item is on top. */
- gnome_canvas_item_raise_to_top (day_view->resize_long_event_rect_item);
-
/* Raise the event's item, above the rect as well. */
gnome_canvas_item_raise_to_top (event->canvas_item);
}
@@ -3197,10 +3140,6 @@ e_day_view_on_event_click (EDayView *day_view,
e_day_view_reshape_main_canvas_resize_bars (day_view);
- /* Make sure the text item is on top. */
- gnome_canvas_item_raise_to_top (day_view->resize_rect_item);
- gnome_canvas_item_raise_to_top (day_view->resize_bar_item);
-
/* Raise the event's item, above the rect as well. */
gnome_canvas_item_raise_to_top (event->canvas_item);
}
@@ -3240,7 +3179,6 @@ e_day_view_reshape_resize_long_event_rect_item (EDayView *day_view)
&start_day, &end_day,
&item_x, &item_y,
&item_w, &item_h)) {
- gnome_canvas_item_hide (day_view->resize_long_event_rect_item);
return;
}
@@ -3248,14 +3186,6 @@ e_day_view_reshape_resize_long_event_rect_item (EDayView *day_view)
y1 = item_y;
x2 = item_x + item_w - 1;
y2 = item_y + item_h - 1;
-
- gnome_canvas_item_set (day_view->resize_long_event_rect_item,
- "x1", x1,
- "y1", y1,
- "x2", x2,
- "y2", y2,
- NULL);
- gnome_canvas_item_show (day_view->resize_long_event_rect_item);
}
@@ -3275,7 +3205,6 @@ e_day_view_reshape_resize_rect_item (EDayView *day_view)
|| !e_day_view_get_event_position (day_view, day, event_num,
&item_x, &item_y,
&item_w, &item_h)) {
- gnome_canvas_item_hide (day_view->resize_rect_item);
return;
}
@@ -3283,22 +3212,6 @@ e_day_view_reshape_resize_rect_item (EDayView *day_view)
y1 = item_y;
x2 = item_x + item_w - 1;
y2 = item_y + item_h - 1;
-
- gnome_canvas_item_set (day_view->resize_rect_item,
- "x1", x1 + E_DAY_VIEW_BAR_WIDTH - 1,
- "y1", y1,
- "x2", x2,
- "y2", y2,
- NULL);
- gnome_canvas_item_show (day_view->resize_rect_item);
-
- gnome_canvas_item_set (day_view->resize_bar_item,
- "x1", x1,
- "y1", y1,
- "x2", x1 + E_DAY_VIEW_BAR_WIDTH - 1,
- "y2", y2,
- NULL);
- gnome_canvas_item_show (day_view->resize_bar_item);
}
@@ -3564,8 +3477,6 @@ e_day_view_on_top_canvas_motion (GtkWidget *widget,
if (day_view->resize_bars_event_day != -1) {
day_view->resize_bars_event_day = -1;
day_view->resize_bars_event_num = -1;
- gnome_canvas_item_hide (day_view->main_canvas_top_resize_bar_item);
- gnome_canvas_item_hide (day_view->main_canvas_bottom_resize_bar_item);
}
target_list = gtk_target_list_new (target_table,
@@ -3667,8 +3578,6 @@ e_day_view_on_main_canvas_motion (GtkWidget *widget,
if (day_view->resize_bars_event_day != -1) {
day_view->resize_bars_event_day = -1;
day_view->resize_bars_event_num = -1;
- gnome_canvas_item_hide (day_view->main_canvas_top_resize_bar_item);
- gnome_canvas_item_hide (day_view->main_canvas_bottom_resize_bar_item);
}
target_list = gtk_target_list_new (target_table,
@@ -3987,8 +3896,6 @@ e_day_view_finish_long_event_resize (EDayView *day_view)
e_calendar_view_modify_and_send (comp, client, mod, toplevel, TRUE);
out:
- gnome_canvas_item_hide (day_view->resize_long_event_rect_item);
-
day_view->resize_drag_pos = E_CALENDAR_VIEW_POS_NONE;
g_object_unref (comp);
@@ -4055,14 +3962,10 @@ e_day_view_finish_resize (EDayView *day_view)
day_view->last_edited_comp_string = e_cal_component_get_as_string (comp);
- gnome_canvas_item_hide (day_view->resize_rect_item);
- gnome_canvas_item_hide (day_view->resize_bar_item);
/* Hide the horizontal bars. */
day_view->resize_bars_event_day = -1;
day_view->resize_bars_event_num = -1;
- gnome_canvas_item_hide (day_view->main_canvas_top_resize_bar_item);
- gnome_canvas_item_hide (day_view->main_canvas_bottom_resize_bar_item);
day_view->resize_drag_pos = E_CALENDAR_VIEW_POS_NONE;
@@ -4122,7 +4025,6 @@ e_day_view_abort_resize (EDayView *day_view)
day_view->last_cursor_set_in_top_canvas = day_view->normal_cursor;
gdk_window_set_cursor (day_view->top_canvas->window,
day_view->normal_cursor);
- gnome_canvas_item_hide (day_view->resize_long_event_rect_item);
} else {
e_day_view_reshape_day_event (day_view, day, event_num);
e_day_view_reshape_main_canvas_resize_bars (day_view);
@@ -4131,8 +4033,6 @@ e_day_view_abort_resize (EDayView *day_view)
day_view->last_cursor_set_in_main_canvas = day_view->normal_cursor;
gdk_window_set_cursor (day_view->main_canvas->window,
day_view->normal_cursor);
- gnome_canvas_item_hide (day_view->resize_rect_item);
- gnome_canvas_item_hide (day_view->resize_bar_item);
}
}
@@ -4708,28 +4608,11 @@ e_day_view_reshape_main_canvas_resize_bars (EDayView *day_view)
y = item_y;
w = item_w - E_DAY_VIEW_BAR_WIDTH;
h = item_h;
+
+ gtk_widget_queue_draw (day_view->main_canvas);
} else {
- gnome_canvas_item_hide (day_view->main_canvas_top_resize_bar_item);
- gnome_canvas_item_hide (day_view->main_canvas_bottom_resize_bar_item);
return;
}
-
- gnome_canvas_item_set (day_view->main_canvas_top_resize_bar_item,
- "x1", x - E_DAY_VIEW_BAR_WIDTH,
- "y1", y - E_DAY_VIEW_BAR_HEIGHT,
- "x2", x + w - 1,
- "y2", y - 1,
- NULL);
- gnome_canvas_item_show (day_view->main_canvas_top_resize_bar_item);
-
- gnome_canvas_item_set (day_view->main_canvas_bottom_resize_bar_item,
- "x1", x - E_DAY_VIEW_BAR_WIDTH,
- "y1", y + h,
- "x2", x + w - 1,
- "y2", y + h + E_DAY_VIEW_BAR_HEIGHT - 1,
- NULL);
-
- gnome_canvas_item_show (day_view->main_canvas_bottom_resize_bar_item);
}
@@ -5888,6 +5771,9 @@ e_day_view_on_text_item_event (GnomeCanvasItem *item,
ECalendarViewPosition pos;
gboolean main_canvas = TRUE;
+ if (day_view->editing_event_num != -1)
+ return FALSE;
+
/* Convert the coords to the main canvas window, or return if the
window is not found. */
if (!e_day_view_convert_event_coords (day_view, (GdkEvent*) event,
@@ -5918,6 +5804,9 @@ e_day_view_on_text_item_event (GnomeCanvasItem *item,
if (pos == E_CALENDAR_VIEW_POS_OUTSIDE)
return FALSE;
+ if (day_view->resize_event_num == event_num)
+ return FALSE;
+
pevent = tooltip_get_view_event (day_view, day, event_num);
g_object_set_data (G_OBJECT (item), "event-num", GINT_TO_POINTER (event_num));
g_object_set_data (G_OBJECT (item), "event-day", GINT_TO_POINTER (day));
@@ -6091,9 +5980,6 @@ e_day_view_change_event_time (EDayView *day_view, time_t start_dt, time_t end_dt
day_view->last_edited_comp_string = e_cal_component_get_as_string (comp);
- gnome_canvas_item_hide (day_view->resize_rect_item);
- gnome_canvas_item_hide (day_view->resize_bar_item);
-
day_view->resize_drag_pos = E_CALENDAR_VIEW_POS_NONE;
if (e_cal_component_is_instance (comp)) {
@@ -6253,9 +6139,6 @@ e_day_view_on_editing_stopped (EDayView *day_view,
event = &g_array_index (day_view->events[day], EDayViewEvent,
event_num);
- /* Hide the horizontal bars. */
- gnome_canvas_item_hide (day_view->main_canvas_top_resize_bar_item);
- gnome_canvas_item_hide (day_view->main_canvas_bottom_resize_bar_item);
}
/* Reset the edit fields. */
@@ -7222,8 +7105,6 @@ e_day_view_on_main_canvas_drag_leave (GtkWidget *widget,
/* Hide the resize bars if they are being used in the drag. */
if (day_view->drag_event_day == day_view->resize_bars_event_day
&& day_view->drag_event_num == day_view->resize_bars_event_num) {
- gnome_canvas_item_hide (day_view->main_canvas_top_resize_bar_item);
- gnome_canvas_item_hide (day_view->main_canvas_bottom_resize_bar_item);
}
}
diff --git a/widgets/ChangeLog b/widgets/ChangeLog
index 1d10540ccd..1ca442d8e6 100644
--- a/widgets/ChangeLog
+++ b/widgets/ChangeLog
@@ -1,3 +1,8 @@
+2006-07-05 Rajeev ramanathan <rajeevramanathan_2004@yahoo.co.in>
+ * text/e-text.c, table/e-cell-text.c:
+ Added code to render ECell and EText text items with
+ antialiasing, hinting and sub-pixel ordering with cairo.
+
2006-07-06 Hiroyuki Ikezoe <poincare@ikezoe.net>
** Fixes bug #341354.
diff --git a/widgets/table/e-cell-text.c b/widgets/table/e-cell-text.c
index 7ea8a54c98..a1b56a674c 100644
--- a/widgets/table/e-cell-text.c
+++ b/widgets/table/e-cell-text.c
@@ -142,7 +142,6 @@ typedef struct {
int xofs, yofs; /* This gets added to the x
and y for the cell text. */
double ellipsis_width[2]; /* The width of the ellipsis. */
-
} ECellTextView;
struct _CellEdit {
@@ -439,6 +438,7 @@ ect_unrealize (ECellView *ecv)
if (parent_class->unrealize)
(* parent_class->unrealize) (ecv);
+
}
static void
@@ -504,6 +504,53 @@ build_attr_list (ECellTextView *text_view, int row, int text_length)
return attrs;
}
+static cairo_font_options_t *
+get_font_options ()
+{
+ char *antialiasing, *hinting, *subpixel_order;
+ cairo_font_options_t *font_options = cairo_font_options_create ();
+
+ /* Antialiasing */
+ antialiasing = gconf_client_get_string (gconf_client_get_default (),
+ "/desktop/gnome/font_rendering/antialiasing", NULL);
+ if (strcmp (antialiasing, "grayscale") == 0)
+ cairo_font_options_set_antialias (font_options, CAIRO_ANTIALIAS_GRAY);
+ else if (strcmp (antialiasing, "rgba") == 0)
+ cairo_font_options_set_antialias (font_options, CAIRO_ANTIALIAS_SUBPIXEL);
+ else if (strcmp (antialiasing, "none") == 0)
+ cairo_font_options_set_antialias (font_options, CAIRO_ANTIALIAS_NONE);
+ else
+ cairo_font_options_set_antialias (font_options, CAIRO_ANTIALIAS_DEFAULT);
+
+ hinting = gconf_client_get_string (gconf_client_get_default (),
+ "/desktop/gnome/font_rendering/hinting", NULL);
+ if (strcmp (hinting, "full") == 0)
+ cairo_font_options_set_hint_style (font_options, CAIRO_HINT_STYLE_FULL);
+ else if (strcmp (hinting, "medium") == 0)
+ cairo_font_options_set_hint_style (font_options, CAIRO_HINT_STYLE_MEDIUM);
+ else if (strcmp (hinting, "slight") == 0)
+ cairo_font_options_set_hint_style (font_options, CAIRO_HINT_STYLE_SLIGHT);
+ else if (strcmp (hinting, "none") == 0)
+ cairo_font_options_set_hint_style (font_options, CAIRO_HINT_STYLE_NONE);
+ else
+ cairo_font_options_set_hint_style (font_options, CAIRO_HINT_STYLE_DEFAULT);
+
+ subpixel_order = gconf_client_get_string (gconf_client_get_default (),
+ "/desktop/gnome/font_rendering/rgba_order", NULL);
+ if (strcmp (subpixel_order, "rgb") == 0)
+ cairo_font_options_set_subpixel_order (font_options, CAIRO_SUBPIXEL_ORDER_RGB);
+ else if (strcmp (subpixel_order, "bgr") == 0)
+ cairo_font_options_set_subpixel_order (font_options, CAIRO_SUBPIXEL_ORDER_BGR);
+ else if (strcmp (subpixel_order, "vrgb") == 0)
+ cairo_font_options_set_subpixel_order (font_options, CAIRO_SUBPIXEL_ORDER_VRGB);
+ else if (strcmp (subpixel_order, "vbgr") == 0)
+ cairo_font_options_set_subpixel_order (font_options, CAIRO_SUBPIXEL_ORDER_VBGR);
+ else
+ cairo_font_options_set_subpixel_order (font_options, CAIRO_SUBPIXEL_ORDER_DEFAULT);
+
+ return font_options;
+}
+
static PangoLayout *
layout_with_preedit (ECellTextView *text_view, int row, const char *text, gint width)
{
@@ -570,6 +617,8 @@ build_layout (ECellTextView *text_view, int row, const char *text, gint width)
ECellText *ect = E_CELL_TEXT (ecell_view->ecell);
PangoAttrList *attrs ;
PangoLayout *layout;
+ PangoContext *context;
+ cairo_font_options_t *font_options;
layout = gtk_widget_create_pango_layout (GTK_WIDGET (((GnomeCanvasItem *)ecell_view->e_table_item_view)->canvas), text);
@@ -581,6 +630,13 @@ build_layout (ECellTextView *text_view, int row, const char *text, gint width)
if (text_view->edit || width <= 0)
return layout;
+ context = pango_layout_get_context (layout);
+
+ font_options = get_font_options();
+ pango_cairo_context_set_font_options (context, font_options);
+ cairo_font_options_destroy (font_options);
+ pango_layout_context_changed (layout);
+
if (ect->font_name)
{
PangoFontDescription *desc = NULL, *fixed_desc = NULL;
@@ -632,7 +688,7 @@ build_layout (ECellTextView *text_view, int row, const char *text, gint width)
default:
break;
}
-
+
return layout;
}
diff --git a/widgets/text/e-text.c b/widgets/text/e-text.c
index 75332cdd8a..50e75dd8f4 100644
--- a/widgets/text/e-text.c
+++ b/widgets/text/e-text.c
@@ -388,6 +388,53 @@ reset_layout_attrs (EText *text)
calc_height (text);
}
+static cairo_font_options_t *
+get_font_options ()
+{
+ char *antialiasing, *hinting, *subpixel_order;
+ cairo_font_options_t *font_options = cairo_font_options_create ();
+
+ /* Antialiasing */
+ antialiasing = gconf_client_get_string (gconf_client_get_default (),
+ "/desktop/gnome/font_rendering/antialiasing", NULL);
+ if (strcmp (antialiasing, "grayscale") == 0)
+ cairo_font_options_set_antialias (font_options, CAIRO_ANTIALIAS_GRAY);
+ else if (strcmp (antialiasing, "rgba") == 0)
+ cairo_font_options_set_antialias (font_options, CAIRO_ANTIALIAS_SUBPIXEL);
+ else if (strcmp (antialiasing, "none") == 0)
+ cairo_font_options_set_antialias (font_options, CAIRO_ANTIALIAS_NONE);
+ else
+ cairo_font_options_set_antialias (font_options, CAIRO_ANTIALIAS_DEFAULT);
+
+ hinting = gconf_client_get_string (gconf_client_get_default (),
+ "/desktop/gnome/font_rendering/hinting", NULL);
+ if (strcmp (hinting, "full") == 0)
+ cairo_font_options_set_hint_style (font_options, CAIRO_HINT_STYLE_FULL);
+ else if (strcmp (hinting, "medium") == 0)
+ cairo_font_options_set_hint_style (font_options, CAIRO_HINT_STYLE_MEDIUM);
+ else if (strcmp (hinting, "slight") == 0)
+ cairo_font_options_set_hint_style (font_options, CAIRO_HINT_STYLE_SLIGHT);
+ else if (strcmp (hinting, "none") == 0)
+ cairo_font_options_set_hint_style (font_options, CAIRO_HINT_STYLE_NONE);
+ else
+ cairo_font_options_set_hint_style (font_options, CAIRO_HINT_STYLE_DEFAULT);
+
+ subpixel_order = gconf_client_get_string (gconf_client_get_default (),
+ "/desktop/gnome/font_rendering/rgba_order", NULL);
+ if (strcmp (subpixel_order, "rgb") == 0)
+ cairo_font_options_set_subpixel_order (font_options, CAIRO_SUBPIXEL_ORDER_RGB);
+ else if (strcmp (subpixel_order, "bgr") == 0)
+ cairo_font_options_set_subpixel_order (font_options, CAIRO_SUBPIXEL_ORDER_BGR);
+ else if (strcmp (subpixel_order, "vrgb") == 0)
+ cairo_font_options_set_subpixel_order (font_options, CAIRO_SUBPIXEL_ORDER_VRGB);
+ else if (strcmp (subpixel_order, "vbgr") == 0)
+ cairo_font_options_set_subpixel_order (font_options, CAIRO_SUBPIXEL_ORDER_VBGR);
+ else
+ cairo_font_options_set_subpixel_order (font_options, CAIRO_SUBPIXEL_ORDER_DEFAULT);
+
+ return font_options;
+}
+
static void
create_layout (EText *text)
{
@@ -405,12 +452,30 @@ create_layout (EText *text)
static void
reset_layout (EText *text)
{
+ GnomeCanvasItem *item = GNOME_CANVAS_ITEM (text);
+ cairo_font_options_t *font_options;
+ PangoContext *context;
+
if (text->layout == NULL) {
create_layout (text);
}
else {
- pango_layout_set_text (text->layout, text->text, -1);
- reset_layout_attrs (text);
+ context = pango_layout_get_context (text->layout);
+
+ font_options = get_font_options();
+ pango_cairo_context_set_font_options (context, font_options);
+ cairo_font_options_destroy (font_options);
+ pango_layout_context_changed (text->layout);
+
+ text->font_desc = pango_font_description_new ();
+ pango_font_description_set_size (text->font_desc,
+ pango_font_description_get_size ((GTK_WIDGET (item->canvas))->style->font_desc));
+ pango_font_description_set_family (text->font_desc,
+ pango_font_description_get_family ((GTK_WIDGET (item->canvas))->style->font_desc));
+ pango_layout_set_font_description (text->layout, text->font_desc);
+
+ pango_layout_set_text (text->layout, text->text, -1);
+ reset_layout_attrs (text);
}
if (!text->button_down) {