[gnome-print] PATCH: Finished GnomeCanvasHacktext 2.0 port.



Here's a patch to make print preview working again. It wasn't working due to missing properties of GnomeCanvasHacktext.

--
Tambet Ingo <tambet@ximian.com>
? libgnomeprintui.patch
Index: gnome-canvas-hacktext.c
===================================================================
RCS file: /cvs/gnome/libgnomeprintui/libgnomeprintui/gnome-canvas-hacktext.c,v
retrieving revision 1.32
diff -u -r1.32 gnome-canvas-hacktext.c
--- gnome-canvas-hacktext.c	6 Sep 2002 06:01:28 -0000	1.32
+++ gnome-canvas-hacktext.c	7 Oct 2002 08:43:11 -0000
@@ -40,16 +40,17 @@
 #include <libgnomeprint/gnome-rfont.h>
 
 #include "gnome-canvas-hacktext.h"
+#include "gnome-print-i18n.h"
 
 enum {
-	ARG_0,
-	ARG_TEXT,
-	ARG_GLYPHLIST,
-	ARG_FILL_COLOR,
-	ARG_FILL_COLOR_RGBA,
-	ARG_FONT,
-	ARG_X,
-	ARG_Y
+	PROP_0,
+	PROP_TEXT,
+	PROP_GLYPHLIST,
+	PROP_FILL_COLOR,
+	PROP_FILL_COLOR_RGBA,
+	PROP_FONT,
+	PROP_X,
+	PROP_Y
 };
 
 
@@ -120,20 +121,57 @@
 	gobject_class->set_property = gnome_canvas_hacktext_set_property;
 	gobject_class->get_property = gnome_canvas_hacktext_get_property;
 
-	/* FIXME: finish port (Chema) */
-#if 0
-	/* When this gets checked into libgnomeui, change the
-	 * GTK_TYPE_POINTER to GTK_TYPE_GNOME_CANVAS_HACKTEXT, and add an
-         * entry to gnome-boxed.defs
-	 */
-	gtk_object_add_arg_type ("GnomeCanvasHacktext::text",            GTK_TYPE_STRING,  GTK_ARG_READWRITE, ARG_TEXT);
-	gtk_object_add_arg_type ("GnomeCanvasHacktext::glyphlist",       GTK_TYPE_POINTER, GTK_ARG_READWRITE, ARG_GLYPHLIST);
-	gtk_object_add_arg_type ("GnomeCanvasHacktext::fill_color",      GTK_TYPE_STRING,  GTK_ARG_WRITABLE,  ARG_FILL_COLOR);
-	gtk_object_add_arg_type ("GnomeCanvasHacktext::fill_color_rgba", GTK_TYPE_UINT,    GTK_ARG_READWRITE, ARG_FILL_COLOR_RGBA);
-	gtk_object_add_arg_type ("GnomeCanvasHacktext::font",            GTK_TYPE_OBJECT,  GTK_ARG_READWRITE, ARG_FONT);
-	gtk_object_add_arg_type ("GnomeCanvasHacktext::x",               GTK_TYPE_DOUBLE,  GTK_ARG_READWRITE, ARG_X);
-	gtk_object_add_arg_type ("GnomeCanvasHacktext::y",               GTK_TYPE_DOUBLE,  GTK_ARG_READWRITE, ARG_Y);
-#endif
+	g_object_class_install_property
+		(gobject_class,
+		 PROP_TEXT,
+		 g_param_spec_string ("text",
+				      _("Text"),
+				      _("Text to render"),
+				      NULL,
+				      G_PARAM_READABLE | G_PARAM_WRITABLE));
+	g_object_class_install_property
+                (gobject_class,
+                 PROP_X,
+                 g_param_spec_double ("x", NULL, NULL,
+				      -G_MAXDOUBLE, G_MAXDOUBLE, 0.0,
+				      (G_PARAM_READABLE | G_PARAM_WRITABLE)));
+        g_object_class_install_property
+                (gobject_class,
+                 PROP_Y,
+                 g_param_spec_double ("y", NULL, NULL,
+				      -G_MAXDOUBLE, G_MAXDOUBLE, 0.0,
+				      (G_PARAM_READABLE | G_PARAM_WRITABLE)));
+	 g_object_class_install_property
+		(gobject_class,
+		 PROP_GLYPHLIST,
+		 g_param_spec_pointer ("glyphlist",
+				       _("Glyphlist"),
+				       _("Glyphlist"),
+				       (G_PARAM_READABLE | G_PARAM_WRITABLE)));
+	 g_object_class_install_property
+                (gobject_class,
+                 PROP_FILL_COLOR,
+                 g_param_spec_string ("fill_color",
+				      _("Color"),
+				      _("Text color, as string"),
+                                      NULL,
+                                      G_PARAM_WRITABLE));
+	 g_object_class_install_property
+                (gobject_class,
+                 PROP_FILL_COLOR_RGBA,
+                 g_param_spec_uint ("fill_color_rgba",
+				    _("Color"),
+				    _("Text color, as an R/G/B/A combined integer"),
+				    0, G_MAXUINT, 0,
+				    (G_PARAM_READABLE | G_PARAM_WRITABLE)));
+	 g_object_class_install_property
+		 (gobject_class,
+		  PROP_FONT,
+		  g_param_spec_object ("font",
+				       _("Font"),
+				       _("Font as a GnomeFont struct"),
+				       GNOME_TYPE_FONT,
+				       (G_PARAM_READABLE | G_PARAM_WRITABLE)));
 
 	object_class->destroy = gnome_canvas_hacktext_destroy;
 
