Re: Gtk Question
- From: "Shawn T. Amundson" <amundson gimp org>
- To: gtk-list redhat com
- Subject: Re: Gtk Question
- Date: Wed, 27 May 1998 17:55:08 -0700 (PDT)
Um, eek.. All our examples are wrong.
The correct function prototype for the delete_event callback is includes
a GdkEventAny*. The following will get you past your problem:
gint windowSignalHandlerStub(GtkWidget *w, GdkEventAny *event, gpointer data)
{
char *junk = (char *) data;
printf("Received the following data: %s\n", junk);
return TRUE;
}
The correct function prototype can be determined by looking (in this
case) at the GtkWidgetClass structure in gtk/gtkwidget.h. Admittedly
this isn't the optimal place to be looking at for things this simple,
so we will have to fix our examples and the tutorial. ;-)
-Shawn
On Wed, 27 May 1998, Achint Sandhu wrote:
> Hi,
>
> I am starting to use Gtk and seem to be running into a small
> problem.
> Other than the problem mentioned below, everything else I have tried
> seems to work fine.
>
> Included is the code for a small "Hello World" type program. I
> am
> trying to pass data to the "callback" for the "delete_event" handler for
> a window and can't seem to get it to work. I have tried this with Gtk
> 1.0.3 on Solaris. I realise I am probably missing something obvious. Any
> help you could provide would be greatly appreciated...
>
> Anyway here is the code...
>
> ---
>
> #include <stdio.h>
> #include <string.h>
> #include <gtk/gtk.h>
>
> gint windowSignalHandlerStub(GtkWidget *w, gpointer data) {
>
> char *junk = (char *) data;
>
> printf("Received the following data: %s\n", junk);
> return TRUE;
> }
>
> int main (int argc, char *argv[])
> {
> GtkWidget *window;
>
> char *aCommand;
> aCommand = strdup("Foo");
>
> gtk_init (&argc, &argv);
>
> window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
> gtk_widget_show(window);
>
> gtk_signal_connect(GTK_OBJECT(window), "delete_event",
> GTK_SIGNAL_FUNC(windowSignalHandlerStub),
> (gpointer) aCommand);
>
> gtk_main ();
>
> return 0;
> }
>
> ---
>
> Thanks for your time.
>
> Cheers,
> Achint
>
> PS: Passing data to the callbacks for the widgets works just fine....
>
>
> --
> Achint Sandhu
> Nortel
>
> Windows 95: n. 32-bit extensions and a graphical shell for
> a 16-bit patch to an 8-bit operating system originally
> coded for a 4-bit microprocessor, written by a 2-bit
> company that can't stand for 1 bit of competition.
>
> --
> To unsubscribe: mail -s unsubscribe gtk-list-request@redhat.com < /dev/null
>
>
--
Shawn T. Amundson
amundson@gimp.org http://www.gimp.org/~amundson
"The assumption that the universe looks the same in every
direction is clearly not true in reality." - Stephen Hawking
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]