[gjs] Implement GObject.prototype.disconnect in JS
- From: Giovanni Campagna <gcampagna src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gjs] Implement GObject.prototype.disconnect in JS
- Date: Mon, 24 Feb 2014 16:01:06 +0000 (UTC)
commit 9a54db2bbdb27261d2c72a2ca28355daed8bc0e2
Author: Giovanni Campagna <gcampagna src gnome org>
Date: Fri Apr 19 18:54:59 2013 +0200
Implement GObject.prototype.disconnect in JS
Because GObject.signal_handler_disconnect() is introspectable now.
https://bugzilla.gnome.org/show_bug.cgi?id=698283
gi/object.cpp | 45 ------------------------------------------
modules/overrides/GObject.js | 4 +++
2 files changed, 4 insertions(+), 45 deletions(-)
---
diff --git a/gi/object.cpp b/gi/object.cpp
index 20a2afe..2745833 100644
--- a/gi/object.cpp
+++ b/gi/object.cpp
@@ -1594,50 +1594,6 @@ connect_func(JSContext *context,
}
static JSBool
-disconnect_func(JSContext *context,
- unsigned argc,
- jsval *vp)
-{
- jsval *argv = JS_ARGV(context, vp);
- JSObject *obj = JS_THIS_OBJECT(context, vp);
- ObjectInstance *priv;
- gulong id;
-
- if (!do_base_typecheck(context, obj, JS_TRUE))
- return JS_FALSE;
-
- priv = priv_from_js(context, obj);
- gjs_debug_gsignal("disconnect obj %p priv %p argc %d", obj, priv, argc);
-
- if (priv == NULL) {
- throw_priv_is_null_error(context);
- return JS_FALSE; /* wrong class passed in */
- }
-
- if (priv->gobj == NULL) {
- /* prototype, not an instance. */
- gjs_throw(context, "Can't disconnect signal on %s.%s.prototype; only on instances",
- priv->info ? g_base_info_get_namespace( (GIBaseInfo*) priv->info) : "",
- priv->info ? g_base_info_get_name( (GIBaseInfo*) priv->info) : g_type_name(priv->gtype));
- return JS_FALSE;
- }
-
- if (argc != 1 ||
- !JSVAL_IS_INT(argv[0])) {
- gjs_throw(context, "disconnect() takes one arg, the signal handler id");
- return JS_FALSE;
- }
-
- id = JSVAL_TO_INT(argv[0]);
-
- g_signal_handler_disconnect(priv->gobj, id);
-
- JS_SET_RVAL(context, vp, JSVAL_VOID);
-
- return JS_TRUE;
-}
-
-static JSBool
emit_func(JSContext *context,
unsigned argc,
jsval *vp)
@@ -1838,7 +1794,6 @@ JSFunctionSpec gjs_object_instance_proto_funcs[] = {
{ "_init", JSOP_WRAPPER((JSNative)init_func), 0, 0 },
{ "connect", JSOP_WRAPPER((JSNative)connect_func), 0, 0 },
{ "connect_after", JSOP_WRAPPER((JSNative)connect_after_func), 0, 0 },
- { "disconnect", JSOP_WRAPPER((JSNative)disconnect_func), 0, 0 },
{ "emit", JSOP_WRAPPER((JSNative)emit_func), 0, 0 },
{ "toString", JSOP_WRAPPER((JSNative)to_string_func), 0, 0 },
{ NULL }
diff --git a/modules/overrides/GObject.js b/modules/overrides/GObject.js
index 7f783ae..99f5b63 100644
--- a/modules/overrides/GObject.js
+++ b/modules/overrides/GObject.js
@@ -264,4 +264,8 @@ function _init() {
FIRST_WINS: 1,
TRUE_HANDLED: 2
};
+
+ this.Object.prototype.disconnect = function(id) {
+ return GObject.signal_handler_disconnect(this, id);
+ }
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]