News for hackers. Stuff that matters.
Re:GTK has a new website by xwowsersx on Sunday March 01, 2020 @05:07PM (#22459703)
I have only ever built for mobile or web. What is the state of affairs on desktop? What are the options for building for desktop? If I wanted to build an app targeting Mac, can I use gtk? Has anyone here done a gtk app with Rust? Generally know very little about the desktop world, can someone enlighten me?
Re:GTK has a new website by einpoklum on Sunday March 01, 2020 @06:11PM (#22460071)
I personally very much dislike Gtk. Other than the prominent example which is the much-maligned (and justly maligned) GNOME, there is the fundamental design feature: It is based on the Glib library - a C-language object system. That's rather outdated, and IMHO makes Gtk like a piece of candy with a rotten core.

What it has going for it is that Qt, perhaps the second most popular cross-platform GUI toolkit, developed on top of C++98 and had a lot of functionality to fill in for libraries missing for the language - which by now are outdated and have standard or more-popular alternatives.

(Actually, Glib is also somewhat like that in some respects.)

Caveat: I'm the opposite of an authority on writing UI code.

Re:GTK has a new website by ptx on Sunday March 01, 2020 @06:35PM (#22460193)
The nice thing about GLib/GObject is that you can use it from any language that has C interop, which is practically every language.

And that works even better now with GObject Introspection, which provides a generic way to access any GObject-based library from any language (kind of like COM's typelibs or WinRT's projections): https://gi.readthedocs.io/en/latest/

Re:GTK has a new website by einpoklum on Sunday March 01, 2020 @07:32PM (#22460492)
But the whole point is that I don't _want_ to use Glib/Gobject's. I want my own language's objects (more often than not - C++).
Re:GTK has a new website by PaulDavisThe1st on Sunday March 01, 2020 @08:37PM (#22460837)
I write a "major" app that uses GTK (via Gtkmm, the C++ language binding). We don't use GObject for anything that isn't already a part of GTK. Put differently ... if we implement or extend a widget, it will necessarily inherit from GObject. But if we implement our own non-GUI objects, we just ignore GObject entirely.
Re:GTK has a new website by ptx on Sunday March 01, 2020 @08:27PM (#22460784)
Well, I also want to use my own language's objects, and GObject Introspection enables that.

With a library written in C++ I can't do anything from most languages. Very few languages offer C++ interop.

What language would you suggest the platform GUI library should be written in if not C? You can't use Qt's C++ objects from Java or Swing's Java objects from C++, but both can call C.

Re:GTK has a new website by lmm on Sunday March 01, 2020 @11:33PM (#22461691)
You can - and do - use Qt's C++ objects from Python in a very native way, as though they were just ordinary Python objects. I would imagine the same would be the case when using Qt from Java or any other language that offers bindings. And since C++ with its class system is a widely adopted standard (for good or ill), there is at least some appetite for offering good bindings to object-oriented C++ libraries among the wider community, and any improvements or techniques there will generally cross-pollinate to improved bindings for Qt and vice versa.

In theory GObject is intended to be a whole parallel OO ecosystem, a better way of doing objects in C-like languages that can compete with C++, and that would ultimately give rise to a whole platform of things like Vala that interop with that platform. However that whole ecosystem just hasn't caught on; outside of Gnome, no-one is using GObject, no-one is using Vala, and so no-one else is interested in working on bindings between other OO languages and GObject (which have to solve much the same problems as bindings between those languages and C++ - GObject may be "C" but it relies heavily on macros, and to bind it in a usable way that makes it feel native in an OO language you have to do a lot more work than just exposing C functions as functions).

Re:GTK has a new website by xfer on Monday March 02, 2020 @12:40AM (#22461930)
There is a reason there aren't any close to complete bindings for other languages except python for Qt5. It takes significant effort compared to binding to Glib/Gobject especially with gir.
Re:GTK has a new website by einpoklum on Monday March 02, 2020 @12:03PM (#22466238)
Qt is not a "fair" comparison. I mean, yes, it's relatively popular, but:

1. It's a huge framework, not just a GUI toolkit. 2. It uses the not-really-C++ mechanism of signals and slots and a "meta-object compiler".

Thus, for example, wxWidgets - written in C++ - has bindings in Lua, Python, Ruby, Rust, Java, Javascript, etc.

Re:GTK has a new website by einpoklum on Monday March 02, 2020 @09:47AM (#22464817)
> GObject Introspection enables that

By definition, not really. I can't be not-using GObjects if I _am_ using GObject introspection.

> Very few languages offer C++ interop.

bu they do offer Glib interop? I don't mind having a C API (for a C or C++ library), and modern C++ inside.

Re:GTK has a new website by steveklabnik on Sunday March 01, 2020 @05:33PM (#22459859)
Newest hotness with gtk and Rust is https://bodil.lol/vgtk/
Re:GTK has a new website by tracker1 on Sunday March 01, 2020 @07:04PM (#22460350)
Definitely cool... been looking into using neon with electron myself, this might be a good alternative for something lighter.
Re:GTK has a new website by simion314 on Sunday March 01, 2020 @05:28PM (#22459821)
I don't have experience with GTK and I stopped working on Desktop apps since 4 years ago. If you target Mac users only then use the Apple tools, if you target Windows only I would use .Net (C# and WinForms or WPF) for cross platform depending of the target users I would use Qt or Java.

My choices are more on what is better for the user and not on what is cool for the developer. Also if you have a small tool that the user will use it a few minutes he will not complain about it's look the functionality is important. As an example the games Sims 3 runs on Windows and Mac(not the latest Catalina) and community made tools for cleaning save files. Most popular tool was .Net and Windows only but someone made a Java tool that was cross-platform, the users were happy/great full and not entitled to demand profesional looking GUI for such a tool.

My advice , if you need a simple UI, buttons, labels, inputs then you should use the thing that has the best support for the language and platform you target. If you need to embed a uptodate webview or a video player or you need to draw graphs, customize widgets then you need a different tool.

If you can provide what you need in details, what platforms, languages and features you need then people could help eliminate the bad choices.

Re:GTK has a new website by PaulDavisThe1st on Sunday March 01, 2020 @08:48PM (#22460893)
I've been working with GTK for a cross-platform app for 20 years (actually cross-platform for 15 or so). I've had the opportunity to have fairly deep interactions with people who've used Qt for similar projects.

The reality is that if your app is substantive in its GUI requirements, then neither Qt nor GTK will entirely shield you from platform specifics, and both of them will fall down in some situations (a little different for each toolkit).

Historical note: I decided to use GTK and not Qt because in the 1990s, Qt, despite being written in C++, was incredibly non-C++-idiomatic. It had its own string class, and required a Qt-provided pre-processor to be run on your code to get their signals/slots mechanism to work (think "anonymous callbacks"). GTK, by contrast, had a C++ binding that fully embraced the power of the C++ of the time. At this point, this difference between them has largely gone away. Qt has far more in its toolset to help people design and build apps, but when you get down to what they can actually do at runtime, there's not a lot of difference.

My one outstanding gripe about GTK is that the initial "G" used to stand for GIMP (it was written to support the development of that application), but now stands for GNOME. This doesn't ruin GTK as a general application toolkit, but some of the design decisions (at several different levels) do reflect its status as the "GNOME Toolkit" rather than a totally platform-agnostic GUI toolkit.

Re:GTK has a new website by simion314 on Monday March 02, 2020 @05:24AM (#22463188)
> I decided to use GTK and not Qt because in the 1990s, Qt, despite being written in C++, was incredibly non-C++-idiomatic.

Yeah, but there were good reasons for Qt to do that, I think that is just a taste thing, when you want to make an application that works the fact that Qt has a sane string,vector, signals is a plus(you did not need boost or third party code) , coming from Java or .Net Qt feels right.

For GUIs I did not hit cross platform related issues. I think I had to re-arrange some menus depending on OS but not to use native code. The only time I had to use some native stuff and I had to include windows.h was because I needed to on a multi screen setup to get each screen dimensions and at that moment this was not implemented or bugged(I do not remember).

About GTK, I strongly dislike the fact they are using their own File Chooser dialog and not the native one and that you can't customize the sorting order in it, especially on GTK2. So I have a few GTK2 apps and I always find it hartd to find my files because n how them are sorted , though in GTK3 I found a config options to change it a bit.

I would still use GTK if the problem to solve would require Python and a simple GUI like ask the user for a name, to chose a file, input some text. show an image and it is a Linux tool only.

About GNOME I agree, it could be possible in future GTK won't officially support menus, tray icons and other things that GNOME does not want.

Re:GTK has a new website by PaulDavisThe1st on Monday March 02, 2020 @10:35AM (#22465216)
There were no reasons for Qt to do that back in the day. Its string class had just as many issues as std::string, and libsigc++ showed how to do signals without a pre-processor. They just didn't want to do the work (then) ... now they have, and it's all just fine.

I contributed some significant fixes for GTK on macOS (OS X) support, all of them based on our experience with it. What's there now still has a few fundamental issues (often caused by fundamental differences in basic concepts within Cocoa versus X), but it's in much better shape than it was in 2004. My interactions with people doing Qt-on-macOS suggest a similar level of pain there too, which is to say "not much if your app is straightforward, but irritating if it has special needs".

Re:GTK has a new website by simion314 on Monday March 02, 2020 @12:06PM (#22466269)
Was that string support cross compiler or only gcc and mingw ? AFAIK you can't do signals with standard c++ until after C++ 14 and you need to keep in mind that Qt is used in automotive industry too so they probably don't have latest features there.

Nevertheless if you use QString then you can populate QVector with it and you can then assign the collection to a QList and you got lots of benefits, the only thing is if you have to use some external library you need to convert the string or char[] to a QString. I never had a case where I was thinking "damm I would like to use the native string or I would like the moc did not exist, who is bothered by moc ? distro packagers ? some mixed projects ? some standard c/c++ project that would like to consume Qt libraries?

What I really missed in Qt is a builtin simple way to create installers for Windows and Mac and a builtin way to do self-updating for Win and Mac. File size for Mac was also a complaint the qt apps received (I do not remember exactly how I was bundling them).

At my work they disliked Qt and I had to use Adobe AIR, I hated it at first but after a while I think at that moment in time it was the right choice, it was cross platform, easy to update, no more segfaults, good stacktraces that I can log and then use to fix bugs.

Re:GTK has a new website by PaulDavisThe1st on Tuesday March 03, 2020 @05:03PM (#22479141)
Gtkmm was using libsigc++ when I started working on Ardour in late 1999. No C++14 required.
Re:GTK has a new website by simion314 on Thursday March 05, 2020 @04:11AM (#22492085)
I still do not know why you object to moc? If is a practical or ideological reason. I also don't like magic in my tools, code that is generated behind me but with Qt I never had issues with it(not like other tools where the magic code crashes and you have to understand what happens under the hood to figureout the problems).

I did not used GTK seriously so I don't know how it's introspection and signal/events compare with Qt, are those as safe and easy to use? Is it easy to have collections of objects/strings and then use them in list/tables/trees? Trying to find examples i see a lot of C pointers and C function calls that seem to me very unsafe and ugly, something that would work fine for a small project but a pain for larger projects.

Anyway I am not trying to sell you anything , I want to understand better what is wrong with moc in your opinions(have you used Qt in a serious project?) and we can learn from others experience.

Re:GTK has a new website by PaulDavisThe1st on Thursday March 05, 2020 @08:33PM (#22500302)
I don't like to have adjust my build systems to run an additional pre-processor over my code when there's no actual requirement for it. I don't want to have to deal with code I did not write appearing in the middle of code I did write.

GTK is written in C. Gtkmm is written in C++. Totally different. Gtkmm's signal/slot system is better than the original one in Qt. I haven't looked at Qt's current system in quite some time.

      someButton.signal_clicked().connect (mem_fun (*this, &Handler::method);
Many variations to allow binding, argument hiding, return value hiding and all the usual stuff.

Gtkmm has several display widgets that use a model/view paradigm, and let you define your own model and then map that to the view. If you literally just have a bunch of strings, there's one specifically to handle that situation.

I haven't used Qt myself but have worked in close collaboration with people who use it a lot.

Re:GTK has a new website by simion314 on Friday March 06, 2020 @09:01AM (#22503569)
OK, so your problem is that moc is an extra build step. but is this for aesthetic reason or why?

From my Qt experience you never see the moc code when you debug your applications. The only way to avoid moc would be to use heavy templates or macros and those also generate code behind your back.

I did not heard of GTKmm so I will check it out to find out more, thanks.

Re:GTK has a new website by xwowsersx on Sunday March 01, 2020 @05:41PM (#22459904)
Thanks for the reply. Why does Transmission, for example, have a Mac app and a GTK app? They wanted a more polished Mac appaand gtk doesn't cut it?
Re:GTK has a new website by simion314 on Sunday March 01, 2020 @06:28PM (#22460156)
Qt has a company behind so is more professional, better documentation, better cross platform support, less bugs.

This video https://www.youtube.com/watch?v=ON0A1dsQOV0 is about the reasons Subsurface (a diving app started by Linus Torvalds) changed from GTK to Qt. Things might have improved from GTK I can't tell and also for simpler GUIs GTK might be enough.

Re:GTK has a new website by solarkraft on Sunday March 01, 2020 @06:19PM (#22460112)
Transmission is an interesting case, since they also have a version in Qt. Another example of an almost identical app written on a completely different platform would be the Fork git client with Cocoa and WPF.
Re:GTK has a new website by kn0where on Sunday March 01, 2020 @05:57PM (#22459995)
Yes, the Mac version of Transmission has a much more Mac-like UI that can’t entirely be replicated in something like GTK.
Re:GTK has a new website by severine on Sunday March 01, 2020 @05:21PM (#22459772)