gnomemm r1526 - in geglmm/trunk: . examples libgegl/src



Author: hub
Date: Fri May 23 04:08:41 2008
New Revision: 1526
URL: http://svn.gnome.org/viewvc/gnomemm?rev=1526&view=rev

Log:
	* libgegl/src/color.hg: Change the name of the property
	for create().

	* libgegl/src/node.ccg:
	* libgegl/src/node.hg:
	* examples/geglbuffer-add-image.cc:
	* examples/geglbuffer-clock.cc:
	* examples/hello-world.cc:
	* examples/2geglbuffer.cc:
	Don't use variadic function. Instead just a templated 
	set() and get().


Modified:
   geglmm/trunk/ChangeLog
   geglmm/trunk/examples/2geglbuffer.cc
   geglmm/trunk/examples/geglbuffer-add-image.cc
   geglmm/trunk/examples/geglbuffer-clock.cc
   geglmm/trunk/examples/hello-world.cc
   geglmm/trunk/libgegl/src/color.hg
   geglmm/trunk/libgegl/src/node.ccg
   geglmm/trunk/libgegl/src/node.hg

Modified: geglmm/trunk/examples/2geglbuffer.cc
==============================================================================
--- geglmm/trunk/examples/2geglbuffer.cc	(original)
+++ geglmm/trunk/examples/2geglbuffer.cc	Fri May 23 04:08:41 2008
@@ -22,9 +22,9 @@
 
   gegl = Gegl::Node::create();
   load_file = gegl->new_child ( "operation", "load");
-  load_file->set("path", argv[1], NULL);
+  load_file->set("path", Glib::ustring(argv[1]));
   save_file = gegl->new_child ( "operation", "save-buffer");
-  save_file->set("buffer", buffer->gobj(), NULL);
+  save_file->set("buffer", buffer);
 
   load_file->link (save_file);
   save_file->process ();

Modified: geglmm/trunk/examples/geglbuffer-add-image.cc
==============================================================================
--- geglmm/trunk/examples/geglbuffer-add-image.cc	(original)
+++ geglmm/trunk/examples/geglbuffer-add-image.cc	Fri May 23 04:08:41 2008
@@ -38,11 +38,11 @@
   gegl = Gegl::Node::create();
 
   write_buffer = gegl->new_child ("operation", "write-buffer");
-  write_buffer->set("buffer", buffer->gobj(), NULL);
+  write_buffer->set("buffer", buffer);
   shift      = gegl->new_child ("operation", "shift");
-  shift->set ( "x", x, "y", y, NULL);
+  shift->set ( "x", x).set("y", y);
   load        = gegl->new_child ("operation", "load");
-  load->set ("path", in_file, NULL);
+  load->set ("path", Glib::ustring(in_file));
 
   load->link(shift);
   load->link(write_buffer);

Modified: geglmm/trunk/examples/geglbuffer-clock.cc
==============================================================================
--- geglmm/trunk/examples/geglbuffer-clock.cc	(original)
+++ geglmm/trunk/examples/geglbuffer-clock.cc	Fri May 23 04:08:41 2008
@@ -31,21 +31,25 @@
 
 
   blank      = gegl->new_child ("operation", "color");
-  blank->set ("value", Gegl::Color::create ("rgba(0.0,0.0,0.0,0.4)")->gobj(), NULL);
+  blank->set ("value", Gegl::Color::create ("rgba(0.0,0.0,0.0,0.4)"));
 
   crop       = gegl->new_child ("operation", "crop");
-  crop->set ("x", 0.0, "y", 0.0, "width", 260.0, "height", 22.0, NULL);
+  crop->set ("x", 0.0);
+  crop->set ("y", 0.0);
+  crop->set ("width", 260.0);
+  crop->set ("height", 22.0);
 
   layer      = gegl->new_child ("operation", "layer");
 
   shift      = gegl->new_child ("operation", "shift");
-  shift->set("x", 0.0, "y", 0.0, NULL);
+  shift->set("x", 0.0);
+  shift->set("y", 0.0);
 
   text       = gegl->new_child ("operation", "text");
-  text->set ("size", 20.0, NULL);
+  text->set ("size", 20.0);
                              /*      "color", gegl_color_new ("rgb(0.0,0.0,0.0)"),*/
   display    = gegl->new_child ("operation", "composite-buffer");
-  display->set ("path", argv[1], NULL);
+  display->set ("path", Glib::ustring(argv[1]));
 
   blank->link(crop);
   blank->link(layer);
@@ -67,8 +71,8 @@
         struct timeval tv;
 
         int t = gettimeofday(&tv, NULL);
-	text->set("string", ctime((const time_t*)&t), NULL);
-	display->process();
+		text->set("string", Glib::ustring(ctime((const time_t*)&t)));
+		display->process();
         g_usleep (1000000);
       }
   }

Modified: geglmm/trunk/examples/hello-world.cc
==============================================================================
--- geglmm/trunk/examples/hello-world.cc	(original)
+++ geglmm/trunk/examples/hello-world.cc	Fri May 23 04:08:41 2008
@@ -39,11 +39,12 @@
     /*< The image nodes representing operations we want to perform */
     Glib::RefPtr<Gegl::Node> display = gegl->create_child("display");
     Glib::RefPtr<Gegl::Node> layer = gegl->new_child("operation", "layer");
