Index: docs/reference/gobject/tmpl/objects.sgml
===================================================================
--- docs/reference/gobject/tmpl/objects.sgml	(revisão 5484)
+++ docs/reference/gobject/tmpl/objects.sgml	(cópia de trabalho)
@@ -1023,6 +1023,32 @@
 @value: return location for the property value
 
 
+<!-- ##### FUNCTION g_object_get_properties ##### -->
+<para>
+Gets properties on an object.
+</para>
+<para>
+Note that g_object_get_properties() is really intended for language
+bindings, g_object_get() is much more convenient for C programming.
+</para>
+
+@object: a #GObject
+@n_parameters: number of parameters to get
+@parameters: parameters
+
+<!-- ##### FUNCTION g_object_set_properties ##### -->
+<para>
+Sets properties on an object.
+</para>
+<para>
+Note that g_object_set_properties() is really intended for language
+bindings, g_object_set() is much more convenient for C programming.
+</para>
+
+@object: a #GObject
+@n_parameters: number of parameters to set
+@parameters: parameters
+
 <!-- ##### FUNCTION g_object_new_valist ##### -->
 <para>
 Creates a new instance of a #GObject subtype and sets its properties.

Mudanças de propriedades em: tests/gobject
___________________________________________________________________
Nome: svn:ignore
   - Makefile
Makefile.in
accumulator
defaultiface
gvalue-test
ifacecheck
ifaceinherit
ifaceinit
ifaceproperties
override
references
testmarshal.c
testmarshal.h
stamp-testmarshal.h
paramspec-test
.libs
.deps

   + Makefile
Makefile.in
accumulator
defaultiface
gvalue-test
ifacecheck
ifaceinherit
ifaceinit
ifaceproperties
override
references
properties
testmarshal.c
testmarshal.h
stamp-testmarshal.h
paramspec-test
.libs
.deps


Index: tests/gobject/Makefile.am
===================================================================
--- tests/gobject/Makefile.am	(revisão 5484)
+++ tests/gobject/Makefile.am	(cópia de trabalho)
@@ -58,7 +58,8 @@
 	ifaceproperties				\
 	override				\
 	singleton				\
-	references
+	references				\
+	properties
 
 check_PROGRAMS = $(test_programs)
 
