Delivered-To: garrigue at math.nagoya-u.ac.jp Authentication-Results: mailhost.math.nagoya-u.ac.jp sender=lablgtk-bounces at yquem.inria.fr; domainkey=neutral (no query protocol specified; no policy for yquem.inria.fr) Delivered-To: lablgtk at yquem.inria.fr DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:received:date:message-id :subject:from:to:content-type; bh=NYiFvCA5oJxhjmxKtO4GLCDR0vRskXbxeITAWi9nsIY=; b=RLlwjC0jwdagEC9AIgm3+h/yFraWi42cL7xJ10NYLgEqG99TZdNe6NuiM1UnFzmPjm /pX94CWXckuB0j4xT8k9wD4NeTANvRg+fmND/duVE0zynvVy2fDAIXoPfFsSMB2h1JHg pmXUzfpoDtT3/Q0Mkdz4WMTuORu29MvN8ytpQ= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:date:message-id:subject:from:to:content-type; b=vVG3tf2WznWffpxWuuo56rDms0UUT+1wyMR/JkhKMsi4OR3EUl1AQ4tTXPWaaMeS64 51FIc/I1Y3pUdXu4zQLYj25tfDOC99pDUnjJexXXDfWCo4GF2QeIgdpdT7eP85tqA8hq H8BlKkLZIvBBbjpiFaIQqZ/I2Dqz85p01oIQ8= MIME-Version: 1.0 Date: Fri, 4 Jun 2010 17:55:07 +0200 Message-ID: From: Francesco Tovagliari To: lablgtk at yquem.inria.fr Content-Type: text/plain; charset=ISO-8859-1 Subject: [Lablgtk] Problem with icon_view#get_path_at_pos Status: U Hello, I'm trying to set up a context menu when I press the right mouse button on a cell in a GTree.icon_view but I'm having trouble getting the tree path from the x, y position of the click event. The problem is that the program crashes when I try to access the tree_path obtained with get_path_at_pos. Here is the code. test_iconview.ml (* ocamlc -o test_iconview -I +lablgtk2 lablgtk.cma gtkInit.cmo test_iconview.ml && ./test_iconview *) let _ = begin let window = GWindow.window ~show:false () in let cols = new GTree.column_list in let col_text = cols#add Gobject.Data.string in let col_pixbuf = cols#add (Gobject.Data.gobject_by_name "GdkPixbuf") in let model = GTree.list_store cols in let sw = GBin.scrolled_window ~packing:window#add () in let view = GTree.icon_view ~model ~width:500 ~height:300 ~packing:sw#add () in view#set_text_column col_text; view#set_pixbuf_column col_pixbuf; view#set_margin 0; let row = model#append() in model#set ~row ~column:col_text "First Element"; (* Image files from the Lablgtk examples *) (*model#set ~row ~column:col_pixbuf (GdkPixbuf.from_file "gnome-fs-directory.png");*) let row = model#append() in model#set ~row ~column:col_text "Second Element"; (*model#set ~row ~column:col_pixbuf (GdkPixbuf.from_file "gnome-fs-regular.png");*) (* let tpath = view#get_path_at_pos 0 0 in Printf.fprintf stderr "tpath = %s;\n%!" (GTree.Path.to_string tpath);*) ignore (view#event#connect#button_press ~callback:begin fun ev -> let x, y = int_of_float (GdkEvent.Button.x ev), int_of_float (GdkEvent.Button.y ev) in let tpath = view#get_path_at_pos x y in let row = model#get_iter tpath in Printf.printf "%s\n%!" (model#get ~row ~column:col_text); false end); ignore (window#connect#destroy ~callback:GMain.quit); window#show(); GMain.main() end Does anyone have some idea what can be wrong? Many thanks. Francesco Tovagliari _______________________________________________ Lablgtk mailing list Lablgtk@yquem.inria.fr http://yquem.inria.fr/cgi-bin/mailman/listinfo/lablgtk