How Does One Create A Gtk+ Application?
blogs.gnome.org
blogs.gnome.org
Before that time, we were using WxWidgets and had many issues, notably with Unicode and Windows support. WxWidget APIs and behaviors were changing too much between releases (even minor ones).
When we moved, we were in the early Qt 4.1/4.2 days, and most VLC developers were using Gnome and pushed a lot for Gtk. But one developer started the new UI in Qt, and I picked up the work. We had an important backlash from users, notably with some people in the community recoding an interface in Gtk...
Afterwards, QGtkStyle was introduced, and people could have a native look, even with Gtk environments.
Finally, Qt moved to a community project, to LGPL and Gtk went down the road with Gtk 3.x, breaking themes, Windows, OSX, and API/behaviors at every release (and removing features).
Those days, every cross-platform application are moving to Qt (subsurface, LXDE, wireshark, audacity). It's funny that we made this decision, at that time, without knowing all that. I think we just got very lucky... :D
Gtk was a pain to develop with, sure, but only due to the awkwardness of GObject's attempts to build an OO system on top of C.
From a user perspective, I never saw the problems you're describing. Even having built Xfce out-of-tree all the time, I never recall having to do a full rebuild due to a Gtk update.
I've since moved on; it's a shame to hear what the OP is saying about 3.x, but 2.x most certainly didn't have these problems that you describe.
I don't recall the stability of the 2.0.x series, though: it's possible they didn't get things right and were still making breaking changes even though it was the stable series. I don't remember that being a problem, but I'll admit my memory of that period isn't perfect.
I do remember some app developers prematurely upgrading and releasing versions that depended on early development releases of 2.0 (and later, on the 2.1.x unstable series), which often did cause breakages. But that was really the app developer's fault for depending on versions that made no API/ABI guarantees.
I.e. in Qt3 and previous versions, creating a parent-less widget resulted in a window frame being created. Why was that? If I am creating a button I do not want a window frame around it. I am going to insert the button to another widget later.
Thank God they fixed that in Qt4 and later versions.
But there is this massively annoying little bug where submenus close immediately when you hover another top menu item before reaching the submenu. This makes quickly navigating menus quite cumbersome. (Doesn't happen with native Windows interfaces.)
Does anybody know if the Qt devs are aware of this? Don't they think of it as an issue?
If so, then yes they are aware of it and treating it as critical.
Edit: Reading into this bug is so cool. This video was linked from it, fascinating stuff: https://www.youtube.com/watch?v=90NsjKvz9Ns&t=18m46s
I feel really bad for GTK developers. The GNOME guys have clearly taken the toolkit from a "general purpose" direction to a much more gnome-centric one.
At the same time though, I can't help but be hopeful for the future. Qt is a wonderful project, with a bunch of wonderful licenses, developed in a wonderfully-open environment (It's not like before!) and with wonderful improvements already available in Qt 5. With more and more applications switching to it, I see Qt as a central part of the Linux desktop ecosystem in the future - finally, not only will we have a beautiful desktop with common themes for all apps, but also the power of a truly cross-platform toolkit in most Linux apps. It will be nice.
However, it's always seemed a little perverse to me to have Gtk+ try to imitate '90s-style C++ in C, and then to use a C++ wrapper around that.
Qt5 and its modularity is the answer to your concern. If you don't want everything including QtKitchenSink, you can limit yourself to QtCore.
On the other hand, as a C++ library it really couldn't be worse, with its flagrant reinvention of the standard library, pervasive UTF16, complex object hierarchies, raw pointers, extensive use of macros, etc., etc.
Maybe I'm just too choosy, but it'd be really nice to have a graphical toolkit that didn't have such an air of sausage factory to it.
WTF is it with people's first instinct being "let's fork instead of contributing fixes"?
As for the raw pointer use you should always use QPointer smart pointers for objects whose lifetime you don't control. However they don't recommend passing QPointers as function parameters since they are easily/cheaply constructed and the reference count is embedded in the QObject instance itself in any case.
I don't see the issue with the object hierarchies either. You have your QObject and QWidget classes that are important and then all the stuff that builds on that. Not that complicated really once you get into it.
The UTF-16 thing is ugly, yea, but I did never see a practical issue with it.
Have you given Qt a serious try? Most of the above arguments don't hold good at all. * c++ std lib is total crap. Anyone arguing for it has no idea what a good API is. Have you used Qt container? It's as intuitive as it gets. The C++ std lib is performance optimized and most desktop apps don't need it. It comes at a cost of developers having to learn complex APIs.
* Complex object hierarchies - huh? Qt's value based types need no memory management. The pointer types has a simple parent-child relationship. Delete the parent and all children are deleted as well. How hard is this?
* Raw pointers - Commented truly like someone who hasn't understood Qt.
* Why do you care about UTF16? It's an internal representation. BTW, Do you write any web apps? Do you know or care what internal representation is used by strings? If you some ultra-special case of a performance critical app, no string library out there will be good for you. You will have to roll out your own.
Let me guess. It really looks like you are one on the few guys who likes writing libraries (as opposed to apps). People who write apps love Qt. People who like writing libraries don't like any other library other than their own because their way is the true way.
There are many valid criticism of Qt but these are none of them.
[1] http://gamedev.stackexchange.com/questions/268/stl-for-games...
Glazing over the fact that Qt has an incredibly complicated object hierarchy by saying "they're good for you" is not acknowledging the fact that it's complicated and difficult to learn or work with. You didn't even mention, e.g., MOC - Qt's incredibly complicated Meta-Object Compiler. And people call GObject complicated...
Ignoring the fact that basically every other platform than Windows (and the platforms it has managed to infect) uses UTF-8 as its One True Encoding, and that you and Qt are proliferating the claim that every sufficiently complicated C++ project has its own string class with its own specific peculiarities is not a good thing.
Most importantly, you can't dismiss his concerns by agreeing that all of them exist and that he shouldn't care.
Not sure how you concluded this is about NIH. Qt's container are very developer friendly and as an application author that's the first and most important thing that matters.
Saying moc is complicated is like saying dalvik or ART is complicated. These are just tools that work in the background. Just like you don't need to know ART internals, you don't need to know moc or the code it generates for you.
Arguing about string encoding is so 1990's, I won't comment.
That's b/c the C++ standard library (or its implementation among various compilers) was terrible 13 years ago when Qt 3 was released. Some say it still is.
I was even enjoying Vala. While it was obviously a young language, it had a lot of interesting ideas.
Then we got the new 3.x version of GTK with its "lets rewrite everything for no other reason than to break compatibility"[2] project goal that seems to have corrupted far too many projects recently. In addition to the problems already mentioned in this thread, it seemed so.. unfinished. Various components or features were gone or rewritten into something else. I guess they spent all their development time trying to tie Gnome and in as tightly as possible instead of finishing features.
The last straw was when they decided to join Pottering's "lets forget Unix and make Linux into Windows" crusade. A terrible design decision on top of years of other questionable choices and bad attitude about actually listening to user needs.
I supported GTK and Gnome waaaaay back when they first started, when the fight was between a Free (GPL) library and the increasingly popular proprietary-license-only[3] Qt. Now, I'm not sure what to support in the GUI toolkit area.
While I figure that out, my current project's GUI is being written in ruby-tk. The widgets in Tk have a terrible look and strange layout/interaction quirks, but at least it isn't a moving target and work more or less everywhere.
[1] e.g.: writing Ruby bindings C++ libraries can be problematic. While problems such as the name-mangled symbols are not as bad as they once were, it is still much easier to link a C library into a random environment.
[2] As Linus said, "...thou shalt not break working code."
[3] Trolltech changed the license about a year (?) afterwords.
Could you give a little more background about this? (True curiosity, I don't doubt that what you say is true!)
"Turning Linux into Windows" is hyperbole, though; the most used and developed-on non-mobile Unix -- Mac OS X -- is similarly epicurean, and blithely makes use of tightly coupled components designed to work together, to deliver a smooth easy-to-manage experience. And it's eating Linux's lunch.
Yes, there's a bit of hyperbole in that statement, but there is a problem there. Pottering has pushed a very "our way and no other" attitude, even when other people have requirements that aren't met by systemd.
Worse, the tight-coupling between components is a perfect example of the "embrace and extend" tactic. The monopoly position systemd currently enjoys has successfully been used to extend into a disturbing number of other components[1].
As for unix-vs-windows - switching to a windows-style binary log and rewriting an inetd into a mandatory "SvcHost.exe" for linux is bad enough, but the real issues is the removing of well-defined barriers between components.
Pottering's hatred scripts is a problem, because using scripts as the "glue" in unix is one of the most important features of unix. Keeping many of the the interactions between components in an open and readable format has forced developers to create (and deal with) methods of API that can actually be extended beyond the original project. Systemd returns to the windows style of just making function calls into the current implementation. Being forced to, for example, listen on a unix socket for a command works easily with anything, even into the future. Requiring that same message be sent by calling some function encourages linking to extra libraries and makes interaction from scripts much more difficult.
This isn't about any technical benefits; keeping the IPC between components open and well-defined is even more important than access to the source code itself if we are to maintain an ecosystem of Free Software. For those of us that would like to have a Free (as in freedom) Software ecosystem survive the current War On General Purpose Computing[2], the campaign by the pro-systemd people is, frankly, terrifying. Sometimes there are more important goals than "faster" or "cleaner API" or "easier to write". Keeping the OS - both the kernel and system-utils - open, free, and interchangeable needs to be a high priority goal, or we will lose the progress the Free Software community has made over the last ~decade.
[1] http://www.phoronix.com/scan.php?page=news_item&px=MTczNDk
TLDR:
* Qt has a community of people developing applications, has good documentation (precise, good coverage) and people who care
* Gtk+ has a bunch of Gnome developers, if you want to develop an application, you're out of luck
If Linux/Linux distributions did support it, rolling release would be a lot more common. One limitation that would remain is that if you have an application that requires a single instance (e.g. a Network Manager), you couldn't have multiple instances of it running at the same time.
I feel like your emphasis is backwards.
It's not surprising that NodeJS, a new project, has solved some of these problems. NPM has the luxury of decades of experience from dozens of linux package managers and package managers from other languages. Plus, they're not tied to the legacy use cases the same way that (e.g.) apt is.
Not supporting multiple versions of the same software is something that I identified as a problem though.
[0] - https://nixos.org/nix/
However, the system should be designed in a manner where I have a choice.
This here: https://en.wikipedia.org/wiki/Filesystem_Hierarchy_Standard
Makes no sense in a world of dynamically linked libraries and 6 month release cycles.
These requirements are not mutually exclusive. With a proper file system hierarchy both of them could be accomplished.
Most of the popular distribution's package managers (apt, pacman, etc) support the sharing dependencies but almost none of them support installing multiple versions of the package.
Given that storage space is very cheap nowadays I think a package manager like NPM which stores copies of the dependencies is not that bad actually.
The goal of an operating system is to run applications. The installation and packaging of software should be as simple as possible.
For whatever reason, the Linux desktop community does not see this as an issue.
If I want Vim 7.4, 7.3 and 7.1 installed at the sametime, your package manager should support it. What if 'X' plugin is only compatible with 7.1 and 'Y' plugin is only compatible with 7.4. This is a valid use case.
Lately, I have been using Docker to work around this, but it's not fun setting up GUI applications in a container.
They do and they have, but they can't conjure-up libraries that haven't been properly versioned and released upstream.
If the GTK+ team can't maintain an ABI then they need to start releasing versions under different sonames such that programs like wireshark link against "libgtk-3.so.0.1200.2" and not "libgtk-3.so.0", then the package managers will be able to do the right thing.
Uh, they have. For ever.
I have parts of boost 1.49, 1.53, 1.54 and 1.55 together on my system. I have GTK2 and GTK3 together on my system. I have Qt3, Qt4 and Qt5 together on my system. Python2 and Python3. libpoppler19, libpoppler44 and libpoppler46.
Parts of the gui that used to render correctly now stops updating at all.
I suffer this problem with an image viewer (geeqie) on debian. I have to restore/maximize the window to force a redraw and it has been like that for months.http://www.upstream-tracker.org/versions/gtk+.html http://www.upstream-tracker.org/versions/qt.html
(Yes, yes, Qt does more than just GUI, I know …)
But we got rid of it, changed all our code to Qt, which run circles around GTK Never looked back, best decision we could ever make. It works beautifully in all platforms, it integrates OpenGL, pdf output, printers support.
The only problem about Qt is that not all open source programs use it, so you use Inkscape(GTK) in Mac and works so badly, you can't even copy vectors(it copies pixel images instead!!).
GTK should die.
Qt, WxWidgets, or even something else.
I'm so glad the Web and Modern Browsers reinvented "desktop applications".
Though I use Qt, the Mac support on GTK is terrible at best. Windows support is even worse (or non-existent) which makes me question their "cross platform gui" title.
If I was to suggest a method, I would suggest using each platforms GUI language and make a backend in something cross platform.
Running on multiple Linux DE's/OS's is not cross platform as far as I am concerned, even though technically it is lol.
"Cross platform" means supporting all of the widely-used platforms at a given point in time, and supporting them well. Today, that includes at least Windows, OS X, and Linux. Some would even extend that to include the BSDs, Solaris, AIX and HP-UX.
Like others have pointed out, GTK+'s support for OS X and Windows has been very, very lacking. It's nowhere near as seamless as that offered by Qt, Swing, or SWT.
Qt has just about as many bindings as GTK does.
http://www.gtk.org/language-bindings.php - 3.10 - 12 http://en.wikipedia.org/wiki/List_of_language_bindings_for_Q... - 7
And of that 7, 3 are the only "language integrations". The rest are parts (Go-QML)/part of Qt (QtQuick, C++).
So 12 to 3 for GTK. And the GTK language binding is not complete, for example Rust has a GTK binding (though not done).
You might be the first person ever to say that.
The simple truth is that if you need your application to support certain distributions, you need to be there on the development releases testing them and either submitting bug reports or improving your application.
And you can automate much of this with a pile of bootable ISOs and a scriptable virtual machine. Testing isn't new.
The author makes it clear updating his code to fix the problems is not the problem.
Testing helps you find issues before your users start knocking on your door and whining about broken software. They expect you to test. Is that fair? Not even the smallest bit... But it's the way things work.
If you don't give a crap about your users, and you only do this as a programming exercise, let your users be your first line of testing.
Again, I'm not saying that the problems described aren't real (or even that they're not frequent) but if you want to live in an ecosystem, you have to become a part of that. Get stuck in and fix these problems as best you can.
---
And maintaining security-only release structures is designed to make this very problem predictable and maintainable. You know what's going to be in the release a month, two months before it's out. Testing and fixing then means your app works for the life of that release.
I mean, in Windows, Microsoft obviously take care not to break binary compatibility - even across several generations of OSes. Right now, in my Windows VM I can run Office 97 on Windows 7 [1].
That's an 18 year old piece of software. And it's still working fine.
I upgrade Ubuntu and it's a flip of a coin whether Google Earth will stop working.
[1] http://www.microsoft.com/en-us/windows/compatibility/CompatC...
Being mindful of ABI compat, though, is important because rebuilds mean more package downloads for end users and more builds for distros. That doesn't mean we should never, ever rebuild stuff, though.
The KDE project has a really helpful C++ ABI compatibility reference: https://techbase.kde.org/Policies/Binary_Compatibility_Issue...
I release an application "today" (and "today" for example is when Gtk 3.4 is released), and six months down the line the Gtk team decides to release Gtk 3.6 which breaks just about every application that has a GtkTable. As an application developer, I believe I have a right to be pissed.
How do I file a grievance? I go to the GNOME bug tracker to find my bug. CLOSED: WONTFIX - we don't care, our solution is you port to GtkGrid. Doesn't matter to us that you now have to bifurcate your codebase to work with people still running Gtk 3.0 or 3.2, or choose to ship your own built version of Gtk 3.4 with your application. Fuck you, application developer.
What do I do to mitigate the impact? Well, I have to spin an emergency release of my application, despite the fact that no other code might have changed, just because the Gtk team decided that breaking ABI was no longer a concern for them.
Now multiply this for basically every Gtk cycle from 3.4 to 3.1(3/4) and you realize the problem.
I'm saying you can test on the versions distributions are actually shipping (and the ones they're about to be using). In a lot of distributions you can rely on that staying stable for a period of time.
If your application depends on an older GTK library the solution is simple: depend on that version or ship it with your application. This is pretty unusual in the Linux world but old hat for Windows developers where you can only really depend on Win32; and for anything else your installer makes sure it's present.
And finally, for the third time, I'll state that I'm not saying there aren't legitimate issues with how GTK+ is developed. There clearly are... I'm just saying that some of the things Morten wrote show issues in their own development process as much as anything else.
Linux guys should stuff faffing about with endless compile times in C++, buffer overruns and pointer exceptions. They should use FreePascal and Lazarus and retain their sanity.
I tried Qt and liked the fact that it had good libraries built in (using the provided networking library v/s using libsoup with Gtk+)
In my opinion Gtk+ with C is a big pain but Vala feels natural and should've been pushed instead of JavaScript by the gnome guys.
Static linking should save you from from this hell. I don't know if gtk even supports it, I know glibc does not, whitch is a shame.
The crazy stuff is having your window decorations disappear when running a GTK application under openbox because somebody thought it would be funny to screw with gtk+-3.12 [1].
[1]: http://redmine.audacious-media-player.org/boards/1/topics/11...
If something breaks ABI compatibility, that doesn't mean it is API incompatible. It just means all you need to do is recompile dependents and everyone's happy. It sounds like almost all of the problems in this post were caused by a failure to rebuild dependents. That's a general problem that can affect any library, not just Gtk+.
That's just fine, until you want to release a binary application that targets more than one distribution...
Unfortunately, convincing the people who write my paychecks, VMware, to contribute Workstation and Player to the Open Source community seems to be a pretty big stretch.
So there you have it. Link statically against the LGPL library and package the object files of your commercial application.
creating gui applications is much better in both windows in osx. Cocoa was a fairly well designed base api that gradually got improved. (yeah, there is a lot of valid criticism here too, but we're comparing it to gtk in this case)
We should build something that can gradually phase out GTK as was done with Carbon. If linux had a nice gui toolkit people would write more linux desktop applications.
Just my opinion. So feel free to completely disagree with it.