Index: tests/gobject/properties.c
===================================================================
--- tests/gobject/properties.c	(revisão 0)
+++ tests/gobject/properties.c	(revisão 0)
@@ -0,0 +1,320 @@
+/* GObject - GLib Type, Object, Parameter and Signal Library
+ * Copyright (C) 2006 Johan Dahlin
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General
+ * Public License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place, Suite 330,
+ * Boston, MA 02111-1307, USA.
+ */
+
+#include <string.h>
+
+#include <glib-object.h>
+
+#define TEST_TYPE_OBJECT          (test_object_get_type ())
+typedef struct _TestObject        TestObject;
+typedef struct _TestObjectClass   TestObjectClass;
+
+enum {
+  PROP_0,
+  PROP_STRING,
+  PROP_INT,
+};
+
+struct _TestObject
+{
+  GObject parent_instance;
+  gchar * prop_string;
+  int prop_int;
+};
+
+struct _TestObjectClass
+{
+  GObjectClass parent_class;
+};
+
+G_DEFINE_TYPE (TestObject, test_object, G_TYPE_OBJECT);
+
+static void
+test_object_set_property (GObject         *object,
+			  guint            prop_id,
+			  const GValue    *value,
+			  GParamSpec      *pspec)
+{
+  TestObject *test = (TestObject*)object;
+
+  switch (prop_id)
+    {
+    case PROP_STRING:
+      test->prop_string = g_strdup (g_value_get_string (value));
+      break;
+    case PROP_INT:
+      test->prop_int = g_value_get_int (value);
+      break;
+    default:
+      G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+      break;
+    }
+}
+
+static void
+test_object_get_property (GObject         *object,
+			  guint            prop_id,
+			  GValue          *value,
+			  GParamSpec      *pspec)
+{
+  TestObject *test = (TestObject*)object;
+  
+  switch (prop_id)
+    {
+    case PROP_STRING:
+      g_value_set_string (value, test->prop_string);
+      break;
+    case PROP_INT:
+      g_value_set_int (value, test->prop_int);
+      break;
+    default:
+      G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+      break;
+    }
+}
+
+static void
+test_object_finalize (GObject *object)
+{
+  TestObject *test = (TestObject*)object;
+
+  g_free (test->prop_string);
+  
+  G_OBJECT_CLASS (test_object_parent_class)->finalize (object);
+}
+
+static void
+test_object_class_init (TestObjectClass *class)
+{
+  GObjectClass *gobject_class = G_OBJECT_CLASS (class);
+
+  gobject_class->finalize = test_object_finalize;
+  gobject_class->set_property = test_object_set_property;
+  gobject_class->get_property = test_object_get_property;
+
+  g_object_class_install_property (gobject_class,
+                                   PROP_STRING,
+                                   g_param_spec_string ("string", NULL, NULL, NULL,
+                                                        G_PARAM_READWRITE));
+
+  g_object_class_install_property (gobject_class,
+                                   PROP_INT,
+                                   g_param_spec_int ("int", NULL, NULL,
+                                                     G_MININT, G_MAXINT, 0,
+                                                     G_PARAM_READWRITE));
+}
+
+static void
+test_object_init (TestObject *test_object)
+{
+}
+
+static void
+test_set_properties (GObject *test)
+{
+  GParameter *parameters;
+  GValue *values;
+
+  parameters = g_new0 (GParameter, 2);
+  values = g_new0 (GValue, 2);
+
+  g_value_init (&values[0], G_TYPE_STRING);
+  g_value_set_static_string (&values[0], "foobar");
+  parameters[0].name = "string";
+  parameters[0].value = values[0];
+    
+  g_value_init (&values[1], G_TYPE_INT);
+  g_value_set_int (&values[1], 42);
+  parameters[1].name = "int";
+  parameters[1].value = values[1];
+
+  g_object_set_properties (test, 2, parameters);
+
+  g_value_unset (&values[0]);
+  g_value_unset (&values[1]);
+  g_free (values);
+  g_free (parameters);
+  
+  g_assert (!strcmp (((TestObject*)test)->prop_string, "foobar"));
+  g_assert (((TestObject*)test)->prop_int == 42);
+}
+
+static void
+test_set (GObject *test)
+{
+  g_object_set (test, "string", "sliff", "int", 10, NULL);
+  g_assert (!strcmp (((TestObject*)test)->prop_string, "sliff"));
+  g_assert (((TestObject*)test)->prop_int == 10);
+}
+
+static void
+test_get (GObject *test)
+{
+  char *str;
+  int i;
+  
+  g_object_get (test, "string", &str, "int", &i, NULL);
+  
+  g_assert (!strcmp (str, "sliff"));
+  g_assert (i == 10);
+}
+
+static void
+test_set_valist_set (GObject *test, const gchar * first_property_name, ...)
+{
+  va_list var_args;
+
+  va_start (var_args, first_property_name);
+  g_object_set_valist (test, first_property_name, var_args);
+  va_end (var_args);
+}
+
+static void
+test_get_valist_get (GObject *test, const gchar * first_property_name, ...)
+{
+  va_list var_args;
+
+  va_start (var_args, first_property_name);
+  g_object_get_valist (test, first_property_name, var_args);
+  va_end (var_args);
+}
+
+static void
+test_set_valist (GObject *test)
+{
+  test_set_valist_set (test, "string", "sloff", "int", 20, NULL);
+
+  g_assert (!strcmp (((TestObject*)test)->prop_string, "sloff"));
+  g_assert (((TestObject*)test)->prop_int == 20);
+   
+}
+
+static void
+test_get_valist (GObject *test)
+{
+  char *str;
+  int i;
+  
+  test_get_valist_get (test, "string", &str, "int", &i, NULL);
+
+  g_assert (!strcmp (str, "sloff"));
+  g_assert (i == 20);
+   
+}
+
+static void
+test_set_property (GObject *test)
+{
+  GValue str_value = { 0, }, int_value = { 0, };
+
+  g_value_init (&str_value, G_TYPE_STRING);
+  g_value_set_string (&str_value, "sleff");
+  g_value_init (&int_value, G_TYPE_INT);
+  g_value_set_int (&int_value, 30);
+
+  g_object_set_property (test, "string", &str_value);
+  g_object_set_property (test, "int", &int_value);
+
+  g_assert (!strcmp (((TestObject*)test)->prop_string, "sleff"));
+  g_assert (((TestObject*)test)->prop_int == 30);
+
+  g_value_unset (&str_value);
+  g_value_unset (&int_value);
+}
+
+static void
+test_get_property (GObject *test)
+{
+  GValue str_value = { 0, }, int_value = { 0, };
+
+  g_value_init (&str_value, G_TYPE_STRING);
+  g_value_init (&int_value, G_TYPE_INT);
+
+  g_object_get_property (test, "string", &str_value);
+  g_object_get_property (test, "int", &int_value);
+
+  g_assert (!strcmp (((TestObject*)test)->prop_string, "sleff"));
+  g_assert (((TestObject*)test)->prop_int == 30);
+
+  g_value_unset (&str_value);
+  g_value_unset (&int_value);
+}
+
+static void
+test_get_properties (GObject *test)
+{
+  GParameter *parameters;
+
+  parameters = g_new0 (GParameter, 2);
+
+  g_value_init (&parameters[0].value, G_TYPE_STRING);
+  parameters[0].name = "string";
+    
+  g_value_init (&parameters[1].value, G_TYPE_INT);
+  parameters[1].name = "int";
+
+  g_object_get_properties (test, 2, parameters);
+
+  g_assert (!strcmp (g_value_get_string (&parameters[0].value), "foobar"));
+  g_assert (g_value_get_int (&parameters[1].value) == 42);
+
+  g_value_unset (&parameters[0].value);
+  g_value_unset (&parameters[1].value);
+  g_free (parameters);
+  
+}
+
+int
+main (int   argc,
+      char *argv[])
+{
+  GObject *obj;
+  char *s;
+  int i;
+  
+  g_log_set_always_fatal (g_log_set_always_fatal (G_LOG_FATAL_MASK) |
+                          G_LOG_LEVEL_WARNING |
+                          G_LOG_LEVEL_CRITICAL);
+  g_type_init ();
+
+  obj = g_object_new (TEST_TYPE_OBJECT, NULL);
+
+  /* Default values */
+  g_object_get (obj, "int", &i, NULL);
+  g_assert (i == 0);
+  
+  g_object_get (obj, "string", &s, NULL);
+  g_assert (s == NULL);
+
+  test_set (obj);
+  test_get (obj);
+
+  test_set_valist (obj);
+  test_get_valist (obj);
+
+  test_set_property (obj);
+  test_get_property (obj);
+
+  test_set_properties (obj);
+  test_get_properties (obj);
+  
+  g_object_unref (obj);
+  
+  return 0;
+}
Index: gobject/gobject.c
===================================================================
--- gobject/gobject.c	(revisão 5484)
+++ gobject/gobject.c	(cópia de trabalho)
@@ -1330,6 +1330,104 @@ g_object_get_property (GObject	   *objec
   g_object_unref (object);
 }
 
