]> git.saurik.com Git - wxWidgets.git/blobdiff - src/gtk/artgtk.cpp
fix warnings about unreachable return statements
[wxWidgets.git] / src / gtk / artgtk.cpp
index 33718756eaa4f0a43059d777f3e623b17e751a4a..c90d9609cbde5c5893f1c4ee7c3325062c5c1356 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:
@@ -47,7 +47,7 @@ protected:
 
 /*static*/ void wxArtProvider::InitNativeProvider()
 {
-    Push(new wxGTK2ArtProvider);
+    PushBack(new wxGTK2ArtProvider);
 }
 
 // ----------------------------------------------------------------------------
@@ -57,10 +57,10 @@ protected:
 namespace
 {
 
-const wxScopedCharBuffer wxArtIDToStock(const wxArtID& id)
+wxString wxArtIDToStock(const wxArtID& id)
 {
     #define ART(wxid, gtkid) \
-           if (id == wxid) return wxScopedCharBuffer::CreateNonOwned(gtkid);
+           if (id == wxid) return gtkid;
 
     ART(wxART_ERROR,                               GTK_STOCK_DIALOG_ERROR)
     ART(wxART_INFORMATION,                         GTK_STOCK_DIALOG_INFO)
@@ -81,6 +81,8 @@ const wxScopedCharBuffer 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 +115,10 @@ const wxScopedCharBuffer 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)
@@ -123,7 +129,7 @@ const wxScopedCharBuffer wxArtIDToStock(const wxArtID& id)
     // allow passing GTK+ stock IDs to wxArtProvider -- if a recognized wx
     // ID wasn't found, pass it to GTK+ in the hope it is a GTK+ or theme
     // icon name:
-    return id.mb_str();
+    return id;
 }
 
 GtkIconSize ArtClientToIconSize(const wxArtClient& client)
@@ -197,7 +203,7 @@ 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;
+    GtkStyle* style = gtk_widget_get_style(wxGTKPrivate::GetButtonWidget());
     GtkIconSet* iconset = gtk_style_lookup_icon_set(style, stockid);
 
     if (!iconset)
@@ -253,7 +259,7 @@ wxIconBundle DoCreateIconBundle(const char *stockid,
             continue;
 
         wxIcon icon;
-        icon.SetPixbuf(pixbuf);
+        icon.CopyFromBitmap(wxBitmap(pixbuf));
         bundle.AddIcon(icon);
     }
 
@@ -266,7 +272,7 @@ wxBitmap wxGTK2ArtProvider::CreateBitmap(const wxArtID& id,
                                          const wxArtClient& client,
                                          const wxSize& size)
 {
-    const wxScopedCharBuffer stockid = wxArtIDToStock(id);
+    const wxString stockid = wxArtIDToStock(id);
 
     GtkIconSize stocksize = (size == wxDefaultSize) ?
                                 ArtClientToIconSize(client) :
@@ -275,7 +281,7 @@ wxBitmap wxGTK2ArtProvider::CreateBitmap(const wxArtID& id,
     if (stocksize == GTK_ICON_SIZE_INVALID)
         stocksize = GTK_ICON_SIZE_BUTTON;
 
-    GdkPixbuf *pixbuf = CreateGtkIcon(stockid, stocksize, size);
+    GdkPixbuf *pixbuf = CreateGtkIcon(stockid.utf8_str(), stocksize, size);
 
     if (pixbuf && size != wxDefaultSize &&
         (size.x != gdk_pixbuf_get_width(pixbuf) ||
@@ -290,22 +296,18 @@ 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))
 {
-    const wxScopedCharBuffer stockid = wxArtIDToStock(id);
+    const wxString stockid = wxArtIDToStock(id);
 
     // try to load the bundle as stock icon first
-    GtkStyle* style = wxGTKPrivate::GetButtonWidget()->style;
-    GtkIconSet* iconset = gtk_style_lookup_icon_set(style, stockid);
+    GtkStyle* style = gtk_widget_get_style(wxGTKPrivate::GetButtonWidget());
+    GtkIconSet* iconset = gtk_style_lookup_icon_set(style, stockid.utf8_str());
     if ( iconset )
     {
         GtkIconSize *sizes;
@@ -313,7 +315,7 @@ wxGTK2ArtProvider::CreateIconBundle(const wxArtID& id,
         gtk_icon_set_get_sizes(iconset, &sizes, &n_sizes);
         wxIconBundle bundle = DoCreateIconBundle
                               (
-                                  stockid,
+                                  stockid.utf8_str(),
                                   sizes, sizes + n_sizes,
                                   &CreateStockIcon
                               );
@@ -328,7 +330,7 @@ wxGTK2ArtProvider::CreateIconBundle(const wxArtID& id,
         gint *sizes = gtk_icon_theme_get_icon_sizes
                       (
                           gtk_icon_theme_get_default(),
-                          stockid
+                          stockid.utf8_str()
                       );
         if ( !sizes )
             return wxNullIconBundle;
@@ -339,7 +341,7 @@ wxGTK2ArtProvider::CreateIconBundle(const wxArtID& id,
 
         wxIconBundle bundle = DoCreateIconBundle
                               (
-                                  stockid,
+                                  stockid.utf8_str(),
                                   sizes, last,
                                   &CreateThemeIcon
                               );