Re: Problem constructing GooCanvasModel* objects



You still weren't using the _CONSTRUCT() macros. I have committed this
patch to use the _CONSTRUCT() macros instead of using the C *_new()
functions.

However, because the *_new() functions in goocanvas do so much more than
g_object_new(), this will still fail to properly instantiate the
objects. It needs one of:
a) Reimplement the code from the *_new() functions, in our C++
constructors.
b) Do a) with the help of some new public API in goocanvas.
c) Ideally, add the properties in goocanvas so that our constructors
work.

The patch does a few other things too.

-- 
Murray Cumming
murrayc murrayc com
www.murrayc.com
www.openismus.com
Index: ChangeLog
===================================================================
--- ChangeLog	(revision 50)
+++ ChangeLog	(working copy)
@@ -1,3 +1,51 @@
+2007-05-22  Murray Cumming  <murrayc murrayc com>
+
+	* libgoocanvas/src/ellipse.ccg:
+	* libgoocanvas/src/ellipsemodel.ccg:
+	* libgoocanvas/src/group.ccg:
+	* libgoocanvas/src/group.hg:
+	* libgoocanvas/src/groupmodel.ccg:
+	* libgoocanvas/src/groupmodel.hg:
+	* libgoocanvas/src/image.ccg:
+	* libgoocanvas/src/image.hg:
+	* libgoocanvas/src/imagemodel.ccg:
+	* libgoocanvas/src/itemmodelsimple.hg:
+	* libgoocanvas/src/path.ccg:
+	* libgoocanvas/src/path.hg:
+	* libgoocanvas/src/pathmodel.ccg:
+	* libgoocanvas/src/pathmodel.hg:
+	* libgoocanvas/src/polyline.ccg:
+	* libgoocanvas/src/polyline.hg:
+	* libgoocanvas/src/polylinemodel.ccg:
+	* libgoocanvas/src/polylinemodel.hg:
+	* libgoocanvas/src/rect.ccg:
+	* libgoocanvas/src/rectmodel.ccg:
+	* libgoocanvas/src/rectmodel.hg:
+	* libgoocanvas/src/text.ccg:
+	* libgoocanvas/src/text.hg:
+	* libgoocanvas/src/textmodel.ccg:
+	* libgoocanvas/src/textmodel.hg: Use the _CONSTRUCT() 
+	macro instead of using the *_new() functions, so we can use 
+	our derived GTypes.
+	Do not do an extra reference, because that is unnecessary now 
+	that we are no longer using the *_new() functions that do an 
+	unreference().
+	Partially reimplement the *_new() functions, calling 
+	goo_canvas_item_add_child() and goo_canvas_item_model_add_child().
+
+	However, there is much more still to reimplement.
+	This will probably cause lots of warnings about use of invalid 
+	properties. That is a goocanvas bug.
+
+	* tools/m4/convert_libgoocanvasmm.m4:
+	* examples/demo/primitives.cc:
+	* examples/demo/primitives.hh:
+	* examples/simple/window.cc:
+	Use Gtk::AnchorType everywhere instead of GtkAnchorType.
+	* libgoocanvas/src/points.ccg:
+	* libgoocanvas/src/points.hg: Do not derive from Glib::Object, 
+	because this is a boxed type. Do not use it via RefPtr.
+
 2007-05-22 Paul Davis <pjdavis engineering uiowa edu>
 
 	* libgoocanvas/src/group.ccg
Index: tools/m4/convert_libgoocanvasmm.m4
===================================================================
--- tools/m4/convert_libgoocanvasmm.m4	(revision 50)
+++ tools/m4/convert_libgoocanvasmm.m4	(working copy)
@@ -44,5 +44,9 @@
 _CONVERSION(`cairo_matrix_t*',`Cairo::Matrix*',`((Cairo::Matrix*))($3))')
 _CONVERSION(`Cairo::Matrix*',`cairo_matrix_t*',`((cairo_matrix_t*)($3))')
 _CONVERSION(`const Cairo::Matrix*',`const cairo_matrix_t*',`((const cairo_matrix_t*)($3))')
-_CONVERSION(`Cairo::RefPtr<Cairo::Pattern>', `GooCairoPattern',__CONVERT_REFPTR_TO_P)
 
+# GooCairoPattern* is actually a cairo_pattern_t*:
+_CONVERSION(`Cairo::RefPtr<Cairo::Pattern>', `GooCairoPattern*',__CONVERT_REFPTR_TO_P)
+
+_CONVERSION(`Gtk::AnchorType',`AnchorType',`($2)($3)')
+
Index: libgoocanvas/src/text.ccg
===================================================================
--- libgoocanvas/src/text.ccg	(revision 50)
+++ libgoocanvas/src/text.ccg	(working copy)
@@ -23,14 +23,13 @@
 namespace Goocanvas
 {
 
-//ItemSimple(GOO_CANVAS_ITEM_SIMPLE(goo_canvas_text_new(parent->gobj(), string.c_str(), x, y, width, anchor, NULL)))
-Text::Text(const Glib::RefPtr<Item>& parent, const Glib::ustring& string, double x, double y, double width, GtkAnchorType anchor)
-  :
-	ItemSimple( GOO_CANVAS_ITEM_SIMPLE( goo_canvas_text_new( parent->gobj(), string.c_str(), x, y, width, anchor, NULL ) ) )
+Text::Text(const Glib::RefPtr<Item>& parent, const Glib::ustring& string, double x, double y, double width, Gtk::AnchorType anchor)
+: 
+  _CONSTRUCT("string", string.c_str(), "x", x, "y", y, "width", width, "anchor", (GtkAnchorType)anchor)
 {
-	//FIXME: This can't be right.
-	reference() ;
+  if(parent)
+    goo_canvas_item_add_child (parent->gobj(), GOO_CANVAS_ITEM(gobj()), -1);
 }
 
-}
+} //namespace Goocanvas
 
Index: libgoocanvas/src/group.ccg
===================================================================
--- libgoocanvas/src/group.ccg	(revision 50)
+++ libgoocanvas/src/group.ccg	(working copy)
@@ -24,19 +24,13 @@
 namespace Goocanvas
 {
 
-Group::Group()
-  :
-    ItemSimple(GOO_CANVAS_ITEM_SIMPLE(goo_canvas_group_new(NULL,NULL)))
-{
-  //reference() ; //No parent, so we don't unref in goocanvas.
-}
-
 Group::Group(const Glib::RefPtr<Item>& parent)
-  :
-    ItemSimple(GOO_CANVAS_ITEM_SIMPLE(goo_canvas_group_new(parent->gobj(),NULL)))
+:
+  _CONSTRUCT()
 {
-  reference() ;
+  if(parent)
+    goo_canvas_item_add_child (parent->gobj(), GOO_CANVAS_ITEM(gobj()), -1);
 }
 
-}
+} //namspace GooCanvas
 
