[HN Gopher] GTK4 for Graphical User Interfaces
       ___________________________________________________________________
        
       GTK4 for Graphical User Interfaces
        
       Author : chauhankiran
       Score  : 145 points
       Date   : 2021-01-03 13:41 UTC (9 hours ago)
        
 (HTM) web link (ssalewski.de)
 (TXT) w3m dump (ssalewski.de)
        
       | wcchandler wrote:
       | The author talks about how android doesn't use GTK. What does
       | Android use? Some kind of Java thing?
        
         | jraph wrote:
         | Its own toolkit, if I'm not mistaken. Here's the class used to
         | create a button for instance:
         | https://developer.android.com/reference/android/widget/Butto...
        
       | longstation wrote:
       | It's great that the author promotes both Nim and GTK4, which, in
       | my opinion, are both great opensource projects. But I think the
       | author should make it clear that he disabled text anti-aliasing
       | for some reason. A lot of people in this thread are complaining
       | how bad the text rendering is. As someone who uses GNOME (build
       | with GTK) for years, I want to make it clear: GTK supports both
       | anti-aliasing and hinting. The text rendering looks great! It's
       | really just one web search away to check the effects.
        
       | mseidl wrote:
       | #qt4ever
       | 
       | https://www.youtube.com/watch?v=gGZyVSOnqm0
       | 
       | The tl;dw: Kernel guys made a scuba diving app, using C + GTK.
       | They switched to C++ and QT, due to issues/poor quality of GTK,
       | bad attitude by GTK. QT also fixed a lot of complaints they had
       | about C++. Also QT looks like native application on other
       | platforms.
        
         | moistbar wrote:
         | I remember using pidgin (then called GAIM) on windows and
         | having it fit right in visually, and that's a GTK2 app. It
         | became slightly more noticeable on Windows 7, where UI
         | animations that were present in the Windows UI would be absent
         | due to, I believe, GTK2 not having a proper animation library,
         | but it still looked like a native app. No idea if that's still
         | the case for GTK3 and onward, though.
        
           | seba_dos1 wrote:
           | > No idea if that's still the case for GTK3 and onward,
           | though.
           | 
           | It's not. GTK3/4 apps look like GTK apps on every platform
           | and don't even try to fit in.
        
             | brnt wrote:
             | Quite annoying even on Linux if you use KDE: GTK3 apps
             | stand out like a sore thumb. More than Electron even.
        
       | chrisseaton wrote:
       | Wow the text rendering is _atrocious_. Is this still the state of
       | GTK and desktop Linux today?
        
         | ptx wrote:
         | No, it's just the author's configuration. Looks just like the
         | core X11 font rendering of old, but I guess you could configure
         | the modern font rendering system to look just as terrible by
         | turning of anti-aliasing.
        
         | guenthert wrote:
         | Not sure why your comment has been downvoted. I couldn't agree
         | more with you on your finding and the question follows
         | naturally for someone not familiar with Linux desktops.
         | 
         | Others have meanwhile clarified that anti-aliasing wasn't
         | enabled in the examples, which is easy enough to do and is in
         | all production code. Not sure, whether the author had some
         | retro-look effect in mind or just wanted to visually emphasize
         | the examples (he sure succeeded in both).
        
         | andoriyu wrote:
         | Author is just weirdo.
         | 
         | Here is a "normal" system looks like
         | https://imgur.com/a/hvKNWIs
         | 
         | Everything that isn't a terminal or VSCode on those screenshots
         | is GTK3.
         | 
         | Everything has the same color scheme, icons, fonts. Qt
         | included.
        
         | tetromino_ wrote:
         | It appears that the author had disabled font antialiasing. Any
         | mainstream Linux distro released in the past 10+ (maybe 20)
         | years would have better font rendering by default - but if you
         | wish, you can disable those defaults by changing a few symlinks
         | in /etc/fonts and revert to 1980s style pixelated rendering.
         | Which is ok, some people prefer the retro look.
        
           | badsectoracula wrote:
           | IMO it looks worse than X11 core rendering because those
           | fonts are often bitmap fonts made to look good without
           | antialiasing whereas just disabling antialiasing in vector
           | fonts often looks too jaggy. Some fonts have good hinting but
           | the vast majority do not bother.
           | 
           | In Windows i also disable antialiasing since i do not like
           | the blurry look but i also force fonts in web sites with good
           | hinting since most sites look horrible with their preferred
           | fonts.
        
       | ku-man wrote:
       | Title should be: GTK4 for Graphical User Interfaces with Nim
        
       | unwind wrote:
       | Oh, did they drop the "+"? The name used to be "GTK+" but that
       | seems to have changed. Does anyone know when?
        
         | Galanwe wrote:
         | https://mail.gnome.org/archives/gtk-devel-list/2019-February...
        
           | EamonnMR wrote:
           | Wait, GTK was spun out of GIMP?
        
             | makapuf wrote:
             | Well, GTK means GIMP Tool Kit, so yes.
        
             | jsmith99 wrote:
             | Yes and the GIMP devs are still hard at work trying to make
             | GIMP use GTK 3... (beta recently released)
        
             | chunkyks wrote:
             | The name is short for "gimp tool kit", yes
        
             | zorked wrote:
             | Yes. GIMP used to use the proprietary Motif toolkit before,
             | and GTK was created to get rid of this dependency.
             | 
             | The Linux logo was created on a Motif version of GIMP (see
             | screenshot):
             | 
             | https://isc.tamu.edu/~lewing/linux/notes.html
        
           | unwind wrote:
           | Thanks! I have been using GTK since the late 90s (1.x
           | versions) but dropped of the devel list a few years ago due
           | to lack of time/focus/interest.
           | 
           | Would love to port my pet project to 4.x. :)
        
       | bastawhiz wrote:
       | I realize this is an article about GTK, but the author is really
       | not selling it. It opens with an explanation that GTK is pretty
       | much not maintained. Later, it's compared to Qt:
       | 
       | > The advantage of Qt is that it is active developed and supports
       | all important operating systems including the mobile Android and
       | iOS systems with a native look and feel.
       | 
       | These feel...like important things for your application framework
       | to support. Qt's "bloat" is listed as the only major
       | disadvantage, but only after lamenting GTK's own bloat.
       | 
       | > For many Windows or macOS users GTK has the disadvantage that
       | GTK draws all it widgets itself, it does not use the native
       | graphical elements of the proprietary systems. GTK allows theming
       | by use of cascading style sheets (CSS) so it can be tuned to look
       | not too strange on Windows and macOS, but look and feel generally
       | does not really map to native apps.
       | 
       | Personally, this is one of the worst disadvantages of GTK for me,
       | and makes me cringe when I see an app using GTK's default
       | styling. Even Electron (also lamented for its bloat) does
       | "native" controls by default.
       | 
       | There's really got to be a better argument for using GTK than
       | "it's less bloated and is written in C"
        
       | _ph_ wrote:
       | I had not looked at Nim before, but certainly will do. If
       | anything, GTK is lacking a bit HOWTOs, which give the beginner a
       | guide, which APIs to use for a certain task. So I will give this
       | a good look. Personally, I have used GTK from Go, which also is a
       | nice match for the API.
        
         | [deleted]
        
       | benbristow wrote:
       | Can't help but think a lot of code is needed here just to render
       | some controls on a window.
       | 
       | Something like XAML for GTK would be nice.
        
         | xmichael0 wrote:
         | https://github.com/jsuarezruiz/forms-gtk-progress
        
         | ognarb wrote:
         | This is why I like Qml so much, it is using an declarative ui
         | language while having a nicely organized cpp code for the
         | backend. But as far as I know GTK also have some xml files for
         | the ui.
        
         | [deleted]
        
         | demomode wrote:
         | It exists, it's GtkBuilder[1]. There's also a tool to create
         | those XML files, Glade[2] (needs to be updated for Gtk4 but...)
         | 
         | 1. https://developer.gnome.org/gtk4/stable/GtkBuilder.html
         | 
         | 2. https://glade.gnome.org/
        
         | danieldk wrote:
         | There is Glade. But some GNOME people seem to recommend against
         | using Glade?
         | 
         | https://blogs.gnome.org/christopherdavis/2020/11/19/glade-no...
         | 
         | I have used GTK several times, but Qt always felt far more
         | pleasant. Plus Qt applications work well on Windows and macOS,
         | whereas GTK renders extremely slowly on macOS and looks and
         | feels very non-native on Windows and macOS.
        
           | makapuf wrote:
           | From the link you provided, it seems Glade is not recommended
           | because there exist better alternatives (in the view of the
           | Gnome project, I can't comment on it).
        
             | throw_m239339 wrote:
             | The alternative is to use... some pen and a paper?
             | 
             | > . If you need to mock something up, you can try sketching
             | on a piece of paper or using our mockup resources.
             | 
             | Linux GUI is honestly in a bizarre state. And the Gnome
             | team seems to keeping on recommending against the tools
             | they developed themselves (Vala...). Seems like QT is the
             | best alternative...
        
           | veddox wrote:
           | I think Qt is generally superior. Still, I find GTK easier to
           | get my head around (though I don't work regularly with
           | either). Also, as a vanilla Ubuntu user, GTK apps look better
           | on my system.
        
       | pierrebai wrote:
       | As a supposedly guide to writing app, the introduction reads more
       | like an opinion piece.
       | 
       | The author has a very anti-C stance to say the least. For an
       | article about writing UI, it spends a lot of time laying out all
       | the short-coming of using C to build a UI toolkit.
       | 
       | Amusingly, Qt is mentioned as initially not having a FOSS license
       | but "now available in version 6 with much less restricted
       | licenses"... that's quite a weak praise given that it is
       | available as LGPL, GPL or commercial non FOSS licensing. He then
       | goes on criticizing Qt for being bloated. Most people would
       | rather say that is very feature-rich. Qt is also modular. You
       | don't need to include libraries you don't use.
       | 
       | English does not seems to be the author native language; there
       | are many bad choices of word, like saying that C in "restricted";
       | I think he meant it is "limited".
        
         | j1elo wrote:
         | > "now available in version 6 with much less restricted
         | licenses"... that's quite a weak praise given that it is
         | available as LGPL, GPL or commercial non FOSS licensing.
         | 
         | I was already writing UI applications with an LGPL licensed Qt
         | 4.x, so the version 6 hasn't changed in that regard, just like
         | version 5 didn't change either. And I'm sure Qt was already
         | FOSS in earlier versions, but 4 and 5 are the ones I can
         | confirm having FOSS licenses.
        
           | paulryanrogers wrote:
           | IIRC Qt now requires registration to download their releases.
           | And some drama around how frequently OSS releases would get
           | updates.
        
           | seba_dos1 wrote:
           | Qt3 was GPL (or commercial); with Qt4 LGPL option was added.
        
           | konjin wrote:
           | From memory version 2 is the one that moved to gpl and this
           | happened before 2001.
           | 
           | So this is reheating a 20 year old talking point.
        
         | ognarb wrote:
         | Qt is fully open source since 2000 and nowadays most of the
         | components are lgpl3. I'm still sad that some people are
         | spreading so much fud about it 20 years later. Same with the
         | bloated thing, people complained that qt and kdelibs were
         | bloated and now that qt and the kde frameworks are modular they
         | complains about too much librairies.
        
           | the_local_host wrote:
           | Just yesterday I was reviewing Qt, GTK and Electron as
           | possible choices for some GUI exercise, and _at a glance_ Qt
           | sure looks likely to involve committing to GPL, which is a
           | pretty irreversible commitment to have to make at the outset
           | of a project.
           | 
           | I guess it's possible to sort through the individual
           | components and find a subset that is LGPL and not GPL, but
           | that's a lot of work, especially if you're not familiar with
           | Qt already and need to make a decision.
        
             | brnt wrote:
             | If you link properly, GPL isnt a problem:
             | https://news.ycombinator.com/item?id=23321448
        
               | the_local_host wrote:
               | I guess that would work, the time and effort involved in
               | getting end-users to link the application makes
               | downloading a large Electron binary seem downright
               | pleasant.
        
               | ubercow13 wrote:
               | You can just ship your application with a dynamically
               | linked Qt library file(s). There is no extra step for the
               | user.
        
           | Rochus wrote:
           | > _Qt is fully open source since 2000_
           | 
           | Not fully; only the X11 and embedded version was open source
           | (GPL). The Windows version was only available under a
           | commercial license until 2005. Because of GPL I had to pay
           | for a commercial license for three platforms until 2008. LGPL
           | became available in 2009.
           | 
           | > _I 'm still sad that some people are spreading so much fud
           | about it 20 years later_
           | 
           | It is not exactly the case that the Qt Company clearly points
           | out to users that they can use Qt free of charge under LGPL;
           | rather the opposite seems to be the case. I know various
           | people who primarily bought a commercial licence because they
           | did not consult their own legal advisor and instead followed
           | the recommendations of the QTC sales people.
        
         | h_anna_h wrote:
         | Qt seems to use less memory compared to gtk in my experience
         | (not qtquick though)
        
           | baybal2 wrote:
           | I saw that, and am still amazed at how much effort they
           | poured into that. They are beating GTK 2.0 here.
        
         | turminal wrote:
         | From a C or Nim programmer's perspective any C++ project can
         | appear bloated so perhaps that was a part of what he was trying
         | to say.
        
       | hmry wrote:
       | The full title appears to be "GTK4 for Graphical User Interfaces
       | with the Nim Programming Language", so putting in a reference to
       | Nim in the HN title might be a good idea.
        
         | tyingq wrote:
         | Agreed. Interestingly, there's a dead comment saying much the
         | same thing.
        
         | app4soft wrote:
         | > _" GTK4 for Graphical User Interfaces with the Nim
         | Programming Language"_
         | 
         | And it is outdated, as there would be no _GTK4_ - instead it
         | would be released as _GTK40_ , so some API could be changed and
         | samples from this book would not work anymore.
        
           | xeeeeeeeeeeenu wrote:
           | You're confusing GTK with GNOME.
        
         | srean wrote:
         | Upvoted and flagged to get Dang's attention. Hopefully mods
         | will will notice and edit the title. Will unflag soon.
         | 
         | Unflagged.
        
           | [deleted]
        
           | Yajirobe wrote:
           | Thank you for your service.
        
       | overgard wrote:
       | > Unfortunately GTK is currently not in a very active state.
       | There seems to be one or two paid full-time developers which try
       | to finish official release 4.0 and a few volunteers which support
       | the development.
       | 
       | Really selling it there. If I'm going to learn a thing the last
       | thing I want to hear is "dead project"
        
       | macmac wrote:
       | The text rendering seems very poor. Is that an artefact of the
       | font used, the platform or something else?
        
         | lqdev wrote:
         | It's due to his system settings. This is how text looks like
         | when you have all antialiasing disabled in fontconfig.
        
         | MayeulC wrote:
         | I noticed that the mouse cursor is bigger than mine. It could
         | be due to using fractional scaling on a high-DPI monitor,
         | making subpixel artifacts a bit glaring?
        
           | mixmastamyk wrote:
           | There's a setting in the appearance control panel.
        
         | marton78 wrote:
         | Looks like it's rendered by Asciidoctor.
        
       | dekhn wrote:
       | After working with a wide range of windowing libraries (from raw
       | win32 and x11 to Tkinter, Wx and Qt), I've finally landed on and
       | am staying with qt. It does pretty much everything better than
       | all the other windowing libraries.
        
       ___________________________________________________________________
       (page generated 2021-01-03 23:01 UTC)