Libove Blog

Personal Blog about anything - mostly programming, cooking and random thoughts

Update: Wahlprogramme Tool

Ich hatte zur letzten Bundestagwahl ein kleines Tool gebaut um die Themen in Wahlprogrammen zu durchsuchen und zu visualisieren.

Mit der anstehenden Wahl wurde es Zeit die neuen Programme einzupflegen. Derzeit sind die meisten Programme nur Entwürfe, lediglich die Union hat schon ein fertiges Wahlprogramm.

Ein kleine Anleitung findet ihr hier: https://blog.libove.org/posts/wahlprogramme/

Der Source Code ist auf GitHub verfügbar: https://github.com/H4kor/wahlprogramme

Erwähnungen der Themen "Klima" und "KI" in den Wahlprogrammen 2025







"Chili" Sin Carne

Servings: 1 großer Topf , Prep Time:

Ingredients

  • 4 Tofuhack
  • 1 große Zucchini
  • 3 Paprika
  • 4 Zwiebeln
  • 8 Knoblauchzehen
  • 3 Lorbeerblätter
  • 4 Dosen Tomatenstücke
  • 4 TL Paprikapulver
  • 2 TL Kreuzkümmel (gemahlen)
  • 2 TL Oregano
  • 1 TL Zwiebelpulver
  • 1 TL gemahlener Pfeffer
  • 2 EL Tomatenmark
  • 1 Liter Gemüsebrühe
  • 500 g Vollkorn Langkornreis
  • 3 Dosen Kidney Bohnen

Instructions

"Chili" sin Carne Rezept für große Mengen zum einfrieren.

  • Zucchini, Paprika und Zwiebeln würfeln
  • Knoblauch hacken
  • Gewürze mischen
  • Tofuhack in Öl anbraten
  • Gemüse hinzufügen und ein paar Minuten mit anbraten
  • Gewürze und Tomatenmark kurz mit anbraten
  • Mit Gemüsebrühe ablöschen und Tomatenstücke hinzufügen
  • Kidney Bohnen und Reis hinzufügen
  • ~40 Minuten köcheln lassen bis Reis gar ist. Wasser hinzufügen falls nötig

#vegan #chili


owl-blogs 0.3.2

I've worked on some smaller features and improvements for owl-blogs.

Main Features:

  • Lists and Tags now have RSS Feeds.
  • Nicer 404 Pages

For development I took the time to setup the "end-to-end" tests using go test instead of the previous pytest setup. This vastly simplifies testing and its much quicker.

To test #ActivityPub functionality I use a small mock server, which content can be controlled during testing.

#owlblogs



Rust GTK: Button with Custom Icon with gtk-rs using Embedded Images

This guide is written fro gtk-rs and GTK 4.6

For my DungeonPlanner project I wanted to use custom icons for the tool buttons. Unfortunately the documentation for this is rather slim. As an additional constraint, the image data should be embedded in the binary as I like to compile and ship a single binary file (as long as this is possible).

Resulting tool bar in DungeonPlanner with custom icons

The nearest approach I could find was to create buttons with downloaded images. The snippet is for GTK3 so it had to be adjusted for GTK4, but it contained the right function names to know what to search for :).

This is the final code I ended up with:

let button = Button::new();
let bytes = include_bytes!("../../assets/icons/add_chamber.png");
let g_bytes = glib::Bytes::from(&bytes.to_vec());
let stream = MemoryInputStream::from_bytes(&g_bytes);
let pixbuf = Pixbuf::from_stream(&stream, Cancellable::NONE).unwrap();
let texture = Texture::for_pixbuf(&pixbuf);
let image = Image::from_paintable(Some(&texture));
button.set_child(Some(&image));

We start by creating a button. Instead of using the ButtonBuilder as you would normally do, I'm just creating an "empty" button. It should be possible to still use the builder, as we are just replacing the child content at the end.

let button = Button::new();

Next we need to load our image data. As I want my images to be embedded in the binary I use the include_bytes! macro. The raw bytes are then turned into a glib:Bytes struct and finally into a MemoryInputStream. The stream is needed to parse the image data.

let bytes = include_bytes!("../../assets/icons/add_chamber.png");
let g_bytes = glib::Bytes::from(&bytes.to_vec());
let stream = MemoryInputStream::from_bytes(&g_bytes);

The next goal is to create an Image object containing our embedded image. With GTK 4.6 we could still use Image::from_pixbuf but this will be deprecated in GTK 4.12. Instead we have to do an extra step and create a Texture and use Image::from_paintable. The texture can simply be created from a Pixbuf, which is created by using the Pixbuf::from_stream function

let pixbuf = Pixbuf::from_stream(&stream, Cancellable::NONE).unwrap();
let texture = Texture::for_pixbuf(&pixbuf);
let image = Image::from_paintable(Some(&texture));

Finally we can set the child of our button to the image and our icon button is done. The same approach also works for ToggleButton.

button.set_child(Some(&image));

#gtk #gtk4 #rust #gtkrs