-    layer->set ("x", 2.0, "y", 4.0, NULL);
+    layer->set ("x", 2.0).set ("y", 4.0);
     Glib::RefPtr<Gegl::Node> text = gegl->new_child("operation", "text");
-    text->set ("size", 10.0, "color", Glib::RefPtr<Gegl::Color>(Gegl::Color::create ("rgb(1.0,1.0,1.0)"))->gobj(), NULL);
+    text->set ("size", 10.0)
+		.set ("color", Glib::RefPtr<Gegl::Color>(Gegl::Color::create ("rgb(1.0,1.0,1.0)")));
     Glib::RefPtr<Gegl::Node> mandelbrot = gegl->new_child ("operation", "fractal-explorer");
-    mandelbrot->set ("width", 512, "height", 384, NULL);
+    mandelbrot->set ("width", 512).set ("height", 384);
 
     mandelbrot->link (layer);
     mandelbrot->link (display);
@@ -76,9 +77,9 @@
             ymin=-3.0;
 
           
-          mandelbrot->set ("xmin", xmin, "ymin", ymin, "xmax", xmax, "ymax", ymax, NULL);
+          mandelbrot->set ("xmin", xmin).set ("ymin", ymin).set ("xmax", xmax).set ("ymax", ymax);
           snprintf (string, sizeof string, "%1.3f,%1.3f %1.3fÃ%1.3f", xmin, ymin, xmax-xmin, ymax-ymin);
-          text->set ("string", string, NULL);
+          text->set ("string", Glib::ustring(string));
           display->process ();
         }
     }

Modified: geglmm/trunk/libgegl/src/color.hg
==============================================================================
--- geglmm/trunk/libgegl/src/color.hg	(original)
+++ geglmm/trunk/libgegl/src/color.hg	Fri May 23 04:08:41 2008
@@ -30,7 +30,7 @@
 {
 	_CLASS_GOBJECT(Color, GeglColor, GEGL_COLOR, Glib::Object, GObject)
 protected:
-	_WRAP_CTOR(Color(const Glib::ustring & s), gegl_color_new)
+	_WRAP_CTOR(Color(const Glib::ustring & string), gegl_color_new)
 
 public:
 	_WRAP_CREATE(const Glib::ustring & s)

Modified: geglmm/trunk/libgegl/src/node.ccg
==============================================================================
--- geglmm/trunk/libgegl/src/node.ccg	(original)
+++ geglmm/trunk/libgegl/src/node.ccg	Fri May 23 04:08:41 2008
@@ -48,35 +48,7 @@
 	}
 
 
-	// GEGL does not export these.
-	// http://bugzilla.gnome.org/show_bug.cgi?id=534288
-	extern "C" void
-	gegl_node_set_valist (GeglNode    *self,
-						  const gchar *first_property_name,
-						  va_list      var_args);
-	extern "C" void
-	gegl_node_get_valist (GeglNode    *self,
-						  const gchar *first_property_name,
-						  va_list      var_args);
 
-	void Node::set(const gchar * first_property_name, ...)
-	{
-		va_list var_args;
-
-		va_start (var_args, first_property_name);
-		gegl_node_set_valist(gobj(), first_property_name, var_args);
-		va_end (var_args);
-	}
-
-
-	void Node::get(const gchar * first_property_name, ...)
-	{
-		va_list var_args;
-
-		va_start (var_args, first_property_name);
-		gegl_node_get_valist(gobj(), first_property_name, var_args);
-		va_end (var_args);
-	}
 
 }
 

Modified: geglmm/trunk/libgegl/src/node.hg
==============================================================================
--- geglmm/trunk/libgegl/src/node.hg	(original)
+++ geglmm/trunk/libgegl/src/node.hg	Fri May 23 04:08:41 2008
@@ -101,10 +101,15 @@
 	_WRAP_METHOD(Glib::RefPtr<Node> create_child(const Glib::ustring & operation), gegl_node_create_child)
 
 
+	_IGNORE(gegl_node_get)
+	_IGNORE(gegl_node_set)
 	_IGNORE(gegl_node_get_property)
 	_IGNORE(gegl_node_set_property)
-	void set(const gchar * first_property_name, ...);
-	void get(const gchar * first_property_name, ...);
+
+	template <class T>
+	Node & set(const Glib::ustring & property_name, const T & value);
+	template <class T>
+	Node & get(const Glib::ustring & property_name, T & value);
 
 	_WRAP_METHOD(static Glib::RefPtr<Node> new_from_xml(const Glib::ustring & xmldata, const Glib::ustring & path_root), gegl_node_new_from_xml)
 	_WRAP_METHOD(static Glib::RefPtr<Node> new_from_file(const Glib::ustring & path), gegl_node_new_from_file)
@@ -122,5 +127,25 @@
 	_WRAP_SIGNAL(void computed(const Rectangle &r), "computed", no_default_handler)
 };
 
+template <class T>
+Node & Node::set(const Glib::ustring & property_name, const T & value)
+{
+	Glib::Value<T> v;
+	v.init(Glib::Value<T>::value_type());
+	v.set(value);
+	gegl_node_set_property(gobj(), property_name.c_str(), v.gobj());
+	return *this;
+}
+
+template <class T>
+Node & Node::get(const Glib::ustring & property_name, T & value)
+{
+	Glib::Value<T> v;
+	v.init(Glib::Value<T>::value_type());
+	gegl_node_get_property(gobj(), property_name.c_str(), v.gobj());
+	value = v.get();
+	return *this;
+}
+
 
 }



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