Live data from Hacker News

GUI development with Rust and GTK 4

gtk-rs.org

101–110 of 172 posts

Re: GUI development with Rust and GTK 4

#101
post #100

Would it be a good idea for a programmer that did not work with Rust before, to dive into GUI programming with GTK4? I'd like to build a simple desktop application for mainly personal use, been dabbling with PyGObject and GJS a bit, but haven't accomplished much yet.

In my experience, these personal projects are the best way to learn.

Most of the key skills that got me a job started with me playing around with some technology to solve a custom problem I had.

Re: GUI development with Rust and GTK 4

#102
post #89

Earlier quoted context omitted.

For me the litmus test is if it has a fully-featured listview or treeview, so you can do something like a file browser, a library app, or other kinds of data-heavy apps. Also important is that keyboard and mouse work as expected (tabbing, shift-selection, etc). Bonus if it supports the current "native" OS paradigms. E.g. on Mac: transparent sidebar, integrated titlebar, on Windows: MS office 2022 style simplified too…

> Gtk doesn't look native anywhere but at least it has a very complete widget set and has been around for a while. It's being worked on. https://twitter.com/paulrouget2/status/1595357518913449992

I’m curious about this, because over the past decade or so, large parts of GTK’s cross-platform ability have been actively sabotaged. It used to be possible to style it to look native on Windows, with some feel problems but mostly comparatively minor. Now, well, no one has quite managed native look (whether or not it’s possible, and certainly I’ll allow that “native” is very ill-defined on Windows these days), and feel is way off in important ways because they’ve deliberately removed a number of important pieces, forcing GNOME HIG conventions. (Things like how they basically force GNOME’s style of overlay scrollbars these days; also keyboard stuff is regularly hopelessly wrong.) The GTK/libadwaita separation is a lie. The GNOME Foundation co-opted GTK and deliberately scupper it for everyone that’s not GNOME (whether on Linux or for other OSes).

So I’m curious whether this sort of patch would be accepted. Assuming reasonable quality of patch, it pretty obviously should be if you want to be a cross-platform toolkit that doesn’t feel massively out of place, but without knowing what position or connections Paul Rouget may have, I’m honestly sceptical that such a patch would be accepted.

Re: GUI development with Rust and GTK 4

#103
I got flashback memories from my days in Obj-c. I love rust but tend to stay away from reference counting as much as possible :). The first example with the two buttons showed my main annoyance with them. They had to decide which closure keeps a strong reference and which one a weak. A refactor later can be a tricky thing because one always needs to double check again if the reference links are still correct. At least with obj-c these errors will only pop up at runtime.

Re: GUI development with Rust and GTK 4

#104
post #98

Earlier quoted context omitted.

Native look and feel is vastly overrated imo. Delphi and before it borland builder made for great UIs despite not looking native. To the point that when I came across that widget set, I knew I was in for a good UX. Still many bespoke interfaces, like at a brakes repair or small lumber yard chain use delphi and it works just fine. As for the webview, thats a thing, but if you will have web access, you can target wasm,…

>Native look and feel is vastly overrated imo. Case in point: Blender has an outstanding GUI toolkit, non-native.

There are a few categories of apps that can get away with non-native look and feel, or even thrive based upon actively doing their own thing in ways that work better for what they are. Blender is a member of such a category. Most things are not.

(Games are the most obvious category. Blender belongs to what I might call 2D/3D design, a category which would include tools like GIMP, Inkscape, FreeCAD, Photoshop, Illustrator, AutoCAD—all ones that can go fairly fully native, but can also benefit from deliberate deviation in both look and feel.)

Re: GUI development with Rust and GTK 4

#105

I got flashback memories from my days in Obj-c. I love rust but tend to stay away from reference counting as much as possible :). The first example with the two buttons showed my main annoyance with them. They had to decide which closure keeps a strong reference and which one a weak. A refactor later can be a tricky thing because one always needs to double check again if the reference links are still correct. At leas…

> At least with obj-c these errors will only pop up at runtime

But it's not a good thing. There's still an error, you're just increasing the chance to miss it.

Re: GUI development with Rust and GTK 4

#106
post #14

Earlier quoted context omitted.

The challenge with egui is the theme. It looks ok, but isn't good enough for a commercial business app for example. Also, I believe it lacks a webview, so if you are in a pinch the only thing you can do is create your own widgets without a way to cheat and embed some web content. I would agree for certain types of apps it may be "good enough" (science, gaming, medical perhaps...anything where the UI is secondary to t…

Native look and feel is vastly overrated imo. Delphi and before it borland builder made for great UIs despite not looking native. To the point that when I came across that widget set, I knew I was in for a good UX. Still many bespoke interfaces, like at a brakes repair or small lumber yard chain use delphi and it works just fine. As for the webview, thats a thing, but if you will have web access, you can target wasm,…

Since you link to the the web demo, I want to caution people: yes, egui can run on the web, but treat that as a demo only done over the web for the convenience of not having to download and run it natively. If you’re making something, do not use egui if you want to actively target the web, because it’s really bad there in fundamentally unfixable ways (given egui’s architecture). Egui is quite compelling on non-web platforms, but it’s not suitable for web content or apps.

More details (including explanation and concrete examples of what’s fundamentally unfixable with egui’s approach to the web, most notably links and scrolling): https://news.ycombinator.com/item?id=33861831

Re: GUI development with Rust and GTK 4

#107

Earlier quoted context omitted.

Qt has supported compilation to web for quite some time now

And when I tried the examples they posted they were massive & laggy.

Yeah, that's the thing that sold me on egui -- the web demo is just buttery smooth, and GPU accelerated.

Re: GUI development with Rust and GTK 4

#108

Earlier quoted context omitted.

The apostrophe isn’t superfluous. ‘Static in this context refers to static lifetime. Lifetimes have absolutely 0 impact on runtime.

How would you get a static lifetime without a static object?

Box::leak() will make a &'static. You can also use lazy_static! to dynamically make a static global constant.

Re: GUI development with Rust and GTK 4

#109

I got flashback memories from my days in Obj-c. I love rust but tend to stay away from reference counting as much as possible :). The first example with the two buttons showed my main annoyance with them. They had to decide which closure keeps a strong reference and which one a weak. A refactor later can be a tricky thing because one always needs to double check again if the reference links are still correct. At leas…

> At least with obj-c these errors will only pop up at runtime But it's not a good thing. There's still an error, you're just increasing the chance to miss it.

No I wanted to imply that I actually don’t know how rust handles this case. I think runtime errors are the worst especially with UI. Even when you have a full integration e2e test suite. I take compile errors over runtime errors any day.

Re: GUI development with Rust and GTK 4

#110
post #57

What about making it easy to import Rust business logic into C# / Swift / whatever GUI language you're using? I get the value of 100% (or 50% or 80%) implementing the UI in Rust; especially for tools that won't benefit from a native UI, or tools that only need light integration into platform-specific UI features. I've also shipped a desktop product that had a 100% native UI and a cross-platform codebase. Today, imple…

This is what I do. Is SUPER productive & easy!

I do ALL the UI logic on Rust: Internationalization, formatting, etc and in SwiftUI/JetpackCompose only pain stuff and send/get a single JSON internal FFI endpoint.

So my "records" are just:

     App:
        {title: "Factura #F10", bg-100:"black", font:"...", ...}
     Data:
        Invoice {total:"$ 1'000.000,00", ...}
my UI logic only deal with "clicks", dispatch & theming.
Post reply on HN