Index: libgoocanvas/src/rect.ccg
===================================================================
--- libgoocanvas/src/rect.ccg	(revision 50)
+++ libgoocanvas/src/rect.ccg	(working copy)
@@ -24,11 +24,12 @@
 {
 
 Rect::Rect(const Glib::RefPtr<Item>& parent, double x, double y, double width, double height)
-  :
-    ItemSimple(GOO_CANVAS_ITEM_SIMPLE(goo_canvas_rect_new(parent->gobj(), x, y, width, height, NULL)))
+:
+  _CONSTRUCT("x", x, "y", y, "width", width, "height", height)
 {
-  reference() ;
+  if(parent)
+    goo_canvas_item_add_child (parent->gobj(), GOO_CANVAS_ITEM(gobj()), -1);
 }
 
-}
+} //namespace Goocanvas
 
Index: libgoocanvas/src/path.hg
===================================================================
--- libgoocanvas/src/path.hg	(revision 50)
+++ libgoocanvas/src/path.hg	(working copy)
@@ -33,6 +33,7 @@
   _CLASS_GOBJECT(Path,GooCanvasPath,GOO_CANVAS_PATH,Goocanvas::ItemSimple,GooCanvasItemSimple)
 protected:
 
+  //TODO: I doubt that ustring is a sensible type for the data. murrayc.
   explicit Path(const Glib::RefPtr<Item>& parent, const Glib::ustring& data );
 
 public:
Index: libgoocanvas/src/pathmodel.ccg
===================================================================
--- libgoocanvas/src/pathmodel.ccg	(revision 50)
+++ libgoocanvas/src/pathmodel.ccg	(working copy)
@@ -24,11 +24,12 @@
 {
 
 PathModel::PathModel(const Glib::RefPtr<ItemModel>& parent, const Glib::ustring& data)
-  :
-    ItemModelSimple(GOO_CANVAS_ITEM_MODEL_SIMPLE(goo_canvas_path_model_new(parent->gobj(), const_cast<char*>(data.c_str()),NULL)))
+:
+  _CONSTRUCT("data", const_cast<char*>(data.c_str()))
 {
-  reference() ;
+  if(parent)
+    goo_canvas_item_model_add_child (parent->gobj(), GOO_CANVAS_ITEM_MODEL(gobj()), -1);
 }
 
-}
+} //namespace Goocanvas
 
Index: libgoocanvas/src/rectmodel.ccg
===================================================================
--- libgoocanvas/src/rectmodel.ccg	(revision 50)
+++ libgoocanvas/src/rectmodel.ccg	(working copy)
@@ -22,12 +22,12 @@
 {
 
 RectModel::RectModel(const Glib::RefPtr<ItemModel>& parent, double x, double y, double width, double height)
-  :
-    Glib::ObjectBase(0),
-    ItemModelSimple(GOO_CANVAS_ITEM_MODEL_SIMPLE(goo_canvas_rect_model_new(parent->gobj(), x, y, width, height, NULL)))
+:
+  _CONSTRUCT("x", x, "y", y, "width", width, "height", height)
 {
-  reference() ;
+  if(parent)
+    goo_canvas_item_model_add_child (parent->gobj(), GOO_CANVAS_ITEM_MODEL(gobj()), -1);
 }
 
-}
+} //namespace Goocanvas
 
Index: libgoocanvas/src/polylinemodel.hg
===================================================================
--- libgoocanvas/src/polylinemodel.hg	(revision 50)
+++ libgoocanvas/src/polylinemodel.hg	(working copy)
@@ -41,7 +41,7 @@
   _WRAP_PROPERTY("arrow-width", double)
   _WRAP_PROPERTY("close-path", bool)
   _WRAP_PROPERTY("end-arrow", bool)
-  _WRAP_PROPERTY("points",Points)
+  _WRAP_PROPERTY("points", Points)
   _WRAP_PROPERTY("start-arrow", bool)
 
 };
