typo in genums.h ?!



Hi,

i have the impression gobject/genums.h from CVS contains a typo.
I propose to apply the following patch:

diff -u -r1.5 genums.h
--- gobject/genums.h	2000/10/25 20:36:35	1.5
+++ gobject/genums.h	2001/01/08 16:31:33
@@ -32,7 +32,7 @@
 #define G_ENUM_CLASS(class)	       (G_TYPE_CHECK_CLASS_CAST ((class), G_TYPE_ENUM, GEnumClass))
 #define G_IS_ENUM_CLASS(class)	       (G_TYPE_CHECK_CLASS_TYPE ((class), G_TYPE_ENUM))
 #define G_ENUM_CLASS_TYPE(class)       (G_TYPE_FROM_CLASS (class))
-#define G_ENUM_CLASS_TYPE_NAME(class)  (g_type_name (G_ENUM_TYPE (class)))
+#define G_ENUM_CLASS_TYPE_NAME(class)  (g_type_name (G_ENUM_CLASS_TYPE (class)))
 #define G_TYPE_IS_FLAGS(type)	       (G_TYPE_FUNDAMENTAL (type) == G_TYPE_FLAGS)
 #define G_FLAGS_CLASS(class)	       (G_TYPE_CHECK_CLASS_CAST ((class), G_TYPE_FLAGS, GFlagsClass))
 #define G_IS_FLAGS_CLASS(class)        (G_TYPE_CHECK_CLASS_TYPE ((class), G_TYPE_FLAGS))


However I have not yet figured out how to access the enum registered with an
object. My code is using

 container_policy_type = 
   g_enum_register_static ("GCimContainerPolicy",
         		   g_cim_container_policy_enum_values);

and installs the enum as property during class initialization:

  param_spec = g_param_spec_enum ("policy", NULL, NULL,
                                  G_CIM_TYPE_CONTAINER_POLICY,
				  G_CIM_CONTAINER_POLICY_STRONG,
				  G_PARAM_READABLE | 
				  G_PARAM_WRITABLE | 
				  G_PARAM_CONSTRUCT_ONLY);
  g_object_class_install_property (object_class, 
				   PROP_POLICY, param_spec);


Now, how do I access the name of an enum_value later? At the moment I try
the following. After retrieving the property_spec from the class, I do:

  g_value_init (value, prop_spec->value_type);
  g_object_get_property (G_OBJECT (object), prop_name, value);

This appereantly works fine. Then I try to find the string representation of 
the enum_value set:

  GEnumValue *enum_value = g_enum_get_value (G_ENUM_CLASS (value),
				             g_value_get_enum (value));

  name = enum_value->value_name;

but g_enum_get_value() fails here. Any ideas what I'm doing wrong here?


Salut, Sven






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