Reputation: 123
Hey guys I've recently started dabbling in Glade with C. I have been able to compile a few GTK+ applications in C but I keep getting compilation errors when compiling the following C file with a glade file (taken from Micah Carrick's tutorial)
main.c
#include <gtk/gtk.h>
void
on_window_destroy (GtkObject *object, gpointer user_data)
{
gtk_main_quit ();
}
int
main (int argc, char *argv[])
{
GtkBuilder *builder;
GtkWidget *window;
gtk_init (&argc, &argv);
builder = gtk_builder_new ();
gtk_builder_add_from_file (builder, "tutorial.glade", NULL);
window = GTK_WIDGET (gtk_builder_get_object (builder, "window"));
gtk_builder_connect_signals (builder, NULL);
g_object_unref (G_OBJECT (builder));
gtk_widget_show (window);
gtk_main ();
return (0);
}
tutorial.glade
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!DOCTYPE glade-interface SYSTEM "glade-2.0.dtd">
<!--Generated with glade3 3.4.0 on Tue Nov 20 14:05:37 2007 -->
<glade-interface>
<widget class="GtkWindow" id="window1">
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
<child>
<placeholder/>
</child>
</widget>
</glade-interface>
and compiling in MSYS with:
gcc -Wall -g -mwindows -O2 main.c -o program.exe `pkg-config --cflags --libs gtk+-3.0`
I get the following error:
main.c:4:20: error: unknown type name 'GtkObject'
on_window_destroy (GtkObject *object, gpointer user_data)
^
I've tried using changing tutorial.glade to an XML file but didn't change anything. Maybe I have to rename GtkObject to something different, or I missed a compilation flag? Sorry if it's a noob question, still learning :S
Upvotes: 1
Views: 2950
Reputation: 57854
Change GtkObject
to GtkWidget
. It looks like your tutorial uses the old GTK 2.0 API, while you are compiling using the current 3.0 API.
I suggest emailing whoever is hosting the tutorial to update it, or at least put a warning banner above it saying that it uses an out of date API.
Upvotes: 3