+void
+g_object_get_properties (GObject    *object,
+                         guint       n_parameters,
+                         GParameter *parameters)
+{
+  int i;
+
+  g_return_if_fail (G_IS_OBJECT (object));
+  
+  g_object_ref (object);
+  
+  for (i = 0; i < n_parameters; i++)
+    {
+      GValue *value = &parameters[i].value;
+      const gchar *name = parameters[i].name;
+      GParamSpec *pspec;
+      
+      pspec = g_param_spec_pool_lookup (pspec_pool,
+                                        name,
+                                        G_OBJECT_TYPE (object),
+                                        TRUE);
+      if (!pspec)
+	{
+	  g_warning ("%s: object class `%s' has no property named `%s'",
+		     G_STRFUNC,
+		     G_OBJECT_TYPE_NAME (object),
+		     name);
+	  break;
+	}
+      if (!(pspec->flags & G_PARAM_READABLE))
+	{
+	  g_warning ("%s: property `%s' of object class `%s' is not readable",
+		     G_STRFUNC,
+		     pspec->name,
+		     G_OBJECT_TYPE_NAME (object));
+	  break;
+	}
+      
+      object_get_property (object, pspec, value);
+
+    }
+
+  g_object_unref (object);
+}
+
+void
+g_object_set_properties (GObject    *object,
+                         guint       n_parameters,
+                         GParameter *parameters)
+{
+  GObjectNotifyQueue *nqueue;
+  int i;
+
+  g_return_if_fail (G_IS_OBJECT (object));
+  
+  g_object_ref (object);
+  nqueue = g_object_notify_queue_freeze (object, &property_notify_context);
+  
+  for (i = 0; i < n_parameters; i++)
+    {
+      GValue *value = &parameters[i].value;
+      const gchar *name = parameters[i].name;
+      GParamSpec *pspec;
+      
+      pspec = g_param_spec_pool_lookup (pspec_pool,
+                                        name,
+                                        G_OBJECT_TYPE (object),
+                                        TRUE);
+      if (!pspec)
+        {
+          g_warning ("%s: object class `%s' has no property named `%s'",
+                     G_STRFUNC,
+                     G_OBJECT_TYPE_NAME (object),
+                     name);
+          break;
+        }
+      if (!(pspec->flags & G_PARAM_WRITABLE))
+        {
+          g_warning ("%s: property `%s' of object class `%s' is not writable",
+                     G_STRFUNC,
+                     pspec->name,
+                     G_OBJECT_TYPE_NAME (object));
+          break;
+        }
+      if ((pspec->flags & G_PARAM_CONSTRUCT_ONLY) && !object_in_construction_list (object))
+        {
+          g_warning ("%s: construct property \"%s\" for object `%s' can't be set after construction",
+                     G_STRFUNC, pspec->name, G_OBJECT_TYPE_NAME (object));
+          break;
+        }
+
+      object_set_property (object, pspec, value, nqueue);
+    }
+
+  g_object_notify_queue_thaw (object, nqueue);
+  g_object_unref (object);
+}
+
 gpointer
 g_object_connect (gpointer     _object,
 		  const gchar *signal_spec,
Index: gobject/gobject.h
===================================================================
--- gobject/gobject.h	(revisão 5484)
+++ gobject/gobject.h	(cópia de trabalho)
@@ -177,6 +177,12 @@
 void        g_object_get_property             (GObject        *object,
 					       const gchar    *property_name,
 					       GValue         *value);
+void        g_object_get_properties           (GObject        *object,
+					       guint	       n_parameters,
+					       GParameter     *properties);
+void        g_object_set_properties           (GObject        *object,
+					       guint	       n_parameters,
+					       GParameter     *properties);
 void        g_object_freeze_notify            (GObject        *object);
 void        g_object_notify                   (GObject        *object,
 					       const gchar    *property_name);
Index: gobject/gobject.symbols
===================================================================
--- gobject/gobject.symbols	(revisão 5484)
+++ gobject/gobject.symbols	(cópia de trabalho)
@@ -124,6 +124,7 @@
 g_object_get G_GNUC_NULL_TERMINATED
 g_object_get_data
 g_object_get_property
+g_object_get_properties
 g_object_get_qdata
 g_object_get_valist
 g_object_interface_find_property
@@ -144,6 +145,7 @@
 g_object_set_data
 g_object_set_data_full
 g_object_set_property
+g_object_set_properties
 g_object_set_qdata
 g_object_set_qdata_full
 g_object_set_valist
