Date: Wed, 22 Jan 2003 13:49:23 +0100 From: Maxence Guesdon To: stalkern2 at tin.it Cc: lablgtk at kaba.or.jp Subject: Re: Tree and Entry in a file viewer Message-Id: <20030122134923.30635a03.maxence.guesdon at inria.fr> In-Reply-To: <200301221339.41315.stalkern2 at tin.it> References: <200301221333.27831.stalkern2 at tin.it> <200301221339.41315.stalkern2@tin.it> Organization: INRIA Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit On Wed, 22 Jan 2003 13:39:41 +0100 Stalkern 2 wrote: > OK, Maxence Guesdon was so kind to give a hint to me. Thank you very much, > Maxence. > I'll let you know. After reading your message on the lablgtk list, i think i should add some more. When a tree item is selected and you want to know what directory it is (i.e. its full name from the root), you should not go through the tree and tree item widgets, asking for their label and concatenate in a string. There is a better way. Basically, when you build a tree item, you know the name of the corresponding directory, so you just display the basename, but the problem is to remember the full name, isn't it ? So, after the creation of the tree_item, you connect functions to the select and unselect events. In the functions associated to these events, you still know the full name and you can use it. For example : let rec fill_tree wt (* the root tree *) dir (* the parent dir name *) = (* do the following for each sub dir *) let complete_name = Filename.concat dirn basename in let item = GTree.tree_item ~label: basename ~show: true () in let _ = wt#append item in let _ = item#connect#select (fun () -> your_select_dir_function complete_name) in let _ = item#connect#deselect (fun () -> your_unselect_dir_function complete_name) in (* if the subdir has children, create a new tree widget, associate it to the item and then recursive call *) if has_children complete_name then ( let new_wt = GTree.tree () in item#set_subtree new_wt ; fill_tree new_wt complete_name; ) Hope this will help you, -- Maxence