Index: libgoocanvas/src/points.hg
===================================================================
--- libgoocanvas/src/points.hg	(revision 50)
+++ libgoocanvas/src/points.hg	(working copy)
@@ -24,20 +24,19 @@
 namespace Goocanvas
 {
 
-class Points : public Glib::Object
+class Points
 {
+public:
   _CLASS_BOXEDTYPE(Points, GooCanvasPoints, NONE, goo_canvas_points_ref, goo_canvas_points_unref)
   _IGNORE(goo_canvas_points_ref, goo_canvas_points_unref)
-
-  Points( int num_points, double* coords ) ;
-
 public:
 
-  _WRAP_CREATE( int num_points, double* coords = NULL )
+  Points(int num_points, double* coords);
 
-  int num_points() ;
-  void set_coordinate( int index, double x, double y ) ;
-  void get_coordinate( int index, double& x, double& y ) ;
+  //TODO: Why not use _WRAP_METHOD() or _MEMBER*?
+  int num_points() const;
+  void set_coordinate(int index, double x, double y);
+  void get_coordinate(int index, double& x, double& y) const;
 };
 
 }
Index: libgoocanvas/src/pathmodel.hg
===================================================================
--- libgoocanvas/src/pathmodel.hg	(revision 50)
+++ libgoocanvas/src/pathmodel.hg	(working copy)
@@ -29,6 +29,7 @@
   _CLASS_GOBJECT(PathModel,GooCanvasPathModel,GOO_CANVAS_PATH_MODEL,Goocanvas::ItemModelSimple,GooCanvasItemModelSimple)
 protected:
 
+  //TODO: I doubt that ustring is a sensible type for the data. murrayc.
   explicit PathModel(const Glib::RefPtr<ItemModel>& parent, const Glib::ustring& data);
 
 public:
Index: libgoocanvas/src/image.hg
===================================================================
--- libgoocanvas/src/image.hg	(revision 50)
+++ libgoocanvas/src/image.hg	(working copy)
@@ -41,7 +41,7 @@
   _WRAP_CREATE(const Glib::RefPtr<Item>& parent, const Glib::RefPtr<Gdk::Pixbuf>& pixbuf, double x, double y)
 
   _WRAP_PROPERTY("height", double)
-  _WRAP_PROPERTY("pattern",Cairo::RefPtr<Cairo::Pattern>)
+  _WRAP_PROPERTY("pattern", Cairo::RefPtr<Cairo::Pattern>)
   _WRAP_PROPERTY("pixbuf",Glib::RefPtr<Gdk::Pixbuf>)
   _WRAP_PROPERTY("width", double)
   _WRAP_PROPERTY("x", double)
Index: libgoocanvas/src/text.hg
===================================================================
--- libgoocanvas/src/text.hg	(revision 50)
+++ libgoocanvas/src/text.hg	(working copy)
@@ -17,6 +17,7 @@
 
 
 #include <libgoocanvasmm/itemsimple.h>
+#include <gtkmm/enums.h> /* For AnchorType. */
 
 _DEFS(libgoocanvasmm,libgoocanvas)
 _PINCLUDE(glibmm/private/object_p.h)
@@ -29,19 +30,19 @@
   _CLASS_GOBJECT(Text,GooCanvasText,GOO_CANVAS_TEXT,Goocanvas::ItemSimple,GooCanvasItemSimple)
 protected:
 
-  explicit Text(const Glib::RefPtr<Item>& parent, const Glib::ustring& string, double x, double y, double width, GtkAnchorType anchor);
+  explicit Text(const Glib::RefPtr<Item>& parent, const Glib::ustring& string, double x, double y, double width, Gtk::AnchorType anchor);
 
 public:
 
-  _WRAP_CREATE(const Glib::RefPtr<Item>& parent, const Glib::ustring& string, double x, double y, double width, GtkAnchorType anchor );
+  _WRAP_CREATE(const Glib::RefPtr<Item>& parent, const Glib::ustring& string, double x, double y, double width, Gtk::AnchorType anchor );
 
   _WRAP_PROPERTY("alignment", Pango::Alignment)
-  _WRAP_PROPERTY("anchor", GtkAnchorType)
+  _WRAP_PROPERTY("anchor", Gtk::AnchorType)
   _WRAP_PROPERTY("ellipsize",Pango::EllipsizeMode)
   _WRAP_PROPERTY("font", Glib::ustring)
   _WRAP_PROPERTY("font-desc", Pango::FontDescription)
   _WRAP_PROPERTY("text", Glib::ustring)
-  _WRAP_PROPERTY("use-markup",bool)
+  _WRAP_PROPERTY("use-markup", bool)
   _WRAP_PROPERTY("width", double)
   _WRAP_PROPERTY("x", double)
   _WRAP_PROPERTY("y", double)
Index: libgoocanvas/src/polyline.ccg
===================================================================
--- libgoocanvas/src/polyline.ccg	(revision 50)
+++ libgoocanvas/src/polyline.ccg	(working copy)
@@ -24,26 +24,30 @@
 {
 
 Polyline::Polyline(const Glib::RefPtr<Item>& parent )
-  :
-    ItemSimple(GOO_CANVAS_ITEM_SIMPLE(goo_canvas_polyline_new(parent->gobj(), FALSE, 0, NULL )))
+:
+  _CONSTRUCT()
 {
-  reference() ;
+  if(parent)
+    goo_canvas_item_add_child (parent->gobj(), GOO_CANVAS_ITEM(gobj()), -1);
 }
 
-Polyline::Polyline(const Glib::RefPtr<Item>& parent, bool close_path, const Glib::RefPtr<Points>& points )
-  :
-    ItemSimple(GOO_CANVAS_ITEM_SIMPLE(goo_canvas_polyline_new(parent->gobj(), close_path ? TRUE : FALSE, points->num_points(), NULL)))
+//TODO: Check what the C _new() function actually does:
+Polyline::Polyline(const Glib::RefPtr<Item>& parent, bool close_path, const Points& points )
+:
+  _CONSTRUCT("close_path", close_path ? TRUE : FALSE)
 {
-  reference() ;
+  if(parent)
+    goo_canvas_item_add_child (parent->gobj(), GOO_CANVAS_ITEM(gobj()), -1) ;
   property_points() = points ;
 }
 
 Polyline::Polyline(const Glib::RefPtr<Item>& parent, double x1, double y1, double x2, double y2)
-  :
-    ItemSimple(GOO_CANVAS_ITEM_SIMPLE(goo_canvas_polyline_new_line(parent->gobj(), x1, y1, x2, y2, NULL)))
+:
+   _CONSTRUCT("x1", x1, "y1", y1, "x2" ,x2, "y2", y2)
 {
-  reference() ;
+  if(parent)
+    goo_canvas_item_add_child (parent->gobj(), GOO_CANVAS_ITEM(gobj()), -1);
 }
 
-}
+} //namespace Goocanvas
 
