summaryrefslogtreecommitdiff
path: root/tests/prop-editor.c
diff options
context:
space:
mode:
authorMatthias Clasen <matthiasc@src.gnome.org>2001-08-09 07:57:56 +0000
committerMatthias Clasen <matthiasc@src.gnome.org>2001-08-09 07:57:56 +0000
commit439cd9a3a505424ea64d099ecbe1b4c910b79649 (patch)
treec28b27d7b548febafbb873df8f1fa3f6296397e2 /tests/prop-editor.c
parentdeefbff9bfbe21cbe40c9ae8c6f4f2729b459520 (diff)
downloadgtk+-439cd9a3a505424ea64d099ecbe1b4c910b79649.tar.gz
tests/prop-editor.c (properties_from_type): Use g_object_class_list_properties
to get the param specs for a given type. (#58609)
Diffstat (limited to 'tests/prop-editor.c')
-rw-r--r--tests/prop-editor.c39
1 files changed, 18 insertions, 21 deletions
diff --git a/tests/prop-editor.c b/tests/prop-editor.c
index 353ac79c1a..50c25134b6 100644
--- a/tests/prop-editor.c
+++ b/tests/prop-editor.c
@@ -23,21 +23,6 @@
#include "prop-editor.h"
-static void
-get_param_specs (GType type,
- GParamSpec ***specs,
- gint *n_specs)
-{
- GObjectClass *class = g_type_class_peek (type);
-
- /* We count on the fact we have an instance, or else we'd have
- * to use g_type_class_ref ();
- */
-
- /* Use private interface for now, fix later */
- *specs = NULL; /* class->property_specs; */
- *n_specs = 0; /* class->n_property_specs; */
-}
typedef struct
{
@@ -446,7 +431,7 @@ object_changed (GObject *object, GParamSpec *pspec, gpointer data)
name = g_type_name (G_TYPE_FROM_INSTANCE (obj));
else
name = "unknown";
- str = g_strdup_printf ("Objetct: %p (%s)", obj, name);
+ str = g_strdup_printf ("Object: %p (%s)", obj, name);
gtk_label_set_text (label, str);
g_free (str);
@@ -670,12 +655,14 @@ properties_from_type (GObject *object,
GtkWidget *sw;
GtkWidget *vbox;
GtkWidget *table;
+ GObjectClass *class;
+ GParamSpec **specs;
+ gint n_specs;
int i;
- gint n_specs = 0;
- GParamSpec **specs = NULL;
-
- get_param_specs (type, &specs, &n_specs);
+ class = G_OBJECT_CLASS (g_type_class_peek (type));
+ specs = g_object_class_list_properties (class, &n_specs);
+
if (n_specs == 0)
return NULL;
@@ -701,6 +688,13 @@ properties_from_type (GObject *object,
continue;
}
+ if (spec->owner_type != type)
+ {
+ /* we're only interested in params of type */
+ ++i;
+ continue;
+ }
+
label = gtk_label_new (spec->nick);
gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5);
gtk_table_attach_defaults (GTK_TABLE (table), label, 0, 1, i, i + 1);
@@ -732,6 +726,9 @@ properties_from_type (GObject *object,
GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC);
gtk_scrolled_window_add_with_viewport (GTK_SCROLLED_WINDOW (sw), vbox);
+
+ g_free (specs);
+
return sw;
}
@@ -771,7 +768,7 @@ create_prop_editor (GObject *object, GType type)
gtk_container_add (GTK_CONTAINER (win), notebook);
type = G_TYPE_FROM_INSTANCE (object);
-
+
title = g_strdup_printf ("Properties of %s widget", g_type_name (type));
gtk_window_set_title (GTK_WINDOW (win), title);
g_free (title);