* gtk-menu-popup [guile-gnome2 2.16.1-4]
@ 2010-06-28 19:15 David Pirotte
2010-06-29 10:04 ` Andy Wingo
0 siblings, 1 reply; 6+ messages in thread
From: David Pirotte @ 2010-06-28 19:15 UTC (permalink / raw)
To: guile-user
just sent but subject line was the wrong one !
Hello,
debian [testing/unstable]
all guile-gnome2 2.16.1-4 installed
gtk-menu-popup
the following error:
ERROR: In procedure gtk-menu-popup:
ERROR: Wrong type argument in position 5: #f
is raised by the following code [unmodified since guile-gnome0]
(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 ;; user supplied data to pass to func
button
time)
user data to pass to func ...
-] when trying to pass '() it raises an error too
-] if I pass an integer [just to try]:
--] no more errors
--] but no popup menu is poped-up :-)
Thanks for some hints,
David
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: gtk-menu-popup [guile-gnome2 2.16.1-4]
2010-06-28 19:15 gtk-menu-popup [guile-gnome2 2.16.1-4] David Pirotte
@ 2010-06-29 10:04 ` Andy Wingo
2010-06-29 14:42 ` David Pirotte
0 siblings, 1 reply; 6+ messages in thread
From: Andy Wingo @ 2010-06-29 10:04 UTC (permalink / raw)
To: David Pirotte; +Cc: guile-user
Hi David,
On Mon 28 Jun 2010 21:15, David Pirotte <david@altosw.be> writes:
> (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 ;; user supplied data to pass to func
> button
> time)
This function did change API when going from guile-gnome-0 to
guile-gnome-2. I paste below the commit that re-added gtk-menu-popup to
guile-gnome-gtk. As you can see the prototype is different -- no user
data to the positioning function.
Cheers,
Andy
Parent: b5bfe47421b32f5fc8684725f18be2cd50f07748 (2007-12-17 Jan Nieuwenhuizen <janneke@gnu.org>)
Child: 3c4f31cba340a85f6545409a409f53a4a401f393 (Update NEWS for release)
Branches: gtk, remotes/origin/gtk
Follows:
Precedes:
2008-04-10 Andy Wingo <wingo@pobox.com>
* gnome/overrides/gtk.defs (popup):
* gnome/gw/gtk-support.h:
* gnome/gw/gtk-support.c (menu_position_fn)
(_wrap_gtk_menu_popup): Wrap gtk-menu-popup, with a scheme
positioning function and no user-data argument.
---------------------------------- ChangeLog ----------------------------------
index 96f736c..5d828a0 100644
@@ -1,3 +1,11 @@
+2008-04-10 Andy Wingo <wingo@pobox.com>
+
+ * gnome/overrides/gtk.defs (popup):
+ * gnome/gw/gtk-support.h:
+ * gnome/gw/gtk-support.c (menu_position_fn)
+ (_wrap_gtk_menu_popup): Wrap gtk-menu-popup, with a scheme
+ positioning function and no user-data argument.
+
2007-12-17 Jan Nieuwenhuizen <janneke@gnu.org>
* gnome/gw/gtk-support.h:
---------------------------- gnome/gw/gtk-support.c ----------------------------
index cc0c17f..998f8a1 100644
@@ -413,6 +413,33 @@ _wrap_gtk_list_store_append (GtkListStore *store)
return new;
}
+static void
+menu_position_fn (GtkMenu *menu, gint *x, gint *y, gboolean *push_in,
+ gpointer data)
+{
+ SCM ret, proc = GPOINTER_TO_SCM (data);
+
+ ret = scm_call_1 (proc, scm_c_gtype_instance_to_scm (menu));
+
+ *x = scm_to_int32 (scm_car (ret));
+ *y = scm_to_int32 (scm_cadr (ret));
+ *push_in = scm_is_true (scm_caddr (ret));
+}
+
+void
+_wrap_gtk_menu_popup (GtkMenu *menu, GtkWidget *parent_menu_shell,
+ GtkWidget *parent_menu_item, SCM func,
+ guint button, guint32 activate_time)
+{
+ if (scm_is_true (func))
+ gtk_menu_popup (menu, parent_menu_shell, parent_menu_item,
+ menu_position_fn, SCM_TO_GPOINTER (func),
+ button, activate_time);
+ else
+ gtk_menu_popup (menu, parent_menu_shell, parent_menu_item,
+ NULL, NULL, button, activate_time);
+}
+
/* FIXME: is this still necessary? */
SCM
_wrap_gtk_message_dialog_new (GtkWindow* parent, GtkDialogFlags flags, GtkMessageType type,
---------------------------- gnome/gw/gtk-support.h ----------------------------
index 71cde36..0326cd1 100644
@@ -59,6 +59,10 @@ GtkTreeIter* _wrap_gtk_list_store_insert_after (GtkListStore *store, GtkTreeIter
GtkTreeIter* _wrap_gtk_list_store_prepend (GtkListStore *store);
GtkTreeIter* _wrap_gtk_list_store_append (GtkListStore *store);
+void _wrap_gtk_menu_popup (GtkMenu *menu, GtkWidget *parent_menu_shell,
+ GtkWidget *parent_menu_item, SCM func,
+ guint button, guint32 activate_time);
+
SCM _wrap_gtk_message_dialog_new (GtkWindow* parent, GtkDialogFlags flags, GtkMessageType type, GtkButtonsType buttons, const gchar *text);
gchar* _gtk_selection_data_get_as_string (GtkSelectionData *data);
--------------------------- gnome/overrides/gtk.defs ---------------------------
index 8edb1fd..e69a5a2 100644
@@ -303,6 +303,21 @@
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; GtkMenu
+(define-method popup
+ (of-object "GtkMenu")
+ (c-name "_wrap_gtk_menu_popup")
+ (overrides "gtk_menu_popup")
+ (return-type "none")
+ (leave-guile-mode #f)
+ (parameters
+ '("GtkWidget*" "parent_menu_shell" (null-ok))
+ '("GtkWidget*" "parent_menu_item" (null-ok))
+ '("SCM" "menu_position_func")
+ '("guint" "button")
+ '("guint32" "activate_time")
+ )
+)
+
(define-function gtk_menu_get_for_attach_widget
(c-name "gtk_menu_get_for_attach_widget")
(overrides "gtk_menu_get_for_attach_widget")
@@ -1100,7 +1115,6 @@
"gtk_list_unselect_child"
"gtk_list_unselect_item"
"gtk_menu_attach_to_widget"
- "gtk_menu_popup"
"gtk_message_dialog_format_secondary_markup"
"gtk_message_dialog_format_secondary_text"
"gtk_notebook_query_tab_label_packing"
--
http://wingolog.org/
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: gtk-menu-popup [guile-gnome2 2.16.1-4]
2010-06-29 10:04 ` Andy Wingo
@ 2010-06-29 14:42 ` David Pirotte
2010-07-01 10:49 ` Andy Wingo
0 siblings, 1 reply; 6+ messages in thread
From: David Pirotte @ 2010-06-29 14:42 UTC (permalink / raw)
To: Andy Wingo; +Cc: guile-user
Hi Andy,
Thank you! It's working!
What confused me is that the doc @
http://www.gnu.org/software/guile-gnome/docs/gtk/html/GtkMenu.html#GtkMenu
[which I [re]red before to write to the list] is partially correct because the
argument list in the function def is correct [but I didn't catch that as they are
all on one line, I guess], where as the explanation of each argument below
the function def still mention 'data' [which I did red well because they on separate
lines ... :-)]
Cheers,
David
did you see my message about get-path-at-pos?
;; --
— Function: gtk-menu-popup (self <gtk-menu>) (parent_menu_shell <gtk-widget>)
(parent_menu_item <gtk-widget>) (menu_position_func scm) (button unsigned-int)
(activate_time unsigned-int32) — Method: popup
Displays a menu and makes it available for selection. Applications can use this
function to display context-sensitive menus, and will typically supply ‘#f’ for
the parent-menu-shell, parent-menu-item, func and data parameters. The default
menu positioning function will position the menu at the current mouse cursor
position.
The button parameter should be the mouse button pressed to initiate the menu
popup. If the menu popup was initiated by something other than a mouse button
press, such as a mouse button release or a keypress, button should be 0.
The activate-time parameter should be the time stamp of the event that initiated
the popup. If such an event is not available, use gtk-get-current-event-time
instead.
menu
a <gtk-menu>.
parent-menu-shell
the menu shell containing the triggering menu item, or ‘#f’
parent-menu-item
the menu item whose activation triggered the popup, or ‘#f’
func
a user supplied function used to position the menu, or ‘#f’
data
user supplied data to be passed to func.
button
the mouse button which was pressed to initiate the event.
activate-time
the time at which the activation event occurred.
;; --
Le Tue, 29 Jun 2010 12:04:27 +0200,
Andy Wingo <wingo@pobox.com> a écrit :
> Hi David,
>
> On Mon 28 Jun 2010 21:15, David Pirotte <david@altosw.be> writes:
>
> > (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 ;; user supplied data to pass to func
> > button
> > time)
>
> This function did change API when going from guile-gnome-0 to
> guile-gnome-2. I paste below the commit that re-added gtk-menu-popup to
> guile-gnome-gtk. As you can see the prototype is different -- no user
> data to the positioning function.
>
> Cheers,
> Andy
> ...
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: gtk-menu-popup [guile-gnome2 2.16.1-4]
2010-06-29 14:42 ` David Pirotte
@ 2010-07-01 10:49 ` Andy Wingo
2010-07-02 3:37 ` David Pirotte
0 siblings, 1 reply; 6+ messages in thread
From: Andy Wingo @ 2010-07-01 10:49 UTC (permalink / raw)
To: David Pirotte; +Cc: guile-user
On Tue 29 Jun 2010 15:42, David Pirotte <david@altosw.be> writes:
> did you see my message about get-path-at-pos?
Can you please mail a complete and concise description of the problem?
Thanks,
A
--
http://wingolog.org/
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: gtk-menu-popup [guile-gnome2 2.16.1-4]
2010-07-01 10:49 ` Andy Wingo
@ 2010-07-02 3:37 ` David Pirotte
2010-07-08 10:51 ` Andy Wingo
0 siblings, 1 reply; 6+ messages in thread
From: David Pirotte @ 2010-07-02 3:37 UTC (permalink / raw)
To: Andy Wingo; +Cc: guile-user
[-- Attachment #1: Type: text/plain, Size: 981 bytes --]
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 #<<generic> get-path-at-pos (1)> in call
(get-path-at-pos #<<gtk-tree-view> 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-event signal
callback, which prevents me to use the 'normal' get-path method.
;; --
Le Thu, 01 Jul 2010 11:49:43 +0100,
Andy Wingo <wingo@pobox.com> a écrit :
> On Tue 29 Jun 2010 15:42, David Pirotte <david@altosw.be> writes:
>
> > did you see my message about get-path-at-pos?
>
> Can you please mail a complete and concise description of the problem?
>
> Thanks,
>
> A
[-- Attachment #2: get-path-at-pos.scm --]
[-- Type: text/x-scheme, Size: 5681 bytes --]
#! /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 <gtk-cell-renderer-text>))
(column1 (make <gtk-tree-view-column>
:title "Column 1"
:sizing 'fixed
:fixed-width 65
;:clickable #f
;:resizable #f
;:reorderable #f
:alignment .5
))
(renderer2 (make <gtk-cell-renderer-text>))
(column2 (make <gtk-tree-view-column>
:title "Column 2"
:sizing 'fixed
:fixed-width 65
;:clickable #f
;:resizable #f
;:reorderable #f
:alignment .5
))
(renderer3 (make <gtk-cell-renderer-text>))
(column3 (make <gtk-tree-view-column>
: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 <gchararray>
<gchararray>
<gchararray>
<gchararray>
<gchararray>
<gchararray>))
(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 <gtk-menu>)))
(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 <gtk-window>
:type 'toplevel
:title "Get path at pos test"
))
(treeview (make <gtk-tree-view>))
(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)
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: gtk-menu-popup [guile-gnome2 2.16.1-4]
2010-07-02 3:37 ` David Pirotte
@ 2010-07-08 10:51 ` Andy Wingo
0 siblings, 0 replies; 6+ messages in thread
From: Andy Wingo @ 2010-07-08 10:51 UTC (permalink / raw)
To: David Pirotte; +Cc: guile-user
Hi,
On Fri 02 Jul 2010 04:37, David Pirotte <david@altosw.be> writes:
> ERROR: No applicable method for #<<generic> get-path-at-pos (1)> in call
> (get-path-at-pos #<<gtk-tree-view> b6320540> 118 30)
Indeed, it seems that gtk-tree-view-get-path-at-pos is not wrapped in
guile-gnome-2. For the moment, you will have to use something else; but
please file a bug. I might be able to get to this within a couple weeks
if you poke me about it.
Andy
--
http://wingolog.org/
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2010-07-08 10:51 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-06-28 19:15 gtk-menu-popup [guile-gnome2 2.16.1-4] David Pirotte
2010-06-29 10:04 ` Andy Wingo
2010-06-29 14:42 ` David Pirotte
2010-07-01 10:49 ` Andy Wingo
2010-07-02 3:37 ` David Pirotte
2010-07-08 10:51 ` Andy Wingo
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).