Re: g_signal_connect -- "button-press-event" vs "pressed"
- From: Emmanuele Bassi <ebassi gmail com>
- To: gtk-list gnome org
- Subject: Re: g_signal_connect -- "button-press-event" vs "pressed"
- Date: Wed, 26 Dec 2007 21:53:35 +0000
On Wed, 2007-12-26 at 15:56 -0500, Charles Packer wrote:
> If I code a button widget like this (I'm using the version
> of GTK that came with Fedora Core 5)...
>
> GtkWidget *B = gtk_button_new_with_label (Label);
> g_signal_connect (GTK_OBJECT (B), "button-press-event",
> G_CALLBACK (Happened), "HELLO");
>
> and the callback is this...
>
> Happened (GtkWidget *W, gpointer Data) {
> g_print ("ButtonHappened...|%s|\n", (char *) Data);
> }
no, the callback for the ::button-press-event signal has this signature:
static gboolean
on_button_press_event (GtkWidget *widget,
GdkEventButton *event,
gpointer user_data);
> Now, "button-press-event" is in lists of event types such as you
> find in the GTK 2.0 tutorial at
> http://www.gtk.org/tutorial/a2769.html
yes, and no.
a ::button-press-event is really a low-level signal which you shouldn't
be using unless you know what it is for.
what you want is the GtkButton::clicked signal, not the
GtkWidget::button-press-event signal.
the signature for the ::clicked signal is:
static void
on_clicked (GtkButton *button,
gpointer user_data);
see: http://library.gnome.org/devel/gtk/stable/GtkButton.html
http://www.gtk.org/tutorial/c491.html#SEC-NORMALBUTTONS
ciao,
Emmanuele.
--
Emmanuele Bassi,
W: http://www.emmanuelebassi.net
B: http://log.emmanuelebassi.net
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]