data in callbacks and file selection widget pointers



First Question:  My map editor uses an enum to identify the different
terrain types. I have buttons which select the current terrain type that
need to pass the type to the callback function.  Currently, I'm doing
this:

    gtk_signal_connect(GTK_OBJECT(terrain_button), "clicked",
                    GTK_SIGNAL_FUNC(ButtonToggled), GRASS);

It works, but I get warnings.  It would seem that the right thing to do
when passing an int would be to pass the address of it and dereference
later.  Obviously, one can't do that with an enum.  I can cast it, like
so:

    gtk_signal_connect(GTK_OBJECT(terrain_button), "clicked",
                    GTK_SIGNAL_FUNC(ButtonToggled), (gpointer)GRASS);

which gets rid of the warning, but just doesn't seem like the right thing
to do.  All the examples in the example code pass character strings into
the callbak.

********
Second Question:

My menu has a couple of options (Open and Save As) that open up file
selectors.  I have attached the OK button of the Open option's file
selector to a function called OpenMap, like so:

void openMap(GtkWidget *widget, GtkFileSelection *fs) {
    loadMapData(bogus_map,
gtk_file_selection_get_filename(GTK_FILE_SELECTION(fs
    DrawTerrain();

    gtk_widget_destroy(fs);

    return;
}

I get warnings that I am passing an incompatible pointer type when I call 
gtk_widget_destroy on fs.  It works, however.  What do I need to do to get
rid of that warning?

Thanks!


  +=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=
  =   Rob Huffstedtler          |     We now return to our regularly     +
  +   (931) 596-3560            |        scheduled programming           =
  =+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]