[evolution/gtk3: 5/10] Adapt ECalendarItem to latest gtk+-3.0 API.



commit cc0c77ba12d22acb884b37aa049bd9ba93668e61
Author: Matthew Barnes <mbarnes redhat com>
Date:   Tue Nov 9 09:57:28 2010 -0500

    Adapt ECalendarItem to latest gtk+-3.0 API.

 widgets/misc/e-calendar-item.c |   64 ++++++++++------------------------------
 1 files changed, 16 insertions(+), 48 deletions(-)
---
diff --git a/widgets/misc/e-calendar-item.c b/widgets/misc/e-calendar-item.c
index 6afe62d..1ba94a2 100644
--- a/widgets/misc/e-calendar-item.c
+++ b/widgets/misc/e-calendar-item.c
@@ -59,19 +59,18 @@ static void e_calendar_item_set_property (GObject	 *object,
 					 const GValue	 *value,
 					 GParamSpec	 *pspec);
 static void e_calendar_item_realize	(GnomeCanvasItem *item);
-static void e_calendar_item_unrealize	(GnomeCanvasItem *item);
 static void e_calendar_item_unmap	(GnomeCanvasItem *item);
 static void e_calendar_item_update	(GnomeCanvasItem *item,
 					 const cairo_matrix_t *i2c,
 					 gint		  flags);
 static void e_calendar_item_draw	(GnomeCanvasItem *item,
-					 GdkDrawable	 *drawable,
+					 cairo_t	 *cr,
 					 gint		  x,
 					 gint		  y,
 					 gint		  width,
 					 gint		  height);
 static void e_calendar_item_draw_month	(ECalendarItem   *calitem,
-					 GdkDrawable	 *drawable,
+					 cairo_t	 *cr,
 					 gint		  x,
 					 gint		  y,
 					 gint		  width,
@@ -79,7 +78,7 @@ static void e_calendar_item_draw_month	(ECalendarItem   *calitem,
 					 gint		  row,
 					 gint		  col);
 static void e_calendar_item_draw_day_numbers (ECalendarItem	*calitem,
-					      GdkDrawable	*drawable,
+					      cairo_t		*cr,
 					      gint		 width,
 					      gint		 height,
 					      gint		 row,
@@ -251,7 +250,6 @@ e_calendar_item_class_init (ECalendarItemClass *class)
 
 	item_class = GNOME_CANVAS_ITEM_CLASS (class);
 	item_class->realize = e_calendar_item_realize;
-	item_class->unrealize = e_calendar_item_unrealize;
 	item_class->unmap = e_calendar_item_unmap;
 	item_class->update = e_calendar_item_update;
 	item_class->draw = e_calendar_item_draw;
@@ -857,22 +855,6 @@ e_calendar_item_realize		(GnomeCanvasItem *item)
 }
 
 static void
-e_calendar_item_unrealize	(GnomeCanvasItem *item)
-{
-	ECalendarItem *calitem;
-	GdkColormap *colormap;
-
-	calitem = E_CALENDAR_ITEM (item);
-
-	colormap = gtk_widget_get_colormap (GTK_WIDGET (item->canvas));
-
-	gdk_colormap_free_colors (colormap, calitem->colors, E_CALENDAR_ITEM_COLOR_LAST);
-
-	if (GNOME_CANVAS_ITEM_CLASS (e_calendar_item_parent_class)->unrealize)
-		(* GNOME_CANVAS_ITEM_CLASS (e_calendar_item_parent_class)->unrealize) (item);
-}
-
-static void
 e_calendar_item_unmap		(GnomeCanvasItem *item)
 {
 	ECalendarItem *calitem;
@@ -1024,7 +1006,7 @@ e_calendar_item_update		(GnomeCanvasItem *item,
  */
 static void
 e_calendar_item_draw		(GnomeCanvasItem *canvas_item,
-				 GdkDrawable	 *drawable,
+				 cairo_t	 *cr,
 				 gint		  x,
 				 gint		  y,
 				 gint		  width,
@@ -1037,7 +1019,6 @@ e_calendar_item_draw		(GnomeCanvasItem *canvas_item,
 	PangoFontDescription *font_desc;
 	PangoContext *pango_context;
 	PangoFontMetrics *font_metrics;
-	cairo_t *cr;
 	GdkColor base, bg;
 
 #if 0
@@ -1063,7 +1044,6 @@ e_calendar_item_draw		(GnomeCanvasItem *canvas_item,
 
 	base = style->base[GTK_STATE_NORMAL];
 	bg = style->bg[GTK_STATE_NORMAL];
-	cr = gdk_cairo_create (drawable);
 
 	/* Clear the entire background. */
 	cairo_save (cr);
@@ -1075,8 +1055,8 @@ e_calendar_item_draw		(GnomeCanvasItem *canvas_item,
 	cairo_restore (cr);
 
 	/* Draw the shadow around the entire item. */
-	gtk_paint_shadow (style, drawable, GTK_STATE_NORMAL, GTK_SHADOW_IN,
-			  NULL, NULL, "entry",
+	gtk_paint_shadow (style, cr, GTK_STATE_NORMAL, GTK_SHADOW_IN,
+			  NULL, "entry",
 			  calitem->x1 - x, calitem->y1 - y,
 			  calitem->x2 - calitem->x1 + 1,
 			  calitem->y2 - calitem->y1 + 1);
@@ -1099,9 +1079,9 @@ e_calendar_item_draw		(GnomeCanvasItem *canvas_item,
 		cairo_fill (cr);
 		cairo_restore (cr);
 
-		gtk_paint_shadow (style, drawable,
+		gtk_paint_shadow (style, cr,
 				  GTK_STATE_NORMAL, GTK_SHADOW_OUT,
-				  NULL, NULL, "calendar-header",
+				  NULL, "calendar-header",
 				  calitem->x1 + xthickness - x, row_y - y,
 				  calitem->x2 - calitem->x1 + 1
 				  - xthickness * 2,
@@ -1111,9 +1091,8 @@ e_calendar_item_draw		(GnomeCanvasItem *canvas_item,
 			if (col != 0) {
 				col_x = calitem->x1 + calitem->x_offset
 					+ calitem->month_width * col;
-				gtk_paint_vline (style, drawable,
-						 GTK_STATE_NORMAL,
-						 NULL, NULL,
+				gtk_paint_vline (style, cr,
+						 GTK_STATE_NORMAL, NULL,
 						 "calendar-separator",
 						 row_y + ythickness + 1 - y,
 						 row_y + bar_height
@@ -1121,7 +1100,7 @@ e_calendar_item_draw		(GnomeCanvasItem *canvas_item,
 						 col_x - 1 - x);
 			}
 
-			e_calendar_item_draw_month (calitem, drawable, x, y,
+			e_calendar_item_draw_month (calitem, cr, x, y,
 						    width, height, row, col);
 		}
 
@@ -1129,7 +1108,6 @@ e_calendar_item_draw		(GnomeCanvasItem *canvas_item,
 	}
 
 	pango_font_metrics_unref (font_metrics);
-	cairo_destroy (cr);
 }
 
 static void
@@ -1144,7 +1122,7 @@ layout_set_day_text (ECalendarItem *calitem, PangoLayout *layout, gint day_index
 
 static void
 e_calendar_item_draw_month	(ECalendarItem   *calitem,
-				 GdkDrawable	 *drawable,
+				 cairo_t	 *cr,
 				 gint		  x,
 				 gint		  y,
 				 gint		  width,
@@ -1168,7 +1146,6 @@ e_calendar_item_draw_month	(ECalendarItem   *calitem,
 	PangoContext *pango_context;
 	PangoFontMetrics *font_metrics;
 	PangoLayout *layout;
-	cairo_t *cr;
 
 #if 0
 	g_print ("In e_calendar_item_draw_month: %i,%i %ix%i row:%i col:%i\n",
@@ -1178,8 +1155,6 @@ e_calendar_item_draw_month	(ECalendarItem   *calitem,
 	widget = GTK_WIDGET (item->canvas);
 	style = gtk_widget_get_style (widget);
 
-	cr = gdk_cairo_create (drawable);
-
 	/* Set up Pango prerequisites */
 	font_desc = calitem->font_desc;
 	if (!font_desc)
@@ -1209,7 +1184,6 @@ e_calendar_item_draw_month	(ECalendarItem   *calitem,
 	/* Just return if the month is outside the given area. */
 	if (month_x >= width || month_x + calitem->month_width <= 0
 	    || month_y >= height || month_y + calitem->month_height <= 0) {
-		cairo_destroy (cr);
 		return;
 	}
 
@@ -1284,7 +1258,6 @@ e_calendar_item_draw_month	(ECalendarItem   *calitem,
 
 	if (clip_width <= 0 || clip_height <= 0) {
 		g_object_unref (layout);
-		cairo_destroy (cr);
 		return;
 	}
 
@@ -1351,12 +1324,11 @@ e_calendar_item_draw_month	(ECalendarItem   *calitem,
 		cairo_restore (cr);
 	}
 
-        e_calendar_item_draw_day_numbers (calitem, drawable, width, height,
-                                          row, col, year, month, start_weekday,
-                                          cells_x, cells_y);
+	e_calendar_item_draw_day_numbers (
+		calitem, cr, width, height, row, col,
+		year, month, start_weekday, cells_x, cells_y);
 
 	g_object_unref (layout);
-	cairo_destroy (cr);
 }
 
 static const gchar *
@@ -1389,7 +1361,7 @@ get_digit_fomat ()
 
 static void
 e_calendar_item_draw_day_numbers (ECalendarItem	*calitem,
-				  GdkDrawable	*drawable,
+				  cairo_t	*cr,
 				  gint		 width,
 				  gint		 height,
 				  gint		 row,
@@ -1421,14 +1393,11 @@ e_calendar_item_draw_day_numbers (ECalendarItem	*calitem,
 	PangoContext *pango_context;
 	PangoFontMetrics *font_metrics;
 	PangoLayout *layout;
-	cairo_t *cr;
 
 	item = GNOME_CANVAS_ITEM (calitem);
 	widget = GTK_WIDGET (item->canvas);
 	style = gtk_widget_get_style (widget);
 
-	cr = gdk_cairo_create (drawable);
-
 	/* Set up Pango prerequisites */
 	font_desc = calitem->font_desc;
 	if (!font_desc)
@@ -1705,7 +1674,6 @@ e_calendar_item_draw_day_numbers (ECalendarItem	*calitem,
 	g_object_unref (layout);
 
 	pango_font_metrics_unref (font_metrics);
-	cairo_destroy (cr);
 }
 
 gint



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]