celix-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Ferry Huberts <maili...@hupie.com>
Subject [RFC] [PATCH v1 9/9] use gtk accessor functions
Date Fri, 13 Jul 2012 21:35:52 GMT
From: Ferry Huberts <ferry.huberts@pelagic.nl>

Signed-off-by: Ferry Huberts <ferry.huberts@pelagic.nl>
---
 .../circle/private/src/circle_shape.c               |    6 +++---
 .../paint/private/src/default_shape.c               |    2 +-
 .../paint/private/src/paint_frame.c                 |   19 +++++++++++++------
 .../square/private/src/square_shape.c               |    2 +-
 .../triangle/private/src/triangle_shape.c           |    2 +-
 5 files changed, 19 insertions(+), 12 deletions(-)

diff --git a/examples/osgi-in-action/chapter04-paint-example/circle/private/src/circle_shape.c
b/examples/osgi-in-action/chapter04-paint-example/circle/private/src/circle_shape.c
index 96aeed4..2c19bbe 100644
--- a/examples/osgi-in-action/chapter04-paint-example/circle/private/src/circle_shape.c
+++ b/examples/osgi-in-action/chapter04-paint-example/circle/private/src/circle_shape.c
@@ -58,12 +58,12 @@ celix_status_t circleShape_create(BUNDLE_CONTEXT context, SIMPLE_SHAPE
*shape) {
 void circleShape_draw(SIMPLE_SHAPE shape, GdkPixmap *pixMap, GtkWidget *widget, gdouble x,
gdouble y){
 	GdkRectangle update_rect;
 	GError *gerror = NULL;
-	gsize rd = 0, wr = 0;
+	gsize rd = 0, wr = 0;// FIXME
 	if (shape->icon_path == NULL) {
 		printf("error message: icon path unknown\n");
 	} else {
 		gchar *gfn = g_locale_to_utf8(shape->icon_path, strlen(shape->icon_path), &rd,
&wr, &gerror);
-		GdkPixbuf*curr_pix_buf = gdk_pixbuf_new_from_file(gfn, &gerror);
+		GdkPixbuf*curr_pix_buf = gdk_pixbuf_new_from_file(gfn, &gerror);// FIXME
 		if(!curr_pix_buf) {
 			g_printerr("error message: %s\n", (gchar *) gerror->message);
 		}
@@ -74,7 +74,7 @@ void circleShape_draw(SIMPLE_SHAPE shape, GdkPixmap *pixMap, GtkWidget *widget,
 		gdk_pixbuf_render_to_drawable(
 				curr_pix_buf,
 				pixMap,
-				widget->style->fg_gc[GTK_WIDGET_STATE (widget)],
+				gtk_widget_get_style(widget)->fg_gc[gtk_widget_get_state(widget)],
 				0, 0,
 				update_rect.x, update_rect.y,
 				update_rect.width,
diff --git a/examples/osgi-in-action/chapter04-paint-example/paint/private/src/default_shape.c
b/examples/osgi-in-action/chapter04-paint-example/paint/private/src/default_shape.c
index df6684f..28a1efd 100644
--- a/examples/osgi-in-action/chapter04-paint-example/paint/private/src/default_shape.c
+++ b/examples/osgi-in-action/chapter04-paint-example/paint/private/src/default_shape.c
@@ -59,7 +59,7 @@ void defaultShape_draw(SIMPLE_SHAPE shape, GdkPixmap *pixMap, GtkWidget
*widget,
 		gdk_pixbuf_render_to_drawable(
 				curr_pix_buf,
 				pixMap,
-				widget->style->fg_gc[GTK_WIDGET_STATE (widget)],
+				gtk_widget_get_style(widget)->fg_gc[gtk_widget_get_state(widget)],
 				0, 0,
 				update_rect.x, update_rect.y,
 				update_rect.width,
diff --git a/examples/osgi-in-action/chapter04-paint-example/paint/private/src/paint_frame.c
b/examples/osgi-in-action/chapter04-paint-example/paint/private/src/paint_frame.c
index bf2d49a..550ec8a 100644
--- a/examples/osgi-in-action/chapter04-paint-example/paint/private/src/paint_frame.c
+++ b/examples/osgi-in-action/chapter04-paint-example/paint/private/src/paint_frame.c
@@ -261,18 +261,23 @@ static void paintFrame_destroyWidgets(PAINT_FRAME frame) {
 
 static void paintFrame_configure(GtkWidget *widget, GdkEventConfigure *event, gpointer data)
{
 	PAINT_FRAME frame = data;
+	GtkAllocation allocation;
+
 	if (frame->pixMap != NULL) {
 		gdk_pixmap_unref(frame->pixMap);
 	}
 
-	frame->pixMap = gdk_pixmap_new(widget->window, widget->allocation.width, widget->allocation.height,
-1);
+	gtk_widget_get_allocation(widget, &allocation);
+	frame->pixMap = gdk_pixmap_new(gtk_widget_get_window(widget), allocation.width, allocation.height,
-1);
 	paintFrame_redraw(frame, 0);
 }
 
 static void paintFrame_expose(GtkWidget *widget, GdkEventExpose *event, gpointer data) {
 	PAINT_FRAME frame = data;
-	gdk_draw_pixmap(widget->window, widget->style->fg_gc[GTK_WIDGET_STATE (widget)],
frame->pixMap,
-			event->area.x, event->area.y, event->area.x, event->area.y, event->area.width,
event->area.height);
+	gdk_draw_pixmap(gtk_widget_get_window(widget),
+			gtk_widget_get_style(widget)->fg_gc[gtk_widget_get_state(widget)],
+			frame->pixMap, event->area.x, event->area.y, event->area.x,
+			event->area.y, event->area.width, event->area.height);
 }
 
 static void paintFrame_buttonClicked(GtkWidget *button, gpointer data) {
@@ -297,13 +302,15 @@ static gboolean paintFrame_mousePressed( GtkWidget *widget, GdkEventButton
*even
 static celix_status_t paintFrame_redraw(PAINT_FRAME frame, GdkModifierType state) {
 	if (frame->pixMap != NULL && frame->showing) {
 		GdkRectangle update_rect;
+		GtkAllocation allocation;
 
 		update_rect.x = 0;
 		update_rect.y = 0;
-		update_rect.width = frame->drawingArea->allocation.width;
-		update_rect.height = frame->drawingArea->allocation.height;
+		gtk_widget_get_allocation(frame->drawingArea, &allocation);
+		update_rect.width = allocation.width;
+		update_rect.height = allocation.height;
 		gdk_draw_rectangle (this->pixMap,
-				frame->drawingArea->style->white_gc,
+				gtk_widget_get_style(frame->drawingArea)->white_gc,
 				TRUE,
 				update_rect.x, update_rect.y,
 				update_rect.width, update_rect.height);
diff --git a/examples/osgi-in-action/chapter04-paint-example/square/private/src/square_shape.c
b/examples/osgi-in-action/chapter04-paint-example/square/private/src/square_shape.c
index ada9506..125c873 100644
--- a/examples/osgi-in-action/chapter04-paint-example/square/private/src/square_shape.c
+++ b/examples/osgi-in-action/chapter04-paint-example/square/private/src/square_shape.c
@@ -60,7 +60,7 @@ void squareShape_draw(SIMPLE_SHAPE shape, GdkPixmap *pixMap, GtkWidget *widget,
 		gdk_pixbuf_render_to_drawable(
 				curr_pix_buf,
 				pixMap,
-				widget->style->fg_gc[GTK_WIDGET_STATE (widget)],
+				gtk_widget_get_style(widget)->fg_gc[gtk_widget_get_state(widget)],
 				0, 0,
 				update_rect.x, update_rect.y,
 				update_rect.width,
diff --git a/examples/osgi-in-action/chapter04-paint-example/triangle/private/src/triangle_shape.c
b/examples/osgi-in-action/chapter04-paint-example/triangle/private/src/triangle_shape.c
index de58885..458b0f1 100644
--- a/examples/osgi-in-action/chapter04-paint-example/triangle/private/src/triangle_shape.c
+++ b/examples/osgi-in-action/chapter04-paint-example/triangle/private/src/triangle_shape.c
@@ -60,7 +60,7 @@ void triangleShape_draw(SIMPLE_SHAPE shape, GdkPixmap *pixMap, GtkWidget
*widget
 	gdk_pixbuf_render_to_drawable(
 			curr_pix_buf,
 			pixMap,
-			widget->style->fg_gc[GTK_WIDGET_STATE (widget)],
+			gtk_widget_get_style(widget)->fg_gc[gtk_widget_get_state(widget)],
 			0, 0,
 			update_rect.x, update_rect.y,
 			update_rect.width,
-- 
1.7.10.4


Mime
View raw message