Index: libgoocanvas/src/itemmodelsimple.hg
===================================================================
--- libgoocanvas/src/itemmodelsimple.hg	(revision 50)
+++ libgoocanvas/src/itemmodelsimple.hg	(working copy)
@@ -40,26 +40,26 @@
 
 public:
 
-  _WRAP_PROPERTY("antialias",Cairo::Antialias)
-  _WRAP_PROPERTY("clip-fill-rule",Cairo::FillRule)
-  _WRAP_PROPERTY("clip-path",Glib::ustring)
-  _WRAP_PROPERTY("fill-color",Glib::ustring)
-  _WRAP_PROPERTY("fill-color-rgba",guint)
-  _WRAP_PROPERTY("fill-pattern",Cairo::RefPtr<Cairo::Pattern>)
-  _WRAP_PROPERTY("fill-pixbuf",Glib::RefPtr<Gdk::Pixbuf>)
-  _WRAP_PROPERTY("font",Glib::ustring)
-  _WRAP_PROPERTY("font-desc",Pango::FontDescription)
-  _WRAP_PROPERTY("hint-metrics",Cairo::HintMetrics)
-  _WRAP_PROPERTY("line-cap",Cairo::LineCap)
-  _WRAP_PROPERTY("line-dash",LineDash)
-  _WRAP_PROPERTY("line-join",Cairo::LineJoin)
-  _WRAP_PROPERTY("line-join-miter-limit",gdouble)
-  _WRAP_PROPERTY("line-width",gdouble)
-  _WRAP_PROPERTY("operator",Cairo::Operator)
-  _WRAP_PROPERTY("stroke-color",Glib::ustring)
-  _WRAP_PROPERTY("stroke-color-rgba",guint)
-  _WRAP_PROPERTY("stroke-pattern",Cairo::RefPtr<Cairo::Pattern>)
-  _WRAP_PROPERTY("stroke-pixbuf",Glib::RefPtr<Gdk::Pixbuf>)
+  _WRAP_PROPERTY("antialias", Cairo::Antialias)
+  _WRAP_PROPERTY("clip-fill-rule", Cairo::FillRule)
+  _WRAP_PROPERTY("clip-path", Glib::ustring)
+  _WRAP_PROPERTY("fill-color", Glib::ustring)
+  _WRAP_PROPERTY("fill-color-rgba", guint)
+  _WRAP_PROPERTY("fill-pattern", Cairo::RefPtr<Cairo::Pattern>)
+  _WRAP_PROPERTY("fill-pixbuf", Glib::RefPtr<Gdk::Pixbuf>)
+  _WRAP_PROPERTY("font", Glib::ustring)
+  _WRAP_PROPERTY("font-desc", Pango::FontDescription)
+  _WRAP_PROPERTY("hint-metrics", Cairo::HintMetrics)
+  _WRAP_PROPERTY("line-cap", Cairo::LineCap)
+  _WRAP_PROPERTY("line-dash", LineDash)
+  _WRAP_PROPERTY("line-join", Cairo::LineJoin)
+  _WRAP_PROPERTY("line-join-miter-limit", gdouble)
+  _WRAP_PROPERTY("line-width", gdouble)
+  _WRAP_PROPERTY("operator", Cairo::Operator)
+  _WRAP_PROPERTY("stroke-color", Glib::ustring)
+  _WRAP_PROPERTY("stroke-color-rgba", guint)
+  _WRAP_PROPERTY("stroke-pattern", Cairo::RefPtr<Cairo::Pattern>)
+  _WRAP_PROPERTY("stroke-pixbuf", Glib::RefPtr<Gdk::Pixbuf>)
 
 };
 
Index: libgoocanvas/src/path.ccg
===================================================================
--- libgoocanvas/src/path.ccg	(revision 50)
+++ libgoocanvas/src/path.ccg	(working copy)
@@ -24,11 +24,12 @@
 {
 
 Path::Path(const Glib::RefPtr<Item>& parent, const Glib::ustring& data)
-  :
-    ItemSimple(GOO_CANVAS_ITEM_SIMPLE(goo_canvas_path_new(parent->gobj(), const_cast<char*>(data.c_str()),NULL)))
+:
+  _CONSTRUCT("data", const_cast<char*>(data.c_str()))
 {
-  reference() ;
+  if(parent)
+    goo_canvas_item_add_child (parent->gobj(), GOO_CANVAS_ITEM(gobj()), -1);
 }
 
-}
+} //namespace Goocanvas
 
