Slashdot Mirror


Why Use GTK+?

An anonymous reader writes "IBM DeveloperWorks is running an interesting student article that introduces users to the world of GTK+. It explains what GTK+ is, why you should consider using it, and the benefits it provides. Together with the rest of the series, this installment provides enough introductory information that, if you decide to use GTK+ in your own projects, you'll know where to look for further materials."

37 of 356 comments (clear)

  1. Nokia by ultrabot · · Score: 5, Informative

    One interesting consideration when determining what toolkit to go with is that the GUI toolkit for Nokia's new internet tablet is GTK+.

    --
    Save your wrists today - switch to Dvorak
    1. Re:Nokia by Anonymous Coward · · Score: 4, Informative

      It's actually a modified version of GTK+, with some components removed (those that they felt weren't needed given the constraints of the device) and some new stuff added in (mainly the "Hildon" libraries) for creating new applications that can take advantage of the device-specific widgets and layout.

    2. Re:Nokia by ebassi · · Score: 2, Informative

      The interesting bit is that, thanks to the Maemo project, Nokia is gving back to the community some of the changes made to the GTK libraries - namely, the stylus mode and other issues that emerged during development of the Hildon platform library.

      --
      You can save space. Or you can save time. Don't ever count on saving both at once. -- First Law of Algorithmic Analisys
  2. What is GTA? by earthstar · · Score: 3, Informative
    For those who didnt RTA,

    GTK+ is a graphical user interface (GUI) tool kit.
    That is, it's a library (or, in fact, a collection of several closely related libraries) that allow you to create GUI-based applications. Think of GTK+ as a toolbox in which you can find many ready building blocks for creating GUIs.

    Originally, GTK+ was created as a spin-off of another well-known open source project: the GNU Image Manipulation Program (GIMP). While working on early GIMP versions, Peter Mattis and Spencer Kimball created GTK (which stands for GIMP Toolkit) as an alternative to the Motif tool kit, which at that time was not free. (The plus sign was added to the name later, when the tool kit gained object-oriented features and extensibility.)

    That was almost 10 years ago. Today, a lot of activity is still going on with the latest GTK+ version -- 2.8 -- and while GIMP certainly continues to be one of the best-known programs using GTK+, it is by far not the only one. Literally thousands of applications have been written for GTK+, and at least two major desktop environments (Xfce and GNOME) use GTK+ to provide a full working environment for users.
  3. Interestingly... by Lendrick · · Score: 4, Informative
    These all apply to Qt as well. To each their own. :)

    • It's both modern and actively developed and maintained, with a vibrant surrounding community.
    • It offers a wide array of options for extending your work to as many people as possible, including a sophisticated framework for internationalization, localization, and accessibility.
    • It's simple and easy to use, both for developers and users.
    • It's well designed, flexible, and extensible.
    • It's free software with a liberal open source license.
    • It's portable, both from the user's and the developer's perspective.

    1. Re:Interestingly... by Anonymous Coward · · Score: 3, Informative

      QT/X11 is indeed free software, but what about QT/w32 ?
      Also, you are allowed to use GTK+ for proprietary projects (LGPL). The free QT is GPL.

    2. Re:Interestingly... by adolfojp · · Score: 4, Informative
      It's free software with a liberal open source license.
      Eh... not quite, unless you plan to make open source software exclusively. http://www.trolltech.com/products/qt/licensing.htm l
      The same thing applies to MySQL but people seem to mistake the GPL for the LGPL.
    3. Re:Interestingly... by FidelCatsro · · Score: 2, Informative

      QT/w32 is believe is now GPL as are all version , but you may also purchase a commercial license if you so wish .

      --
      The only things certain in war are Propaganda and Death. You can never be sure which is which though
    4. Re:Interestingly... by adolfojp · · Score: 5, Informative
      ... I dislike disingenuous articles like the present developerworks article which pretends that GTK+ is the only toolkit that exists.

      From the article:
      In actuality, modern GUI tool kits do more than merely avoid duplication. They offer many advanced capabilities that users have come to expect in their applications and which wouldn't be attainable otherwise because the time and work investment in such tool kits exceeds whatever you could spend on a single application. Therefore, if using a GUI in your application is important to you, use a tool kit. There's simply no other way. Now, the only question left is, which tool kit should you use?
      The author makes it very clear to the reader that other GUI toolkits exist. Since he likes GTK+ he writes an article advocating it. It is not meant as a comparison between different toolkits. It is meant as an introduction to one of them.
      Also, considering the wealth of GUI toolkits avaliable, his article would loose focus quickly if he meant to mention all of them.
    5. Re:Interestingly... by agurkan · · Score: 2, Informative

      its only GPL for non-commercial stuff
      you cannot do this. it is either GPL or not, if it is GPL you cannot have "non-commercial" attached to it.
      i can develop stuff with a dual-licensed library (GPL and proprietary; say with Qt) and and sell my stuff while distributing the library or its derivative works relying on GPL. however, then i have to release my own work as GPL as well; and my first customer can undersell me, because i cannot restrict further copying. only if i want to restrict further copying (or do not want to release source code etc. etc.) i have to use the proprietary license, not if i want to sell my work.

      --
      ato
    6. Re:Interestingly... by hughk · · Score: 3, Informative
      If you visit their website, you will find that MySQL are quite up front about their dual licensing policy.

      If you want to use it from something like Perl/PHP whatever, you will find the license cost is zero. If you want to incorporate it as part of an in-house system, there is no issue. It is only if you want to build non-GPL software for distribution. OTOH, you will find that many commercial users have no issues with paying for support. Although not as full featured as Oracle 10g, it costs a tad less.

      --
      See my journal, I write things there
    7. Re:Interestingly... by cortana · · Score: 5, Informative

      The MySQL client libraries are under the GPL, not the LGPL.

      MySQL even claim that if you implement your own client, it speaks the MySQL protocol, and as such is a derivative work of the MySQL server and so must be made available under the GPL.

    8. Re:Interestingly... by doctormetal · · Score: 2, Informative
      QT/w32 is believe is now GPL as are all version , but you may also purchase a commercial license if you so wish

      Yes, QT for windows is GPL, but you must buy commercial licenses because it is GPL and not LGPL.

      If you make an application using a GPL library your application is a derrived work, which means it is also GPL.

      If you use a LGPL library, your application does not have to be open source, but it must mention somewhere it uses the library.

    9. Re:Interestingly... by arkanes · · Score: 2, Informative
      The GPL implies that one can "use" the software without restrictions, and then relies on an extra-legal interpretation of copyright law to enforce the "viral-ness".

      Not really. The viralness of the GPL is well founded - what you may be thinking of is how the FSF interperts "derived work", which is a legal grey area at the best of times. In the important cases, like when you statically link GPL code, it's pretty cut & dried. Dynamic linking is more complicated and as far as I know there's never been a court case that really spelled out the limits, and I doubt there would be - there still isn't a hard standard for music or written works. The main legal weakpoint of the GPL is actually in an area where it is overly permissive - distribution within an organization is absolutely considerd "distribution" under copyright law and should invoke the GPL, and I'm not sure why they think it shouldn't.

      Not to mention that the FSF's take on the issue of libraries and derived works is entirely different than every commercial library vendor's!

      This is totally false and you won't find any commercial library vendors saying that you don't owe them money because you only dynamically linked to thier library, or because you didn't distribute it.

  4. Re:With the bazillion GUI toolkits out there.. by undeadly · · Score: 5, Informative
    Are there any cross platform (linux, mac, windows) GUI RAD tools ala Builder, yet?

    You have QT Designer that is part of the QT Toolkit.

  5. Re:With the bazillion GUI toolkits out there.. by adolfojp · · Score: 3, Informative
    Are there any cross platform (linux, mac, windows) GUI RAD tools ala Builder, yet?
    I like to use this one: http://glade.gnome.org/ Its windows port works fine but I haven't tried the Mac version yet.
    These guys love to use it but it is more of a political issue than a technological one.

    And now, If you'll excuse me, I've got some work to finish on Photoshop vi. :-P
  6. Re:Just curious by strider44 · · Score: 4, Informative

    Yes Gimp still uses the Gimp Tool Kit.

  7. Re:Distribution on Windows by wysiwia · · Score: 2, Informative
    ... I recommend to use wxWidgets ...

    Biased by my own project wyoGuide (see http://developers.slashdot.org/comments.pl?sid=172 263&cid=14343909) I can say that wxWidgets is probably the best choice for cross-platform development.

    O. Wyss

    --
    See http://wyoguide.sf.net/papers/Cross-platform.html
  8. Re:GTK is alright...but no raves by Theatetus · · Score: 3, Informative

    Then again, actually GTK has what you want anyways, despite my earlier response rant:

    mywidget = gtk_dialog_new_with_buttons("Quit without saving?", GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT, "Save", GTK_RESPONSE_OK, "Don't Save", GTK_RESPONSE_CANCEL);
    --
    All's true that is mistrusted
  9. Cross-platform GUI RAD (for GTK+, etc): wxDesigner by Chuck+Messenger · · Score: 5, Informative


    Are there any cross platform (linux, mac, windows) GUI RAD tools ala Builder, yet?


    Yes -- wxDesigner is a very nice RAD for use with the wxWidgets GUI-building environment. wxWidgets is a cross-platform GUI framework which uses native widgets. On Linux, it uses GTK+. On Windows, it uses Windows widgets. On Mac, it uses Mac widgets. There are other somewhat-supported platforms. This approach contrasts with that of the Qt framework -- another cross-platform builder (which is excellent), which implements all its own widgets on each platform. Also unlike Qt, wxWidgets is not bound by the GPL -- you're pretty much free to do as you like with it (i.e. incorporating it into commercial apps, without the requirement that you release your source code, or pay any licensing fee). wxDesigner is a very nice GUI RAD builder for wxWidgets. It's not free, but it's cheap. You definitely get your money's worth.

  10. No, 3.5 MB by jcupitt65 · · Score: 2, Informative

    No, the current stable win32 GTK+ runtime is 3.5 MB. Here's the download page.

  11. Re:Tempting.... by jcupitt65 · · Score: 5, Informative
    The official docs are OK, I think. There's a tutorial too. There's also an excellent book: The Official GNOME2 Developers Guide, but sadly it's not available as a free download.

    People do rave about the Qt docs I know.

  12. Re:Tempting.... by harves · · Score: 3, Informative

    Sorry, but what's wrong with http://developer.gnome.org/doc/API/2.0/gtk/, with every supporting library also document at http://developer.gnome.org/doc/API/?

    Though when things get really tough and I absolutely have to know the little details, I like to hit the source http://cvs.gnome.org/viewcvs/gtk%2B/gtk/ instead.

  13. wxWidgets? by El_Muerte_TDS · · Score: 3, Informative

    Why not wxWidgets? It's more flexible if you ask me. It simply wraps the native GUI stuff, or an other toolkit like GTK+.
    I don't have any numbers, but I think the performance would be better and the distribution size shouldn't suffer much (as with Qt or GTK+).

  14. Yes but... by wwahammy · · Score: 4, Informative

    IBM seems to skip over one of the biggest reasons to NOT use GTK+ - it just doesn't look right on Windows. I'm not sure who said it but a commentator suggested a while ago that one of the reasons open-source programs weren't overtaking closed source was due to a lack of polish (which does of course cover more than just appearance); he used GAIM vs. MSN Messenger as an example. The jarring difference between controls in GTK+ or Java or even Mozilla to some extent vs Win32 is important when you're creating an application for normal end users. In my opinion, that difference can look unprofessional. I would figure that the issue of appearance could be mitigated but it hasn't yet so I don't know for sure.

    A question for someone who knows more about GUI toolkits: What are the issues involved in matching the appearance between toolkit controls and the native controls?

    1. Re:Yes but... by Anonymous Coward · · Score: 1, Informative

      Fortunatly I only boot into Windows to play the odd game, but when I do, programs that use the gtk-wimp theme don't look out of place at all.

      Oh, yes they do! Simple list:

      * Menus and tooltips don't use window shadows when they're enabled on Windows 2000/XP.
      * Menus are shaded flat-out wrong. That's not Windows 9x OR Windows XP style, that's some third style.
      * Menu separators should be a single solid gray line on Windows XP.
      * Menus should fade in when that setting is enabled. (Firefox is guilty of this too.)
      * When a menu option is selected, the rest of the menu should fade out fast and the menu option should fade out slower. (Firefox is guilty of this too.)
      * "Access" keys (the little underlined letters on buttons/menu items) are always displayed, even though they should only be displayed when ALT is pressed when that setting is enabled. (Firefox is guilty of this too.)
      * WIMP ignores requests to change the theme, so if you switch color schemes while a WIMP app is running, it'll keep the old theme and not change to the new one. Includes changing certain other settings. (Just checked to see if this is still true, it turns out that will CRASH the GTK+ app.)
      * Button contents "depress" when clicked when using Windows XP's theme. They do not in Windows XP apps.
      * Drop down combos should animate extending when that option is enabled. (Firefox is guilty of this too.)
      * The list dropped down by a drop down combo should be placed below the combo, only pushed upwards/left if it hits the edge of the screen. (WIMP does it MacOS style, with the selected option centered over the combo.)
      * When the "empty" part of a scroll bar is clicked, that half should darken while the content scrolls. (Firefox is guilty of this too.)
      * Check boxes and radio buttons should darken when depressed.
      * Table headers should turn orange when hovered over when using Windows XP.
      * Non-active tabs should turn orange when hovered over when using Windows XP.

      Those are just the things I've noticed in normal use, I'm sure there's more. As noted, Firefox, which ALSO attempts to mimic Windows using a different themeing engine, ALSO screws some of this stuff up. Trying to mimic a native theme is nearly impossible.

      The best "widgeting toolkit" I've seen for actually creating native-looking apps in SWT, a Java toolkit. But it still has some serious drawbacks, and the only real way to create apps that don't just look right on all platforms but actually FEEL right is to create a separate version for each platform.

    2. Re:Yes but... by _xeno_ · · Score: 2, Informative

      Nope. Firefox is built using a custom toolkit designed explicitly for Mozilla.

      Firefox has the ability to import theme data from both Windows XP and GTK+, so it should look (sort of) like a native app under both platforms. It comes real close under Windows, but it still messes some things up. I've never tried it under GNOME since they added GTK+ themeing support, so I have no idea if it works under that.

      However, the Mozilla toolkit is actually much closer to properly mimicing the Windows environment than GTK+'s WIMP is. WIMP needs a ton of work to properly fit in with Windows.

      --
      You are in a maze of twisty little relative jumps, all alike.
  15. Re:Distribution on Windows by Richard+W.M.+Jones · · Score: 4, Informative

    if it depends on 6-8 MB for GTK

    Our cross-platform "hello world" program including Gtk is about 300K compressed in total on Windows.

    Rich.

  16. Re:Distribution on Windows by Theatetus · · Score: 4, Informative
    I don't know about vbrun but the MFC DLL is less than a meg in size.

    And MFC.DLL is the equivalent of maybe half of glib and the stubs for the rest of the libs. Count all your non-Office OCX files; those are delivering the rest of the equivalent capability

    --
    All's true that is mistrusted
  17. Re:A better title would be "Why use a toolkit"? by Draek · · Score: 2, Informative
    Originally, GTK+ was created as a spin-off of another well-known open source project: the GNU Image Manipulation Program (GIMP). While working on early GIMP versions, Peter Mattis and Spencer Kimball created GTK (which stands for GIMP Toolkit) as an alternative to the Motif tool kit, which at that time was not free. (The plus sign was added to the name later, when the tool kit gained object-oriented features and extensibility.)
    from the article, second paragraph =)
    --
    No problem is insoluble in all conceivable circumstances.
  18. Re:Tempting.... by mpeg4codec · · Score: 2, Informative

    Sean Egan's Open Source Messaging Application Development: Building and Extending Gaim covers basic to intermediate GTK+ programming [with sockets, no less] quite nicely. He meticulously describes everything he does with numerous examples. He never skimps on the details and even gives insights into his own thinking on most problems.

    It's a very, very good read, even for non-Gaim developers. On the plus side, you'll be supporting open-source development if you purchase it.

  19. Re:GTK is alright...but no raves by AnyoneEB · · Score: 2, Informative

    I don't know about the C# message dialog, but Java's Swing has a very similar method to which you can add an array of new names for the buttons. I would expect the C# method to allow for the same.

    --
    Centralization breaks the internet.
  20. Re:Time For Apple To Release The Cocoa Runtime by FellowConspirator · · Score: 2, Informative

    In many industries, this is the preferred method. I know our company increasingly is offered (and purchases) laboratory information management systems (LIMS) and curated databases with various front-ends that are Java apps.

    Comment as you will, they have actually proven to perfom exceptionally well and been quite resilient and easy to install across a variety of platforms (like most in our industry, we have a combination of Windows, Mac OSX, and Linux desktops with Solaris, Irix, and HP/UX servers).

    For things like Linux, the ability to treat jar-files as native executables (using the binfmt-misc mechanism) makes it dead-simple to deploy apps.

    This is not entirely unique to Java. .Net holds some promise here. It won't be useful in our industry until it's well-supported outside Windows, but I imagine that there's other industries that still have less heterogeneous environments...

    I whole-heartedly favor cross-platform VMs to whatever extent they are appropriate and I really don't buy the "jarring difference in appearance" argument. Clipboard interoperability, maybe; hosting native media widgets, sure, but button textures? Dumb.

  21. Why I chose GTK+ by ChaoticCoyote · · Score: 3, Informative

    I haven't read the article, since GTK+ is already my preferred GUI toolkit. And this in spite of the fact that I run KDE as my primary desktop! I run both Gnome and KDE, and my choice of KDE over Gnome is based more on organization and flexibility than it is on the underlying GUI toolkit.

    As background: My wrote my first GUI programs back in the days of Window 3.1, and while most of my work is on data-crunching engines, I do write quite a few GUI applications. I need to rapidly generate an interface, back it with code, and have it presentable on Windows and Linux.

    As a programmer, I don't like QT. It feels klunky, bloated; nor do I find QT Designer all that friendly. Beyond matters of taste and comfort, TrollTech requires a commercial license for certain tools (e.g., a MathML widget) that I can obtain under GPL for GTK+.

    I'm rather fond of Glade. Most of my GTK+ GUI programs are in C, some in C++; I define an interface in Glade, fill in the appropriate functions, and I'm ready to rock and roll.

    GTK+ 2.8 brought with it Cairo, a very nice drawing toolkit. I just put together a little interactive graphics application, just to better familiarize myself with Cairo, and the result is quite nice.

    In the near future, I'll be writing some very extensive OpenGL applications, and I'll likely wrap these in a GTK+ GUI. If something better comes along, I'll try it -- but for now, GTK+ provides what I need. Your mileage may vary.

  22. Re: Other languages by Black+Parrot · · Score: 2, Informative

    > So a big question for me is "what other languages does your toolkit support easily?" Is there a good perl interface? python? scheme? What can I use to lash it together quickly?

    For GTK+, see http://www.gtk.org/bindings.html, where they have a status table for ~28 languages. Presumably the Qt site does the same thing.

    > And when you need an alternative language APIs, we need documentation that is native to those languages. All too many of these toolkits provide some rudimentary alternative UI, but it's just an export of the C++ API, and the programmer is expected to read the C++ documentation, and mentally convert that to the appropriate perl, python or what-have-you alternative.

    FWIW, the GtkAda project does provide pretty good documentation, both a User's Guide and a Reference Manual. There are holes sometimes, but they usually tell me everything I need to know.

    --
    Sheesh, evil *and* a jerk. -- Jade
  23. Re:GTK is alright...but no raves by mangu · · Score: 2, Informative
    DialogResult result = MessageBox.Show("Quit without saving?", "", MessageBoxButtons.YesNoCancel);


    How is that easier than this example from the Qt dcoumentation:


    QMessageBox::question(this,tr("Overwrite File?"),tr("A file called %1 already exists.Do you want to overwrite it?").arg(filename),tr("&Yes"),tr("&No"),QString:: null,0,1))


    Note that Qt provides translation to your local language and choice of button text and keyboard shortcut as well.


    for much of GUI history, it's been easier to write GUI code for Windows than for almost any other platform.


    Maybe I don't know much about GUI history, but at least from the late 1980s when I started writing GUI code for VAXstations until today I have never noticed anything as being easier in MS-Windows. The Petzold book was well written, and maybe that's why you think it was easy, but any advantage that MS-Windows had stopped there. I have written or supported GUI code in Xwindow, Motif, Qt, MFC, OWL, Gtk, FLTK, Tk, wxWinodws, Java, and maybe a few others that I can't remember right now.


    My personal choice of toolkit for new projects is Qt, due to three factors: an excellent API, the absolutely best documentation of all those I mentioned above, and a good set of development software, consisting of kdevelop and Qt Designer.

  24. In the interests of salesmanship by obeythefist · · Score: 2, Informative

    Yet another slashdot article referring to a product without explaining the purpose of said product.

    GTK+ is a toolkit for GIMP.
    GIMP is an open sourced graphics manipulation package (think Photoshop but free as in speech and beer).

    --
    I am government man, come from the government. The government has sent me. -- G.I.R.