This is one of the GSoC 2010 Projects.
Themed Tk on Unix
Tk Widget Styling Support is a really old topic. First mention I found is https://www.tcl-lang.org/cgi-bin/tct/tip/48 with date of 23 July 2001, and I want to finish it now. I often have that urge to change the look of applications. But I know that theming is not just to make eye candies. This topic is generally about rewriting the code from Motif-looking widgets to use Qt or GTK instead. That way system layouts can have an effect on Tk programs.
I want to rewrite the code from Motif-looking widgets to use Qt or GTK instead. That way system layouts can have an effect on Tk programs. I am aware of previous attempts to achieve this goal. In the course of the project I will evaluate them and either use them or reimplement the code.
The concept of the solution was evolving through the years. Now Tile-qt is working but incomplete and segfaults on exit. Tile-gtk doesn't work at the moment. I want to spend some time reviewing it and talk to community of users, get mentor advice to get sure that they would be satisfied of that I will do and how.
I always spend some time to give my applications a distinct look and take care of good HCI. I like it how Tk looks under Mac, but I work mostly on Linux last days, so I more often have that feeling to do it another way and use the rich graphic possibilities.
After a lecture of Tcl/Tk Engineering Manual by John K. Ousterhout, and reading a lot of Tcl wiki pages and also scouring many of posts on comp.lang.tcl group and tons of other Internet information sources, I have compiled latest of Tcl and Tk sources and also tile-gtk and tile-qt. There were some problems, mostly in fault of my system deficiencies. While I was compiling tile-gtk, it ended with an error that it couldn't find some headers. It shows up that I didn't had the gtk-dev packages installed, but configure script didn't end with an error.
The basic difference those extensions bring is already visible in the simplest example: http://asterix.maxnet.org.pl/~aweelka/comparison.png http://asterix.maxnet.org.pl/~aweelka/Tile-qt.png The background color changes only on used widgets not on all window, so the border of widget is visible and can look ugly.
There is also a problem with changing themes on the fly. It doesn't happened until restart of an application. Despite that Qt and GTK support changing themes on the fly and all others applications on the system changes, tile-qt and tile-gtk applications don't work that way.
As you can see, both Qt and GTK based themes look more or less the same as all other applications on my Ubuntu version. They work up to some point, but consist mostly of rough edges. But the real problem seems to be the quality of the code. Configure scripts don't complain on missing libraries. There are no tests at all. Code is not following the engineering manual guidelines, lacks in comments and parts of it are in #if 0 blocks... On the other hand, it seems that the extensions seem to be good enough to run real applications (Coccinella uses tile-qt as the default theme on my system, even when running GNOME).
Dominant language in Tile-gtk is cpp - 4734 lines, which is 80.18% of its code. There is just 1017 (17.23%) of tcl. The rest 2.59% (153 l.) is written in bash, Makefiles and configure files. The situation with Tile-qt is almost the same - cpp make cpp 83.03% (3553 LoC), tcl 14.09% (603 LoC) and sh is 2.87% (123 l.) of code.
And some people have reported crashes, which I couldn't reproduce on my system. I still have much testing to do, which is bogged down by not having enough RAM (I have to install systems on a physical partition to test on them). I am using Ubuntu 9.10 - the Karmic Koala. I have 2.18.3-1ubuntu2.2 version of development files for the GTK+ library. Qt 4 development tools I have in 4.5.3really4.5.2-0ubuntu1 version. To work I currently use Tk CVS HEAD revision 1.2430 and Tcl revision 1.5154. The version of tile-gtk is commit 8be012927ccdbb66b4db271bfd35dabc634622bf, tile-qt fa7c3afbc426d16e82c59d01d93e8eaa913532d2 (both are the newest, but not really new, revisions).
So I have started writing my own extension. I have spent many hours on preparing all files to produce a Tcl extension (I started using an outdated TEA example and had to start from scratch at some point). It is detecting whether the system is GNOME or KDE based and load an appropriate package - tile-qt or tile-gtk.
My current plan is to find all the lackings of both tile-qt and tile-gtk (like the one with label border described above) and try to cope with them. Then I'll try to work on overall code quality of the whole code base (this is not a small task, as both extensions are in the 5k range of LoC). Finally my extension will only be a wrapper that will choose which one will fit best the system (tile-qt or tile-gtk).
My schedule was too optimistic, what I knew when I wrote it, but finishing in those dates sounded so good.. So, I am still behind the schedule.
But I achieved to apply the native color palette to Tk widgets in applications using tile-qt or tile-gtk.
Curiosity: The new KDE could do that even before, but now simple Tk widgets look better on both KDE and GNOME.
MILESTONE 1: read documentation, preparing working system with the latest sources - have recent CVS HEAD checkouts up and running, coding of own extension
(True the all time:
MILESTONE 2: have bugs Identified and addressed how I will improve them July 22 20:00 UTC
Progress: I have added some tickets todo in my repository (All tickets: [L1 ] ).
MILESTONE 3: Have the existing code corrected
July 29 20:00 UTC
Identified and addressed how I will improve tile-gtk and tile-qt
July 30 17:00 UTC
MILESTONE 4: have the code done
August 6 20:00 UTC
August 9 (my birthday):
"Suggested 'pencils down' date. Take a week to scrub code, write tests, improve documentation, etc."
August 16 19:00 UTC:
Firm 'pencils down' date. Mentors, students and organization administrators can begin submitting final evaluations to Google.
August 20 19:00 UTC: Final evaluation deadline
August 23: Final results of GSoC 2010 announced
August 30: Students can begin submitting required code samples to Google
For the past couple of days I receive a lot of feedback. I will try to address some of the issues raised there below:
I think I've heard that the Qt or Gtk widget aren't as fast as the current Tk widgets. Would the reimplementation make Tk unacceptably slow?
They are probably slower but this is not so much of difference - Qt is kind of fast and GTK is acceptable.
Are the Qt or Gtk widgets multiplatform, or will we need a separate fork for the MS-Windows and Aqua platforms?
There already are some working Tile projects for both Windows and OS X, so this one is aimed explicitly at Linux/Unix. But Qt is portable to all important platforms, looking good under both Windows and OS X (this is the reason why I did my previous applications in it). Gtk works well under Windows and is available under OS X, but in the latter case it feels a bit alien.
Would it be possible to add code to the current Tk or Tile to respond to system layout hints? Could the system layout hints be imported into the options database?
When we actually use the native widgets, we get all the styling done exactly the same way as in the rest of the environment.
e-mail address: aweelka[at]gmail.com or jabber/xmpp: aweelka[at]maxnet.org.pl