To: fabrice at lefessant.net Cc: lablgtk at kaba.or.jp Subject: Re: selection In-Reply-To: <15964.45769.143209.977244 at lachesis.inria.fr> References: <15964.45769.143209.977244 at lachesis.inria.fr> Mime-Version: 1.0 Content-Type: Text/Plain; charset=us-ascii Content-Transfer-Encoding: 7bit Message-Id: <20030304181714I.garrigue at kurims.kyoto-u.ac.jp> Date: Tue, 04 Mar 2003 18:17:14 +0900 From: Jacques Garrigue Lines: 38 From: Fabrice Le Fessant > I would like to know how it is possible to change the selection in > lablgtk. We have tried to use the text#grab_selection, and connect the > selection_get event, but it did not work. Could somebody post an > example of code that can do the right thing ? Depends on what you are trying to do. If you just want to select something inside a text widget, the GEdit.text#select_region works fine: $ lablgtk -thread # let w = GWindow.window ~show:true ();; # let t = GEdit.text ~editable:true ~packing:w#add ();; # t#select_region 0 t#length;; If you want to set the selection independently of the contents of the text widget, then it is slightly more complex. # let w = GWindow.window ~show:true ();; # w#misc#add_selection_target "STRING" `PRIMARY;; # w#misc#connect#selection_get ~callback: (fun ctx ~info ~time -> ctx#return "Hello everybody");; # w#misc#grab_selection `PRIMARY;; Of course you don't need to use a window for that. I ignore when the callback is cancelled... > Another problem is that only the PRIMARY and SECONDARY selections > are available. For some applications, other selections are needed > (the CLIPBOARD for example, or the CUT_BUFFER). Is there a way to > access them using lablgtk ? Due to my misunderstanding, this is not available in lablgtk1. Lablgtk2 does it the right way. Jacques