X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/3fe39b0ce3c0f47faea34ef99c3d0260957cc4e0..e83e16de9e00a596b06d9c970039fd4fbfbfe703:/src/gtk/artgtk.cpp diff --git a/src/gtk/artgtk.cpp b/src/gtk/artgtk.cpp index f1de4e0951..07d8f4cf4c 100644 --- a/src/gtk/artgtk.cpp +++ b/src/gtk/artgtk.cpp @@ -1,5 +1,5 @@ ///////////////////////////////////////////////////////////////////////////// -// Name: artstd.cpp +// Name: src/gtk/artstd.cpp // Purpose: stock wxArtProvider instance with native GTK+ stock icons // Author: Vaclav Slavik // Modified by: @@ -20,12 +20,19 @@ #pragma hdrstop #endif -#if defined(__WXGTK20__) && !defined(__WXUNIVERSAL__) +#if !defined(__WXUNIVERSAL__) #include "wx/artprov.h" -#include "wx/module.h" -#include "wx/gtk/private.h" +#ifndef WX_PRECOMP + #include "wx/module.h" +#endif + +#include +#if GTK_CHECK_VERSION(2, 9, 0) + // gtk_object_sink + #undef GTK_DISABLE_DEPRECATED +#endif #include // compatibility with older GTK+ versions: @@ -50,7 +57,7 @@ protected: /*static*/ void wxArtProvider::InitNativeProvider() { - wxArtProvider::PushProvider(new wxGTK2ArtProvider); + Push(new wxGTK2ArtProvider); } // ---------------------------------------------------------------------------- @@ -175,7 +182,7 @@ static GtkIconSize FindClosestIconSize(const wxSize& size) if (size.x > s_sizes[i].x || size.y > s_sizes[i].y) continue; - unsigned dist = (size.x - s_sizes[i].x) * (size.x - s_sizes[i].x) + + unsigned dist = (size.x - s_sizes[i].x) * (size.x - s_sizes[i].x) + (size.y - s_sizes[i].y) * (size.y - s_sizes[i].y); if (dist == 0) return s_sizes[i].icon; @@ -207,7 +214,7 @@ static GdkPixbuf *CreateStockIcon(const char *stockid, GtkIconSize size) gs_gtkStyle = gtk_rc_get_style(widget); wxASSERT( gs_gtkStyle != NULL ); g_object_ref(gs_gtkStyle); - gtk_widget_destroy(widget); + gtk_object_sink((GtkObject*)widget); } GtkIconSet *iconset = gtk_style_lookup_icon_set(gs_gtkStyle, stockid); @@ -258,10 +265,9 @@ wxBitmap wxGTK2ArtProvider::CreateBitmap(const wxArtID& id, GdkPixbuf *pixbuf = CreateStockIcon(stockid, stocksize); #ifdef __WXGTK24__ - if (!gtk_check_version(2,4,0)) + if (!pixbuf && !gtk_check_version(2,4,0)) { - if (!pixbuf) - pixbuf = CreateThemeIcon(stockid, stocksize, size); + pixbuf = CreateThemeIcon(stockid, stocksize, size); } #endif @@ -278,13 +284,9 @@ wxBitmap wxGTK2ArtProvider::CreateBitmap(const wxArtID& id, } } - if (!pixbuf) - return wxNullBitmap; - wxBitmap bmp; - bmp.SetWidth(gdk_pixbuf_get_width(pixbuf)); - bmp.SetHeight(gdk_pixbuf_get_height(pixbuf)); - bmp.SetPixbuf(pixbuf); + if (pixbuf != NULL) + bmp.SetPixbuf(pixbuf); return bmp; } @@ -311,4 +313,4 @@ public: IMPLEMENT_DYNAMIC_CLASS(wxArtGtkModule, wxModule) -#endif // defined(__WXGTK20__) && !defined(__WXUNIVERSAL__) +#endif // !defined(__WXUNIVERSAL__)