aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthew Barnes <mbarnes@redhat.com>2011-01-15 23:21:29 +0800
committerRodrigo Moya <rodrigo@gnome-db.org>2011-06-30 00:41:27 +0800
commitf4927d794a2628f2c38998b0c2ec8fff7e2cabb7 (patch)
tree92364b7a0e9f8b5a5ea6248ba4dbb6971fae3ab2
parentd0f088d329977e9a5f8aa4d4cf1122596eb8704f (diff)
downloadgsoc2013-evolution-f4927d794a2628f2c38998b0c2ec8fff7e2cabb7.tar
gsoc2013-evolution-f4927d794a2628f2c38998b0c2ec8fff7e2cabb7.tar.gz
gsoc2013-evolution-f4927d794a2628f2c38998b0c2ec8fff7e2cabb7.tar.bz2
gsoc2013-evolution-f4927d794a2628f2c38998b0c2ec8fff7e2cabb7.tar.lz
gsoc2013-evolution-f4927d794a2628f2c38998b0c2ec8fff7e2cabb7.tar.xz
gsoc2013-evolution-f4927d794a2628f2c38998b0c2ec8fff7e2cabb7.tar.zst
gsoc2013-evolution-f4927d794a2628f2c38998b0c2ec8fff7e2cabb7.zip
Adapt EWeekView + widgets to latest gtk+-3.0 API.
-rw-r--r--calendar/gui/e-week-view-event-item.c51
-rw-r--r--calendar/gui/e-week-view-main-item.c9
-rw-r--r--calendar/gui/e-week-view-titles-item.c7
-rw-r--r--calendar/gui/e-week-view.c20
4 files changed, 25 insertions, 62 deletions
diff --git a/calendar/gui/e-week-view-event-item.c b/calendar/gui/e-week-view-event-item.c
index 68884cc596..57f859b7df 100644
--- a/calendar/gui/e-week-view-event-item.c
+++ b/calendar/gui/e-week-view-event-item.c
@@ -387,7 +387,7 @@ week_view_draw_time (EWeekView *week_view,
static void
week_view_event_item_draw_icons (EWeekViewEventItem *event_item,
- GdkDrawable *drawable,
+ cairo_t *cr,
gint icon_x,
gint icon_y,
gint x2,
@@ -404,7 +404,6 @@ week_view_event_item_draw_icons (EWeekViewEventItem *event_item,
gboolean draw_timezone_icon = FALSE, draw_attach_icon = FALSE;
gboolean draw_meeting_icon = FALSE;
GSList *categories_pixbufs = NULL, *pixbufs;
- cairo_t *cr;
canvas = GNOME_CANVAS_ITEM (event_item)->canvas;
parent = gtk_widget_get_parent (GTK_WIDGET (canvas));
@@ -423,8 +422,6 @@ week_view_event_item_draw_icons (EWeekViewEventItem *event_item,
e_cal_component_set_icalcomponent (
comp, icalcomponent_new_clone (event->comp_data->icalcomp));
- cr = gdk_cairo_create (drawable);
-
if (e_cal_component_has_alarms (comp)) {
draw_reminder_icon = TRUE;
num_icons++;
@@ -502,7 +499,6 @@ week_view_event_item_draw_icons (EWeekViewEventItem *event_item,
g_slist_foreach (categories_pixbufs, (GFunc)g_object_unref, NULL);
g_slist_free (categories_pixbufs);
- cairo_destroy (cr);
g_object_unref (comp);
}
@@ -510,7 +506,7 @@ week_view_event_item_draw_icons (EWeekViewEventItem *event_item,
the days visible on screen. */
static void
week_view_event_item_draw_triangle (EWeekViewEventItem *event_item,
- GdkDrawable *drawable,
+ cairo_t *cr,
GdkColor bg_color,
gint x,
gint y,
@@ -526,7 +522,6 @@ week_view_event_item_draw_triangle (EWeekViewEventItem *event_item,
GdkPoint points[3];
const gchar *color_spec;
gint c1, c2;
- cairo_t *cr;
if (!can_draw_in_region (draw_region, x, y, w, h))
return;
@@ -544,8 +539,6 @@ week_view_event_item_draw_triangle (EWeekViewEventItem *event_item,
if (!is_comp_data_valid (event))
return;
- cr = gdk_cairo_create (drawable);
-
points[0].x = x;
points[0].y = y;
points[1].x = x + w;
@@ -559,20 +552,7 @@ week_view_event_item_draw_triangle (EWeekViewEventItem *event_item,
e_cal_model_get_color_for_component (model, event->comp_data);
if (gdk_color_parse (color_spec, &bg_color)) {
- GdkColormap *colormap;
-
- colormap = gtk_widget_get_colormap (GTK_WIDGET (week_view));
- if (gdk_colormap_alloc_color (colormap, &bg_color, TRUE, TRUE)) {
- gdk_cairo_set_source_color (cr, &bg_color);
- } else {
- EWeekViewColors wvc;
- GdkColor *color;
-
- wvc = E_WEEK_VIEW_COLOR_EVENT_BACKGROUND;
- color = &week_view->colors[wvc];
-
- gdk_cairo_set_source_color (cr, color);
- }
+ gdk_cairo_set_source_color (cr, &bg_color);
} else {
EWeekViewColors wvc;
GdkColor *color;
@@ -607,8 +587,6 @@ week_view_event_item_draw_triangle (EWeekViewEventItem *event_item,
cairo_move_to (cr, x, y + h - 1);
cairo_line_to (cr, x + w, c2);
cairo_restore (cr);
-
- cairo_destroy (cr);
}
static void
@@ -703,7 +681,7 @@ week_view_event_item_update (GnomeCanvasItem *item,
static void
week_view_event_item_draw (GnomeCanvasItem *canvas_item,
- GdkDrawable *drawable,
+ cairo_t *cr,
gint x,
gint y,
gint width,
@@ -723,7 +701,6 @@ week_view_event_item_draw (GnomeCanvasItem *canvas_item,
gboolean draw_start, draw_end;
gboolean draw_start_triangle = FALSE, draw_end_triangle = FALSE;
GdkColor bg_color;
- cairo_t *cr;
cairo_pattern_t *pat;
guint16 red, green, blue;
gdouble radius, cx0, cy0, rect_height, rect_width;
@@ -787,8 +764,6 @@ week_view_event_item_draw (GnomeCanvasItem *canvas_item,
return;
}
- cr = gdk_cairo_create (drawable);
-
icon_y = y1 + E_WEEK_VIEW_EVENT_BORDER_HEIGHT + E_WEEK_VIEW_ICON_Y_PAD;
/* Get the start & end times in 24-hour format. */
@@ -812,13 +787,8 @@ week_view_event_item_draw (GnomeCanvasItem *canvas_item,
e_cal_model_get_color_for_component (model, event->comp_data);
bg_color = week_view->colors[E_WEEK_VIEW_COLOR_EVENT_BACKGROUND];
- if (gdk_color_parse (color_spec, &bg_color)) {
- GdkColormap *colormap;
-
- colormap = gtk_widget_get_colormap (GTK_WIDGET (week_view));
- if (!gdk_colormap_alloc_color (colormap, &bg_color, TRUE, TRUE)) {
- bg_color = week_view->colors[E_WEEK_VIEW_COLOR_EVENT_BACKGROUND];
- }
+ if (!gdk_color_parse (color_spec, &bg_color)) {
+ bg_color = week_view->colors[E_WEEK_VIEW_COLOR_EVENT_BACKGROUND];
}
red = bg_color.red;
@@ -918,7 +888,7 @@ week_view_event_item_draw (GnomeCanvasItem *canvas_item,
/* Draw the icons. */
week_view_event_item_draw_icons (
- event_item, drawable, icon_x,
+ event_item, cr, icon_x,
icon_y, x2, FALSE, draw_region);
} else {
@@ -987,7 +957,7 @@ week_view_event_item_draw (GnomeCanvasItem *canvas_item,
if (draw_start_triangle) {
week_view_event_item_draw_triangle (
- event_item, drawable, bg_color,
+ event_item, cr, bg_color,
x1 + E_WEEK_VIEW_EVENT_L_PAD + 2,
y1, -3, y2 - y1 + 1, draw_region);
} else if (can_draw_in_region (draw_region, rect_x, y1, 1, y2 - y1)) {
@@ -1008,7 +978,7 @@ week_view_event_item_draw (GnomeCanvasItem *canvas_item,
if (draw_end_triangle) {
week_view_event_item_draw_triangle (
- event_item, drawable, bg_color,
+ event_item, cr, bg_color,
x2 - E_WEEK_VIEW_EVENT_R_PAD - 2,
y1, 3, y2 - y1 + 1, draw_region);
} else if (can_draw_in_region (draw_region, rect_x2, y2, 1, 1)) {
@@ -1098,11 +1068,10 @@ week_view_event_item_draw (GnomeCanvasItem *canvas_item,
|| week_view->editing_span_num != event_item->priv->span_num)) {
icon_x = span->text_item->x1 - E_WEEK_VIEW_ICON_R_PAD - x;
week_view_event_item_draw_icons (
- event_item, drawable, icon_x,
+ event_item, cr, icon_x,
icon_y, max_icon_x, TRUE, draw_region);
}
}
- cairo_destroy (cr);
cairo_region_destroy (draw_region);
}
diff --git a/calendar/gui/e-week-view-main-item.c b/calendar/gui/e-week-view-main-item.c
index 252aa3c299..ae4316ca50 100644
--- a/calendar/gui/e-week-view-main-item.c
+++ b/calendar/gui/e-week-view-main-item.c
@@ -69,7 +69,7 @@ static void
week_view_main_item_draw_day (EWeekViewMainItem *main_item,
gint day,
GDate *date,
- GdkDrawable *drawable,
+ cairo_t *cr,
gint x,
gint y,
gint width,
@@ -87,12 +87,10 @@ week_view_main_item_draw_day (EWeekViewMainItem *main_item,
PangoFontMetrics *font_metrics;
PangoLayout *layout;
gboolean today = FALSE;
- cairo_t *cr;
CalWeekdays working_days;
week_view = e_week_view_main_item_get_week_view (main_item);
style = gtk_widget_get_style (GTK_WIDGET (week_view));
- cr = gdk_cairo_create (drawable);
/* Set up Pango prerequisites */
font_desc = pango_font_description_copy (style->font_desc);
@@ -295,7 +293,6 @@ week_view_main_item_draw_day (EWeekViewMainItem *main_item,
}
pango_font_metrics_unref (font_metrics);
pango_font_description_free (font_desc);
- cairo_destroy (cr);
}
static void
@@ -368,7 +365,7 @@ week_view_main_item_update (GnomeCanvasItem *item,
static void
week_view_main_item_draw (GnomeCanvasItem *canvas_item,
- GdkDrawable *drawable,
+ cairo_t *cr,
gint x,
gint y,
gint width,
@@ -399,7 +396,7 @@ week_view_main_item_draw (GnomeCanvasItem *canvas_item,
if (day_x < x + width && day_x + day_w >= x
&& day_y < y + height && day_y + day_h >= y) {
week_view_main_item_draw_day (
- main_item, day, &date, drawable,
+ main_item, day, &date, cr,
day_x - x, day_y - y, day_w, day_h);
}
g_date_add_days (&date, 1);
diff --git a/calendar/gui/e-week-view-titles-item.c b/calendar/gui/e-week-view-titles-item.c
index 2a5056d7f4..7ea7b1ffdc 100644
--- a/calendar/gui/e-week-view-titles-item.c
+++ b/calendar/gui/e-week-view-titles-item.c
@@ -115,7 +115,7 @@ week_view_titles_item_update (GnomeCanvasItem *item,
static void
week_view_titles_item_draw (GnomeCanvasItem *canvas_item,
- GdkDrawable *drawable,
+ cairo_t *cr,
gint x,
gint y,
gint width,
@@ -130,13 +130,12 @@ week_view_titles_item_draw (GnomeCanvasItem *canvas_item,
gboolean abbreviated;
gint weekday;
PangoLayout *layout;
- cairo_t *cr;
titles_item = E_WEEK_VIEW_TITLES_ITEM (canvas_item);
week_view = e_week_view_titles_item_get_week_view (titles_item);
g_return_if_fail (week_view != NULL);
- cr = gdk_cairo_create (drawable);
+ cairo_save (cr);
cairo_set_line_width (cr, 1.0);
gtk_widget_get_allocation (
@@ -234,7 +233,7 @@ week_view_titles_item_draw (GnomeCanvasItem *canvas_item,
}
g_object_unref (layout);
- cairo_destroy (cr);
+ cairo_restore (cr);
}
static GnomeCanvasItem *
diff --git a/calendar/gui/e-week-view.c b/calendar/gui/e-week-view.c
index acba2b6700..6497ec7694 100644
--- a/calendar/gui/e-week-view.c
+++ b/calendar/gui/e-week-view.c
@@ -1045,13 +1045,9 @@ e_week_view_get_text_color (EWeekView *week_view, EWeekViewEvent *event, GtkWidg
if (is_comp_data_valid (event) && gdk_color_parse (e_cal_model_get_color_for_component (e_calendar_view_get_model (E_CALENDAR_VIEW (week_view)), event->comp_data),
&bg_color)) {
- GdkColormap *colormap;
- colormap = gtk_widget_get_colormap (GTK_WIDGET (week_view));
- if (gdk_colormap_alloc_color (colormap, &bg_color, TRUE, TRUE)) {
- red = bg_color.red;
- green = bg_color.green;
- blue = bg_color.blue;
- }
+ red = bg_color.red;
+ green = bg_color.green;
+ blue = bg_color.blue;
}
style = gtk_widget_get_style (widget);
@@ -2911,14 +2907,16 @@ e_week_view_reshape_events (EWeekView *week_view)
if (week_view->rows_per_day[day] <= max_rows) {
gnome_canvas_item_hide (week_view->jump_buttons[day]);
} else {
+ cairo_matrix_t matrix;
+
e_week_view_get_day_position (week_view, day,
&day_x, &day_y,
&day_w, &day_h);
- gnome_canvas_item_set (week_view->jump_buttons[day],
- "GnomeCanvasPixbuf::x", (gdouble) (day_x + day_w - E_WEEK_VIEW_JUMP_BUTTON_X_PAD - E_WEEK_VIEW_JUMP_BUTTON_WIDTH),
- "GnomeCanvasPixbuf::y", (gdouble) (day_y + day_h - E_WEEK_VIEW_JUMP_BUTTON_Y_PAD - E_WEEK_VIEW_JUMP_BUTTON_HEIGHT),
- NULL);
+ cairo_matrix_init_translate (&matrix,
+ day_x + day_w - E_WEEK_VIEW_JUMP_BUTTON_X_PAD - E_WEEK_VIEW_JUMP_BUTTON_WIDTH,
+ day_y + day_h - E_WEEK_VIEW_JUMP_BUTTON_Y_PAD - E_WEEK_VIEW_JUMP_BUTTON_HEIGHT);
+ gnome_canvas_item_set_matrix (week_view->jump_buttons[day], &matrix);
gnome_canvas_item_show (week_view->jump_buttons[day]);
gnome_canvas_item_raise_to_top (week_view->jump_buttons[day]);