Index: libgoocanvas/src/polyline.hg
===================================================================
--- libgoocanvas/src/polyline.hg	(revision 50)
+++ libgoocanvas/src/polyline.hg	(working copy)
@@ -31,20 +31,20 @@
 protected:
 
   explicit Polyline(const Glib::RefPtr<Item>& parent ) ;
-  Polyline(const Glib::RefPtr<Item>& parent, bool close_path, const Glib::RefPtr<Points>& coords ) ;
+  Polyline(const Glib::RefPtr<Item>& parent, bool close_path, const Points& coords ) ;
   Polyline(const Glib::RefPtr<Item>& parent, double x1, double y1, double x2, double y2);
 
 public:
 
   _WRAP_CREATE(const Glib::RefPtr<Item>& parent )
-  _WRAP_CREATE(const Glib::RefPtr<Item>& parent, bool close_ath, const Glib::RefPtr<Points>& coords )
+  _WRAP_CREATE(const Glib::RefPtr<Item>& parent, bool close_ath, const Points& coords )
   _WRAP_CREATE(const Glib::RefPtr<Item>& parent, double x1, double y1, double x2, double y2 )
   _WRAP_PROPERTY("arrow-length", double)
   _WRAP_PROPERTY("arrow-tip-length", double)
   _WRAP_PROPERTY("arrow-width", double)
   _WRAP_PROPERTY("close-path", bool)
   _WRAP_PROPERTY("end-arrow", bool)
-  _WRAP_PROPERTY("points",Glib::RefPtr<Points>)
+  _WRAP_PROPERTY("points", Points)
   _WRAP_PROPERTY("start-arrow", bool)
 
 };
Index: libgoocanvas/src/ellipse.ccg
===================================================================
--- libgoocanvas/src/ellipse.ccg	(revision 50)
+++ libgoocanvas/src/ellipse.ccg	(working copy)
@@ -23,11 +23,13 @@
 namespace Goocanvas
 {
 
+//TODO: Reimplement the C _new function:
 Ellipse::Ellipse(const Glib::RefPtr<Item>& parent, double center_x, double center_y, double radius_x, double radius_y)
-  :
-    ItemSimple(GOO_CANVAS_ITEM_SIMPLE(goo_canvas_ellipse_new(parent->gobj(), center_x, center_y, radius_x, radius_y, NULL)))
+:
+  _CONSTRUCT("center_x", center_x, "center_y", center_y, "radius_x", radius_x, "radius_y", radius_y)
 {
-	reference() ;
+  if(parent)
+    goo_canvas_item_add_child (parent->gobj(), GOO_CANVAS_ITEM(gobj()), -1);
 }
 
-}
+} //namespace GooCanvas
Index: libgoocanvas/src/group.hg
===================================================================
--- libgoocanvas/src/group.hg	(revision 50)
+++ libgoocanvas/src/group.hg	(working copy)
@@ -30,7 +30,7 @@
 
 protected:
 
-  Group() ;
+  _CTOR_DEFAULT
   explicit Group(const Glib::RefPtr<Item>& parent) ;
 
 public:
Index: libgoocanvas/src/imagemodel.ccg
===================================================================
--- libgoocanvas/src/imagemodel.ccg	(revision 50)
+++ libgoocanvas/src/imagemodel.ccg	(working copy)
@@ -23,20 +23,22 @@
 namespace Goocanvas
 {
 
+//TODO: Reimplement goo_canvas_image_new()
 ImageModel::ImageModel(const Glib::RefPtr<Goocanvas::ItemModel>& parent, double x, double y)
-  :
-    ItemModelSimple( GOO_CANVAS_ITEM_MODEL_SIMPLE(goo_canvas_image_model_new(parent->gobj(),NULL,x,y,NULL)))
+:
+  _CONSTRUCT("x", x, "y", y)
 {
-  reference() ;
+  if(parent)
+    goo_canvas_item_model_add_child (parent->gobj(), GOO_CANVAS_ITEM_MODEL(gobj()), -1);
 }
 
 ImageModel::ImageModel(const Glib::RefPtr<Goocanvas::ItemModel>& parent, const Glib::RefPtr<Gdk::Pixbuf>& pixbuf, double x, double y)
-  :
-    ItemModelSimple(GOO_CANVAS_ITEM_MODEL_SIMPLE(goo_canvas_image_model_new(parent->gobj(),pixbuf->gobj(),x,y,NULL)))
+:
+  _CONSTRUCT("pixbuf", pixbuf->gobj(), "x", x, "y", y)
 {
-  reference() ;
+  if(parent)
+    goo_canvas_item_model_add_child (parent->gobj(), GOO_CANVAS_ITEM_MODEL(gobj()), -1);
 }
 
+} //namespace Goocanvas
 
-}
-
Index: libgoocanvas/src/textmodel.ccg
===================================================================
--- libgoocanvas/src/textmodel.ccg	(revision 50)
+++ libgoocanvas/src/textmodel.ccg	(working copy)
@@ -23,12 +23,13 @@
 namespace Goocanvas
 {
 
-TextModel::TextModel(const Glib::RefPtr<ItemModel>& parent, const Glib::ustring& string, double x, double y, double width, GtkAnchorType anchor)
-  :
-    ItemModelSimple(GOO_CANVAS_ITEM_MODEL_SIMPLE(goo_canvas_text_model_new(parent->gobj(), string.c_str(), x, y, width, anchor, NULL)))
+TextModel::TextModel(const Glib::RefPtr<ItemModel>& parent, const Glib::ustring& string, double x, double y, double width, Gtk::AnchorType anchor)
+: 
+  _CONSTRUCT("string", string.c_str(), "x", x, "y", y, "width", width, "anchor", (GtkAnchorType)anchor)
 {
-  reference() ;
+  if(parent)
+    goo_canvas_item_model_add_child (parent->gobj(), GOO_CANVAS_ITEM_MODEL(gobj()), -1);
 }
 
-}
+} //namespace GooCanvas
 
