-- Leo's gemini proxy

-- Connecting to blog.schmidhuberj.de:1965...

-- Connected

-- Sending request

-- Meta line: 20 text/gemini

Writing a GTK application in one week.

Posted on 2022-03-14


I have decided to write another GTK application in Rust, this time I am progressing extremely fast.


Note that this post goes on for probably way to long, probably including too much unnecessary things. The tldr is: I was busy and very productive this week.


Background


I have a PinePhone, and I really like it. Since I got it, I some day wanted to daily-drive it as my main smartphone, but there was some software still missing:


YouTube

Signal

Some application to manage journeys with trains (hard to describe in English, but basically "DB Navigator" in Germany)

More recently: Covid Pass


I already have made a YouTube-Client in the time I had the PinePhone, called Tubefeeder, which I use daily, so this is no problem. I hoped that someone smarted than me would come up with a good Signal-Application, but as far as I saw, there are no perfect candidates yet (yes, I know Axolotl, but I want my application to act as a secondary, not primary device). This lead me to today, where I am currently making a application for railway travel.


Finding the REST-API


Belive it or not, this was actually the hardest part in developing the application, I spend many hours just searching for the right API (and I am still not sure if this is official or not). Just searching for something like "deutsche bahn REST" will lead to something like:


REST-APIs provided by DB


There are only some REST-APIs, none of them really interesting, for example regarding parking spaces. Searching around more, one may find:


DB-python


The person seems to have reverse-engineered the "DB Navigator" android application. But as it way Python and outdated, it was not really interesting. Looking at one of the issues results in:


DB-Hafas


Hafas? What is that. It seems to be exactly what I am looking for, giving me real-time data about the trains. But this is JavaScript, so also not really useful. They have to provide some REST-API, where is it? Searching for "Hafas" results in a great list of Hafas endpoints:


List of Hafas API Endpoints


Looking at a few URLs in the browser, these are all websites and not APIs. Even trying to CURL them asking explicitly for JSON results in HTML. More searching is required. Digging deeper, I finally found it:


DB-Rest


A JavaScript library getting data from:


https://v5.db.transport.rest/


Finally.


REST-Wrapper


After I finally found what I was looking for, I searched for a crate that would simplify the creation of the REST client. I found one, but it was very much out of date and unmaintained. So I programming my own REST client application that I am totally willing to maintain for the next ten years (sarcasm if you have not notices).


Rust REST Wrapper (rrw)


It really was not that hard to implement, and with the help of some macros, the next step will be very easy to implement.


Hafas-Client


After rrw was at a usable state, I started to implement my not-yet-published client application for the Hafas API. This was, thanks to the previous step, really easy to do.


The Application


Now that the basis for the application was finished, the work on the actual GTK-application can begin. This was a little bit harder than the previous steps, but still manageable. Once you get used to GTK (which I already was thanks to afore mentioned YouTube client), it is really easy to actually write the application. Oh, and did I mention that is I also fully translated it already?


Parallel to that, I already started to package it as a Flatpak, which for no reason was way harder and with many more hurdles as it should have been.


I have not yet published the application, it still needs small things like error handling, but it will likely happen within the next few days. This means (depending on how you count) that I made the GTK-application in a week (or maybe a little more than a week).


Conclusion


I was very productive this week. If I keep being so productive, I might even try to write a Signal-GTK client before university continues. But I will not promise anything.



Return to home

-- Response ended

-- Page fetched on Mon May 13 09:48:21 2024