To: stalkern2 at tin.it Cc: lablgtk at kaba.or.jp Subject: Re: How do I disconnect all callbacks from a button? In-Reply-To: <200302031108.10286.stalkern2 at tin.it> References: <200301311901.18801.stalkern2 at tin.it> <20030203104047F.garrigue@kurims.kyoto-u.ac.jp> <200302031108.10286.stalkern2@tin.it> Mime-Version: 1.0 Content-Type: Text/Plain; charset=us-ascii Content-Transfer-Encoding: 7bit Message-Id: <20030203191151L.garrigue at kurims.kyoto-u.ac.jp> Date: Mon, 03 Feb 2003 19:11:51 +0900 From: Jacques Garrigue Lines: 50 From: Stalkern 2 > I was puzzled by reading in the GUtil page in the last available CDK > documentation > > class ['a] signal : > unit -> > object > val mutable callbacks : (GtkSignal.id * ('a -> unit)) list > method callbacks : (GtkSignal.id * ('a -> unit)) list > method call : 'a -> unit > method connect : after:bool -> callback:('a -> unit) -> GtkSignal.id > method disconnect : GtkSignal.id -> bool > end > > So signal#callbacks should give a list of connection IDs, isn't it? > But I didn't know how to get from the button to the signals (is this > possible? No, GUtil.signal reimplements signals on the Caml side. You cannot use it for Gtk signals, which are handled on the Gtk side. In particular, there is no function in Gtk to give the list of handlers connected to a signal. You might wonder, why reimplement signals on the Caml side? Actually, this is very nice to produce modular software: you can write something like class my_app_signals ~mysignal1 ~mysignal2 = object inherit ml_signals [mysignal1#disconnect; mysignal2#disconnect] method mysignal1 = mysignal1#connect ~after method mysignal2 = mysignal2#connect ~after end class my_app ... ?packing ?show () = let hbox = new GPack.hbox ?packing ?show () in .... object (self) inherit GObj.widget hbox#as_widget val mysignal1 = new signal obj val mysignal2 = new signal obj method connect = new my_app_signals ~mysignal1 ~mysignal2 ... initializer ...#connect ~callback:(fun ... -> mysignal1#call ...) end This way you can connect various parts of your application afterwards, using a scheme that just looks like Gtk signals. Jacques