So since nobody uses Motif anymore (
) I've embarked on yet another abortive attempt to learn the accursed gtk. I downloaded the "official" gtk "hello world" tutorial, and figured out what it takes to compile it, yes
this:
And what does it do when it runs? It segfaults! So yeah, that's everything that's wrong with gtk in a nutshell.
For anyone who's interested, a backtrace:
and the code (comments are mine, theirs are too verbose):
Code: Select all
gcc -Wall -pedantic -W -ggdb \
-I/usr/include/gtk-2.0 \
-I/usr/include/glib-2.0 \
-I/usr/lib/glib-2.0/include \
-I/usr/lib/gtk-2.0/include \
-I/usr/include/cairo \
-I/usr/include/pango-1.0 \
-I/usr/include/gdk-pixbuf-2.0 \
-I/usr/include/atk-1.0 \
-lgtk -lgdk -lgobject-2.0 hello_world.c -o hello_world
And what does it do when it runs? It segfaults! So yeah, that's everything that's wrong with gtk in a nutshell.
For anyone who's interested, a backtrace:
Code: Select all
#0 0xb7e33fdd in g_type_check_instance () from /usr/X11R6/lib/libgobject-2.0.so.0
#1 0xb7e26122 in g_signal_connect_data () from /usr/X11R6/lib/libgobject-2.0.so.0
#2 0x08048855 in main (argc=1, argv=0xbffff304) at hello_world.c:55
and the code (comments are mine, theirs are too verbose):
Code: Select all
#include <gtk/gtk.h>
/* callback function */
static void hello(GtkWidget * w, gpointer data)
{
g_print("Hello, World!\n");
}
static gboolean delete_event(GtkWidget * w, GdkEvent * e, gpointer data)
{
g_print("delete event occurred\n");
return TRUE;
}
/* another callback */
static void destroy(GtkWidget * w, gpointer data)
{
gtk_main_quit();
}
int main(int argc, char * argv[])
{
GtkWidget * window;
GtkWidget * button;
gtk_init(&argc, &argv);
/* create a new window */
window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
/* connect the "delete-event" to a signal handler */
g_signal_connect(window, "delete-event", G_CALLBACK (delete_event), NULL);
/* connect the "destroy" event to a signal handler */
g_signal_connect(window, "destroy", G_CALLBACK (destroy), NULL);
/* sets the border width of the window */
gtk_container_set_border_width(GTK_CONTAINER(window), 10);
button = gtk_button_new_with_label("Hello World");
/* button clicked callback */
g_signal_connect(button, "clicked", G_CALLBACK(hello), NULL);
/* whatever */
g_signal_connect_swapped(button, "clicked", G_CALLBACK(gtk_widget_destroy), window);
/* packs the button into the window (a gtk container) */
gtk_container_add(GTK_CONTAINER(window), button);
/* realize the widget */
gtk_widget_show(button);
/* and the window */
gtk_widget_show(window);
gtk_main();
return 0;
}
Project:
Temporarily lost at sea...
Plan:
World domination! Or something...
Temporarily lost at sea...
Plan:
World domination! Or something...