Avoid stock icon functions with GTK+4
Only theme lookup is available
This commit is contained in:
@@ -205,6 +205,7 @@ GtkIconSize FindClosestIconSize(const wxSize& size)
|
|||||||
return best;
|
return best;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifndef __WXGTK4__
|
||||||
GdkPixbuf *CreateStockIcon(const char *stockid, GtkIconSize size)
|
GdkPixbuf *CreateStockIcon(const char *stockid, GtkIconSize size)
|
||||||
{
|
{
|
||||||
// FIXME: This code is not 100% correct, because stock pixmap are
|
// FIXME: This code is not 100% correct, because stock pixmap are
|
||||||
@@ -217,12 +218,14 @@ GdkPixbuf *CreateStockIcon(const char *stockid, GtkIconSize size)
|
|||||||
|
|
||||||
GtkWidget* widget = wxGTKPrivate::GetButtonWidget();
|
GtkWidget* widget = wxGTKPrivate::GetButtonWidget();
|
||||||
#ifdef __WXGTK3__
|
#ifdef __WXGTK3__
|
||||||
|
wxGCC_WARNING_SUPPRESS(deprecated-declarations)
|
||||||
GtkStyleContext* sc = gtk_widget_get_style_context(widget);
|
GtkStyleContext* sc = gtk_widget_get_style_context(widget);
|
||||||
GtkIconSet* iconset = gtk_style_context_lookup_icon_set(sc, stockid);
|
GtkIconSet* iconset = gtk_style_context_lookup_icon_set(sc, stockid);
|
||||||
GdkPixbuf* pixbuf = NULL;
|
GdkPixbuf* pixbuf = NULL;
|
||||||
if (iconset)
|
if (iconset)
|
||||||
pixbuf = gtk_icon_set_render_icon_pixbuf(iconset, sc, size);
|
pixbuf = gtk_icon_set_render_icon_pixbuf(iconset, sc, size);
|
||||||
return pixbuf;
|
return pixbuf;
|
||||||
|
wxGCC_WARNING_RESTORE()
|
||||||
#else
|
#else
|
||||||
GtkStyle* style = gtk_widget_get_style(widget);
|
GtkStyle* style = gtk_widget_get_style(widget);
|
||||||
GtkIconSet* iconset = gtk_style_lookup_icon_set(style, stockid);
|
GtkIconSet* iconset = gtk_style_lookup_icon_set(style, stockid);
|
||||||
@@ -235,6 +238,7 @@ GdkPixbuf *CreateStockIcon(const char *stockid, GtkIconSize size)
|
|||||||
GTK_STATE_NORMAL, size, NULL, NULL);
|
GTK_STATE_NORMAL, size, NULL, NULL);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
#endif // !__WXGTK4__
|
||||||
|
|
||||||
GdkPixbuf *CreateThemeIcon(const char *iconname, int size)
|
GdkPixbuf *CreateThemeIcon(const char *iconname, int size)
|
||||||
{
|
{
|
||||||
@@ -253,10 +257,12 @@ GdkPixbuf *CreateThemeIcon(const char *iconname, int size)
|
|||||||
GdkPixbuf *CreateGtkIcon(const char *icon_name,
|
GdkPixbuf *CreateGtkIcon(const char *icon_name,
|
||||||
GtkIconSize stock_size, const wxSize& pixel_size)
|
GtkIconSize stock_size, const wxSize& pixel_size)
|
||||||
{
|
{
|
||||||
|
#ifndef __WXGTK4__
|
||||||
// try stock GTK+ icon first
|
// try stock GTK+ icon first
|
||||||
GdkPixbuf *pixbuf = CreateStockIcon(icon_name, stock_size);
|
GdkPixbuf *pixbuf = CreateStockIcon(icon_name, stock_size);
|
||||||
if ( pixbuf )
|
if ( pixbuf )
|
||||||
return pixbuf;
|
return pixbuf;
|
||||||
|
#endif
|
||||||
|
|
||||||
// if that fails, try theme icon
|
// if that fails, try theme icon
|
||||||
wxSize size(pixel_size);
|
wxSize size(pixel_size);
|
||||||
@@ -328,6 +334,8 @@ wxGTK2ArtProvider::CreateIconBundle(const wxArtID& id,
|
|||||||
wxIconBundle bundle;
|
wxIconBundle bundle;
|
||||||
const wxString stockid = wxArtIDToStock(id);
|
const wxString stockid = wxArtIDToStock(id);
|
||||||
|
|
||||||
|
#ifndef __WXGTK4__
|
||||||
|
wxGCC_WARNING_SUPPRESS(deprecated-declarations)
|
||||||
// try to load the bundle as stock icon first
|
// try to load the bundle as stock icon first
|
||||||
GtkWidget* widget = wxGTKPrivate::GetButtonWidget();
|
GtkWidget* widget = wxGTKPrivate::GetButtonWidget();
|
||||||
#ifdef __WXGTK3__
|
#ifdef __WXGTK3__
|
||||||
@@ -351,6 +359,8 @@ wxGTK2ArtProvider::CreateIconBundle(const wxArtID& id,
|
|||||||
g_free(sizes);
|
g_free(sizes);
|
||||||
return bundle;
|
return bundle;
|
||||||
}
|
}
|
||||||
|
wxGCC_WARNING_RESTORE()
|
||||||
|
#endif // !__WXGTK4__
|
||||||
|
|
||||||
// otherwise try icon themes
|
// otherwise try icon themes
|
||||||
gint *sizes = gtk_icon_theme_get_icon_sizes
|
gint *sizes = gtk_icon_theme_get_icon_sizes
|
||||||
|
Reference in New Issue
Block a user