@@ -245,13 +283,8 @@
 				    const GValue          *value,
 				    GParamSpec            *pspec)
 {
-
-	g_assert_not_reached ();
-/* FIMXE: Finish port to 2.0 (Chema) */
-#if 0	
 	GnomeCanvasItem *item;
 	GnomeCanvasHacktext *bp;
-	char *text;
 	GnomeGlyphList * gl;
 	GdkColor color;
 	GnomeFont * font;
@@ -259,10 +292,8 @@
 	item = GNOME_CANVAS_ITEM (object);
 	bp = GNOME_CANVAS_HACKTEXT (object);
 
-	switch (arg_id) {
-	case ARG_TEXT:
-		text = GTK_VALUE_POINTER (*arg);
-
+	switch (param_id) {
+	case PROP_TEXT:
 		if (bp->text) {
 			g_free (bp->text);
 			bp->text = NULL;
@@ -273,14 +304,13 @@
 			bp->priv->glyphlist = NULL;
 		}
 
-		if (text)
-			bp->text = g_strdup (text);
+		bp->text = g_value_dup_string (value);
 
 		gnome_canvas_item_request_update (item);
 		break;
 
-	case ARG_GLYPHLIST:
-		gl = GTK_VALUE_POINTER (*arg);
+	case PROP_GLYPHLIST:
+		gl = g_value_get_pointer (value);
 
 		if (bp->text) {
 			g_free (bp->text);
@@ -302,8 +332,8 @@
 
 		break;
 
-	case ARG_FILL_COLOR:
-		if (gnome_canvas_get_color (item->canvas, GTK_VALUE_STRING (*arg), &color)) {
+	case PROP_FILL_COLOR:
+		if (gnome_canvas_get_color (item->canvas, g_value_get_string (value), &color)) {
 			bp->fill_set = TRUE;
 			bp->fill_pixel = color.pixel;
 			bp->fill_rgba =
@@ -319,17 +349,17 @@
 		gnome_canvas_item_request_update (item);
 		break;
 
-	case ARG_FILL_COLOR_RGBA:
+	case PROP_FILL_COLOR_RGBA:
 		bp->fill_set = TRUE;
-		bp->fill_rgba = GTK_VALUE_UINT (*arg);
+		bp->fill_rgba = g_value_get_uint (value);
 
 		/* should probably request repaint on the fill_svp */
 		gnome_canvas_item_request_update (item);
 
 		break;
 
-	case ARG_FONT:
-		font = GTK_VALUE_POINTER (*arg);
+	case PROP_FONT:
+		font = g_value_get_object (value);
 		if (font)
 			gnome_font_ref (font);
 		if (bp->priv->font)
@@ -339,20 +369,19 @@
 		gnome_canvas_item_request_update (item);
 		break;
 
-	case ARG_X:
-		bp->x = GTK_VALUE_DOUBLE (*arg);
+	case PROP_X:
+		bp->x = g_value_get_double (value);
 		gnome_canvas_item_request_update (item);
 		break;
 
-	case ARG_Y:
-		bp->y = GTK_VALUE_DOUBLE (*arg);
+	case PROP_Y:
+		bp->y = g_value_get_double (value);
 		gnome_canvas_item_request_update (item);
 		break;
 
 	default:
 		break;
 	}
-#endif
 }
 
 static void
@@ -361,40 +390,35 @@
 				    GValue                *value,
 				    GParamSpec            *pspec)
 {
-/* FIXME: Finish port to 2.0 (Chema) */
-#if 0
 	GnomeCanvasHacktext *bp;
 
 	bp = GNOME_CANVAS_HACKTEXT (object);
 
-	switch (arg_id) {
-	case ARG_TEXT:
-		if (bp->text) {
-			GTK_VALUE_POINTER (*arg) = g_strdup (bp->text);
-		} else
-			GTK_VALUE_POINTER (*arg) = NULL;
+	switch (param_id) {
+	case PROP_TEXT:
+		g_value_set_string (value, bp->text);
 		break;
-	case ARG_FILL_COLOR_RGBA:
-		GTK_VALUE_UINT (*arg) = bp->fill_color;
+
+	case PROP_FILL_COLOR_RGBA:
+		g_value_set_uint (value, bp->fill_color);
 		break;
 
-	case ARG_FONT:
-		GTK_VALUE_POINTER (*arg) = bp->priv->font;
+	case PROP_FONT:
+		g_value_set_object (value, bp->priv->font);
 		break;
 
-	case ARG_X:
-		GTK_VALUE_DOUBLE (*arg) = bp->x;
+	case PROP_X:
+		g_value_set_double (value, bp->x);
 		break;
 
-	case ARG_Y:
-		GTK_VALUE_DOUBLE (*arg) = bp->y;
+	case PROP_Y:
+		g_value_set_double (value, bp->y);
 		break;
 
 	default:
-		arg->type = GTK_TYPE_INVALID;
+		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, param_id, pspec);
 		break;
 	}
-#endif
 }
 
 static void


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