From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: David Pirotte Newsgroups: gmane.lisp.guile.user Subject: Re: gtk-menu-popup [guile-gnome2 2.16.1-4] Date: Fri, 2 Jul 2010 00:37:58 -0300 Organization: Alto Air Services [http://www.altosw.be/aas/] Message-ID: <20100702003758.038d2da9@rascar> References: <20100628161537.1669886d@rascar> <20100629114235.16a07bb7@rascar> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="MP_/cI+2SQn6ig6E1pM_PEavfCG" X-Trace: dough.gmane.org 1278041903 3489 80.91.229.12 (2 Jul 2010 03:38:23 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Fri, 2 Jul 2010 03:38:23 +0000 (UTC) Cc: guile-user To: Andy Wingo Original-X-From: guile-user-bounces+guile-user=m.gmane.org@gnu.org Fri Jul 02 05:38:21 2010 Return-path: Envelope-to: guile-user@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1OUX50-0000AT-Hc for guile-user@m.gmane.org; Fri, 02 Jul 2010 05:38:20 +0200 Original-Received: from localhost ([127.0.0.1]:48093 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1OUX4x-0002C6-LD for guile-user@m.gmane.org; Thu, 01 Jul 2010 23:38:15 -0400 Original-Received: from [140.186.70.92] (port=54292 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1OUX4r-0002C1-HG for guile-user@gnu.org; Thu, 01 Jul 2010 23:38:10 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1OUX4p-0000WK-UQ for guile-user@gnu.org; Thu, 01 Jul 2010 23:38:09 -0400 Original-Received: from maximusconfessor.all2all.org ([62.58.108.13]:49508) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1OUX4p-0000WB-Ku for guile-user@gnu.org; Thu, 01 Jul 2010 23:38:07 -0400 Original-Received: from localhost (unknown [192.168.0.2]) by maximusconfessor.all2all.org (Postfix) with ESMTP id 3A09BA04C13B; Fri, 2 Jul 2010 05:38:05 +0200 (CEST) Original-Received: from maximusconfessor.all2all.org ([192.168.0.1]) by localhost (maximusconfessor.all2all.org [192.168.0.2]) (amavisd-new, port 10024) with ESMTP id APZbnS+HCok6; Fri, 2 Jul 2010 05:27:07 +0200 (CEST) Original-Received: from rascar (unknown [189.60.69.82]) by maximusconfessor.all2all.org (Postfix) with ESMTPSA id 1EAA8A04C0EF; Fri, 2 Jul 2010 05:38:01 +0200 (CEST) In-Reply-To: X-Mailer: Claws Mail 3.7.6 (GTK+ 2.20.1; i486-pc-linux-gnu) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 3) X-BeenThere: guile-user@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: General Guile related discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: guile-user-bounces+guile-user=m.gmane.org@gnu.org Errors-To: guile-user-bounces+guile-user=m.gmane.org@gnu.org Xref: news.gmane.org gmane.lisp.guile.user:7943 Archived-At: --MP_/cI+2SQn6ig6E1pM_PEavfCG Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Content-Disposition: inline Hello Andy, Sure, attached [feel free to add it to the examples] As it is, it works. But if you uncomment the line 162 [and comment the line= 163], then you get the following message: ERROR: No applicable method for #< get-path-at-pos (1)> in call (get-path-at-pos #< b6320540> 118 30) Cheers, David ps: the reason i am using this type of coding to bring the popup is because= in my 'real code', the popup content depends on the row content, and although gtk= selects the row even on a right button click, it is done after the button-press-eve= nt signal callback, which prevents me to use the 'normal' get-path method. ;; -- Le Thu, 01 Jul 2010 11:49:43 +0100, Andy Wingo a =C3=A9crit : > On Tue 29 Jun 2010 15:42, David Pirotte writes: >=20 > > did you see my message about get-path-at-pos? >=20 > Can you please mail a complete and concise description of the problem? >=20 > Thanks, >=20 > A --MP_/cI+2SQn6ig6E1pM_PEavfCG Content-Type: text/x-scheme Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename=get-path-at-pos.scm #! /bin/sh # -*- scheme -*- exec guile-gnome-2 -s $0 "$@" !# ;; guile-gnome ;; Copyright (C) 2003,2004 Free Software Foundation, Inc. ;; This program is free software; you can redistribute it and/or ;; modify it under the terms of the GNU General Public License as ;; published by the Free Software Foundation; either version 2 of ;; the License, or (at your option) any later version. ;; ;; This program is distributed in the hope that it will be useful, ;; but WITHOUT ANY WARRANTY; without even the implied warranty of ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ;; GNU General Public License for more details. ;; ;; You should have received a copy of the GNU General Public License ;; along with this program; if not, contact: ;; ;; Free Software Foundation Voice: +1-617-542-5942 ;; 59 Temple Place - Suite 330 Fax: +1-617-542-2652 ;; Boston, MA 02111-1307, USA gnu@gnu.org (read-set! keywords 'prefix) (use-modules (ice-9 receive) (oop goops) (gnome gobject) (gnome gtk) (gnome gtk gdk-event)) (define *model* #f) (define *selection* #f) (define (pack-tv-column tv column renderer pos) (pack-start column renderer #t) (add-attribute column renderer "text" pos) (append-column tv column)) (define (add-columns treeview) (let* ((renderer1 (make )) (column1 (make :title "Column 1" :sizing 'fixed :fixed-width 65 ;:clickable #f ;:resizable #f ;:reorderable #f :alignment .5 )) (renderer2 (make )) (column2 (make :title "Column 2" :sizing 'fixed :fixed-width 65 ;:clickable #f ;:resizable #f ;:reorderable #f :alignment .5 )) (renderer3 (make )) (column3 (make :title "Column 3" :expand #t :alignment .5 ))) (pack-tv-column treeview column1 renderer1 0) (pack-tv-column treeview column2 renderer2 1) (pack-tv-column treeview column3 renderer3 2) ;; (set-search-column treeview 1) )) (define (ocs/add-model treeview) (let* ((column-types (list )) (model (gtk-list-store-new column-types))) (set-model treeview model) (values model (get-selection treeview)) )) (define (setup-treeview treeview) (add-columns treeview) (receive (model selection) (ocs/add-model treeview) (set-mode selection 'single) (values model selection))) (define (populate-model model) (for-each (lambda (row) (let ((iter (gtk-list-store-append model))) (set-value model iter 0 (car row)) (set-value model iter 1 (cadr row)) (set-value model iter 2 (caddr row)))) '(("r1c1" "r1c2" "r1c3") ("r2c1" "r2c2" "r2c3") ("r3c1" "r3c2" "r3c3")) )) (define (make-simple-popup-menu entries) (let ((menu (make ))) (for-each (lambda (entry) (if (pair? entry) (let* ((label (car entry)) (callback (cdr entry)) (menu-item (gtk-menu-item-new-with-label label))) (connect menu-item 'activate (lambda (widget) (callback))) (gtk-menu-shell-append menu menu-item) (show menu-item)) (let ((menu-item (gtk-separator-menu-item-new))) (gtk-menu-shell-append menu menu-item) (show menu-item)))) entries) menu)) (define (make-popup-menu) (make-simple-popup-menu `(("popup option 1" . ,(lambda () (display "popup option 1\n"))) ("popup option 2" . ,(lambda () (display "popup option 2\n"))) separator ("popup option 3" . ,(lambda () (display "popup option 3\n")))) )) (define (animate) (let* ((window (make :type 'toplevel :title "Get path at pos test" )) (treeview (make )) (popup-menu (make-popup-menu))) (set-default-size window 300 100) (receive (model selection) (setup-treeview treeview) (populate-model model) (add window treeview) (connect window 'delete-event (lambda (widget event) (destroy widget) (gtk-main-quit) #f)) (connect treeview 'button-press-event (lambda (w ev) (case (gdk-event:type ev) ((button-press) (let* ((button (gdk-event-button:button ev)) (time (gdk-event-button:time ev)) (x-pos (inexact->exact (gdk-event-button:x ev))) (y-pos (inexact->exact (gdk-event-button:y ev))) (path-values ;; (get-path-at-pos w x-pos y-pos) (values (list 1) #t 10 10) )) (case button ((3) (receive (indices bool x y) path-values (let* ((row (car indices)) (iter (get-iter model row))) (gtk-menu-popup popup-menu #f ;; parent-menu-shell or #f #f ;; parent-menu-item or #f #f ;; user supplied func to position the menu or #f ;; #f - no more user supplied data to pass to func button time ))))))) ((2button-press) (simple-format #t "ignoring 2button-press events...~%")) ((3button-press) (simple-format #t "ignoring 3button-press events...~%")) ) #f )) ) (show-all window) (gtk-main))) (animate) --MP_/cI+2SQn6ig6E1pM_PEavfCG--