diff options
author | Hans Petter Jansson <hpj@ximian.com> | 2003-04-16 05:43:05 +0800 |
---|---|---|
committer | Hans Petter <hansp@src.gnome.org> | 2003-04-16 05:43:05 +0800 |
commit | db8f0cbfbccccab53f43872307079eb43625726d (patch) | |
tree | 7ca45a79fa94671fd9658481c3e67436321d737f /widgets/misc/e-calendar-item.c | |
parent | bd5da6d3e16a9a5076ce6fd61b7abe9f7ecaf811 (diff) | |
download | gsoc2013-evolution-db8f0cbfbccccab53f43872307079eb43625726d.tar.gz gsoc2013-evolution-db8f0cbfbccccab53f43872307079eb43625726d.tar.zst gsoc2013-evolution-db8f0cbfbccccab53f43872307079eb43625726d.zip |
Unref the metrics. (e_calendar_item_draw): Re-use the widget's context
2003-04-15 Hans Petter Jansson <hpj@ximian.com>
* e-calendar-item.c (e_calendar_item_update): Unref the metrics.
(e_calendar_item_draw): Re-use the widget's context instead of
creating a new one. Unref the metrics.
(e_calendar_item_draw_month): Unref the metrics. Don't create the
layout where it might be leaked by an early return. Unref the layout
before returning if we're outside the clip area.
(e_calendar_item_draw_day_numbers): Unref the metrics.
(e_calendar_item_recalc_sizes): Unref the metrics.
(e_calendar_item_convert_position_to_day): Unref the metrics.
* e-calendar.c (e_calendar_size_allocate): Unref the metrics.
svn path=/trunk/; revision=20855
Diffstat (limited to 'widgets/misc/e-calendar-item.c')
-rw-r--r-- | widgets/misc/e-calendar-item.c | 20 |
1 files changed, 17 insertions, 3 deletions
diff --git a/widgets/misc/e-calendar-item.c b/widgets/misc/e-calendar-item.c index d5a9b37a7b..06b3691095 100644 --- a/widgets/misc/e-calendar-item.c +++ b/widgets/misc/e-calendar-item.c @@ -891,6 +891,8 @@ e_calendar_item_update (GnomeCanvasItem *item, gnome_canvas_request_redraw (item->canvas, item->x1, item->y1, item->x2, item->y2); + + pango_font_metrics_unref (font_metrics); } @@ -926,7 +928,7 @@ e_calendar_item_draw (GnomeCanvasItem *canvas_item, font_desc = calitem->font_desc; if (!font_desc) font_desc = style->font_desc; - pango_context = gtk_widget_create_pango_context (GTK_WIDGET (canvas_item->canvas)); + pango_context = gtk_widget_get_pango_context (GTK_WIDGET (canvas_item->canvas)); font_metrics = pango_context_get_metrics (pango_context, font_desc, pango_context_get_language (pango_context)); @@ -993,6 +995,8 @@ e_calendar_item_draw (GnomeCanvasItem *canvas_item, row_y += calitem->month_height; } + + pango_font_metrics_unref (font_metrics); } @@ -1046,7 +1050,8 @@ e_calendar_item_draw_month (ECalendarItem *calitem, xthickness = style->xthickness; ythickness = style->ythickness; fg_gc = style->fg_gc[GTK_STATE_NORMAL]; - layout = gtk_widget_create_pango_layout (widget, NULL); + + pango_font_metrics_unref (font_metrics); /* Calculate the top-left position of the entire month display. */ month_x = item->x1 + xthickness + calitem->x_offset @@ -1068,6 +1073,9 @@ e_calendar_item_draw_month (ECalendarItem *calitem, /* Draw the month name & year, with clipping. Note that the top row needs extra space around it for the buttons. */ + + layout = gtk_widget_create_pango_layout (widget, NULL); + if (row == 0 && col == 0) min_x = E_CALENDAR_ITEM_XPAD_BEFORE_MONTH_NAME_WITH_BUTTON; else @@ -1122,8 +1130,10 @@ e_calendar_item_draw_month (ECalendarItem *calitem, clip_width = month_x + month_w - clip_rect.x; clip_height = month_y + month_h - clip_rect.y; - if (clip_width <= 0 || clip_height <= 0) + if (clip_width <= 0 || clip_height <= 0) { + g_object_unref (layout); return; + } clip_rect.width = clip_width; clip_rect.height = clip_height; @@ -1492,6 +1502,7 @@ e_calendar_item_draw_day_numbers (ECalendarItem *calitem, gdk_gc_set_foreground (fg_gc, &style->fg[GTK_STATE_NORMAL]); g_object_unref (layout); + pango_font_metrics_unref (font_metrics); } @@ -1668,6 +1679,7 @@ e_calendar_item_recalc_sizes (ECalendarItem *calitem) g_object_unref (layout); g_object_unref (pango_context); + pango_font_metrics_unref (font_metrics); } @@ -2057,6 +2069,8 @@ e_calendar_item_convert_position_to_day (ECalendarItem *calitem, xthickness = style->xthickness; ythickness = style->ythickness; + pango_font_metrics_unref (font_metrics); + *entire_week = FALSE; x = event_x - xthickness - calitem->x_offset; |