seed-signals: allow notify:: signals
authorDiego Escalante Urrelo <descalante@igalia.com>
Wed, 17 Feb 2010 22:04:54 +0000 (17:04 -0500)
committerTim Horton <hortont424@gmail.com>
Thu, 18 Feb 2010 23:02:59 +0000 (18:02 -0500)
g_signal_query/g_signal_lookup don't recognize notify::x signal names,
they do recognize notify signal of course. Take this into account and
enable connecting to notify::x signals like shown by documentation.
Also add a SeedException when signal name is not valid instead of just
returning NULL.

Bug #610311

libseed/seed-signals.c

index 7c40e93..fe2be47 100644 (file)
@@ -1,4 +1,5 @@
 /* -*- mode: C; indent-tabs-mode: t; tab-width: 8; c-basic-offset: 2; -*- */
+/* vim: set sw=2 ts=2 sts=2 et: */
 
 /*
  * This file is part of Seed, the GObject Introspection<->Javascript bindings.
@@ -47,8 +48,13 @@ seed_gobject_signal_connect (JSContextRef ctx,
   GSignalQuery query;
   GClosure *closure;
 
-  g_signal_query (g_signal_lookup (signal_name, G_OBJECT_TYPE (on_obj)),
-                 &query);
+  if (g_str_has_prefix (signal_name, "notify::"))
+    g_signal_query (g_signal_lookup ("notify", G_OBJECT_TYPE (on_obj)),
+                    &query);
+  else
+    g_signal_query (g_signal_lookup (signal_name, G_OBJECT_TYPE (on_obj)),
+                    &query);
+
 #ifdef SEED_ENABLE_DEBUG
   {
     guint function_arity = seed_value_to_uint (ctx,
@@ -402,8 +408,12 @@ seed_signal_holder_get_property (JSContextRef ctx,
       return NULL;
     }
 
-  if (!g_signal_lookup (signal_name, G_OBJECT_TYPE (gobj)))
+  if (!g_str_has_prefix (signal_name, "notify::") &&
+      !g_signal_lookup (signal_name, G_OBJECT_TYPE (gobj)))
     {
+      seed_make_exception (ctx, exception, "InvalidSignalName",
+                          "Failed to connect to %s. "
+                          "Invalid signal name.", signal_name);
       g_free (signal_name);
       return NULL;
     }