Index: libgoocanvas/src/textmodel.hg
===================================================================
--- libgoocanvas/src/textmodel.hg	(revision 50)
+++ libgoocanvas/src/textmodel.hg	(working copy)
@@ -17,6 +17,7 @@
 
 
 #include <libgoocanvasmm/itemmodelsimple.h>
+#include <gtkmm/enums.h> /* For AnchorType. */
 
 _DEFS(libgoocanvasmm,libgoocanvas)
 _PINCLUDE(glibmm/private/object_p.h)
@@ -29,18 +30,18 @@
   _CLASS_GOBJECT(TextModel,GooCanvasTextModel,GOO_CANVAS_TEXT_MODEL,Goocanvas::ItemModelSimple,GooCanvasItemModelSimple)
 protected:
 
-  TextModel(const Glib::RefPtr<ItemModel>& parent, const Glib::ustring& string, double x, double y, double width, GtkAnchorType anchor ) ;
+  TextModel(const Glib::RefPtr<ItemModel>& parent, const Glib::ustring& string, double x, double y, double width, Gtk::AnchorType anchor ) ;
 
 public:
 
-  _WRAP_CREATE(const Glib::RefPtr<ItemModel>& parent, const Glib::ustring& string, double x, double y, double width, GtkAnchorType anchor)
+  _WRAP_CREATE(const Glib::RefPtr<ItemModel>& parent, const Glib::ustring& string, double x, double y, double width, Gtk::AnchorType anchor)
 
   _WRAP_PROPERTY("alignment", PangoAlignment)
-  _WRAP_PROPERTY("anchor", GtkAnchorType)
+  _WRAP_PROPERTY("anchor", Gtk::AnchorType)
   _WRAP_PROPERTY("font", Glib::ustring)
-  _WRAP_PROPERTY("font-desc", PangoFontDescription)
+  _WRAP_PROPERTY("font-desc", Pango::FontDescription) //TODO: Use pointer? */
   _WRAP_PROPERTY("text", Glib::ustring)
-  _WRAP_PROPERTY("use-markup",bool)
+  _WRAP_PROPERTY("use-markup", bool)
   _WRAP_PROPERTY("width", double)
   _WRAP_PROPERTY("x", double)
   _WRAP_PROPERTY("y", double)
Index: libgoocanvas/src/points.ccg
===================================================================
--- libgoocanvas/src/points.ccg	(revision 50)
+++ libgoocanvas/src/points.ccg	(working copy)
@@ -24,7 +24,8 @@
 namespace Goocanvas
 {
 
-Points::Points( int num_points, double* coords )
+//TODO: Check that this constructor is correct. murrayc.
+Points::Points(int num_points, double* coords)
   :
    gobject_(goo_canvas_points_new(num_points)) 
 {
@@ -39,7 +40,7 @@
 }
 
 int
-Points::num_points()
+Points::num_points() const
 {
   return gobj()->num_points ;
 }
@@ -52,7 +53,7 @@
 }
 
 void
-Points::get_coordinate( int index, double& x, double& y )
+Points::get_coordinate( int index, double& x, double& y ) const
 {
   x = gobj()->coords[2*index] ;
   y = gobj()->coords[2*index+1] ;
Index: libgoocanvas/src/polylinemodel.ccg
===================================================================
--- libgoocanvas/src/polylinemodel.ccg	(revision 50)
+++ libgoocanvas/src/polylinemodel.ccg	(working copy)
@@ -23,12 +23,14 @@
 namespace Goocanvas
 {
 
+//TODO: Reimplement 
 PolylineModel::PolylineModel(const Glib::RefPtr<ItemModel>& parent, double x1, double y1, double x2, double y2)
-  :
-    ItemModelSimple(GOO_CANVAS_ITEM_MODEL_SIMPLE(goo_canvas_polyline_model_new_line(parent->gobj(), x1, y1, x2, y2, NULL)))
+:
+  _CONSTRUCT("x1", x1, "y1", y1, "x2", x2, "y2", y2)
 {
-  reference() ;
+  if(parent)
+    goo_canvas_item_model_add_child (parent->gobj(), GOO_CANVAS_ITEM_MODEL(gobj()), -1);
 }
 
-}
+} //namespace Goocanvas
 
Index: libgoocanvas/src/groupmodel.ccg
===================================================================
--- libgoocanvas/src/groupmodel.ccg	(revision 50)
+++ libgoocanvas/src/groupmodel.ccg	(working copy)
@@ -24,19 +24,13 @@
 namespace Goocanvas
 {
 
-GroupModel::GroupModel()
-  :
-    ItemModelSimple(GOO_CANVAS_ITEM_MODEL_SIMPLE(goo_canvas_group_model_new(NULL,NULL)))
-{
-  //reference() ; No parent, so we don't unref.
-}
-
 GroupModel::GroupModel(const Glib::RefPtr<ItemModel>& parent)
-  :
-    ItemModelSimple(GOO_CANVAS_ITEM_MODEL_SIMPLE(goo_canvas_group_model_new(parent->gobj(),NULL)))
+:
+  _CONSTRUCT()
 {
-  reference() ;
+  if(parent)
+    goo_canvas_item_model_add_child (parent->gobj(), GOO_CANVAS_ITEM_MODEL(gobj()), -1) ;
 }
 
-}
+} //namespace Goocanvas
 
