I'm trying to learn GTK+ and am trying to write a basic program that has a button in a window and doesn't really do anything exciting.
I'm kinda doing this in a C++ way as well, but that shouldn't matter here.
My code (the relevant bit) looks like this:
Code:
int main(int argc, char *argv[])
{
gtk_init(&argc, &argv);
GtkWidget *window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
g_signal_connect(G_OBJECT(window), "delete_event", G_CALLBACK(delete_event), NULL);
gtk_container_set_border_width(GTK_CONTAINER(window), 10);
GtkWidget *button = gtk_button_new_with_label("Hello world!");
gtk_signal_connect(G_OBJECT(button), "clicked", G_CALLBACK(callback), (gpointer)"button");
gtk_widget_show(button);
gtk_widget_show(window);
gtk_main();
return 0;
}
The problematic line is in bold. When I try to compile with "g++ filename.cc -ofilename `pkg-config --cflags --libs gtk+-2.0", I get the following error:
filename.cc: In function `int main(int, char**)':
filename.cc:18: error: cannot convert `GObject*' to `GtkObject*' for
argument `1' to `gulong gtk_signal_connect_full(GtkObject*, const gchar*,
void (*)(), void (*)(GtkObject*, void*, unsigned int, GtkArg*), void*, void
(*)(void*), int, int)'
I don't understand, because there's a line that looks almost identical to mine
here and that compiles fine
. Any ideas?
All help appreciated!