[gtkmm-documentation] Update ToolPalette example



commit e16d9edd5a40f294e240df4e8050546c8e62fe9a
Author: Kjell Ahlstedt <kjellahlstedt gmail com>
Date:   Fri Jan 12 16:46:31 2018 +0100

    Update ToolPalette example
    
    Gtk::IconTheme::load_icon() now returns a constant pixbuf.

 examples/book/toolpalette/canvas.h         |    2 +-
 examples/book/toolpalette/examplewindow.cc |    4 +++-
 2 files changed, 4 insertions(+), 2 deletions(-)
---
diff --git a/examples/book/toolpalette/canvas.h b/examples/book/toolpalette/canvas.h
index 6f065ae..33ebec2 100644
--- a/examples/book/toolpalette/canvas.h
+++ b/examples/book/toolpalette/canvas.h
@@ -45,7 +45,7 @@ private:
       this->m_y = y;
     }
 
-    Glib::RefPtr<Gdk::Pixbuf> m_pixbuf;
+    Glib::RefPtr<const Gdk::Pixbuf> m_pixbuf;
     double m_x, m_y;
   };
 
diff --git a/examples/book/toolpalette/examplewindow.cc b/examples/book/toolpalette/examplewindow.cc
index b88e302..034c777 100644
--- a/examples/book/toolpalette/examplewindow.cc
+++ b/examples/book/toolpalette/examplewindow.cc
@@ -47,7 +47,9 @@ void ExampleWindow::load_icon_items()
       Glib::RefPtr<Gdk::Pixbuf> pixbuf;
       try
       {
-        pixbuf = icon_theme->load_icon(icon_name, requested_icon_size, 
Gtk::IconLookupFlags::GENERIC_FALLBACK);
+        // Take a copy of the pixbuf from load_icon().
+        // Gtk::Image(pixbuf) requires a non-const pixbuf.
+        pixbuf = icon_theme->load_icon(icon_name, requested_icon_size, 
Gtk::IconLookupFlags::GENERIC_FALLBACK)->copy();
       }
       catch (const Gtk::IconThemeError& /* ex */)
       {


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]