Bringing Desktop Apps Back with GTK+ (and Go!)

 Holiday Season 2020

Desktop Apps using GTK+

Given my enthusiasm with making phone apps with first React Native, then Flutter on Dart, I couldn't help but reminisce about making my first desktop apps - crude calculators using copy/pasted HWindow structure in C++ or a Java applet. It made me realize how much one guy could do in the new world of networked computers. Silly, I know, to look back on that in the modern days of "no code" apps and cheap offshore code farms.

Anyway, I wanted to try it again. Earlier I've written about the joys of WebAssembly coding in Rust. So during the slow holiday daze, I wrote a simple typing app with Rust that looks like this:


You click the options on top like so:

The purpose is to be able to write in different script formats, so currently the challenge is to switch indent lengths from paragraph to paragraph with the touch of the right keyboard commands. It also needs to have a better text entry input with word wrap; it doesn't do that by default!

For the top option selection, I was going for radio buttons, but that seems to be outre? Given the lack of guidance online regarding how to do it.

I used GTK+. Why? Why not?! Qt seems to be an excellent premium IDE, maybe I'll try that later when I'm making enough to justify over $200 a month on an IDE. 

Besides, when you're (re-)starting your career, it's vital to really understand how code works on the molecular level. And the only way to do that is to do things as manually as possible...which is why low-level languages like Rust or C++ are essential to learn, if only to just try stuff.

I might Github this if that's something that will be beneficial to anyone, but just one quick pointer: unwrap() is a powerful tool.

As in:

let style_menu = ComboBoxText::new();

(add options with append_text(), and then)

let format_style = style_menu.get_active_text().unwrap();
match format_style.as_ref() {    /* switch options here*/}

In case you were wondering how to solve that particular riddle. I only got it by spending quite a lot of time here, on the many Githubs of apps that have been created with this marvelous framework already. Scroll down for all the help you could want.

Also, you know what I like about Rust? The compiler errors are really useful. They actually tell you what code to use instead of the command you're ill-advisedly sticking in there. Bless them for that. The docs.rs documentation is OK, too. It doesn't help you like the cookbooks provided by GTK+ or rustwasm do, but again, when you're starting out, you need to see how far you can walk before you crash. And whine about crashing.

Not that I've ever done that...

Desktop apps are important in the office (wherever that may be these days). Mobile app creation frameworks like Dart or AppSheet (which is still kind of limited, but has potential) can adapt to both mobile and desktop hardware, which is why they're going to be vital to know in 2021+. 

ETA And Go! I like Webview with Go for making desktop apps. Or this interesting package which is ready to build to mobile, too.

So knowing this stuff can make a huge difference in your coding career.

What are you going to make today?

Comments

Popular Posts