vcl/unx/gtk3/gtkinst.cxx | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+)
New commits: commit d16d5b0dfdd43d6dfcf8caffaede6f5cfe22af29 Author: Caolán McNamara <caol...@redhat.com> AuthorDate: Thu Sep 16 13:03:29 2021 +0100 Commit: Caolán McNamara <caol...@redhat.com> CommitDate: Thu Sep 16 16:28:02 2021 +0200 gtk4: use gtk_menu_button_set_child when available to fill in icon Change-Id: I3da421969cf1775cbf0072bf94891d883a96b70e Reviewed-on: https://gerrit.libreoffice.org/c/core/+/122193 Tested-by: Jenkins Reviewed-by: Caolán McNamara <caol...@redhat.com> diff --git a/vcl/unx/gtk3/gtkinst.cxx b/vcl/unx/gtk3/gtkinst.cxx index 9cdbac410f31..13e441fe58f8 100644 --- a/vcl/unx/gtk3/gtkinst.cxx +++ b/vcl/unx/gtk3/gtkinst.cxx @@ -21758,6 +21758,29 @@ private: } } } + else if (GTK_IS_MENU_BUTTON(pWidget)) + { + GtkMenuButton* pButton = GTK_MENU_BUTTON(pWidget); + if (const gchar* icon_name = gtk_menu_button_get_icon_name(pButton)) + { + OUString aIconName(icon_name, strlen(icon_name), RTL_TEXTENCODING_UTF8); + if (!IsAllowedBuiltInIcon(aIconName)) + { + if (GdkPixbuf* pixbuf = load_icon_by_name_theme_lang(aIconName, m_aIconTheme, m_aUILang)) + { + GtkWidget* pImage = gtk_image_new_from_pixbuf(pixbuf); + gtk_widget_set_halign(pImage, GTK_ALIGN_CENTER); + gtk_widget_set_valign(pImage, GTK_ALIGN_CENTER); + g_object_unref(pixbuf); + // TODO after gtk 4.6 is released require that version and drop this + static auto menu_button_set_child = reinterpret_cast<void (*) (GtkMenuButton*, GtkWidget*)>(dlsym(nullptr, "gtk_menu_button_set_child")); + if (menu_button_set_child) + menu_button_set_child(pButton, pImage); + gtk_widget_show(pImage); + } + } + } + } #endif //set helpids