Index: libgoocanvas/src/ellipsemodel.ccg
===================================================================
--- libgoocanvas/src/ellipsemodel.ccg	(revision 50)
+++ libgoocanvas/src/ellipsemodel.ccg	(working copy)
@@ -23,11 +23,13 @@
 namespace Goocanvas
 {
 
+//TODO: Reimplement goo_canvas_ellipse_model_new:
 EllipseModel::EllipseModel(const Glib::RefPtr<ItemModel>& parent, double center_x, double center_y, double radius_x, double radius_y)
-  :
-    ItemModelSimple( GOO_CANVAS_ITEM_MODEL_SIMPLE( goo_canvas_ellipse_model_new( parent->gobj(), center_x, center_y, radius_x, radius_y, NULL ) ) )
+:
+  _CONSTRUCT("center_x", center_x, "center_y", center_y, "radius_x", radius_x, "radius_y", radius_y)
 {
-	reference() ;
+  if(parent)
+    goo_canvas_item_model_add_child (parent->gobj(), GOO_CANVAS_ITEM_MODEL(gobj()), -1);
 }
 
-}
+} //namespace GooCanvas
Index: libgoocanvas/src/groupmodel.hg
===================================================================
--- libgoocanvas/src/groupmodel.hg	(revision 50)
+++ libgoocanvas/src/groupmodel.hg	(working copy)
@@ -30,7 +30,7 @@
 
 protected:
 
-  GroupModel() ;
+  _CTOR_DEFAULT
   explicit GroupModel(const Glib::RefPtr<ItemModel>& parent);
 
 public:
Index: libgoocanvas/src/rectmodel.hg
===================================================================
--- libgoocanvas/src/rectmodel.hg	(revision 50)
+++ libgoocanvas/src/rectmodel.hg	(working copy)
@@ -31,18 +31,18 @@
 
 protected:
 
-  RectModel( const Glib::RefPtr<ItemModel>& parent, gdouble x, double y, gdouble width, gdouble height ) ;
+  RectModel(const Glib::RefPtr<ItemModel>& parent, gdouble x, double y, gdouble width, gdouble height) ;
 
 public:
 
-  _WRAP_CREATE( const Glib::RefPtr<ItemModel>& parent, gdouble x, gdouble y, gdouble width, gdouble height )
+  _WRAP_CREATE(const Glib::RefPtr<ItemModel>& parent, gdouble x, gdouble y, gdouble width, gdouble height)
 
-  _WRAP_PROPERTY("height",gdouble)
-  _WRAP_PROPERTY("radius-x",gdouble)
-  _WRAP_PROPERTY("radius-y",gdouble)
-  _WRAP_PROPERTY("width",gdouble)
-  _WRAP_PROPERTY("x",gdouble)
-  _WRAP_PROPERTY("y",gdouble)
+  _WRAP_PROPERTY("height", gdouble)
+  _WRAP_PROPERTY("radius-x", gdouble)
+  _WRAP_PROPERTY("radius-y", gdouble)
+  _WRAP_PROPERTY("width", gdouble)
+  _WRAP_PROPERTY("x", gdouble)
+  _WRAP_PROPERTY("y", gdouble)
 
 };
 
Index: libgoocanvas/src/image.ccg
===================================================================
--- libgoocanvas/src/image.ccg	(revision 50)
+++ libgoocanvas/src/image.ccg	(working copy)
@@ -24,17 +24,20 @@
 {
 
 Image::Image( const Glib::RefPtr<Goocanvas::Item>& parent, const Glib::RefPtr<Gdk::Pixbuf>& pixbuf, double x, double y )
-  :
-    ItemSimple( GOO_CANVAS_ITEM_SIMPLE( goo_canvas_image_new( parent->gobj(), pixbuf->gobj(), x, y, NULL ) ) )
+:
+  _CONSTRUCT("pixbuf", pixbuf->gobj(), "x", x, "y", y)
 {
-  reference() ;
+  if(parent)
+    goo_canvas_item_add_child (parent->gobj(), GOO_CANVAS_ITEM(gobj()), -1);
 }
 
 Image::Image( const Glib::RefPtr<Goocanvas::Item>& parent, double x, double y )
-  : ItemSimple( GOO_CANVAS_ITEM_SIMPLE( goo_canvas_image_new( parent->gobj(), NULL, x, y, NULL ) ) )
+:
+  _CONSTRUCT("x", x, "y", y)
 {
-  reference() ;
+  if(parent)
+    goo_canvas_item_add_child (parent->gobj(), GOO_CANVAS_ITEM(gobj()), -1);
 }
 
-}
+} //namspace Goocanvas
 
Index: examples/demo/primitives.cc
===================================================================
--- examples/demo/primitives.cc	(revision 50)
+++ examples/demo/primitives.cc	(working copy)
@@ -95,7 +95,7 @@
 	double x = (pos%3) * 200 + 100 ;
 	double y = (pos/3) * 150 + 5 ;
 
-	Glib::RefPtr<Goocanvas::Text> text = Goocanvas::Text::create( _canvas->get_root_item(), heading, x, y, -1, GTK_ANCHOR_N ) ;
+	Glib::RefPtr<Goocanvas::Text> text = Goocanvas::Text::create( _canvas->get_root_item(), heading, x, y, -1, Gtk::ANCHOR_N ) ;
 	text->property_font() = "Sans 12" ;
 	text->skew_y( 30, x, y ) ;
 }
