Gtk2
view release on metacpan or search on metacpan
xs/GtkContainer.xs view on Meta::CPAN
## GParamSpec* gtk_container_class_find_child_property (GObjectClass *cclass, const gchar *property_name)
## GParamSpec** gtk_container_class_list_child_properties (GObjectClass *cclass, guint *n_properties)
=for apidoc Gtk2::Container::list_child_properties
=for signature list = $object_or_class_name->list_child_properties
=for arg ... (__hide__)
Return a list of C<Glib::ParamSpec> objects which are the child
properties available for children of a container
C<$object_or_class_name>. See L<Glib::Object> C<list_properties> for
the fields in a ParamSpec.
=cut
=for apidoc Gtk2::Container::find_child_property
=for signature pspec or undef = $object_or_class_name->find_child_property ($name)
=for arg name (string)
=for arg ... (__hide__)
Return a C<Glib::ParamSpec> for child property C<$name> on container
C<$object_or_class_name>. If there's no property C<$name> then return
C<undef>. See L<Glib::Object> C<list_properties> for the fields in a
ParamSpec.
=cut
void
find_child_property (container_or_class_name, ...)
SV * container_or_class_name
ALIAS:
Gtk2::Container::list_child_properties = 1
PREINIT:
GType type;
gchar *name = NULL;
GObjectClass *object_class;
PPCODE:
/* ENHANCE-ME: share this SV to GType with
Glib::Object::find_property and probably other places. Might
pass GTK_TYPE_CONTAINER to say it should be a container. */
if (gperl_sv_is_defined (container_or_class_name) &&
SvROK (container_or_class_name)) {
GObject * object = SvGObject (container_or_class_name);
if (!object)
croak ("wha? NULL object in list_properties");
type = G_OBJECT_TYPE (object);
} else {
type = gperl_object_type_from_package
(SvPV_nolen (container_or_class_name));
if (!type)
croak ("package %s is not registered with GPerl",
SvPV_nolen (container_or_class_name));
}
switch (ix) {
case 0:
if (items != 2)
croak ("Usage: Gtk2::Container::find_child_property (class, name)");
name = SvGChar (ST (1));
break;
default: /* ix==1 */
if (items != 1)
croak ("Usage: Gtk2::Container::list_child_properties (class)");
break;
}
if (! g_type_is_a (type, GTK_TYPE_CONTAINER))
croak ("Not a Gtk2::Container");
/* classes registered by perl are kept alive by the bindings.
* those coming straight from C are not. if we had an actual
* object, the class will be alive, but if we just had a
* package, the class may not exist yet. thus, we'll have to
* do an honest ref here, rather than a peek.
*/
object_class = g_type_class_ref (type);
if (ix == 0) {
GParamSpec *pspec
= gtk_container_class_find_child_property
(object_class, name);
XPUSHs (pspec
? sv_2mortal (newSVGParamSpec (pspec))
: &PL_sv_undef);
}
else if (ix == 1) {
GParamSpec **props;
guint n_props, i;
props = gtk_container_class_list_child_properties
(object_class, &n_props);
if (n_props) {
EXTEND (SP, n_props);
for (i = 0; i < n_props; i++)
PUSHs (sv_2mortal (newSVGParamSpec (props[i])));
}
g_free (props); /* must free even when n_props==0 */
}
g_type_class_unref (object_class);
=for apidoc
=for arg ... list of property name/value pairs
=cut
## void gtk_container_add_with_properties (GtkContainer *container, GtkWidget *widget, const gchar *first_prop_name, ...)
void
gtk_container_add_with_properties (container, widget, ...)
GtkContainer *container
GtkWidget *widget
PREINIT:
GValue value = {0,};
int i;
CODE:
g_object_ref (container);
g_object_ref (widget);
gtk_widget_freeze_child_notify (widget);
gtk_container_add (container, widget);
if (widget->parent) {
if (0 != ((items - 2) % 2))
croak ("add_with_properties expects name => value pairs "
"(odd number of arguments detected)");
for (i = 2; i < items; i += 2) {
char *name = SvPV_nolen (ST (i));
SV *newval = ST (i + 1);
init_child_property_value (G_OBJECT (container), name, &value);
gperl_value_from_sv (&value, newval);
( run in 3.025 seconds using v1.01-cache-2.11-cpan-99c4e6809bf )