Linked by Eugenia Loli on Wed 11th Jan 2006 23:23 UTC
GTK+ This article, the second in a three-part series titled "GTK+ fundamentals," introduces you to programming with GTK+. It analyzes a sample GTK+ application written in C, then shows that same application written in Python and C#. Finally, it discusses some useful tools that can help you develop better applications faster with GTK+.
Order by: Score:
Time
by klynch on Thu 12th Jan 2006 00:00 UTC
klynch
Member since:
2005-07-06

I've always wanted to learn some GUI programming with GTK+. I've just never had the time to. Maybe reading this will spark my motivation.

Another decent (and more extensive) tutorial for using GTK+-2.0 can be found on GTK's own site at http://www.gtk.org/tutorial/

Reply Score: 2

RE: Time
by mcrbids on Fri 13th Jan 2006 10:37 UTC in reply to "Time"
mcrbids Member since:
2005-10-25

If you want to learn GTK+ programming, and want to make it as easy as possible, you might consider http://gtk.php.net/ PHP-GTK.

I've used PHP 4/GTK 1.3 to write a large (80,000 line) application used to generate compliance paperwork for schools. It works well, and I can often edit the source code to a *running* program and see the result right away.

To hide the sources in distribution, I use ioncube encoder.

Reply Score: 1

v Question for GTK developers
by Tom K on Thu 12th Jan 2006 00:33 UTC
RE: Question for GTK developers
by Unbeliever on Thu 12th Jan 2006 00:38 UTC in reply to "Question for GTK developers"
Unbeliever Member since:
2005-07-09

Becuase they're using a different toolkit. Now, let me ask you this, why do Apple apps look so out-of-place in Windows? With their Aqua scrollbars, and all.

Reply Score: 0

RE[2]: Question for GTK developers
by Tom K on Thu 12th Jan 2006 00:45 UTC in reply to "RE: Question for GTK developers"
Tom K Member since:
2005-07-06

Hmm ... did I mention Apple? No, I'm pretty sure I didn't.

Anyway, using a different toolkit is no excuse. QT Windows apps look fine. So again, why do GTK apps look so out-of-place?

Reply Score: 0

Eugenia Member since:
2005-06-28

Because GTK+ is a toolkit on its own, it does not use the Windows toolkit in any way to get the look copied (similar to what toolkits do on OSX, where they can use the "Appearance Manager" API). wxWidgets and Qt do that on both Windows and OSX and so they feel more native. GTK has chosen not to do so and relies on the abilities of a Windows-like theme to make the look similar to Windows'. But a flat out answer to your troll-baiting question is: it was a design decision from Day 1. And it was probably easier to implement it this way.

Reply Score: 5

RE[4]: Question for GTK developers
by Tom K on Thu 12th Jan 2006 01:16 UTC in reply to "RE[3]: Question for GTK developers"
Tom K Member since:
2005-07-06

Easier? So what? Are the GTK devs lazy?

If it means the difference between a decent toolkit that looks good in an OS used on 90% of the world's desktop computers, and a decent toolkit that looks out of place and causes some people to choose not to use GTK-based apps because of their appearance, then the choice is obvious.

Reply Score: 0

Daniel Borgmann Member since:
2005-07-08

Gtk is cross-platform because it is open source, so it can theoretically be ported to every platform. It is not cross-platform because this would be its primary purpose or anything. Most Gtk developers don't even work on the Windows port, this is done by people who happen to be interested in this. Your flaming attempts just make you look silly and have nothing to do with this news story anyway.

Reply Score: 1

RE[6]: Question for GTK developers
by ma_d on Thu 12th Jan 2006 05:11 UTC in reply to "RE[5]: Question for GTK developers"
ma_d Member since:
2005-06-29

That's because porting to Windows (and probably from sometimes) is a nightmare.
Of course, if you can assume services for unix (hence the posix libraries) then it'd be easy; but that's out of the question for most GTK applications.

Reply Score: 1

chemical_scum Member since:
2005-11-02

If it means the difference between a decent toolkit that looks good in an OS used on 90% of the world's desktop computers, and a decent toolkit that looks out of place and causes some people to choose not to use GTK-based apps because of their appearance, then the choice is obvious.

I think GTK apps like Inkscape look much nicer on Windows than native Windows apps. It is all in the eye of the beholder.

Reply Score: 1

zerblat Member since:
2005-07-06

