aboutsummaryrefslogtreecommitdiffstats
path: root/calendar
diff options
context:
space:
mode:
authorBenjamin Otte <otte@redhat.com>2010-10-21 06:45:43 +0800
committerMatthew Barnes <mbarnes@redhat.com>2010-10-30 01:50:04 +0800
commit90381cf3bcd346c3e042efa12f9cbd1b3bb2e1ff (patch)
tree82a47f5a0fd52e3a127f9c941b0d3aabad375a82 /calendar
parent90c26d6fe6db1e9a2f03498dce8f9f135233bcf8 (diff)
downloadgsoc2013-evolution-90381cf3bcd346c3e042efa12f9cbd1b3bb2e1ff.tar
gsoc2013-evolution-90381cf3bcd346c3e042efa12f9cbd1b3bb2e1ff.tar.gz
gsoc2013-evolution-90381cf3bcd346c3e042efa12f9cbd1b3bb2e1ff.tar.bz2
gsoc2013-evolution-90381cf3bcd346c3e042efa12f9cbd1b3bb2e1ff.tar.lz
gsoc2013-evolution-90381cf3bcd346c3e042efa12f9cbd1b3bb2e1ff.tar.xz
gsoc2013-evolution-90381cf3bcd346c3e042efa12f9cbd1b3bb2e1ff.tar.zst
gsoc2013-evolution-90381cf3bcd346c3e042efa12f9cbd1b3bb2e1ff.zip
calendar: Draw day view with cairo
Diffstat (limited to 'calendar')
-rw-r--r--calendar/gui/e-day-view-main-item.c5
-rw-r--r--calendar/gui/e-day-view-top-item.c68
-rw-r--r--calendar/gui/e-day-view.c14
-rw-r--r--calendar/gui/e-day-view.h3
4 files changed, 33 insertions, 57 deletions
diff --git a/calendar/gui/e-day-view-main-item.c b/calendar/gui/e-day-view-main-item.c
index a0d881d563..366062f36f 100644
--- a/calendar/gui/e-day-view-main-item.c
+++ b/calendar/gui/e-day-view-main-item.c
@@ -192,7 +192,6 @@ day_view_main_item_draw_day_event (EDayViewMainItem *main_item,
EDayViewEvent *event;
ECalModel *model;
gint item_x, item_y, item_w, item_h, bar_y1, bar_y2;
- GdkGC *gc;
GdkColor bg_color;
ECalComponent *comp;
gint num_icons, icon_x, icon_y, icon_x_inc = 0, icon_y_inc = 0;
@@ -247,8 +246,6 @@ day_view_main_item_draw_day_event (EDayViewMainItem *main_item,
gdk_cairo_set_source_color (cr,
&day_view->colors[E_DAY_VIEW_COLOR_EVENT_VBAR]);
- gc = day_view->main_gc;
-
gradient = calendar_config_get_display_events_gradient ();
alpha = calendar_config_get_display_events_alpha ();
@@ -725,8 +722,6 @@ day_view_main_item_draw_day_event (EDayViewMainItem *main_item,
#undef draw_pixbuf
#undef fit_in_event
-
- gdk_gc_set_clip_mask (gc, NULL);
}
/* free memory */
diff --git a/calendar/gui/e-day-view-top-item.c b/calendar/gui/e-day-view-top-item.c
index 126f9833f8..fffb6141eb 100644
--- a/calendar/gui/e-day-view-top-item.c
+++ b/calendar/gui/e-day-view-top-item.c
@@ -157,7 +157,6 @@ day_view_top_item_draw_long_event (EDayViewTopItem *top_item,
EDayView *day_view;
EDayViewEvent *event;
GtkStyle *style;
- GdkGC *gc, *fg_gc;
gint start_day, end_day;
gint item_x, item_y, item_w, item_h;
gint text_x, icon_x, icon_y, icon_x_inc;
@@ -168,7 +167,6 @@ day_view_top_item_draw_long_event (EDayViewTopItem *top_item,
gint min_end_time_x, suffix_width, max_icon_x;
const gchar *suffix;
gboolean draw_start_triangle, draw_end_triangle;
- GdkRectangle clip_rect;
GSList *categories_list, *elem;
PangoLayout *layout;
GdkColor bg_color;
@@ -210,8 +208,6 @@ day_view_top_item_draw_long_event (EDayViewTopItem *top_item,
return;
style = gtk_widget_get_style (GTK_WIDGET (day_view));
- gc = day_view->main_gc;
- fg_gc = style->fg_gc[GTK_STATE_NORMAL];
comp = e_cal_component_new ();
e_cal_component_set_icalcomponent (
comp, icalcomponent_new_clone (event->comp_data->icalcomp));
@@ -350,6 +346,8 @@ day_view_top_item_draw_long_event (EDayViewTopItem *top_item,
time_width = e_day_view_get_time_string_width (day_view);
+ gdk_cairo_set_source_color (cr, &style->fg[GTK_STATE_NORMAL]);
+
if (event->start > day_view->day_starts[start_day]) {
offset = day_view->first_hour_shown * 60
+ day_view->first_minute_shown + event->start_minute;
@@ -368,25 +366,26 @@ day_view_top_item_draw_long_event (EDayViewTopItem *top_item,
display_hour, minute, suffix);
}
- clip_rect.x = item_x - x;
- clip_rect.y = item_y - y;
- clip_rect.width = item_w - E_DAY_VIEW_LONG_EVENT_BORDER_WIDTH;
- clip_rect.height = item_h;
- gdk_gc_set_clip_rectangle (fg_gc, &clip_rect);
+ cairo_save (cr);
+
+ cairo_rectangle (cr,
+ item_x - x, item_y - y,
+ item_w - E_DAY_VIEW_LONG_EVENT_BORDER_WIDTH, item_h);
+ cairo_clip (cr);
time_x = item_x + E_DAY_VIEW_LONG_EVENT_X_PAD - x;
if (display_hour < 10)
time_x += day_view->digit_width;
layout = gtk_widget_create_pango_layout (GTK_WIDGET (day_view), buffer);
- gdk_draw_layout (drawable, fg_gc,
- time_x,
- item_y + E_DAY_VIEW_LONG_EVENT_BORDER_HEIGHT +
- E_DAY_VIEW_LONG_EVENT_Y_PAD - y,
- layout);
+ cairo_move_to (cr,
+ time_x,
+ item_y + E_DAY_VIEW_LONG_EVENT_BORDER_HEIGHT +
+ E_DAY_VIEW_LONG_EVENT_Y_PAD - y);
+ pango_cairo_show_layout (cr, layout);
g_object_unref (layout);
- gdk_gc_set_clip_rectangle (fg_gc, NULL);
+ cairo_restore (cr);
min_end_time_x += time_width
+ E_DAY_VIEW_LONG_EVENT_TIME_X_PAD;
@@ -424,10 +423,10 @@ day_view_top_item_draw_long_event (EDayViewTopItem *top_item,
time_x += day_view->digit_width;
layout = gtk_widget_create_pango_layout (GTK_WIDGET (day_view), buffer);
- gdk_draw_layout (drawable, fg_gc,
- time_x,
- item_y + E_DAY_VIEW_LONG_EVENT_Y_PAD + 1 - y,
- layout);
+ cairo_move_to (cr,
+ time_x,
+ item_y + E_DAY_VIEW_LONG_EVENT_Y_PAD + 1 - y);
+ pango_cairo_show_layout (cr, layout);
g_object_unref (layout);
max_icon_x -= time_width + E_DAY_VIEW_LONG_EVENT_TIME_X_PAD;
@@ -495,13 +494,13 @@ day_view_top_item_draw_long_event (EDayViewTopItem *top_item,
continue;
if (icon_x <= max_icon_x) {
- gdk_gc_set_clip_origin (gc, icon_x, icon_y);
- gdk_draw_pixbuf (drawable, gc,
- pixbuf,
- 0, 0, icon_x, icon_y,
+ gdk_cairo_set_source_pixbuf (cr, pixbuf,
+ icon_x, icon_y);
+ cairo_rectangle (cr,
+ icon_x, icon_y,
E_DAY_VIEW_ICON_WIDTH,
- E_DAY_VIEW_ICON_HEIGHT,
- GDK_RGB_DITHER_NORMAL, 0, 0);
+ E_DAY_VIEW_ICON_HEIGHT);
+ cairo_fill (cr);
icon_x -= icon_x_inc;
}
}
@@ -509,7 +508,6 @@ day_view_top_item_draw_long_event (EDayViewTopItem *top_item,
e_cal_component_free_categories_list (categories_list);
g_object_unref (comp);
cairo_destroy (cr);
- gdk_gc_set_clip_mask (gc, NULL);
}
static void
@@ -603,7 +601,6 @@ day_view_top_item_draw (GnomeCanvasItem *canvas_item,
EDayViewTopItem *top_item;
EDayView *day_view;
GtkStyle *style;
- GdkGC *fg_gc;
gchar buffer[128];
GtkAllocation allocation;
GdkRectangle clip_rect;
@@ -622,7 +619,6 @@ day_view_top_item_draw (GnomeCanvasItem *canvas_item,
cr = gdk_cairo_create (drawable);
style = gtk_widget_get_style (GTK_WIDGET (day_view));
- fg_gc = style->fg_gc[GTK_STATE_NORMAL];
gtk_widget_get_allocation (
GTK_WIDGET (canvas_item->canvas), &allocation);
canvas_width = allocation.width;
@@ -720,19 +716,21 @@ day_view_top_item_draw (GnomeCanvasItem *canvas_item,
clip_rect.width = day_view->day_widths[day];
clip_rect.height = item_height - 2;
- gdk_gc_set_clip_rectangle (fg_gc, &clip_rect);
+ cairo_save (cr);
+
+ gdk_cairo_rectangle (cr, &clip_rect);
+ cairo_clip (cr);
layout = gtk_widget_create_pango_layout (GTK_WIDGET (day_view), buffer);
pango_layout_get_pixel_size (layout, &date_width, NULL);
date_x = day_view->day_offsets[day] + (clip_rect.width - date_width) / 2;
- gdk_draw_layout (drawable, fg_gc,
- date_x - x,
- 3 - y,
- layout);
- g_object_unref (layout);
+ gdk_cairo_set_source_color (cr, &style->fg[GTK_STATE_NORMAL]);
+ cairo_move_to (cr, date_x - x, 3 - y);
+ pango_cairo_show_layout (cr, layout);
- gdk_gc_set_clip_rectangle (fg_gc, NULL);
+ g_object_unref (layout);
+ cairo_restore (cr);
/* Draw the lines down the left and right of the date cols. */
if (day != 0) {
diff --git a/calendar/gui/e-day-view.c b/calendar/gui/e-day-view.c
index 8f04f51006..1482398367 100644
--- a/calendar/gui/e-day-view.c
+++ b/calendar/gui/e-day-view.c
@@ -1036,7 +1036,6 @@ e_day_view_init (EDayView *day_view)
day_view->last_hour_shown = 24;
day_view->last_minute_shown = 0;
- day_view->main_gc = NULL;
e_day_view_recalc_num_rows (day_view);
day_view->working_days = E_DAY_VIEW_MONDAY | E_DAY_VIEW_TUESDAY
@@ -1430,7 +1429,6 @@ static void
e_day_view_realize (GtkWidget *widget)
{
EDayView *day_view;
- GdkColormap *colormap;
GdkWindow *window;
if (GTK_WIDGET_CLASS (e_day_view_parent_class)->realize)
@@ -1438,16 +1436,11 @@ e_day_view_realize (GtkWidget *widget)
day_view = E_DAY_VIEW (widget);
window = gtk_widget_get_window (widget);
- day_view->main_gc = gdk_gc_new (window);
-
- colormap = gtk_widget_get_colormap (widget);
/* Allocate the colors. */
e_day_view_set_colors (day_view, widget);
- gdk_gc_set_colormap (day_view->main_gc, colormap);
-
/* Create the pixmaps. */
day_view->reminder_icon = e_icon_factory_get_icon ("stock_bell", GTK_ICON_SIZE_MENU);
day_view->recurrence_icon = e_icon_factory_get_icon ("view-refresh", GTK_ICON_SIZE_MENU);
@@ -1500,16 +1493,9 @@ static void
e_day_view_unrealize (GtkWidget *widget)
{
EDayView *day_view;
- GdkColormap *colormap;
day_view = E_DAY_VIEW (widget);
- g_object_unref (day_view->main_gc);
- day_view->main_gc = NULL;
-
- colormap = gtk_widget_get_colormap (widget);
- gdk_colormap_free_colors (colormap, day_view->colors, E_DAY_VIEW_COLOR_LAST);
-
g_object_unref (day_view->reminder_icon);
day_view->reminder_icon = NULL;
g_object_unref (day_view->recurrence_icon);
diff --git a/calendar/gui/e-day-view.h b/calendar/gui/e-day-view.h
index 45397d9750..04f41867d4 100644
--- a/calendar/gui/e-day-view.h
+++ b/calendar/gui/e-day-view.h
@@ -353,9 +353,6 @@ struct _EDayView {
PangoFontDescription *large_font_desc;
PangoFontDescription *small_font_desc;
- /* The GC used for painting in different colors. */
- GdkGC *main_gc;
-
/* The icons. */
GdkPixbuf *reminder_icon;
GdkPixbuf *recurrence_icon;