]> Pileus Git - ~andy/gtk/commitdiff
tests/prop-editor.c (properties_from_type): Use g_object_class_list_properties
authorMatthias Clasen <matthiasc@src.gnome.org>
Thu, 9 Aug 2001 07:57:56 +0000 (07:57 +0000)
committerMatthias Clasen <matthiasc@src.gnome.org>
Thu, 9 Aug 2001 07:57:56 +0000 (07:57 +0000)
to get the param specs for a given type. (#58609)

ChangeLog
ChangeLog.pre-2-0
ChangeLog.pre-2-10
ChangeLog.pre-2-2
ChangeLog.pre-2-4
ChangeLog.pre-2-6
ChangeLog.pre-2-8
tests/prop-editor.c

index 2f30f7a5fec685d435e3fbcc3f61cf969c509283..587577f0c2570e246a036015c427213bebb8e1c1 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2001-08-09  Matthias Clasen  <matthiasc@waldgeist.poet.de>
+
+       * tests/prop-editor.c (properties_from_type): Use 
+       g_object_class_list_properties to get the param specs 
+       for a given type. (#58609)
+
 2001-08-09  Matthias Clasen  <matthiasc@waldgeist.poet.de>
 
        * gtk/gtkstyle.c (gtk_style_real_unrealize): Don't forget to
index 2f30f7a5fec685d435e3fbcc3f61cf969c509283..587577f0c2570e246a036015c427213bebb8e1c1 100644 (file)
@@ -1,3 +1,9 @@
+2001-08-09  Matthias Clasen  <matthiasc@waldgeist.poet.de>
+
+       * tests/prop-editor.c (properties_from_type): Use 
+       g_object_class_list_properties to get the param specs 
+       for a given type. (#58609)
+
 2001-08-09  Matthias Clasen  <matthiasc@waldgeist.poet.de>
 
        * gtk/gtkstyle.c (gtk_style_real_unrealize): Don't forget to
index 2f30f7a5fec685d435e3fbcc3f61cf969c509283..587577f0c2570e246a036015c427213bebb8e1c1 100644 (file)
@@ -1,3 +1,9 @@
+2001-08-09  Matthias Clasen  <matthiasc@waldgeist.poet.de>
+
+       * tests/prop-editor.c (properties_from_type): Use 
+       g_object_class_list_properties to get the param specs 
+       for a given type. (#58609)
+
 2001-08-09  Matthias Clasen  <matthiasc@waldgeist.poet.de>
 
        * gtk/gtkstyle.c (gtk_style_real_unrealize): Don't forget to
index 2f30f7a5fec685d435e3fbcc3f61cf969c509283..587577f0c2570e246a036015c427213bebb8e1c1 100644 (file)
@@ -1,3 +1,9 @@
+2001-08-09  Matthias Clasen  <matthiasc@waldgeist.poet.de>
+
+       * tests/prop-editor.c (properties_from_type): Use 
+       g_object_class_list_properties to get the param specs 
+       for a given type. (#58609)
+
 2001-08-09  Matthias Clasen  <matthiasc@waldgeist.poet.de>
 
        * gtk/gtkstyle.c (gtk_style_real_unrealize): Don't forget to
index 2f30f7a5fec685d435e3fbcc3f61cf969c509283..587577f0c2570e246a036015c427213bebb8e1c1 100644 (file)
@@ -1,3 +1,9 @@
+2001-08-09  Matthias Clasen  <matthiasc@waldgeist.poet.de>
+
+       * tests/prop-editor.c (properties_from_type): Use 
+       g_object_class_list_properties to get the param specs 
+       for a given type. (#58609)
+
 2001-08-09  Matthias Clasen  <matthiasc@waldgeist.poet.de>
 
        * gtk/gtkstyle.c (gtk_style_real_unrealize): Don't forget to
index 2f30f7a5fec685d435e3fbcc3f61cf969c509283..587577f0c2570e246a036015c427213bebb8e1c1 100644 (file)
@@ -1,3 +1,9 @@
+2001-08-09  Matthias Clasen  <matthiasc@waldgeist.poet.de>
+
+       * tests/prop-editor.c (properties_from_type): Use 
+       g_object_class_list_properties to get the param specs 
+       for a given type. (#58609)
+
 2001-08-09  Matthias Clasen  <matthiasc@waldgeist.poet.de>
 
        * gtk/gtkstyle.c (gtk_style_real_unrealize): Don't forget to
index 2f30f7a5fec685d435e3fbcc3f61cf969c509283..587577f0c2570e246a036015c427213bebb8e1c1 100644 (file)
@@ -1,3 +1,9 @@
+2001-08-09  Matthias Clasen  <matthiasc@waldgeist.poet.de>
+
+       * tests/prop-editor.c (properties_from_type): Use 
+       g_object_class_list_properties to get the param specs 
+       for a given type. (#58609)
+
 2001-08-09  Matthias Clasen  <matthiasc@waldgeist.poet.de>
 
        * gtk/gtkstyle.c (gtk_style_real_unrealize): Don't forget to
index 353ac79c1afb6580749715459ed24f3656260c8b..50c25134b6502ae2b141d4994e00e7fb3a13951f 100644 (file)
 
 #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);