> I made a simple test by changing some lines in the ActionBar example
> in the gtkmm tutorial. In file
> https://git.gnome.org/browse/gtkmm-documentation/tree/examples/book/actionbar/examplewindow.cc
> I replaced
> 
>     m_face_image.set_from_icon_name("face-cool",
> Gtk::ICON_SIZE_DIALOG);
> 
> by
> 
>        Cairo::RefPtr<Cairo::ImageSurface> isurface =
>     Cairo::ImageSurface::create_from_png("rain.png");
>        m_face_image.set(isurface);
> 
> 
> It works! The umbrella is shown. (rain.png comes from another example
> in the tutorial.)
> 
> Can you please show a complete, but small, program that does not work.

Interesting, thanks for checking.  Here is a patch for examplewindow.cc
that demonstrates the problem.  Must be something to do with the way the
surface is created?

Thanks again,
Adam.


diff -Nru gtk.orig/examplewindow.cc gtk/examplewindow.cc
--- gtk.orig/examplewindow.cc   2015-08-01 17:34:59.000000000 +1000
+++ gtk/examplewindow.cc        2015-08-01 17:44:54.682482453 +1000
@@ -14,6 +14,7 @@
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  */
 
+#include <cairomm/cairomm.h>
 #include "examplewindow.h"
 
 ExampleWindow::ExampleWindow()
@@ -31,7 +32,19 @@
   settings->property_gtk_application_prefer_dark_theme().set_value(true);
 
   // Face
-  m_face_image.set_from_icon_name("face-cool", Gtk::ICON_SIZE_DIALOG);
+  auto surface = Cairo::ImageSurface::create(Cairo::FORMAT_ARGB32, 16, 16);
+
+  // Draw something onto the Cairo surface so you can see whether it worked
+  auto content = surface->get_data();
+  for (int i = 0; i < 16*16*4; i+=4) {
+    content[i+0] = content[i+1] = content[i+2] = ((i/4)%16)<<4;
+    content[i+3] = 255;
+  }
+  // Set the Cairo surface - this doesn't work
+  m_face_image.set(surface);
+  // Convert the Cairo surface to a GDK pixbuf and set that, this does work
+  //auto gdkimg = Gdk::Pixbuf::create(surface, 0, 0, 16, 16);
+  //m_face_image.set(gdkimg);
 
   // Center widget layout
   m_prev_button.set_image_from_icon_name("go-previous-symbolic",
   Gtk::ICON_SIZE_BUTTON, true);


_______________________________________________
gtkmm-list mailing list
[email protected]
https://mail.gnome.org/mailman/listinfo/gtkmm-list

Reply via email to