diff options
author | fiaxh <git@lightrise.org> | 2022-10-11 17:50:54 +0200 |
---|---|---|
committer | fiaxh <git@lightrise.org> | 2022-10-11 17:50:54 +0200 |
commit | 11b6e615b73e4183a06f9d456634c44ead612336 (patch) | |
tree | 0c69a48b40ce850eb4ee676769a10a62d3ab9182 /main/src/ui/util | |
parent | 80258a874ddfeb87b4b71f5791eab94a2465de6d (diff) | |
download | dino-11b6e615b73e4183a06f9d456634c44ead612336.tar.gz dino-11b6e615b73e4183a06f9d456634c44ead612336.zip |
Don't require use of MenuButton.set_child introduced with GTK 4.6
Diffstat (limited to 'main/src/ui/util')
-rw-r--r-- | main/src/ui/util/helper.vala | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/main/src/ui/util/helper.vala b/main/src/ui/util/helper.vala index df7438b1..0f0fc605 100644 --- a/main/src/ui/util/helper.vala +++ b/main/src/ui/util/helper.vala @@ -452,4 +452,19 @@ public bool use_tooltips() { return Gtk.MINOR_VERSION != 6 || (Gtk.MICRO_VERSION < 4 || Gtk.MICRO_VERSION > 6); } +public static void menu_button_set_icon_with_size(MenuButton menu_button, string icon_name, int pixel_size) { +#if GTK_4_6 + menu_button.set_child(new Image.from_icon_name(icon_name) { pixel_size=pixel_size }); +#else + menu_button.set_icon_name(icon_name); + var button = menu_button.get_first_child() as Button; + if (button == null) return; + var box = button.child as Box; + if (box == null) return; + var image = box.get_first_child() as Image; + if (image == null) return; + image.pixel_size = pixel_size; +#endif +} + } |