Re: pop-ups
- From: "Michael K. Johnson" <johnsonm redhat com>
- To: gtk-list redhat com
- Subject: Re: pop-ups
- Date: Mon, 15 Sep 1997 21:30:29 -0400
Andy Tai writes:
>pop-ups are definitely in gtk. It is used extensively in gimp.
Thanks for pointing that out to me; I was being excessively dense.
>However, the documentation is not done yet, and it seems no infomation on popup
>is available.
That's all right. I found gtk_menu_popup(), which I think will do what I
want. It seems to do the right thing in the layers dialog on line 1397 of
layers_dialog.c in my source tree.
I've got a bunch of other (preparatory) work to do first before I mess
with this, but it looks like a simple:
/* "event" is passed in to the handler */
if (event->type == GDK_BUTTON_PRESS) {
GdkEventButton bevent = (GdkEventButton *) event;
gtk_menu_popup (menu, NULL, NULL, NULL, NULL,
bevent->button, bevent->time);
}
or similar construct will suffice.
It looks like the second two NULL's can be replaced with a function and
its data which determine exactly where the menu is placed (see the
gtk_option_menu_postition() function in gtkoptionmenu.c); the first two
NULL's should be NULL because this function is also used to place submenus,
and those two NULLs refer to the (in this case non-existant) parent.
Here's the prototype:
gtk_menu_popup (GtkMenu *menu,
GtkWidget *parent_menu_shell,
GtkWidget *parent_menu_item,
GtkMenuPositionFunc func,
gpointer data,
gint button,
guint32 activate_time);
The only really new thing here is GtkMenuPositionFunc(), which
is prototyped as:
typedef void (*GtkMenuPositionFunc) (GtkMenu *menu,
gint *x,
gint *y,
gpointer user_data);
So the GtkMenuPositionFunc takes the menu and aribrary user_data
and returns an x and y value by reference. An instructive version
appears right at the bottom of gtk+/gtk/gtkoptionmenu.c, but you
may well not need to use it.
Peter, is that right?
Raph, if Peter says that's right, feel free to abuse what I've written
in any way you want for the menu section of the tutorial if you like.
Otherwise I may remember to revisit the topic in more detail when I've
actually done some popup programming instead of only code inspection.
:-)
michaelkjohnson
"Magazines all too frequently lead to books and should be regarded by the
prudent as the heavy petting of literature." -- Fran Lebowitz
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]