Everything Else

gtk rant

So since nobody uses Motif anymore ( :roll: ) 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:

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...
r-a-c.de
I have diddled around with the fox toolkit, but gave up on it because it couldn't (at least not then) handle UTF8. I bought the wxwidgets book a couple of years ago with the intent of learning that, but actually haven't gotten around to it yet, so that's probably what I'll do next (although the wxwidgets Motif port is sadly either undermaintained or unmaintained). I tried learning KDE once but the fact that their signals and slots architecture didn't work with any debuggers turned me away. I'm just guessing but there's probably a fix for that now...
Project:
Temporarily lost at sea...
Plan:
World domination! Or something...
Is the KDE toolkit as much of a nightmare morass of kitchen-sink dependencies as the eleven billion interdependent packages that make up the KDE project as a whole? I'd steer clear of it if that's the case.
Computers: Amiga 1200, DEC VAXStation 4000/60, DEC MicroPDP-11/73
Synthesizers: Roland JX-10/MT-32/D-10, Oberheim Matrix-6, Yamaha DX7/FB-01, Korg MS-20 Mini, Ensoniq Mirage/SQ-80, Sequential Circuits Prophet-600, Hohner String Performer

"'Legacy code' often differs from its suggested alternative by actually working and scaling." - Bjarne Stroustrup
Strictly speaking it's not the KDE toolkit it's the K Desktop Environment which is built with the qt toolkit from Troll Tech. The consensus seems to be that qt is the best C++ based toolkit but, and at least this was the case last time I looked at it, it runs a preprocessor over your code which implements their signals and slots architecture so really when you're debugging, you're not debugging the code you wrote, you're debugging the code you wrote that the preprocessor modified, and, at least back then, there weren't any debuggers that could understand that. I'm sure it's all different now I haven't looked at it in a decade at least, and have pretty much stuck with Motif that whole time... :roll:
Project:
Temporarily lost at sea...
Plan:
World domination! Or something...
vishnu wrote: Strictly speaking it's not the KDE toolkit it's the K Desktop Environment which is built with the qt toolkit from Troll Tech.

Troll Tech -> Nokia -> Digia, but yeah.

vishnu wrote: The consensus seems to be that qt is the best C++ based toolkit but, and at least this was the case last time I looked at it, it runs a preprocessor over your code which implements their signals and slots architecture so really when you're debugging, you're not debugging the code you wrote, you're debugging the code you wrote that the preprocessor modified, and, at least back then, there weren't any debuggers that could understand that. I'm sure it's all different now I haven't looked at it in a decade at least, and have pretty much stuck with Motif that whole time... :roll:

The signal / slot mechanism is actually pretty nifty. It's implemented via macros, but it's not like there's a special processor munging your code -- if your debugger cannot handle it it will have issues with everything in /usr/include as well.

Maybe you're talking about the user interface layout? The .ui files are processed into source code by a processor (moc). Then again, you don't want to debug the layout of your buttons, you want to debug the action taken after the user presses it.

Current versions (> 4.7) are not supported on IRIX.
Now this is a deep dark secret, so everybody keep it quiet :)
It turns out that when reset, the WD33C93 defaults to a SCSI ID of 0, and it was simpler to leave it that way... -- Dave Olson, in comp.sys.sgi

Currently in commercial service: Image :Onyx2: (2x) :O3x02L:
In the museum : almost every MIPS/IRIX system.
Wanted : GM1 board for Professional Series GT graphics (030-0076-003, 030-0076-004)
Well I suppose if I'd ever actually used KDE I'd have been more disposed to look kindly upon their toolkit of choice. I do remember an article Eric Foster-Johnson wrote in Unix Review way back when saying that KDE would be the holy grail for the Unix desktop, that the Unix desktop could finally be as polished and well integrated as Windows. Say what you will about Mickeysoft but they got OLE right. But when no commercial Unix vendor ever adopted KDE it just made me wonder. Now the deeper I get into the wxwidgets book the more I'm appreciating the design and simplicity of Xt and Motif... :lol:
Project:
Temporarily lost at sea...
Plan:
World domination! Or something...
vishnu wrote: I have diddled around with the fox toolkit, but gave up on it because it couldn't (at least not then) handle UTF8.

The FOX toolkit does support UTF-8 now, just not RTL text.

I favor simple code over visual bling, so if I liked C++, I'd be using FLTK. XForms seems to be the simplest toolkit in C. It now has beta support for UTF-8.
http://xforms-toolkit.org/

You might want to look at IUP. It is not just an elementary toolkit; there are many powerful widgets. The user community is so small I suspect they could all fit into a bus, but the developers are active and very responsive. On Unix/Linux, you have a choice of GTK or Motif backends, and they actively support some Motif based apps on commercial Unix. You can write with Lua or their own LED, but I found it unnecessary since the C code was so clean.
http://sourceforge.net/projects/iup/
nice thanks. didn't know these two
r-a-c.de