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."

39 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. 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 adolfojp · · Score: 5, Insightful

      You make a very good point.

      I like to call the GPL the viral open source license. Everything it touches is also made open by default.

      You would be surprised by the number of developers that I know that developed their apps using MySQL and then had to pay for the comercial license many months later because they didn't read the fine print. Lets just say that if they had known beforehand they would have charged a little more for their applications ;-)

      I am not against the GPL. I am just amused by the large number of people that advocate it fanatically and yet don't understand it.

      Cheers,
      Adolfo

    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 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
    6. Re:Interestingly... by Nugget · · Score: 4, Insightful

      It absolutely does if you're using the mysql libraries to connect to the mysql database. Rather than being sanely LGPL'd, the mysql connector libraries are GPL which precludes their use in non-GPL codebases. So, unless you're a GPL developer, you need to purchase a commercial license for mysql (or find a database with less restrictive licensing).

      The fact that you're ignorant of this crucual detail (which is the foundation of mysql ab's ability to make money) reinforces the GP's point.

    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 squiggleslash · · Score: 3, Insightful
      But when Qt is using GPL, suddenly the GNU zealots turn around and say, hey that's bad, you can't write proprietary software with it
      I'm trying to work out why you'd assume that someone criticising a product for not letting you produce proprietary software that uses it is a "GNU zealot". Is the GP known to you and always ranting on about GNU and how wonderful the GPL, or are you just making an assumption?

      If the GP is genuinely against a license because it means a library cannot be linked against a proprietary program, then they're not a "GNU" (or FSF, or GPL) zealot. They may be a zealot, but they're not a GNU one.

      Many Free Software people, which is a diverse group encompassing many opinions, eschew the GPL for precisely this reason and consider themselves active opponents of it. One example would be the OpenBSD team, and Theo DeRaadt in particular, who is strongly against the GPL because he wants his work to be freely available even to those who'd not make public the source of their released changes.

      These are legitimate opinions. Your characterization is as bad as someone who sees, say, Bush criticised for not proposing a clearly religiously-motivated supreme court nominee, and then Bush criticised for reversing his position, withdrawing the nominee, and making an apparently religiously-inspired one, as "Christian Conservative Zealots not letting Bush win". They're different critics.

      --
      You are not alone. This is not normal. None of this is normal.
    9. Re:Interestingly... by Tellalian · · Score: 4, Insightful

      It'd be interesting to see if such a "claim" would ever hold up in court. You'd think if it did, AOL or MSN would have sued Gaim years ago for breaking their "license". Commonsense would dictate if Gaim can implement a proprietary protocol for interoperability, than anyone could implement MySQL's protocol for the same reason. I don't have a reference on hand, but I believe a court decided client-server interaction didn't constitute a level of usage where licenses like the GPL were applicable.

    10. Re:Interestingly... by jonored · · Score: 3, Interesting

      Leaves me wondering if you could successfully play linking games to keep your software non-GPLed when you distribute it. Construct a general database interface API (or find a compatibly licensed one - not GPL...), write your app to use that API, and distribute it. Also distribute a module that is GPLed that talks to the mysql database. The user links the module with the app, and the GPL asserts itself on this new derivative work; the end user cannot distribute this work without distributing full source; but the end user is restricted from distributing it anyways, if it's a commercial product. If not, then they can distribute it unlinked anyhow. The interface is not a work based on the GPLed work; the GPLed work wasn't involved in it's construction, it's just an database interface tailored to the needs of your app. Your app is only based on the interface; the interface isn't GPLed, no problem. The code that translates your interface to the GPLed work is based on the GPLed work; it must be under the GPL if you are releasing it. That does not, however, do anything to the licensing of the interface or your app. When linked, they are a derivative work, and therefore cannot be copied, distributed, modified and all that except under the GPL; nobody cares. This happens well after you'd want to do any of those with it - it doesn't keep you from using it. This is actually the scheme that the madwifi project uses to get their FCC-mandated binary module into the kernel; it doesn't particularly interact with the kernel, it interacts with their code, based on an interface which is licensed such that the GPL doesn't apply.

  4. Re:Distribution on Windows by Max+Threshold · · Score: 5, Insightful

    Yeah, right. How big is the latest vbrunxxx.dll?

  5. GUI? by Anonymous Coward · · Score: 5, Funny

    What the hell is wrong with printf?

    1. Re:GUI? by archeopterix · · Score: 5, Funny
      What the hell is wrong with printf?
      Yeah, everyone seems so excited about printf. Having spent 40 years programming computers I can tell you its another fad.

      Thousands of developers all over the world are misled with the apparent ease of printf'ing the text to the stdout. They all miss the most important fact: the printf doesn't actually generate the text! You still have to supply it, although the printf marketeers might want you to think otherwise.

      Another thing - where are the mathematical foundations for printf? Relational databases rely on solid theory that dates back to 1795. Printf enthusiasts cannot deny the fact that it just lacks proper scientific support. It's a sad thing that giant amounts of investors' money are poured into a technology that relies on a wishy-washy muddy set of 'format specifiers'. Haha, 'format specifiers'! I challenge you to come up with a proper mathematical definition for that!

      And a final death blow to the whole 'printf' craze. It has no support whatsoever for colors or blinking text! Young printf-bamboozled programmers all over the world realize they're using a purely academic technology when the real world requirements call for a blinking 'Hello world\n' or a colourful 'Foobar'!

  6. The Question is... by Chaffar · · Score: 4, Funny
    Martin Fink Tells it like it is: The question is NOT why you should use GTK+, but WHY NOT? _______ Click here to read more
  7. 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.

  8. GTK is alright...but no raves by Hosiah · · Score: 5, Interesting
    I'm not a very big fan of *any* GUI toolkit. GUIs are a pain to program in anyway, no matter what language or library you use. GTK is much easier if you hook it up with Glade, which drains some of the pain from the experience. Personally, for small jobs, I'm more apt to use Tcl/Tk, which is very brief. Literally, I will be unhappy with *every* GUI toolkit until I find one where you can express an entire dialog box in a SINGLE LINE (I don't care how Perl-like the syntax!) and get on with your life.

    No, I'm not kidding: a dialog box with three buttons should be:
    D(H:50,W:200){M:"Quit without saving?",B1:"Save"(do_save()),B2:"Don't Save"(no_op&exit()),B3:"Cancel"(drop_quit())};

    1. Re:GTK is alright...but no raves by ichin4 · · Score: 5, Insightful

      Um, you mean like this C# code?

      DialogResult result = MessageBox.Show("Quit without saving?", "", MessageBoxButtons.YesNoCancel);

      Many slashdotters like to drone on about how evil business practices got Microsoft where it is today. But one thing that definitely helped is that, for much of GUI history, it's been easier to write GUI code for Windows than for almost any other platform.

    2. 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
    3. Re:GTK is alright...but no raves by Techster · · Score: 4, Insightful

      Not even close to what the OP wanted. Yours just specifies text, an empty title, and the fact that it has three buttons (yes, no, cancel). You still need a block statement to handle the response, not to mention the fact that width and height will be determined automagically.

      His code specified the height, width, alternate text for the buttons (which some of us want without having to make a new dialog at times) and methods/functions to perform when the buttons are activated. Currently, a wrapper/class/function is the only way to accomplish all that in one line.

    4. Re:GTK is alright...but no raves by red990033 · · Score: 3, Funny

      >I will be unhappy with *every* GUI toolkit until I find one where you can express an entire dialog box in a SINGLE LINE (I don't care how Perl-like the syntax!) and get on with your life.

      I'm pretty sure you can do this with Visual Basic.. happy now?

      --
      Do what I say, cuz I said it.
      -Meatwad
  9. 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
  10. Re:Just curious by strider44 · · Score: 4, Informative

    Yes Gimp still uses the Gimp Tool Kit.

  11. Re:Distribution on Windows by KiloByte · · Score: 4, Insightful

    vbrunxxx.dll? That's nothing. Try the .NET runtime, and talk about bloat again.

    --
    The creatures outside looked from Alt-Right to Antifa; but already it was impossible to say which was which.
  12. Re:Distribution on Windows by TheLoneCabbage · · Score: 4, Insightful

    No one distributes software on floppies any more. 6-8MB added to your installer isn't a BIG deal. It translates into another 30sec worth of download. If its a burden on anyone, it's a burden on your webservers.

    The Advantage of course is that for that 6-8meg, it installs with virtually no hassles, and all the way back to w95.

    I've dealt with numerous ditribution issues, and while sysadmins are worried about the package size, mostly they are worried about hassle. Try shoe horning .NET apps onto w98 systems (it won't install on anything earlier), it's a 21MB hair ball and a real paint to install. Once my employer made the decision to port their entire app base to .NET, which made development LOTS easier, but we went from a 5meg install to a 30meg nightmare that wouldn't run on w95 no matter what (still an issue believe it or not).

    The GTK pack isn't HUGE and it installs with virtually no problems. If download size is a problem the NSIS2 installer does support on the fly package downloads.

  13. 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.

  14. Holy 5417! by Black+Parrot · · Score: 4, Funny

    > GTK+ is a graphical user interface (GUI) tool kit.

    And all this time I thought everyone was talking about a game called "Grand Theft Potassium Ion".

    --
    Sheesh, evil *and* a jerk. -- Jade
  15. 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.

  16. 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.

  17. 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+).

  18. 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?

  19. Forget something? by RedBear · · Score: 4, Insightful

    No one distributes software on floppies any more. 6-8MB added to your installer isn't a BIG deal. It translates into another 30sec worth of download. If its a burden on anyone, it's a burden on your webservers.

    I think you meant to say it IS a big deal, since it translates to 30 MINUTES of extra download time on a dial-up line, which unfortunately most users are still stuck with. Even broadband lines aren't all 1.5Mb/s.

  20. 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.

  21. 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
  22. Other languages by rpg25 · · Score: 3, Interesting

    One issue that I like to look at when I'm thinking about GUI toolkits is the question of what programming languages does it support.

    I often need to rapidly prototype a graphical UI, and one that's not just a standard set of static attributes. I find that for these cases the graphical layout tools fall down pretty quickly, and I'm back to writing code to make the UI.

    Now, if I'm going to be writing code for GUI prototypes, I want code that I can write, test, and show off fast. I don't want to start a language war, but to me that says "not C++."

    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 this kind of thing, sadly enough, it seems like the venerable Tcl + Tk combination is still hard to beat.

    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.

    So what are the easy cross-platform, scripting UI alternatives? Tcl + Tk, python + wxWidgets, and what else? Any way to get at those Swing libraries without heavy lifting with Java?

  23. 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.