[Date Prev][Date Next] [Thread Prev][Thread Next]
[Thread Index]
[Date Index]
[Author Index]
Re: newbie question
- From: christophe barbé <christophe barbe lineo fr>
- To: gtk-app-devel-list gnome org
- Subject: Re: newbie question
- Date: Thu, 30 Aug 2001 14:27:13 +0200
Thanks a lot.
It works perfect.
Christophe
Le jeu, 30 aoû 2001 12:38:04, Thomas Mailund a écrit :
> On Thu, 2001-08-30 at 20:45, christophe barbé wrote:
> > I would like to attach a function to a click on a gtk pixmap or a gtk
> vbox.
> > I've tried various code and finally my conclusion is that it's
> impossible.
> > This seem's to be because these widgets don't own a (X) window. In my
> > (limited) understanding these are drawn directly on there parent
> window.
>
> to get events without an X window you use GtkEventBox. I've attached an
> example. (In the example I use gdkpixbuf, 'cause I had some code lying
> around, but you can use whatever you need).
>
> /mailund
>
> --
> If an animal is caught in a trap it will chew its leg off to
> escape. If a human is caught in a trap it will wait and kill the
> trapper and eliminate a threat to its kind.
> -- Frank Herbert
>
>
>
> #include <gtk/gtk.h>
> #include <gdk-pixbuf/gdk-pixbuf.h>
>
> void
> clicked (void)
> {
> g_print ("clicked\n");
> }
>
> int
> main (int argc, char *argv[])
> {
> GtkWidget *win;
>
> GdkPixbuf *img;
> GdkPixmap *pixmap;
> GdkBitmap *mask;
> GtkWidget *image;
>
> GtkWidget *event_box;
>
> gtk_init (&argc, &argv);
>
> win = gtk_window_new (GTK_WINDOW_TOPLEVEL);
>
> img = gdk_pixbuf_new_from_file ("./pr0n.jpg");
> gdk_pixbuf_render_pixmap_and_mask (img, &pixmap, &mask, 0);
> image = gtk_pixmap_new (pixmap, mask);
>
> event_box = gtk_event_box_new ();
>
> gtk_container_add (GTK_CONTAINER (win), event_box);
> gtk_container_add (GTK_CONTAINER (event_box), image);
>
> gtk_signal_connect(GTK_OBJECT(event_box), "button_press_event",
> GTK_SIGNAL_FUNC (clicked), NULL);
> gtk_widget_add_events(event_box, GDK_BUTTON_PRESS_MASK);
>
> gtk_widget_show_all (win);
>
>
> gtk_main ();
>
> return 0;
> }
>
--
Christophe Barbé
Software Engineer - christophe.barbe@lineo.fr
Lineo France - Lineo High Availability Group
42-46, rue Médéric - 92110 Clichy - France
phone (33).1.41.40.02.12 - fax (33).1.41.40.02.01
http://www.lineo.com
[Date Prev][Date Next] [Thread Prev][Thread Next]
[Thread Index]
[Date Index]
[Author Index]