From d6afa6e8ff4cfb533140d9434b83f18f627f11ca Mon Sep 17 00:00:00 2001 From: Marvin W Date: Sun, 21 Aug 2022 00:57:03 +0200 Subject: GTK4: Don't require use of MenuButton.set_child introduced with 4.6 --- main/src/ui/call_window/call_bottom_bar.vala | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) (limited to 'main/src/ui/call_window') diff --git a/main/src/ui/call_window/call_bottom_bar.vala b/main/src/ui/call_window/call_bottom_bar.vala index c30a86e9..aa318a45 100644 --- a/main/src/ui/call_window/call_bottom_bar.vala +++ b/main/src/ui/call_window/call_bottom_bar.vala @@ -37,7 +37,7 @@ public class Dino.Ui.CallBottomBar : Gtk.Box { audio_button.margin_end = audio_button.margin_bottom = 5; // space for the small settings button audio_button_overlay.set_child(audio_button); audio_button_overlay.add_overlay(audio_settings_button); - audio_settings_button.set_child(new Image.from_icon_name("go-up-symbolic") { pixel_size=10 }); + menu_button_set_icon_with_size(audio_settings_button, "go-up-symbolic", 10); audio_settings_button.add_css_class("call-mediadevice-settings-button"); main_buttons.append(audio_button_overlay); @@ -47,7 +47,7 @@ public class Dino.Ui.CallBottomBar : Gtk.Box { video_button.margin_end = video_button.margin_bottom = 5; video_button_overlay.set_child(video_button); video_button_overlay.add_overlay(video_settings_button); - video_settings_button.set_child(new Image.from_icon_name("go-up-symbolic") { pixel_size=10 }); + menu_button_set_icon_with_size(video_settings_button, "go-up-symbolic", 10); video_settings_button.add_css_class("call-mediadevice-settings-button"); main_buttons.append(video_button_overlay); @@ -76,6 +76,21 @@ public class Dino.Ui.CallBottomBar : Gtk.Box { this.add_css_class("call-bottom-bar"); } + private 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 + } + public AudioSettingsPopover? show_audio_device_choices(bool show) { audio_settings_button.visible = show; if (audio_settings_popover != null) audio_settings_popover.visible = false; -- cgit v1.2.3-70-g09d2