@@ -205,7 +205,7 @@
 {
 	Glib::RefPtr<Goocanvas::Text> text ;
 
-	text = Goocanvas::Text::create( _create_anchor( 420, 20 ), "Anchor NW", 0, 0, -1, GTK_ANCHOR_NW ) ;
+	text = Goocanvas::Text::create( _create_anchor( 420, 20 ), "Anchor NW", 0, 0, -1, Gtk::ANCHOR_NW ) ;
 	//ellipse->property_fill_pattern() = _create_stipple( "blue" ) ;
 	Cairo::RefPtr<Cairo::Pattern> p = _create_stipple( "blue" ) ;
 	g_object_set( text->gobj(), "fill-pattern", p->cobj(), NULL ) ;
@@ -214,7 +214,7 @@
 	text->property_fill_color() = "firebrick" ;
 	_setup_signals( text ) ;
 
-	text = Goocanvas::Text::create( _create_anchor( 470, 75 ), "Anchor center\nJustify center\nMultiline text\n8bit text 'gibberish'", 0, 0, -1, GTK_ANCHOR_CENTER ) ;
+	text = Goocanvas::Text::create( _create_anchor( 470, 75 ), "Anchor center\nJustify center\nMultiline text\n8bit text 'gibberish'", 0, 0, -1, Gtk::ANCHOR_CENTER ) ;
 	text->property_font() = "monospace bold 14" ;
 	text->property_alignment() = Pango::ALIGN_CENTER ;
 	text->property_fill_color() = "firebrick" ;
@@ -222,12 +222,12 @@
 
 	text = Goocanvas::Text::create( _create_anchor( 420, 240 ),
 		"This is a very long paragraph that will need to be wrapped over several lines so we can see what happens to line-breaking as the view is zoomed in and out.",
-		0, 0, 180, GTK_ANCHOR_W ) ;
+		0, 0, 180, Gtk::ANCHOR_W ) ;
 	text->property_font() = "Sans 12" ;
 	text->property_fill_color() = "goldenrod" ;
 	_setup_signals( text ) ;
 
-	text = Goocanvas::Text::create( _canvas->get_root_item(), "Ellipsized text.", 20, 420, 115, GTK_ANCHOR_W ) ;
+	text = Goocanvas::Text::create( _canvas->get_root_item(), "Ellipsized text.", 20, 420, 115, Gtk::ANCHOR_W ) ;
 	text->property_font() = "Sans 12" ;
 	text->property_fill_color() = "blue" ;
 	text->property_ellipsize() = Pango::ELLIPSIZE_END ;
@@ -255,10 +255,10 @@
 		g_warning( "Couldn't find the toroid.png sample file." ) ;
 	}
 
-	_create_flower( 20.0, 170.0, GTK_ANCHOR_NW ) ;
-	_create_flower( 180.0, 170.0, GTK_ANCHOR_NE ) ;
-	_create_flower( 20.0, 280.0, GTK_ANCHOR_SW ) ;
-	_create_flower( 180.0, 280.0, GTK_ANCHOR_SE ) ;
+	_create_flower( 20.0, 170.0, Gtk::ANCHOR_NW ) ;
+	_create_flower( 180.0, 170.0, Gtk::ANCHOR_NE ) ;
+	_create_flower( 20.0, 280.0, Gtk::ANCHOR_SW ) ;
+	_create_flower( 180.0, 280.0, Gtk::ANCHOR_SE ) ;
 }
 
 void
@@ -339,7 +339,7 @@
 }
 
 void
-Primitives::_create_flower( double x, double y, GtkAnchorType anchor )
+Primitives::_create_flower( double x, double y, Gtk::AnchorType anchor )
 {
 	Cairo::RefPtr<Cairo::ImageSurface> surface ;
 
@@ -360,7 +360,7 @@
 	Cairo::RefPtr<Cairo::SurfacePattern> pattern = Cairo::SurfacePattern::create( surface ) ;
 
 	Glib::RefPtr<Goocanvas::Image> img = Goocanvas::Image::create( _canvas->get_root_item(), x, y ) ;
-	//img->property_pattern() = pattern ;
+	//TODO: img->property_pattern() = pattern ;
 	g_object_set( img->gobj(), "pattern", pattern->cobj(), NULL ) ;
 	img->property_width() = w ;
 	img->property_height() = h ;
Index: examples/demo/primitives.hh
===================================================================
--- examples/demo/primitives.hh	(revision 50)
+++ examples/demo/primitives.hh	(working copy)
@@ -59,7 +59,7 @@
 		Glib::RefPtr<Goocanvas::Item>
 								_create_anchor( double x, double y ) ;
 
-		void					_create_flower( double x, double y, GtkAnchorType anchor ) ;
+		void					_create_flower( double x, double y, Gtk::AnchorType anchor ) ;
 		void					_create_polish_diamond() ;
 		void					_create_hilbert() ;
 
Index: examples/simple/window.cc
===================================================================
--- examples/simple/window.cc	(revision 50)
+++ examples/simple/window.cc	(working copy)
@@ -22,7 +22,7 @@
 	rect->property_stroke_color().set_value( "yellow" ) ;
 	rect->property_fill_color().set_value( "red" ) ;
 
-	Glib::RefPtr<Goocanvas::Text> text = Goocanvas::Text::create( root, "Hello World", 300, 300, -1, GTK_ANCHOR_CENTER ) ;
+	Glib::RefPtr<Goocanvas::Text> text = Goocanvas::Text::create( root, "Hello World", 300, 300, -1, Gtk::ANCHOR_CENTER ) ;
 	text->property_font().set_value( "Sans 24" ) ;
 	text->rotate( 45, 300, 300 ) ;
 


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