]> git.saurik.com Git - wxWidgets.git/blobdiff - src/gtk/artgtk.cpp
Disable wxUSE_ENH_METAFILE for wxGTK builds.
[wxWidgets.git] / src / gtk / artgtk.cpp
index db029ddb178810e50a71a035722137ed590531fe..b29c33dda5b1da86a8e5e2212e8cab09fcf25ccc 100644 (file)
@@ -1,5 +1,5 @@
 /////////////////////////////////////////////////////////////////////////////
-// Name:        src/gtk/artstd.cpp
+// Name:        src/gtk/artgtk.cpp
 // Purpose:     stock wxArtProvider instance with native GTK+ stock icons
 // Author:      Vaclav Slavik
 // Modified by:
@@ -21,6 +21,8 @@
 #endif
 
 #include "wx/artprov.h"
+
+#include <gtk/gtk.h>
 #include "wx/gtk/private.h"
 
 // compatibility with older GTK+ versions:
@@ -47,7 +49,7 @@ protected:
 
 /*static*/ void wxArtProvider::InitNativeProvider()
 {
-    Push(new wxGTK2ArtProvider);
+    PushBack(new wxGTK2ArtProvider);
 }
 
 // ----------------------------------------------------------------------------
@@ -81,6 +83,8 @@ wxString wxArtIDToStock(const wxArtID& id)
     ART(wxART_GO_DOWN,                             GTK_STOCK_GO_DOWN)
     ART(wxART_GO_TO_PARENT,                        GTK_STOCK_GO_UP)
     ART(wxART_GO_HOME,                             GTK_STOCK_HOME)
+    ART(wxART_GOTO_FIRST,                          GTK_STOCK_GOTO_FIRST)
+    ART(wxART_GOTO_LAST,                           GTK_STOCK_GOTO_LAST)
     ART(wxART_FILE_OPEN,                           GTK_STOCK_OPEN)
     ART(wxART_PRINT,                               GTK_STOCK_PRINT)
     ART(wxART_HELP,                                GTK_STOCK_HELP)
@@ -113,6 +117,10 @@ wxString wxArtIDToStock(const wxArtID& id)
     ART(wxART_UNDO,                                GTK_STOCK_UNDO)
     ART(wxART_REDO,                                GTK_STOCK_REDO)
 
+    ART(wxART_PLUS,                                GTK_STOCK_ADD)
+    ART(wxART_MINUS,                               GTK_STOCK_REMOVE)
+
+    ART(wxART_CLOSE,                               GTK_STOCK_CLOSE)
     ART(wxART_QUIT,                                GTK_STOCK_QUIT)
 
     ART(wxART_FIND,                                GTK_STOCK_FIND)
@@ -197,7 +205,16 @@ GdkPixbuf *CreateStockIcon(const char *stockid, GtkIconSize size)
     //        with "stock-id" representation (in addition to pixmap and pixbuf
     //        ones) and would convert it to pixbuf when rendered.
 
-    GtkStyle* style = wxGTKPrivate::GetButtonWidget()->style;
+    GtkWidget* widget = wxGTKPrivate::GetButtonWidget();
+#ifdef __WXGTK3__
+    GtkStyleContext* sc = gtk_widget_get_style_context(widget);
+    GtkIconSet* iconset = gtk_style_context_lookup_icon_set(sc, stockid);
+    GdkPixbuf* pixbuf = NULL;
+    if (iconset)
+        pixbuf = gtk_icon_set_render_icon_pixbuf(iconset, sc, size);
+    return pixbuf;
+#else
+    GtkStyle* style = gtk_widget_get_style(widget);
     GtkIconSet* iconset = gtk_style_lookup_icon_set(style, stockid);
 
     if (!iconset)
@@ -206,6 +223,7 @@ GdkPixbuf *CreateStockIcon(const char *stockid, GtkIconSize size)
     return gtk_icon_set_render_icon(iconset, style,
                                     gtk_widget_get_default_direction(),
                                     GTK_STATE_NORMAL, size, NULL, NULL);
+#endif
 }
 
 GdkPixbuf *CreateThemeIcon(const char *iconname, int size)
@@ -253,7 +271,7 @@ wxIconBundle DoCreateIconBundle(const char *stockid,
             continue;
 
         wxIcon icon;
-        icon.SetPixbuf(pixbuf);
+        icon.CopyFromBitmap(wxBitmap(pixbuf));
         bundle.AddIcon(icon);
     }
 
@@ -290,28 +308,31 @@ wxBitmap wxGTK2ArtProvider::CreateBitmap(const wxArtID& id,
         }
     }
 
-    wxBitmap bmp;
-    if (pixbuf != NULL)
-        bmp.SetPixbuf(pixbuf);
-
-    return bmp;
+    return wxBitmap(pixbuf);
 }
 
 wxIconBundle
 wxGTK2ArtProvider::CreateIconBundle(const wxArtID& id,
                                     const wxArtClient& WXUNUSED(client))
 {
+    wxIconBundle bundle;
     const wxString stockid = wxArtIDToStock(id);
 
     // try to load the bundle as stock icon first
-    GtkStyle* style = wxGTKPrivate::GetButtonWidget()->style;
+    GtkWidget* widget = wxGTKPrivate::GetButtonWidget();
+#ifdef __WXGTK3__
+    GtkStyleContext* sc = gtk_widget_get_style_context(widget);
+    GtkIconSet* iconset = gtk_style_context_lookup_icon_set(sc, stockid.utf8_str());
+#else
+    GtkStyle* style = gtk_widget_get_style(widget);
     GtkIconSet* iconset = gtk_style_lookup_icon_set(style, stockid.utf8_str());
+#endif
     if ( iconset )
     {
         GtkIconSize *sizes;
         gint n_sizes;
         gtk_icon_set_get_sizes(iconset, &sizes, &n_sizes);
-        wxIconBundle bundle = DoCreateIconBundle
+        bundle = DoCreateIconBundle
                               (
                                   stockid.utf8_str(),
                                   sizes, sizes + n_sizes,
@@ -322,33 +343,27 @@ wxGTK2ArtProvider::CreateIconBundle(const wxArtID& id,
     }
 
     // otherwise try icon themes
-#ifdef __WXGTK26__
-    if ( !gtk_check_version(2,6,0) )
-    {
-        gint *sizes = gtk_icon_theme_get_icon_sizes
-                      (
-                          gtk_icon_theme_get_default(),
-                          stockid.utf8_str()
-                      );
-        if ( !sizes )
-            return wxNullIconBundle;
-
-        gint *last = sizes;
-        while ( *last )
-            last++;
-
-        wxIconBundle bundle = DoCreateIconBundle
-                              (
-                                  stockid.utf8_str(),
-                                  sizes, last,
-                                  &CreateThemeIcon
-                              );
-        g_free(sizes);
+    gint *sizes = gtk_icon_theme_get_icon_sizes
+                  (
+                      gtk_icon_theme_get_default(),
+                      stockid.utf8_str()
+                  );
+    if ( !sizes )
         return bundle;
-    }
-#endif // __WXGTK26__
 
-    return wxNullIconBundle;
+    gint *last = sizes;
+    while ( *last )
+        last++;
+
+    bundle = DoCreateIconBundle
+                          (
+                              stockid.utf8_str(),
+                              sizes, last,
+                              &CreateThemeIcon
+                          );
+    g_free(sizes);
+
+    return bundle;
 }
 
 // ----------------------------------------------------------------------------