+GdkPixbuf *CreateThemeIcon(const char *iconname, int size)
+{
+ return gtk_icon_theme_load_icon
+ (
+ gtk_icon_theme_get_default(),
+ iconname,
+ size,
+ (GtkIconLookupFlags)0,
+ NULL
+ );
+}
+
+
+// creates either stock or theme icon
+GdkPixbuf *CreateGtkIcon(const char *icon_name,
+ GtkIconSize stock_size, const wxSize& pixel_size)
+{
+ // try stock GTK+ icon first
+ GdkPixbuf *pixbuf = CreateStockIcon(icon_name, stock_size);
+ if ( pixbuf )
+ return pixbuf;
+
+ // if that fails, try theme icon
+ wxSize size(pixel_size);
+ if ( pixel_size == wxDefaultSize )
+ gtk_icon_size_lookup(stock_size, &size.x, &size.y);
+ return CreateThemeIcon(icon_name, size.x);
+}
+
+template<typename SizeType, typename LoaderFunc>
+wxIconBundle DoCreateIconBundle(const char *stockid,
+ const SizeType *sizes_from,
+ const SizeType *sizes_to,
+ LoaderFunc get_icon)
+
+{
+ wxIconBundle bundle;
+
+ for ( const SizeType *i = sizes_from; i != sizes_to; ++i )
+ {
+ GdkPixbuf *pixbuf = get_icon(stockid, *i);
+ if ( !pixbuf )
+ continue;
+
+ wxIcon icon;
+ icon.SetPixbuf(pixbuf);
+ bundle.AddIcon(icon);
+ }
+
+ return bundle;
+}
+
+} // anonymous namespace
+
+wxBitmap wxGTK2ArtProvider::CreateBitmap(const wxArtID& id,
+ const wxArtClient& client,
+ const wxSize& size)
+{
+ const wxString stockid = wxArtIDToStock(id);
+
+ GtkIconSize stocksize = (size == wxDefaultSize) ?
+ ArtClientToIconSize(client) :
+ FindClosestIconSize(size);
+ // we must have some size, this is arbitrary
+ if (stocksize == GTK_ICON_SIZE_INVALID)
+ stocksize = GTK_ICON_SIZE_BUTTON;
+
+ GdkPixbuf *pixbuf = CreateGtkIcon(stockid.utf8_str(), stocksize, size);