Monday, May 3, 2010

C++

Links: gui kits comparison   C++ examples   Connecting C++ to MySQL   makefile tutorial   make manual   YoLinux C++ links   C++ tips  CScene mag   Vid:Glade, GTK+, C++

gui issues
So, after some functionality with a database interaction, is it worth the effort to put this into a GUI format? It appears that the API for building Windows apps in Linux will be wxWidgets or VCF. For our Linux C++ program, there are too many to choose from. There is no unified Linux GUI api, unlike Windows. Some would say this is one of the few true drawbacks of Linux, others would say it demonstrates Linux diversity. Essentially, you have to either go to the trouble of coding in XLib, at the time consuming atomic level, or parse through the API's until one seems to match-up with the look and feel (L&F), functionality, and bloat that you are willing to tolerate.

This comparison shows several different formats. SFML and FLTK, maybe even XLib, will probably be in my future, but the Glade+GTK(gtkmm)+C++ approach seems good for the present. Users of my application will need the GTK libraries installed to run my application. XLib coding ay be the only way to avoid that kind of a dependency since X is installed on all Linux systems.

glade
Glade is a useful GTK tool for interfacing with C++. In it, we can create the GUI pieces and signals from user actions (clicks, data entry, etc), and send them to our underlying C++ program for intelligent processing. In my view, it's better than an IDE, since it just manages the interface without messing with the logic. On the negative side, it creates a glade file for the GUI. The file requires a separate library, libglade, to be installed during compilation so. That's one layer of bloat, but probably worth it. Additionally, making sure the make process is right with the extra type of file means a slightly more complex compile command or makefile.

$gcc -export-dynamic testapp.c -o testapp `pkg-config --cflags -g -o2 --libs gtk+-2.4 libglade-2.4`

It gets more complex if one first transforms the glade file into an object and inserts it into the final application to make it more portable.

No comments: