summaryrefslogtreecommitdiffstats
path: root/gobject/gobjectmodule.c
diff options
context:
space:
mode:
authorJohan Dahlin <johan@src.gnome.org>2005-07-15 20:27:38 +0000
committerJohan Dahlin <johan@src.gnome.org>2005-07-15 20:27:38 +0000
commit233789c73ffcbbe18b8dffdcf91416875f99c3a4 (patch)
tree4ef38f9033e92b6944827c862e0c0cc0838d0051 /gobject/gobjectmodule.c
parentb06e98fe21c4748d79d9eb966ddb301dc7779c4b (diff)
downloadpygobject-233789c73ffcbbe18b8dffdcf91416875f99c3a4.tar.gz
pygobject-233789c73ffcbbe18b8dffdcf91416875f99c3a4.tar.xz
pygobject-233789c73ffcbbe18b8dffdcf91416875f99c3a4.zip
Allow enums to be specified in the constructor Return flags or enum object
* gobject/gobjectmodule.c: (create_property): Allow enums to be specified in the constructor * gobject/pygparamspec.c: (pyg_param_spec_getattr): Return flags or enum object for pspec.default_value * tests/test_enum.py: Remove usage of assert statement, add default_value test, both for flags and enum
Diffstat (limited to 'gobject/gobjectmodule.c')
-rw-r--r--gobject/gobjectmodule.c18
1 files changed, 15 insertions, 3 deletions
diff --git a/gobject/gobjectmodule.c b/gobject/gobjectmodule.c
index b6dba0d..e038bfa 100644
--- a/gobject/gobjectmodule.c
+++ b/gobject/gobjectmodule.c
@@ -701,9 +701,15 @@ create_property (const gchar *prop_name,
case G_TYPE_ENUM:
{
gint default_value;
-
- if (!PyArg_ParseTuple(args, "i", &default_value))
+ PyObject *pydefault;
+
+ if (!PyArg_ParseTuple(args, "O", &pydefault))
+ return NULL;
+
+ if (pyg_enum_get_value(prop_type, pydefault,
+ (gint *)&default_value))
return NULL;
+
pspec = g_param_spec_enum (prop_name, nick, blurb,
prop_type, default_value, flags);
}
@@ -711,9 +717,15 @@ create_property (const gchar *prop_name,
case G_TYPE_FLAGS:
{
guint default_value;
+ PyObject *pydefault;
- if (!PyArg_ParseTuple(args, "i", &default_value))
+ if (!PyArg_ParseTuple(args, "O", &pydefault))
+ return NULL;
+
+ if (pyg_flags_get_value(prop_type, pydefault,
+ (gint *)&default_value))
return NULL;
+
pspec = g_param_spec_flags (prop_name, nick, blurb,
prop_type, default_value, flags);
}