If I understand correctly, Qt doesn't actually use Windows widgets, it uses XP's style engine to draw the widgets ( http://doc.trolltech.com/4.0/qwindowsxpstyle.html#details ), which gives them a native look that follows the theme etc. That is, assuming you are using Qt's XP theme.

But AFAICT, the same is true for GTK if you use GTK-Wimp ( http://gtk-wimp.sourceforge.net ).

So, is there a technical difference between what the Windows XP theme for Qt does and what GTK-Wimp does?

Reply Score: 1

segedunum Member since:
2005-07-06

wxWidgets and Qt do that on both Windows and OSX and so they feel more native.

Qt does emulation which strikes a balance between native look and feel and maintainability, with the extremely complex differences you can get between supporting each platform natively. SWT has a lot of experience with this.

But a flat out answer to your troll-baiting question is: it was a design decision from Day 1. And it was probably easier to implement it this way.

That's a bit of a problem for a cross-platform toolkit, isn't it?

Reply Score: 3

netdur Member since:
2005-07-07

it's about theme not the code!

Reply Score: 1

Eugenia Member since:
2005-06-28

>it's about theme not the code!

You are wrong. It is about the code. GTK does not use Windows' widgets directly like other ported toolkits do. It was easier for the developers to do it this way. A theme can only help the situation so much.

Reply Score: 5

Unbeliever Member since:
2005-07-09

You don't have to mention Apple. It was an example to counter your little theory that only GTK+ apps look out-of-place in Windows.

Every app looks out of place in Windows, Microsoft apps included (hint: WMP). QT apps look out of place as well, you just don't take into account the fact that design-wise, KDE apps (which use Qt) are much closer to Windows than GNOME is.

Reply Score: 1

RE[4]: Question for GTK developers
by Tom K on Thu 12th Jan 2006 01:19 UTC in reply to "RE[3]: Question for GTK developers"
Tom K Member since:
2005-07-06

Whoa whoa, don't put words in my mouth. I didn't say that ONLY GTK apps look out-of-place. That was your assumption.

And no, every app does not look out of place on Windows. Apple apps are even designed to look like Windows Luna/Classic, so that's a moot point. Microsoft's poor consistency with regards to Office/Media Player are something that I wish was corrected, but you can't have everything.

GTK apps, on the other hand, DO attempt to look like Windows, but do it poorly.

Reply Score: 3

RE[5]: Question for GTK developers
by ma_d on Thu 12th Jan 2006 05:17 UTC in reply to "RE[4]: Question for GTK developers"
ma_d Member since:
2005-06-29

Let's name Windows programs that don't maintain a default look and feel:
WMP
iTuns
MSN Messenger
GTK Programs
Trillian
Winamp
Opera!
(Firefox can, with skins, but blends in by default)

Microsoft isn't out to have a completely thorough look and feel; and they haven't gotten it. Spending valuable time trying to make it seem that way would be largely purposeless for gtk developers.

WIMP looks close enough to the default XP that most users who aren't looking won't notice. So, 90% of that 90% doesn't care ;) .


If you want a consistent look and feel you're never going to get it from Redmond. They're adding more power for developers to go toward per-application look and feel all the time. WPF is a huge step forward in this. Setting your own widget sizes, and even completely rewiring how things like list views look (the media center in vista, with the boxes, IIRC that's a list view).

I know you don't like it, but pretty non-standard looks sell to non-technical consumers. People who aren't going to stare at their screen for 6 hours don't mind different themes. It may not even be a bad idea, I imagine it could help people identify different programs more easily.
So, your different look complaint is completely bunk. I know a lot of people want a consistent look; but you aren't going to get it from Redmond anymore.

Reply Score: 2

RE[6]: Question for GTK developers
by Tom K on Thu 12th Jan 2006 07:30 UTC in reply to "RE[5]: Question for GTK developers"
Tom K Member since:
2005-07-06

Most "standard" applications look alike. Trillian, WMP, and iTunes are designed to appeal to a huge crowd of non-technical users, so I don't expect to get consistency there.

But when it comes to other applications, like WinRAR, Notepad, QuickSFV, Explorer, and so on, they all follow the Windows Classic look. GTK apps also try to follow the Windows Classic look, but look out of place.

Reply Score: 1

XemonerdX Member since:
2005-07-03

If you don't like it, don't use it. What's your big problem?!

Reply Score: 1

RE[7]: Question for GTK developers
by MORB on Thu 12th Jan 2006 10:00 UTC in reply to "RE[6]: Question for GTK developers"
MORB Member since:
2005-07-06

The big problem in windows is that the standard widget toolkit is quite not good enough for most uses. Microsoft themselves don't use the native widgets in at least IE and Office: http://blogs.msdn.com/oldnewthing/archive/2005/02/11/371042.aspx

They do use the theming api to render them (just what QT does), but they still have to reimplement their behavior completly so that they work like the native controls.

Reply Score: 1

somebody Member since:
2005-07-07

And no, every app does not look out of place on Windows. Apple apps are even designed to look like Windows Luna/Classic, so that's a moot point. Microsoft's poor consistency with regards to Office/Media Player are something that I wish was corrected, but you can't have everything.

I agree. Only 99.9% apps on Windows look out of space. Calculator and Notepad follow HIG as they should.

Then again why does my OSX look like a color palette without any taste in colors? 5 different toolkits. Counting only Apple ones. Counting others. Wow. My desktop looks almost like average vegetable soup.

Again why do Windows.Forms look different than basic common controls? And why isn't fancy look working trough all WinXP and all applications.

So here on WinXP desktop I have for example WinXP, Firefox, Thunderbird, AVG, WMP, Pinacle burning software, MSN, Office 2003, Eclipse, Photoshop. Not even two of them are consistant (except Firefox and Thunderbird). Hell would probably froze if at least half of apps would support even basic Window Color.

GTK apps, on the other hand, DO attempt to look like Windows, but do it poorly.

WRONG!!!!

Talking about Wimp or Gtk here? Wimp is separate project that tries to do what you say. Gtk isn't. Read the fine print and then try to be funny.

http://gtk-wimp.sourceforge.net/
GTK-Wimp ("Windows impersonator") is a GTK+ theme that integrates well with the Microsoft Windows desktop environment. GTK-Wimp was created by Raymond Penners, based upon code from Redmond95 by Owen Taylor and Nativewin by Evan Martin. It is now maintained by Dominic Lachowicz.

http://gtk.org/
GTK+ is a multi-platform toolkit for creating graphical user interfaces. Offering a complete set of widgets, GTK+ is suitable for projects ranging from small one-off projects to complete application suites.

Reply Score: 1

RE[3]: Question for GTK developers
by t3RRa on Thu 12th Jan 2006 01:22 UTC in reply to "RE[2]: Question for GTK developers"
t3RRa Member since:
2005-11-22

Have you ever looked at yourself at all? Please look at the mirror now! You will finally notice ... that.. actually... you are the poo itself! You look so out-of-place among us. Why is that? Do troll NO MORE. It makes you not-respectful/worthless person in this society.


Back to the topic, It seems the programming in GTK+ easier than I thought after quick look at the article. However, for this kind of development, I feel like OOP makes much more sense than non-OOP.

Reply Score: 0

Daniel Borgmann Member since:
2005-07-08

Back to the topic, It seems the programming in GTK+ easier than I thought after quick look at the article. However, for this kind of development, I feel like OOP makes much more sense than non-OOP.

It is OOP, the C-syntax just makes it look awkward. As the article shows, you can easily use Gtk with an object oriented language like Python or C# (and C++ of course).

Reply Score: 1

RE: Question for GTK developers
by betson on Thu 12th Jan 2006 00:55 UTC in reply to "Question for GTK developers"
betson Member since:
2005-12-17

Because they neglected to deliever the WIMP theme with their GTK+ runtimes.

Once that's been accomplished, GTK+ apps don't look out of place on Windows--they only *feel* out of place.

Reply Score: 2

uh
by gplCop318 on Thu 12th Jan 2006 01:22 UTC
gplCop318
Member since:
2006-01-10

i like GTK on linux or win... better than java and that ugly stuff....

Reply Score: 2

uh
by gplCop318 on Thu 12th Jan 2006 03:20 UTC
gplCop318
Member since:
2006-01-10

well QT still has some licensing issues on windows and I had a lot of problem getting it setup and working along with pyQT due to the different versions... There is a unofficial FREE winQT port and and a official NC (non commercial) port but none seem to like the pyQT I was trying to use to build some pyQT apps...

I find gtk to be simple and have no problems on either platform...

Reply Score: 0

RE: uh
by BryanFeeney on Thu 12th Jan 2006 10:08 UTC in reply to "uh"
BryanFeeney Member since:
2005-07-06

A GPL version of Qt4 is available for every platform (including Windows) at this page: http://www.trolltech.com/download/opensource.html

If the GPL isn't good enough, then you have to pay. But it should be good enough for open-source, and if you don't want to write open-source (e.g. you want your users to pay) I don't see why you shouldn't expect to pay yourself.

PyQt hasn't caught up with Qt4 yet, but when it does no-one will have any troubles. Until then, you can still use C++.

Personally I find Qt to be a lot easier than GTK. It's important not to confuse "licensing issues" with actual development.

Reply Score: 2

RE[2]: uh
by gplCop318 on Thu 12th Jan 2006 17:04 UTC in reply to "RE: uh"
gplCop318 Member since:
2006-01-10

yea i think I mentioned that....
So you do a lot of QT and in particular pyQT developing on windows and have no troubles?
Please give me a step by step of your setup and let me know which python you use, which QT and which pyQT I would be very interested. When I do it my QT NC version always looks for the NC pyQT matchign version or some such and then it seems to overlook my python2.4 install and so forth...
Oh, I am mostly just trying to get some apps compiled and am having lots of problems...in fact I gave up! ;)

Reply Score: 1

Get real
by buff on Thu 12th Jan 2006 03:42 UTC
buff
Member since:
2005-11-12

Come on get real. GTK apps don't stick out that much in Windows. I installed Gimp2 on all our labs windows xp boxes and nobody has said anything about how it looks. They are just happy to be able to edit their photos for free. Not everything has to have gel buttons on it or brushed metal to make it work well.

Edited 2006-01-12 03:43

Reply Score: 2

RE: Get real
by Wrawrat on Thu 12th Jan 2006 05:14 UTC in reply to "Get real"
Wrawrat Member since:
2005-06-30

For the look, yeah. WIMP does a great job. As for the feel... For example, the Save dialog is completely foreign. The redraw speed isn't typical of the other applications, either.

Of course, it doesn't remove its merits nor its usefulness. The possibility of using a powerful application for manipulating your pictures at no charge is nothing to sneeze at. Still, it doesn't feel completely at home. That said, it would probably need a new UI just for Windows and I don't believe the port maintainers are interested...

Reply Score: 1

RE: Get real
by Lumbergh on Thu 12th Jan 2006 05:27 UTC in reply to "Get real"
Lumbergh Member since:
2005-06-29

Agreed. With the WMP theme, gtk+ on windows looks pretty good. At least it uses native fonts, unlike the still butt-ugly Swing.

Reply Score: 1

RE[2]: Get real
by chemical_scum on Fri 13th Jan 2006 02:50 UTC in reply to "RE: Get real"
chemical_scum Member since:
2005-11-02

Agreed. With the WMP theme, gtk+ on windows looks pretty good. At least it uses native fonts, unlike the still butt-ugly Swing.

Yeah - though in the win port of Gnumeric you can choose if you want the WMP or GTK theme, I prefer it with the GTK look. But I guess that's the way I am used to seeing it.

The Swing fonts look worst on Linux/GTK especially with that disgusting parody of a GTK theme (I switch it back to metal if I can). Thank god for SWT, it gets the fonts right on both Windows and GTK and looks nice on both.

Reply Score: 1

opposite end of the equation.... usually
by re_re on Thu 12th Jan 2006 08:07 UTC
re_re
Member since:
2005-07-06

well poo, more often then not I disagree with you, however on this issue, I do agree with you, gtk apps look horrable in windows, I've run gaim and gimp in windows in the past and it looks nasty, I don't care because I haven't run Windows in quite some time on any of my machines but most people do run windows and they do care.

I'll be honest, I tend to lean towards qt for a lot of things but this is not why I say these things about gtk, I try to be very objective, and from my point of view gtk does not fit well into the windows api.

Reply Score: 1

RE[2]: uh
by Morty on Thu 12th Jan 2006 10:35 UTC
Morty
Member since:
2005-07-06

PyQt hasn't caught up with Qt4 yet, but when it does no-one will have any troubles. Until then, you can still use C++.

But it's getting there, while I was reading your post this message appeared on the PyQt mailinglist:-)

"You can find a binary package of a current snapshot of PyQt4 GPL for Windows
at http://www.riverbankcomputing.com/Downloads/PyQt4/"

Reply Score: 1

Win consistency
by miro on Thu 12th Jan 2006 13:37 UTC
miro
Member since:
2005-07-13

Ah common, and look closer, notepad, winrar, winzip, powerarchiver, office, outlook look definitely not the same. Each of these apps have different toolbars, different size of icons, different menus, some are flat some are more 3D. On my win2000 machine, some apps have xp style menus, some don't, some apps use the File, Edit, View .. Help menu system some don't. Sometimes the difference between a VC app and a delphi app is far greater then notepad <-> gtk / Qt app.

I think that the bigger problem here is not how apps LOOK like but that they all WORK in a different way. Most gtk+ programs have a connection to gnome, which WORKS a *little* different than windows.

Reply Score: 1

RE: Win consistency
by Ookaze on Thu 12th Jan 2006 15:19 UTC in reply to "Win consistency"
Ookaze Member since:
2005-11-14

You forgot the apps that have colored icons by default, and those that appear gray and are colored when you point your mouse other them. There are so much examples.
Windows users that talk about inconsistency in other OS than Windows are zealots : the pot that call the kettle black. Everyone of them with some sense admit it, even on this thread, but they are quick to find excuses and dismiss what they found so important seconds before : talk about hypocrisis.
Currently, I have to use 2 Windows OS at work (NT4 and XP SP2), and you can bet no app look the same, and I have Wordpad, Outlook, Firefox and Explorer opened !!! Fonts are different, widgets are different, behaviour is different, size and design of icons are different, ... And they dare talk about consistency !! On the XP SP2 it's even worse.

I think that the bigger problem here is not how apps LOOK like but that they all WORK in a different way. Most gtk+ programs have a connection to gnome, which WORKS a *little* different than windows

The major problem is Windows zealots actually.
You say Gnome works a little different than Windows, I say it works a LOT different.
Gnome apps are consistent, Gnome apps are integrated, Gnome apps work right (well sort of), Windows apps don't.
There still are basic things that don't work on Windows : the application bar (which for example, shrinks itself at each reboot when in vertical position, or does not disappear automatically sometimes), the multi file selection (order still wrong when you paste), the install/remove that does not work, ... The inconsistent things have been listed already.
I have other examples of how Gnome works a lot different : simple click is usable, files copied have their size updated in real time, theme is consistent not per app, session works, input methods are consistent, virtual desktops works, multisession exists and is powerful, email clients never infect you, ...
Windows power users should stop these Windows zealots that give a bad reputation to their OS (there I said it).
These complaints were true, but as soon as Gnome 2.0 came out (with pango, gobject, gconf, gnome-vfs, ...) to address all of these, the complaints should have stopped, cause at least Gnome devs tried to do sth about these problems. MS did not do that for Windows till then, but you never hear a complaint from the zealot.

Reply Score: 1

Looks and feel
by Tweek on Thu 12th Jan 2006 16:05 UTC
Tweek
Member since:
2006-01-12

I would like to point out that the average user just flat out doesnt care if an application looks different.

Take Limewire for instance. I have asked MANY people if the different color scheme and controls bother them and most people didnt even pay attention/notice it till i brought it up. THe rest simply didnt care.

If the app is easy to use, the look and feel (at the trivial color scheme and button style) is absolutely the lease important factor for the average user.

Basically when these discussion arise it just shows that the average geek is long out of touch with the average USER.

Reply Score: 1

RE: Looks and feel
by Ookaze on Thu 12th Jan 2006 16:32 UTC in reply to "Looks and feel"
Ookaze Member since:
2005-11-14

I would like to point out that the average user just flat out doesnt care if an application looks different

That's my experience too. Actually, I never saw a user complain about that, except Windows zealots of course.

If the app is easy to use, the look and feel is absolutely the lease important factor for the average user

I'd go as far as saying even if the app is not easy to use, people will use the app without complaining, especially if that's all they know about/can afford. I used to do fansubs on Windows, and had to battle through a lot of hard to use apps and the crappy OS to get something done, but I never complained about inconsistency, I was at least getting work done, and that's what count.

Basically when these discussion arise it just shows that the average geek is long out of touch with the average USER

I don't think so, I think Windows zealots are out of touch. It has been showed time and again that geeks don't mind these things. Gnome 1.0 was heavily criticised as a geek desktop because of that.

Reply Score: 1

RE: Looks and feel
by Emerson on Thu 12th Jan 2006 18:45 UTC in reply to "Looks and feel"
Emerson Member since:
2005-09-19

"I would like to point out that the average user just flat out doesnt care if an application looks different."

I'd agree, but make an exception for the gimp. Aside from the internet, I've never met a person who didn't have to overcome an initial revulsion at its gui. I'm not trying to overstate the case either. Most artists I've shown it too really were right next to the point of cringing when I showed it to them.

Not really trying to put down the gimp, so much as just state amazement at how a single program can break so many expectations.

Reply Score: 1

But wait there's more
by Sphinx on Thu 12th Jan 2006 17:41 UTC
Sphinx
Member since:
2005-07-09

The gtkembedded object from Mozilla gives your gtk program the most 3wc compliant browser there is for you to easily hook to your hardware events, a whole big can of whoop-ass for embedded linux. I easily created browser javascript function hooks for a mag card reader and bar code scanner with it, endless possibilities available. GTK+ rocks.

Reply Score: 1