Please help me understand how programs are layered

Dariusz J. Garbowski thuforuk at yahoo.co.uk
Tue Oct 3 20:02:17 UTC 2006


On 10/03/2006 08:00 PM, Dotan Cohen wrote:
> Please excuse the newbie-question, but I'd like to know why certain
> apps are "gnome apps" and others are "KDE apps".

Dotan,

These are excellent questions. So good that I will try and answer them :-)

> If I understand
> correctly, programs are written in languages (C, perl, mono), using
> toolkits (QT, GTK), for certain operating systems (Linux, Windows).
> Now, as I understand it, programs written with the QT toolkit are KDE
> apps, and those written with the GTK toolkit are Gnome apps. Is this
> correct?

Toolkits (GTK/Qt) provide (for the sake of simplicity of my answer, I'm 
sure others may elaborate more ;-)

- widgets like buttons, labels, edit fields, etc. and even file selectors
- methods for handling user interaction (e.g. event loop or callbacks)
- some other things depending on toolkit

http://en.wikipedia.org/wiki/Gui_toolkit


Now desktops, like Gnome and KDE, build on top of a toolkit and 
operating system providing things like menu, desktop with icons, basic 
applications (e.g. text editor, clock), windows (window manager), file 
manager, etc.

http://en.wikipedia.org/wiki/Desktop_environment


> Now, I understand that changing a program from C to mono is impossible
> without rewritting the whole program from scratch.

It's not necessarily as "black&white". But this is long discussion and 
depends on many factors...

> But can a program
> be switched from GTK to QT or vice-versa? How involved is that? Can
> there be a QT version and a GTK version of the same app?

If your application core is nicely separated from frontend (GUI) it's 
possible to do so. In fact it's very common in Unix/Linux world -- quite 
a few apps are written as command line utilities and there are different 
frontends for them. Example: K3b is a frontend for bunch of CD/DVD 
mastering and recording tools.

This by no means is the only way. You can for example write a library 
that is used by the different frontends. See how xine engine is used by 
Amarok and other applications.

There are other possibilties too...


> Also, I understand that programs written in C can work on either linux
> or windows, but those written in Java can run on both, because the
> Java runtime environment is specific to the OS. How does the toolkit
> affect this- are they written in only QT || only GTK || neither?

Java is yet another "animal". Java Runtime Environment (JRE) provides 
two GUI toolkits:

- AWT, which is simpler and uses native OS widgets, thus looking and 
behaving slightly differently on different OSes
- Swing, which is more advanced and OS indepentent (yet, it can 
integrate with underlying OS, e.g. look more Windows-like on Windows, or 
GTK-like on Linux); it draws its own widgets without using native toolkits

There's another native toolkit, SWT/JFace, used by Eclipse platform and 
application built on top of Eclipse (http://www.eclipse.org/swt). This 
one is not part of JRE. It uses native toolkits for widget rendering and 
so integrates better with underlying OS (e.g. on Linux it uses GTK). 
There is an effort to write Swing implementation of SWT allowing for SWT 
to be OS-independent. Currently application developers need to include 
different native part of SWT for different OSes, which somewhat defies 
Java's "write once, run anywhere" motto.


> Thanks for the info. Nothing I've been able to google has explained
> this very well, for non-developers like myself.

Hope this helps :-)

Regards,
Dariusz


		
___________________________________________________________ 
Now you can scan emails quickly with a reading pane. Get the new Yahoo! Mail. http://uk.docs.yahoo.com/nowyoucan.html





More information about the kubuntu-users mailing list