From dimitri.giardina@gmail.com Fri Jul 4 17:56:56 2014 Return-Path: X-Original-To: javascript-list@gnome.org Delivered-To: javascript-list@gnome.org Received: from localhost (localhost.localdomain [127.0.0.1]) by restaurant.gnome.org (Postfix) with ESMTP id 6C4447697B for ; Fri, 4 Jul 2014 17:56:56 +0000 (UTC) X-Virus-Scanned: by amavisd-new at gnome.org X-Spam-Flag: NO X-Spam-Score: -2.699 X-Spam-Level: X-Spam-Status: No, score=-2.699 tagged_above=-999 required=2 tests=[BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, FREEMAIL_FROM=0.001, HTML_MESSAGE=0.001, RCVD_IN_DNSWL_LOW=-0.7, SPF_PASS=-0.001] autolearn=ham Received: from restaurant.gnome.org ([127.0.0.1]) by localhost (restaurant.gnome.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id P4d3-6TH5r-c for ; Fri, 4 Jul 2014 17:56:54 +0000 (UTC) Received: from mail-wi0-f176.google.com (mail-wi0-f176.google.com [209.85.212.176]) by restaurant.gnome.org (Postfix) with ESMTP id A2DD676967 for ; Fri, 4 Jul 2014 17:56:43 +0000 (UTC) Received: by mail-wi0-f176.google.com with SMTP id n3so13369181wiv.9 for ; Fri, 04 Jul 2014 10:56:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=message-id:subject:from:to:date:content-type:mime-version; bh=gkkc/I+EMQwYTQ05kVxMrQeCYrBxWfXNM0El+Izo4MU=; b=UQW7j+JEecdKLFp9V4oowFAw5nBb07LXbus2yqlFoJE+BDWT/U0JsSJpjgHiUI9FnL h4UVX5y2w48kUZjrjVqZ3Xr7t5HXuM8E3BCXt/HPENmim5thR3pbkDdlEo8DryLfOLEe k4RXpalWvjriuS4AEygZc2qiTAECnNQM9+U7oPfavM4sqTjMOp6BRdacMh6ht6sfQNJc Eu7+qf5S017VWq7+GAQR4+p5x4fi3kKxbaMNJ/WRf9yFO16kYHHfzPgjwhDm8NIAZHk3 Dq0ME5jSB16HashWnO8rCwScTxZtsGInOUeJUPryU3E2BfPfCQ7zD1fo8IU68t8FK4s3 n4QQ== X-Received: by 10.180.91.194 with SMTP id cg2mr19931563wib.12.1404496602263; Fri, 04 Jul 2014 10:56:42 -0700 (PDT) Received: from [192.168.4.3] (93-40-59-21.ip37.fastwebnet.it. [93.40.59.21]) by mx.google.com with ESMTPSA id wi9sm70408177wjc.23.2014.07.04.10.56.41 for (version=TLSv1 cipher=RC4-SHA bits=128/128); Fri, 04 Jul 2014 10:56:41 -0700 (PDT) Message-ID: <1404496599.4002.4.camel@whitewater> Subject: custom signals From: Dimitri Giardina To: javascript-list@gnome.org Date: Fri, 04 Jul 2014 19:56:39 +0200 Content-Type: multipart/alternative; boundary="=-2A3kYxXEc2H0d/nkTSJk" X-Mailer: Evolution 3.10.4-0ubuntu1 Mime-Version: 1.0 X-BeenThere: javascript-list@gnome.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: JavaScript in GNOME List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 04 Jul 2014 17:56:56 -0000 --=-2A3kYxXEc2H0d/nkTSJk Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 7bit Hi list, i'm searching for some days on google about attaching custom signals to custom widgets on gjs. i see some examples for seed-js but they seem not to be applicable on gjs. i found the overriding of gobject.js but i don't know if i can use that: https://mail.gnome.org/archives/commits-list/2012-January/msg11238.html something like: gi.signal_new(this.prototype,'close-clicked',GObject.SignalFlags.RUN_FIRST,GObject.AccumulatorType.NONE,GObject.TYPE_NONE,[]); where gi is const gi=imports.gi; but it don't work. if i use this.connect('close-clicked',this.close_clicked); interpreter give me a message that close-ticket is not one of signals. anyone can help me? thanks Dimitri. --=-2A3kYxXEc2H0d/nkTSJk Content-Type: text/html; charset="utf-8" Content-Transfer-Encoding: 7bit Hi list,

i'm searching for some days on google about attaching custom signals to custom widgets on gjs.
i see some examples for seed-js but they seem not to be applicable on gjs.

i found the overriding of gobject.js but i don't know if i can use that:
https://mail.gnome.org/archives/commits-list/2012-January/msg11238.html

something like:
        gi.signal_new(this.prototype,'close-clicked',GObject.SignalFlags.RUN_FIRST,GObject.AccumulatorType.NONE,GObject.TYPE_NONE,[]);

where gi is const gi=imports.gi;
but it don't work.

if i use
this.connect('close-clicked',this.close_clicked);

interpreter give me a message that close-ticket is not one of signals.

anyone can help me?

thanks
Dimitri. --=-2A3kYxXEc2H0d/nkTSJk-- From ebassi@gmail.com Mon Jul 7 16:50:34 2014 Return-Path: X-Original-To: javascript-list@gnome.org Delivered-To: javascript-list@gnome.org Received: from localhost (localhost.localdomain [127.0.0.1]) by restaurant.gnome.org (Postfix) with ESMTP id 87B3976996 for ; Mon, 7 Jul 2014 16:50:34 +0000 (UTC) X-Virus-Scanned: by amavisd-new at gnome.org X-Spam-Flag: NO X-Spam-Score: -2.7 X-Spam-Level: X-Spam-Status: No, score=-2.7 tagged_above=-999 required=2 tests=[BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_LOW=-0.7, SPF_PASS=-0.001] autolearn=ham Received: from restaurant.gnome.org ([127.0.0.1]) by localhost (restaurant.gnome.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 4s9uZWlrsCUb for ; Mon, 7 Jul 2014 16:50:33 +0000 (UTC) Received: from mail-ve0-f171.google.com (mail-ve0-f171.google.com [209.85.128.171]) by restaurant.gnome.org (Postfix) with ESMTP id 4221C76955 for ; Mon, 7 Jul 2014 16:50:12 +0000 (UTC) Received: by mail-ve0-f171.google.com with SMTP id jz11so4428168veb.30 for ; Mon, 07 Jul 2014 09:50:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; bh=3il6ra/Oid6IN+Tv00PeDjl+ZActxyszU6p8xexptFU=; b=VenBltbQfiMJWhFetOmEd0a9FKMyL55ijLxUnlj3Vlv4Kf+1+iaTkzq6Qtp2m1Qeoc /erQkgJCW+6WDgZXN9Wr+BmxHoxRX0lsC3Z2AcghKdqO79bCN15FUhzm5ivdxQ8nQ8Wn PwdCMi/B6NIO91ejYcE5Fh8LWd47/51uTjqxlmWzfzUnVvF5UFDmb1dzh91Vz5tqMi1Q JOmHXNV0bIRcA73htUV31NuRP+9n+O5Ew5OafVQwXSV/jo8V6IIGmz0ycTK7ANGCQcXg 5+a/jA+n1+qf/56FehwOSl8T3bHik8JD10ROcOcDoSY4cq1jDzWGkPXGqcA4MGLxFQ0h oaXA== MIME-Version: 1.0 X-Received: by 10.220.95.135 with SMTP id d7mr2640956vcn.49.1404751810975; Mon, 07 Jul 2014 09:50:10 -0700 (PDT) Received: by 10.220.16.12 with HTTP; Mon, 7 Jul 2014 09:50:10 -0700 (PDT) In-Reply-To: <1404496599.4002.4.camel@whitewater> References: <1404496599.4002.4.camel@whitewater> Date: Mon, 7 Jul 2014 17:50:10 +0100 Message-ID: Subject: Re: custom signals From: Emmanuele Bassi To: Dimitri Giardina Content-Type: text/plain; charset=UTF-8 Cc: "javascript-list@gnome.org" X-BeenThere: javascript-list@gnome.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: JavaScript in GNOME List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 07 Jul 2014 16:50:34 -0000 hi; to define new signals, you need to use the `Signals` key in object you pass to the Lang.Class() constructor you use when subclassing a GObject. you can look at this code: https://git.gnome.org/browse/gjs/tree/installed-tests/js/testGObjectClass.js#n115 for how to define properties and signals on GObject classes implemented via gjs. ciao, Emmanuele. On 4 July 2014 18:56, Dimitri Giardina wrote: > Hi list, > > i'm searching for some days on google about attaching custom signals to > custom widgets on gjs. > i see some examples for seed-js but they seem not to be applicable on gjs. > > i found the overriding of gobject.js but i don't know if i can use that: > https://mail.gnome.org/archives/commits-list/2012-January/msg11238.html > > something like: > > gi.signal_new(this.prototype,'close-clicked',GObject.SignalFlags.RUN_FIRST,GObject.AccumulatorType.NONE,GObject.TYPE_NONE,[]); > > where gi is const gi=imports.gi; > but it don't work. > > if i use > this.connect('close-clicked',this.close_clicked); > > interpreter give me a message that close-ticket is not one of signals. > > anyone can help me? > > thanks > Dimitri. > > _______________________________________________ > javascript-list mailing list > javascript-list@gnome.org > https://mail.gnome.org/mailman/listinfo/javascript-list > -- W: http://www.emmanuelebassi.name B: http://blogs.gnome.org/ebassi/ From dimitri.giardina@gmail.com Tue Jul 8 17:03:02 2014 Return-Path: X-Original-To: javascript-list@gnome.org Delivered-To: javascript-list@gnome.org Received: from localhost (localhost.localdomain [127.0.0.1]) by restaurant.gnome.org (Postfix) with ESMTP id BAC9C765C8 for ; Tue, 8 Jul 2014 17:03:02 +0000 (UTC) X-Virus-Scanned: by amavisd-new at gnome.org X-Spam-Flag: NO X-Spam-Score: -2.7 X-Spam-Level: X-Spam-Status: No, score=-2.7 tagged_above=-999 required=2 tests=[BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_LOW=-0.7, SPF_PASS=-0.001] autolearn=ham Received: from restaurant.gnome.org ([127.0.0.1]) by localhost (restaurant.gnome.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id QwIB7_ETh1fz for ; Tue, 8 Jul 2014 17:03:01 +0000 (UTC) Received: from mail-wi0-f175.google.com (mail-wi0-f175.google.com [209.85.212.175]) by restaurant.gnome.org (Postfix) with ESMTP id 2E491765AC for ; Tue, 8 Jul 2014 17:02:50 +0000 (UTC) Received: by mail-wi0-f175.google.com with SMTP id ho1so1379357wib.2 for ; Tue, 08 Jul 2014 10:02:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=message-id:subject:from:to:cc:date:in-reply-to:references :content-type:mime-version:content-transfer-encoding; bh=38j3d/lHpo7MaX1S5fAkZacmqvYsyuFS3ojiBqLow7o=; b=eNoBhI9PkC2TF6Cz+bo86i6yqUMv16g0DgRB2Qhtfx5wJHRehnBQKmZpvHVOXv7PjU FyJAt5OfRrolz51NfR2am3sEBFv3xJW1XimGWA+klgf5L6hqwUVfp+IVcmglK5hzplYu APA5VqfbEvLfhxIkV5g3dttd1vDpnOVIB4KckF4uUabxBX7lLjyr6mPUlVMkGs4EmPff NfQ4qbmHcGJaeBQZ6nKd8XpPNMf9diMC0LHGPfRVN+MQpZJ6BYo0eWWLgfAwqW/TbXZK TqH+K9jrLIy5xwE2ihuZPJRc+KuNZLQ/KETYZiE5Kym9fwLHTErrVoGgxktIml80zy9Z zgsg== X-Received: by 10.180.87.161 with SMTP id az1mr5384297wib.63.1404838968660; Tue, 08 Jul 2014 10:02:48 -0700 (PDT) Received: from [192.168.4.3] (93-40-95-234.ip38.fastwebnet.it. [93.40.95.234]) by mx.google.com with ESMTPSA id hq20sm9108594wib.0.2014.07.08.10.02.47 for (version=TLSv1 cipher=RC4-SHA bits=128/128); Tue, 08 Jul 2014 10:02:48 -0700 (PDT) Message-ID: <1404838966.3308.8.camel@whitewater> Subject: Re: custom signals From: Dimitri Giardina To: Emmanuele Bassi Date: Tue, 08 Jul 2014 19:02:46 +0200 In-Reply-To: References: <1404496599.4002.4.camel@whitewater> Content-Type: text/plain; charset="UTF-8" X-Mailer: Evolution 3.10.4-0ubuntu1 Mime-Version: 1.0 Content-Transfer-Encoding: 7bit Cc: "javascript-list@gnome.org" X-BeenThere: javascript-list@gnome.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: JavaScript in GNOME List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 08 Jul 2014 17:03:02 -0000 Il giorno lun, 07/07/2014 alle 17.50 +0100, Emmanuele Bassi ha scritto: > hi; > > to define new signals, you need to use the `Signals` key in object you > pass to the Lang.Class() constructor you use when subclassing a > GObject. ok, i've resolved in this way, it's equivalent? const WebBrowserTabLabel = new Lang.Class({ Name: 'WebBrowserTabLabel', Extends: Gtk.Box, _init: function() { this.parent(); Signals.addSignalMethods(WebBrowserTabLabel.prototype); [...] button.connect("clicked", this.buttonClick); this.pack_start(button, false, false, 0); this.show_all(); }, clickClose: function() {}, buttonClick: function(self, button, data) { self.p.emit('close-clicked'); }, }); what's the difference using Signals property and Signals.addSignalMethods? without the Singals.addSignalMethods, the interpreter tell me that the Gtk.Box haven't the signal 'close-clicked' (it's normal, i know). regards, Dimitri From scampa.giovanni@gmail.com Tue Jul 8 17:13:31 2014 Return-Path: X-Original-To: javascript-list@gnome.org Delivered-To: javascript-list@gnome.org Received: from localhost (localhost.localdomain [127.0.0.1]) by restaurant.gnome.org (Postfix) with ESMTP id C328C76920 for ; Tue, 8 Jul 2014 17:13:31 +0000 (UTC) X-Virus-Scanned: by amavisd-new at gnome.org X-Spam-Flag: NO X-Spam-Score: -2.7 X-Spam-Level: X-Spam-Status: No, score=-2.7 tagged_above=-999 required=2 tests=[BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_LOW=-0.7, SPF_PASS=-0.001] autolearn=ham Received: from restaurant.gnome.org ([127.0.0.1]) by localhost (restaurant.gnome.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id hMsFqaF6BMAv for ; Tue, 8 Jul 2014 17:13:29 +0000 (UTC) Received: from mail-we0-f176.google.com (mail-we0-f176.google.com [74.125.82.176]) by restaurant.gnome.org (Postfix) with ESMTP id 79957765C8 for ; Tue, 8 Jul 2014 17:13:18 +0000 (UTC) Received: by mail-we0-f176.google.com with SMTP id u56so6181431wes.35 for ; Tue, 08 Jul 2014 10:13:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:sender:in-reply-to:references:from:date:message-id :subject:to:cc:content-type; bh=YBSGetJNTyBTyh37kIhFZBCF3h2cFOXe1YvPm/OMuQc=; b=uxeLfjOV9+kvAUKWSY5CktgN2bNwecSTsYTp//lpI3OltOvSPSceypyEH5mw3wt8VS vVR5AFBAwp7T7U62z43sPbalfoGuDSy6B5j8gDBs9gUaG5NXCgfsQsRKuE9x/IA9MLRA +Xd0AbsMVzNc6/eS9ATsR3lXdRvhruPS1Y+b53h3qmJUHlUzjXRpGKMSIElO75Q+7skz c1QYrl6Ynr8SyfhDfpgLMe81MB8x+ZCB/Sbt/W9cZKgafPsyooQmmyBoxqy0yBarhnsj ZPd9iV37am0HjO8quvoU6wzkdIbyJIAI1BJHPXGjxT2emSZPIhKyzT55Z8P2/afr4Ay9 5oTQ== X-Received: by 10.194.109.71 with SMTP id hq7mr5818824wjb.114.1404839597025; Tue, 08 Jul 2014 10:13:17 -0700 (PDT) MIME-Version: 1.0 Sender: scampa.giovanni@gmail.com Received: by 10.216.119.5 with HTTP; Tue, 8 Jul 2014 10:12:56 -0700 (PDT) In-Reply-To: <1404838966.3308.8.camel@whitewater> References: <1404496599.4002.4.camel@whitewater> <1404838966.3308.8.camel@whitewater> From: Giovanni Campagna Date: Tue, 8 Jul 2014 19:12:56 +0200 X-Google-Sender-Auth: pn_4PcQdjfHPi1yU4-xl3fCN6w8 Message-ID: Subject: Re: custom signals To: Dimitri Giardina Content-Type: text/plain; charset=UTF-8 Cc: "javascript-list@gnome.org" X-BeenThere: javascript-list@gnome.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: JavaScript in GNOME List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 08 Jul 2014 17:13:31 -0000 2014-07-08 19:02 GMT+02:00 Dimitri Giardina : > Il giorno lun, 07/07/2014 alle 17.50 +0100, Emmanuele Bassi ha scritto: >> hi; >> >> to define new signals, you need to use the `Signals` key in object you >> pass to the Lang.Class() constructor you use when subclassing a >> GObject. > ok, i've resolved in this way, it's equivalent? > > const WebBrowserTabLabel = new Lang.Class({ > Name: 'WebBrowserTabLabel', > Extends: Gtk.Box, > _init: function() { > this.parent(); > Signals.addSignalMethods(WebBrowserTabLabel.prototype); > [...] > button.connect("clicked", this.buttonClick); > this.pack_start(button, false, false, 0); > this.show_all(); > }, > clickClose: function() {}, > buttonClick: function(self, button, data) { > self.p.emit('close-clicked'); > }, > }); > > what's the difference using Signals property and > Signals.addSignalMethods? If you use Signals.addSignalMethods, you lose all GObject signals and only see the JS ones. Not what you want, probably. > without the Singals.addSignalMethods, the interpreter tell me that the > Gtk.Box haven't the signal 'close-clicked' (it's normal, i know). Try with const WebBrowserTabLabel = new Lang.Class({ Name: 'WebBrowserTabLabel', Extends: Gtk.Box, Signals: { 'close-clicked': { } } _init: function() { this.parent(); button.connect("clicked", Lang.bind(this, this.buttonClick)); this.pack_start(button, false, false, 0); this.show_all(); }, clickClose: function() {}, buttonClick: function(button) { this.emit('close-clicked'); }, }); See https://people.gnome.org/~gcampagna/docs/GObject-2.0/GObject.Class.html for a description of how GObject.Class works (or Lang.Class, they're equivalent if you specify Extends) Btw, you should always use Lang.bind() to have "this" properly set in callbacks. Giovanni