]> spindle.queued.net Git - midori/commitdiff
Enumerate script object property names.
authorChristian Dywan <christian@twotoasts.de>
Mon, 28 Apr 2008 22:12:23 +0000 (00:12 +0200)
committerChristian Dywan <christian@twotoasts.de>
Mon, 28 Apr 2008 22:12:23 +0000 (00:12 +0200)
src/midori-addons.c

index 0dd013f04174343de916242c8d6cc4b82d01311c..f2f38d220541ad4b68ec9ce9ffd529a4bf2854fa 100644 (file)
@@ -59,7 +59,7 @@ midori_addons_button_add_clicked_cb (GtkToolItem*  toolitem,
                                      MidoriAddons* addons)
 {
     GtkWidget* dialog = gtk_message_dialog_new (
-        gtk_widget_get_toplevel (GTK_WIDGET (addons)),
+        GTK_WINDOW (gtk_widget_get_toplevel (GTK_WIDGET (addons))),
         GTK_DIALOG_DESTROY_WITH_PARENT,
         GTK_MESSAGE_INFO, GTK_BUTTONS_CLOSE,
         "Put scripts in the folder ~/.local/share/midori/scripts");
@@ -159,6 +159,29 @@ _js_string_utf8 (JSStringRef js_string)
     return string_utf8;
 }
 
+static void
+_js_class_get_property_names_cb (JSContextRef                 js_context,
+                                 JSObjectRef                  js_object,
+                                 JSPropertyNameAccumulatorRef js_properties)
+{
+    GObject* object = JSObjectGetPrivate (js_object);
+    if (object)
+    {
+        guint n_properties;
+        GParamSpec** pspecs = g_object_class_list_properties (
+            G_OBJECT_GET_CLASS (object), &n_properties);
+        gint i;
+        for (i = 0; i < n_properties; i++)
+        {
+            GType type = G_PARAM_SPEC_TYPE (pspecs[i]);
+            const gchar* property = g_param_spec_get_name (pspecs[i]);
+            JSStringRef js_property = JSStringCreateWithUTF8CString (property);
+            JSPropertyNameAccumulatorAddName (js_properties, js_property);
+            JSStringRelease (js_property);
+        }
+    }
+}
+
 static bool
 _js_class_has_property_cb (JSContextRef js_context,
                            JSObjectRef  js_object,
@@ -281,6 +304,7 @@ _js_object_new (JSContextRef js_context,
 {
     JSClassDefinition js_class_def = kJSClassDefinitionEmpty;
     js_class_def.className = g_strdup (KATZE_OBJECT_NAME (object));
+    js_class_def.getPropertyNames = _js_class_get_property_names_cb;
     js_class_def.hasProperty = _js_class_has_property_cb;
     js_class_def.getProperty = _js_class_get_property_cb;
     js_class_def.setProperty = _js_class_set_property_cb;