aboutsummaryrefslogtreecommitdiffstats
path: root/calendar/gui
diff options
context:
space:
mode:
authorMatthew Barnes <mbarnes@redhat.com>2011-01-15 23:21:08 +0800
committerRodrigo Moya <rodrigo@gnome-db.org>2011-06-30 00:41:27 +0800
commitd0f088d329977e9a5f8aa4d4cf1122596eb8704f (patch)
tree98a07deb70995661f871b0e85fe1b700ce1e7691 /calendar/gui
parentbd98a2d620a9403637db1010966cb0a707a547b7 (diff)
downloadgsoc2013-evolution-d0f088d329977e9a5f8aa4d4cf1122596eb8704f.tar.gz
gsoc2013-evolution-d0f088d329977e9a5f8aa4d4cf1122596eb8704f.tar.zst
gsoc2013-evolution-d0f088d329977e9a5f8aa4d4cf1122596eb8704f.zip
Adapt EDayView + widgets to latest gtk+-3.0 API.
Diffstat (limited to 'calendar/gui')
-rw-r--r--calendar/gui/e-day-view-main-item.c91
-rw-r--r--calendar/gui/e-day-view-time-item.c27
-rw-r--r--calendar/gui/e-day-view-top-item.c53
-rw-r--r--calendar/gui/e-day-view.c12
4 files changed, 46 insertions, 137 deletions
diff --git a/calendar/gui/e-day-view-main-item.c b/calendar/gui/e-day-view-main-item.c
index 061224b04f..7e5fed0275 100644
--- a/calendar/gui/e-day-view-main-item.c
+++ b/calendar/gui/e-day-view-main-item.c
@@ -88,7 +88,7 @@ icalcomp_is_transparent (icalcomponent *icalcomp)
static void
day_view_main_item_draw_long_events_in_vbars (EDayViewMainItem *main_item,
- GdkDrawable *drawable,
+ cairo_t *cr,
gint x,
gint y,
gint width,
@@ -100,7 +100,6 @@ day_view_main_item_draw_long_events_in_vbars (EDayViewMainItem *main_item,
ECalendarView *cal_view;
gint time_divisions;
gint event_num, start_day, end_day, day, bar_y1, bar_y2, grid_x;
- cairo_t *cr = NULL;
GdkColor bg_color;
day_view = e_day_view_main_item_get_day_view (main_item);
@@ -148,40 +147,28 @@ day_view_main_item_draw_long_events_in_vbars (EDayViewMainItem *main_item,
}
if (bar_y1 < height && bar_y2 > 0 && bar_y2 > bar_y1 && can_draw_in_region (draw_region, grid_x, bar_y1, E_DAY_VIEW_BAR_WIDTH - 2, bar_y2 - bar_y1)) {
- if (!cr) {
- cr = gdk_cairo_create (drawable);
- cairo_save (cr);
- gdk_cairo_set_source_color (cr, &day_view->colors[E_DAY_VIEW_COLOR_EVENT_BACKGROUND]);
- }
+ cairo_save (cr);
+ gdk_cairo_set_source_color (cr, &day_view->colors[E_DAY_VIEW_COLOR_EVENT_BACKGROUND]);
if (first) {
first = FALSE;
if (gdk_color_parse (e_cal_model_get_color_for_component (e_calendar_view_get_model (E_CALENDAR_VIEW (day_view)), event->comp_data), &bg_color)) {
- GdkColormap *colormap;
-
- colormap = gtk_widget_get_colormap (GTK_WIDGET (day_view));
- if (gdk_colormap_alloc_color (colormap, &bg_color, TRUE, TRUE)) {
- gdk_cairo_set_source_color (cr, &bg_color);
- }
+ gdk_cairo_set_source_color (cr, &bg_color);
}
}
cairo_rectangle (cr, grid_x, bar_y1, E_DAY_VIEW_BAR_WIDTH - 2, bar_y2 - bar_y1);
cairo_fill (cr);
+ cairo_restore (cr);
}
}
}
-
- if (cr) {
- cairo_restore (cr);
- cairo_destroy (cr);
- }
}
static void
day_view_main_item_draw_day_event (EDayViewMainItem *main_item,
- GdkDrawable *drawable,
+ cairo_t *cr,
gint x,
gint y,
gint width,
@@ -203,7 +190,6 @@ day_view_main_item_draw_day_event (EDayViewMainItem *main_item,
gboolean draw_reminder_icon, draw_recurrence_icon, draw_timezone_icon, draw_meeting_icon;
gboolean draw_attach_icon;
ECalComponentTransparency transparency;
- cairo_t *cr;
cairo_pattern_t *pat;
cairo_font_options_t *font_options;
guint16 red, green, blue;
@@ -247,24 +233,19 @@ day_view_main_item_draw_day_event (EDayViewMainItem *main_item,
if (!can_draw_in_region (draw_region, item_x, item_y, item_w, item_h))
return;
- cr = gdk_cairo_create (drawable);
gdk_cairo_set_source_color (cr,
&day_view->colors[E_DAY_VIEW_COLOR_EVENT_VBAR]);
font_options = get_font_options ();
- if (!is_array_index_in_bounds (day_view->events[day], event_num)) {
- cairo_destroy (cr);
+ if (!is_array_index_in_bounds (day_view->events[day], event_num))
return;
- }
event = &g_array_index (day_view->events[day], EDayViewEvent,
event_num);
- if (!is_comp_data_valid (event)) {
- cairo_destroy (cr);
+ if (!is_comp_data_valid (event))
return;
- }
/* Fill in the event background. Note that for events in the first
column of the day, we might not want to paint over the vertical bar,
@@ -278,14 +259,9 @@ day_view_main_item_draw_day_event (EDayViewMainItem *main_item,
if (gdk_color_parse (e_cal_model_get_color_for_component (e_calendar_view_get_model (E_CALENDAR_VIEW (day_view)), event->comp_data),
&bg_color)) {
- GdkColormap *colormap;
-
- colormap = gtk_widget_get_colormap (GTK_WIDGET (day_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;
}
is_editing = day_view->editing_event_day == day && day_view->editing_event_num == event_num;
@@ -429,6 +405,9 @@ day_view_main_item_draw_day_event (EDayViewMainItem *main_item,
}
cairo_restore (cr);
}
+
+ item_x += 1;
+ item_y += 2;
}
/* Draw the background of the event with white to play with transparency */
@@ -825,12 +804,11 @@ day_view_main_item_draw_day_event (EDayViewMainItem *main_item,
g_free (text);
g_object_unref (comp);
- cairo_destroy (cr);
}
static void
day_view_main_item_draw_day_events (EDayViewMainItem *main_item,
- GdkDrawable *drawable,
+ cairo_t *cr,
gint x,
gint y,
gint width,
@@ -846,14 +824,14 @@ day_view_main_item_draw_day_events (EDayViewMainItem *main_item,
for (event_num = 0; event_num < day_view->events[day]->len;
event_num++) {
day_view_main_item_draw_day_event (
- main_item, drawable, x, y, width, height,
+ main_item, cr, x, y, width, height,
day, event_num, draw_region);
}
}
static void
day_view_main_item_draw_events_in_vbars (EDayViewMainItem *main_item,
- GdkDrawable *drawable,
+ cairo_t *cr,
gint x,
gint y,
gint width,
@@ -866,7 +844,6 @@ day_view_main_item_draw_events_in_vbars (EDayViewMainItem *main_item,
ECalendarView *cal_view;
gint time_divisions;
gint grid_x, event_num, bar_y, bar_h;
- cairo_t *cr = NULL;
GdkColor bg_color;
day_view = e_day_view_main_item_get_day_view (main_item);
@@ -903,30 +880,19 @@ day_view_main_item_draw_events_in_vbars (EDayViewMainItem *main_item,
continue;
}
- if (!cr) {
- cr = gdk_cairo_create (drawable);
- cairo_save (cr);
+ cairo_save (cr);
- gdk_cairo_set_source_color (cr, &day_view->colors[E_DAY_VIEW_COLOR_EVENT_BACKGROUND]);
- }
+ gdk_cairo_set_source_color (cr, &day_view->colors[E_DAY_VIEW_COLOR_EVENT_BACKGROUND]);
if (gdk_color_parse (e_cal_model_get_color_for_component (e_calendar_view_get_model (E_CALENDAR_VIEW (day_view)), event->comp_data), &bg_color)) {
- GdkColormap *colormap;
-
- colormap = gtk_widget_get_colormap (GTK_WIDGET (day_view));
- if (gdk_colormap_alloc_color (colormap, &bg_color, TRUE, TRUE)) {
- gdk_cairo_set_source_color (cr, &bg_color);
- }
+ gdk_cairo_set_source_color (cr, &bg_color);
}
cairo_rectangle (cr, grid_x, bar_y, E_DAY_VIEW_BAR_WIDTH - 2, bar_h);
cairo_fill (cr);
- }
- if (cr) {
cairo_restore (cr);
- cairo_destroy (cr);
}
}
@@ -1000,7 +966,7 @@ day_view_main_item_update (GnomeCanvasItem *item,
static void
day_view_main_item_draw (GnomeCanvasItem *canvas_item,
- GdkDrawable *drawable,
+ cairo_t *cr,
gint x,
gint y,
gint width,
@@ -1022,13 +988,10 @@ day_view_main_item_draw (GnomeCanvasItem *canvas_item,
gint start_row, end_row, rect_x, rect_y, rect_width, rect_height;
struct icaltimetype day_start_tt, today_tt;
gint weekday;
- cairo_t *cr;
gboolean today = FALSE;
cairo_region_t *draw_region;
GdkRectangle rect;
- cr = gdk_cairo_create (drawable);
-
main_item = E_DAY_VIEW_MAIN_ITEM (canvas_item);
day_view = e_day_view_main_item_get_day_view (main_item);
g_return_if_fail (day_view != NULL);
@@ -1199,20 +1162,20 @@ day_view_main_item_draw (GnomeCanvasItem *canvas_item,
/* Fill in the bars when the user is busy. */
day_view_main_item_draw_events_in_vbars (
- main_item, drawable, x, y,
+ main_item, cr, x, y,
width, height, day, draw_region);
}
/* Fill in the vertical bars corresponding to the busy times from the
long events. */
day_view_main_item_draw_long_events_in_vbars (
- main_item, drawable, x, y, width, height, draw_region);
+ main_item, cr, x, y, width, height, draw_region);
/* Draw the event borders and backgrounds, and the vertical bars
down the left edges. */
for (day = 0; day < day_view->days_shown; day++)
day_view_main_item_draw_day_events (
- main_item, drawable, x, y,
+ main_item, cr, x, y,
width, height, day, draw_region);
if (e_day_view_marcus_bains_get_show_line (day_view)) {
@@ -1226,11 +1189,7 @@ day_view_main_item_draw (GnomeCanvasItem *canvas_item,
&day_view->colors[E_DAY_VIEW_COLOR_MARCUS_BAINS_LINE]);
if (day_view->marcus_bains_day_view_color && gdk_color_parse (day_view->marcus_bains_day_view_color, &mb_color)) {
- GdkColormap *colormap;
-
- colormap = gtk_widget_get_colormap (GTK_WIDGET (day_view));
- if (gdk_colormap_alloc_color (colormap, &mb_color, TRUE, TRUE))
- gdk_cairo_set_source_color (cr, &mb_color);
+ gdk_cairo_set_source_color (cr, &mb_color);
}
zone = e_calendar_view_get_timezone (E_CALENDAR_VIEW (day_view));
time_now = icaltime_current_time_with_zone (zone);
diff --git a/calendar/gui/e-day-view-time-item.c b/calendar/gui/e-day-view-time-item.c
index 35a8e3ebda..2340f25220 100644
--- a/calendar/gui/e-day-view-time-item.c
+++ b/calendar/gui/e-day-view-time-item.c
@@ -77,7 +77,7 @@ static void e_day_view_time_item_update (GnomeCanvasItem *item,
const cairo_matrix_t *i2c,
gint flags);
static void e_day_view_time_item_draw (GnomeCanvasItem *item,
- GdkDrawable *drawable,
+ cairo_t *cr,
gint x, gint y,
gint width, gint height);
static GnomeCanvasItem *e_day_view_time_item_point (GnomeCanvasItem *item,
@@ -275,7 +275,7 @@ e_day_view_time_item_update (GnomeCanvasItem *item,
*/
static void
edvti_draw_zone (GnomeCanvasItem *canvas_item,
- GdkDrawable *drawable,
+ cairo_t *cr,
gint x,
gint y,
gint width,
@@ -301,12 +301,9 @@ edvti_draw_zone (GnomeCanvasItem *canvas_item,
PangoContext *context;
PangoFontDescription *small_font_desc;
PangoFontMetrics *large_font_metrics, *small_font_metrics;
- cairo_t *cr;
GdkColor fg, dark;
GdkColor mb_color;
- cr = gdk_cairo_create (drawable);
-
time_item = E_DAY_VIEW_TIME_ITEM (canvas_item);
day_view = e_day_view_time_item_get_day_view (time_item);
g_return_if_fail (day_view != NULL);
@@ -431,12 +428,8 @@ edvti_draw_zone (GnomeCanvasItem *canvas_item,
gdk_cairo_set_source_color (cr, &day_view->colors[E_DAY_VIEW_COLOR_MARCUS_BAINS_LINE]);
if (day_view->marcus_bains_time_bar_color && gdk_color_parse (day_view->marcus_bains_time_bar_color, &mb_color)) {
- GdkColormap *colormap;
- colormap = gtk_widget_get_colormap (GTK_WIDGET (day_view));
- if (gdk_colormap_alloc_color (colormap, &mb_color, TRUE, TRUE)) {
- gdk_cairo_set_source_color (cr, &mb_color);
- }
+ gdk_cairo_set_source_color (cr, &mb_color);
} else
mb_color = day_view->colors[E_DAY_VIEW_COLOR_MARCUS_BAINS_LINE];
@@ -451,12 +444,7 @@ edvti_draw_zone (GnomeCanvasItem *canvas_item,
mb_color = day_view->colors[E_DAY_VIEW_COLOR_MARCUS_BAINS_LINE];
if (day_view->marcus_bains_time_bar_color && gdk_color_parse (day_view->marcus_bains_time_bar_color, &mb_color)) {
- GdkColormap *colormap;
-
- colormap = gtk_widget_get_colormap (GTK_WIDGET (day_view));
- if (gdk_colormap_alloc_color (colormap, &mb_color, TRUE, TRUE)) {
- gdk_cairo_set_source_color (cr, &mb_color);
- }
+ gdk_cairo_set_source_color (cr, &mb_color);
}
}
@@ -609,7 +597,6 @@ edvti_draw_zone (GnomeCanvasItem *canvas_item,
pango_font_metrics_unref (large_font_metrics);
pango_font_metrics_unref (small_font_metrics);
- cairo_destroy (cr);
g_free (midnight_day);
g_free (midnight_month);
@@ -617,7 +604,7 @@ edvti_draw_zone (GnomeCanvasItem *canvas_item,
static void
e_day_view_time_item_draw (GnomeCanvasItem *canvas_item,
- GdkDrawable *drawable,
+ cairo_t *cr,
gint x,
gint y,
gint width,
@@ -628,10 +615,10 @@ e_day_view_time_item_draw (GnomeCanvasItem *canvas_item,
time_item = E_DAY_VIEW_TIME_ITEM (canvas_item);
g_return_if_fail (time_item != NULL);
- edvti_draw_zone (canvas_item, drawable, x, y, width, height, 0, NULL);
+ edvti_draw_zone (canvas_item, cr, x, y, width, height, 0, NULL);
if (time_item->priv->second_zone)
- edvti_draw_zone (canvas_item, drawable, x, y, width, height, time_item->priv->column_width, time_item->priv->second_zone);
+ edvti_draw_zone (canvas_item, cr, x, y, width, height, time_item->priv->column_width, time_item->priv->second_zone);
}
/* Increment the time by the 5/10/15/30/60 minute interval.
diff --git a/calendar/gui/e-day-view-top-item.c b/calendar/gui/e-day-view-top-item.c
index e517e75781..def481ea2a 100644
--- a/calendar/gui/e-day-view-top-item.c
+++ b/calendar/gui/e-day-view-top-item.c
@@ -61,7 +61,7 @@ static gpointer parent_class;
the days visible on screen. */
static void
day_view_top_item_draw_triangle (EDayViewTopItem *top_item,
- GdkDrawable *drawable,
+ cairo_t *cr,
gint x,
gint y,
gint w,
@@ -73,7 +73,6 @@ day_view_top_item_draw_triangle (EDayViewTopItem *top_item,
GdkColor bg_color;
GdkPoint points[3];
gint c1, c2;
- cairo_t *cr;
day_view = e_day_view_top_item_get_day_view (top_item);
@@ -99,24 +98,13 @@ day_view_top_item_draw_triangle (EDayViewTopItem *top_item,
if (!is_comp_data_valid (event))
return;
- cr = gdk_cairo_create (drawable);
-
cairo_save (cr);
/* Fill it in. */
if (gdk_color_parse (
e_cal_model_get_color_for_component (
e_calendar_view_get_model (E_CALENDAR_VIEW (day_view)),
event->comp_data), &bg_color)) {
- GdkColormap *colormap;
-
- colormap = gtk_widget_get_colormap (GTK_WIDGET (day_view));
- if (gdk_colormap_alloc_color (colormap, &bg_color, TRUE, TRUE)) {
- gdk_cairo_set_source_color (cr, &bg_color);
- } else {
- gdk_cairo_set_source_color (
- cr, &day_view->colors
- [E_DAY_VIEW_COLOR_LONG_EVENT_BACKGROUND]);
- }
+ gdk_cairo_set_source_color (cr, &bg_color);
} else {
gdk_cairo_set_source_color (
cr, &day_view->colors
@@ -139,15 +127,13 @@ day_view_top_item_draw_triangle (EDayViewTopItem *top_item,
cairo_line_to (cr, x + w, c2);
cairo_stroke (cr);
cairo_restore (cr);
-
- cairo_destroy (cr);
}
/* This draws one event in the top canvas. */
static void
day_view_top_item_draw_long_event (EDayViewTopItem *top_item,
gint event_num,
- GdkDrawable *drawable,
+ cairo_t *cr,
gint x,
gint y,
gint width,
@@ -169,7 +155,6 @@ day_view_top_item_draw_long_event (EDayViewTopItem *top_item,
GSList *categories_list, *elem;
PangoLayout *layout;
GdkColor bg_color;
- cairo_t *cr;
cairo_pattern_t *pat;
guint16 red, green, blue;
gdouble cc = 65535.0;
@@ -199,8 +184,6 @@ day_view_top_item_draw_long_event (EDayViewTopItem *top_item,
if (!is_comp_data_valid (event))
return;
- cr = gdk_cairo_create (drawable);
-
style = gtk_widget_get_style (GTK_WIDGET (day_view));
comp = e_cal_component_new ();
e_cal_component_set_icalcomponent (
@@ -210,18 +193,9 @@ day_view_top_item_draw_long_event (EDayViewTopItem *top_item,
e_cal_model_get_color_for_component (
e_calendar_view_get_model (E_CALENDAR_VIEW (day_view)),
event->comp_data), &bg_color)) {
- GdkColormap *colormap;
-
- colormap = gtk_widget_get_colormap (GTK_WIDGET (day_view));
- if (gdk_colormap_alloc_color (colormap, &bg_color, TRUE, TRUE)) {
- red = bg_color.red;
- green = bg_color.green;
- blue = bg_color.blue;
- } else {
- red = day_view->colors[E_DAY_VIEW_COLOR_LONG_EVENT_BACKGROUND].red;
- green = day_view->colors[E_DAY_VIEW_COLOR_LONG_EVENT_BACKGROUND].green;
- blue = day_view->colors[E_DAY_VIEW_COLOR_LONG_EVENT_BACKGROUND].blue;
- }
+ red = bg_color.red;
+ green = bg_color.green;
+ blue = bg_color.blue;
} else {
red = day_view->colors[E_DAY_VIEW_COLOR_LONG_EVENT_BACKGROUND].red;
green = day_view->colors[E_DAY_VIEW_COLOR_LONG_EVENT_BACKGROUND].green;
@@ -304,7 +278,7 @@ day_view_top_item_draw_long_event (EDayViewTopItem *top_item,
if (draw_start_triangle
&& event->start < day_view->day_starts[start_day]) {
day_view_top_item_draw_triangle (
- top_item, drawable, item_x - x + 4, item_y - y,
+ top_item, cr, item_x - x + 4, item_y - y,
-E_DAY_VIEW_BAR_WIDTH, item_h, event_num);
}
@@ -312,7 +286,7 @@ day_view_top_item_draw_long_event (EDayViewTopItem *top_item,
if (draw_end_triangle
&& event->end > day_view->day_starts[end_day + 1]) {
day_view_top_item_draw_triangle (
- top_item, drawable, item_x + item_w - 4 - x,
+ top_item, cr, item_x + item_w - 4 - x,
item_y - y, E_DAY_VIEW_BAR_WIDTH, item_h,
event_num);
}
@@ -322,7 +296,6 @@ day_view_top_item_draw_long_event (EDayViewTopItem *top_item,
if (day_view->editing_event_day == E_DAY_VIEW_LONG_EVENT
&& day_view->editing_event_num == event_num) {
g_object_unref (comp);
- cairo_destroy (cr);
return;
}
@@ -497,7 +470,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);
}
static void
@@ -582,7 +554,7 @@ day_view_top_item_update (GnomeCanvasItem *item,
static void
day_view_top_item_draw (GnomeCanvasItem *canvas_item,
- GdkDrawable *drawable,
+ cairo_t *cr,
gint x,
gint y,
gint width,
@@ -597,7 +569,6 @@ day_view_top_item_draw (GnomeCanvasItem *canvas_item,
gint canvas_width, canvas_height, left_edge, day, date_width, date_x;
gint item_height, event_num;
PangoLayout *layout;
- cairo_t *cr;
GdkColor bg, light, dark;
gboolean show_dates;
@@ -606,8 +577,6 @@ day_view_top_item_draw (GnomeCanvasItem *canvas_item,
g_return_if_fail (day_view != NULL);
show_dates = top_item->priv->show_dates;
- cr = gdk_cairo_create (drawable);
-
style = gtk_widget_get_style (GTK_WIDGET (day_view));
gtk_widget_get_allocation (
GTK_WIDGET (canvas_item->canvas), &allocation);
@@ -760,12 +729,10 @@ day_view_top_item_draw (GnomeCanvasItem *canvas_item,
/* Draw the long events. */
for (event_num = 0; event_num < day_view->long_events->len; event_num++) {
day_view_top_item_draw_long_event (
- top_item, event_num, drawable,
+ top_item, event_num, cr,
x, y, width, height);
}
}
-
- cairo_destroy (cr);
}
static GnomeCanvasItem *
diff --git a/calendar/gui/e-day-view.c b/calendar/gui/e-day-view.c
index a183553456..a548b764c0 100644
--- a/calendar/gui/e-day-view.c
+++ b/calendar/gui/e-day-view.c
@@ -1262,7 +1262,7 @@ e_day_view_on_canvas_realized (GtkWidget *widget,
GdkWindow *window;
window = gtk_layout_get_bin_window (GTK_LAYOUT (widget));
- gdk_window_set_back_pixmap (window, NULL, FALSE);
+ gdk_window_set_background_pattern (window, NULL);
}
/**
@@ -1440,13 +1440,9 @@ e_day_view_get_text_color (EDayView *day_view, EDayViewEvent *event, GtkWidget *
if (is_comp_data_valid (event) && gdk_color_parse (e_cal_model_get_color_for_component (e_calendar_view_get_model (E_CALENDAR_VIEW (day_view)), event->comp_data),
&bg_color)) {
- GdkColormap *colormap;
- colormap = gtk_widget_get_colormap (GTK_WIDGET (day_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);