[gtkmm] Gtk::Image: Fix Image(pixbuf)



commit 7885fe9fcaf4e71e09775a87880c1563c92e6fd3
Author: Kjell Ahlstedt <kjellahlstedt gmail com>
Date:   Fri Nov 3 16:31:38 2017 +0100

    Gtk::Image: Fix Image(pixbuf)
    
    The Image(const Glib::RefPtr<Gdk::Pixbuf>& pixbuf) constructor must be
    hand-coded now. GtkImage no longer has a "pixbuf" property.

 gtk/src/image.ccg |    7 +++++++
 gtk/src/image.hg  |    5 ++++-
 2 files changed, 11 insertions(+), 1 deletions(-)
---
diff --git a/gtk/src/image.ccg b/gtk/src/image.ccg
index d8aa449..0c40348 100644
--- a/gtk/src/image.ccg
+++ b/gtk/src/image.ccg
@@ -24,6 +24,13 @@ using Type = Gtk::Image::Type;
 namespace Gtk
 {
 
+Image::Image(const Glib::RefPtr<Gdk::Pixbuf>& pixbuf)
+:
+  _CONSTRUCT()
+{
+  gtk_image_set_from_pixbuf(gobj(), Glib::unwrap(pixbuf));
+}
+
 Glib::ustring Image::get_icon_name() const
 {
   const gchar* pchIconName = nullptr;
diff --git a/gtk/src/image.hg b/gtk/src/image.hg
index 99609b3..9465ff7 100644
--- a/gtk/src/image.hg
+++ b/gtk/src/image.hg
@@ -58,11 +58,14 @@ public:
    */
   _WRAP_CTOR(Image(const std::string& filename), gtk_image_new_from_file)
 
+  // gtk_image_new_from_pixbuf() does more than just call g_object_new().
+  // GtkImage has no "pixbuf" property.
   /** Creates a new Image widget displaying @a pixbuf.
    * Note that this just creates an GtkImage from the pixbuf. The Gtk::Image created will not react to state 
changes.
    * Should you want that, you should use the default constructor and set_from_icon_name().
    */
-  _WRAP_CTOR(Image(const Glib::RefPtr<Gdk::Pixbuf>& pixbuf), gtk_image_new_from_pixbuf)
+  Image(const Glib::RefPtr<Gdk::Pixbuf>& pixbuf);
+  _IGNORE(gtk_image_new_from_pixbuf)
 
   //We don't wrap gtk_image_new_from_icon_name() to avoid a clash with the from-filename constructor.
   //But we do wrap gtk_image_set_from_icon_name()


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