10 ms·
GTK4 for Graphical User Interfaces
- bastawhiz 6y agoI 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"
- curioussavage 6y agoUh ok. Gtk is maintained and he only said it has few maintainers. Calling the adwaita theme “cringey” seems silly to me. The latest Mac default style is very similar. Windows “native” look and feel is a joke. A ton of popular apps don’t care about native look anyways they just want their branding. Qt just tried to pull some crap again with their licensing too. I appreciate the author because I like nim and gtk development. He even fixed an issue for me last year when I was trying these bindings out. I don’t agree with his slightly pessimistic view though. There are a lot of new people learning it right now spurred by the new phones and mobile Linux desktop ends. It’s true the main appeal is to people who like their default styling and the gnome desktop
- ku-man 6y agoTitle should be: GTK4 for Graphical User Interfaces with Nim
- unwind 6y agoOh, did they drop the "+"? The name used to be "GTK+" but that seems to have changed. Does anyone know when?
- Galanwe 6y agohttps://mail.gnome.org/archives/gtk-devel-list/2019-February/msg00000.html https://mail.gnome.org/archives/gtk-devel-list/2019-February...
- EamonnMR 6y agoWait, GTK was spun out of GIMP?
- makapuf 6y agoWell, GTK means GIMP Tool Kit, so yes.
- jsmith99 6y agoYes and the GIMP devs are still hard at work trying to make GIMP use GTK 3... (beta recently released)
- chunkyks 6y agoThe name is short for "gimp tool kit", yes
- zorked 6y agoYes. 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 https://isc.tamu.edu/~lewing/linux/notes.html
- unwind 6y agoThanks! 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. :)
- chrisseaton 6y agoWow the text rendering is atrocious. Is this still the state of GTK and desktop Linux today?
- andoriyu 6y agoAuthor is just weirdo. Here is a "normal" system looks like https://imgur.com/a/hvKNWIs 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.
- guenthert 6y agoNot 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).
- tetromino_ 6y agoIt 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 6y agoIMO 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.
- 6y ago
- _ph_ 6y agoI 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 6y ago[deleted]
- hmry 6y agoThe 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 6y agoAgreed. Interestingly, there's a dead comment saying much the same thing.
- srean 6y agoUpvoted and flagged to get Dang's attention. Hopefully mods will will notice and edit the title. Will unflag soon. Unflagged.
- deleted 6y ago[deleted]
- Yajirobe 6y agoThank you for your service.
- app4soft 6y ago> "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 6y agoYou're confusing GTK with GNOME.
- macmac 6y agoThe text rendering seems very poor. Is that an artefact of the font used, the platform or something else?
- marton78 6y agoLooks like it's rendered by Asciidoctor.
- lqdev 6y agoIt's due to his system settings. This is how text looks like when you have all antialiasing disabled in fontconfig.
- MayeulC 6y agoI 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 6y agoThere’s a setting in the appearance control panel.
- mseidl 6y ago#qt4ever https://www.youtube.com/watch?v=gGZyVSOnqm0 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 6y agoI 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 6y ago> 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 6y agoQuite annoying even on Linux if you use KDE: GTK3 apps stand out like a sore thumb. More than Electron even.
- curioussavage 6y agoThere is a breeze gtk theme available
- brnt 6y agoYes, but if you use a 'modern' GTK3 app (take a recent Meld), the absence of the titlebar (or decorated one, if you are into mdern GTK) really stands out. You're right that with some (older?) GTK apps breeze-gtk-theme used to work pretty well, not sure what changed.
- benbristow 6y agoCan'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.
- flukus 6y agoThis is nothing compared to something like the Win32 API. More importantly, this sort of code is incredibly simple and linear with virtually no logic or state, this is the worst sort of code to try and code golf into something more "elegant", you just end up with something more complicated but less flexible.
- demomode 6y agoIt 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 https://developer.gnome.org/gtk4/stable/GtkBuilder.html 2. https://glade.gnome.org/ https://glade.gnome.org/
- danieldk 6y agoThere is Glade. But some GNOME people seem to recommend against using Glade? https://blogs.gnome.org/christopherdavis/2020/11/19/glade-not-recommended/ 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 6y agoFrom 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 6y agoThe 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...
- pierrebai 6y agoAs 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 6y ago> "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.
- seba_dos1 6y agoQt3 was GPL (or commercial); with Qt4 LGPL option was added.
- paulryanrogers 6y agoIIRC Qt now requires registration to download their releases. And some drama around how frequently OSS releases would get updates.
- jcelerier 6y ago> IIRC Qt now requires registration to download their releases. not if you use it throuh vcpkg or https://pypi.org/project/aqtinstall/ https://pypi.org/project/aqtinstall/ or your distro's package manager or mingw or...
- overgard 6y ago> 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"
- curioussavage 6y agoIt’s not dead. Yes development is slow but there is the foundation which had a few paid devs and red hat pays some people too. Mostly it just means the scope of future plans for the project remains narrow
- SolitudeSF 6y agohe is not trying to sell/convince you to learn gtk. he is warning if you already want to learn it. not everything posted on hn should be a promotion material.
- wcchandler 6y agoThe author talks about how android doesn’t use GTK. What does Android use? Some kind of Java thing?
- jraph 6y agoIts 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/Button https://developer.android.com/reference/android/widget/Butto...
- dekhn 6y agoAfter 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.
- longstation 6y agoIt'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.