[gtk+] image: Add gtk_image_new_from_texture()



commit 85b3f6d3729ec956b52b29c68fbbbd9eb46b1874
Author: Benjamin Otte <otte redhat com>
Date:   Sat Dec 2 01:29:36 2017 +0100

    image: Add gtk_image_new_from_texture()
    
    Docs and header knew about this function.
    There just was no implementation.

 gtk/gtkimage.c |   31 +++++++++++++++++++++++++++++--
 1 files changed, 29 insertions(+), 2 deletions(-)
---
diff --git a/gtk/gtkimage.c b/gtk/gtkimage.c
index 82b9c43..81710fa 100644
--- a/gtk/gtkimage.c
+++ b/gtk/gtkimage.c
@@ -468,7 +468,7 @@ gtk_image_new_from_resource (const gchar *resource_path)
  * pixbuf; you still need to unref it if you own references.
  * #GtkImage will add its own reference rather than adopting yours.
  *
- * This is a helper for gtk_image_new_from_texture, and you can't
+ * This is a helper for gtk_image_new_from_texture(), and you can't
  * get back the exact pixbuf once this is called, only a texture.
  *
  * Note that this function just creates an #GtkImage from the pixbuf. The
@@ -490,6 +490,33 @@ gtk_image_new_from_pixbuf (GdkPixbuf *pixbuf)
 }
 
 /**
+ * gtk_image_new_from_texture:
+ * @pixbuf: (allow-none): a #GdkTexture, or %NULL
+ *
+ * Creates a new #GtkImage displaying @texture.
+ * The #GtkImage does not assume a reference to the
+ * texture; you still need to unref it if you own references.
+ * #GtkImage will add its own reference rather than adopting yours.
+ *
+ * Note that this function just creates an #GtkImage from the texture. The
+ * #GtkImage created will not react to state changes. Should you want that, 
+ * you should use gtk_image_new_from_icon_name().
+ * 
+ * Returns: a new #GtkImage
+ **/
+GtkWidget*
+gtk_image_new_from_texture (GdkTexture *texture)
+{
+  GtkImage *image;
+
+  image = g_object_new (GTK_TYPE_IMAGE, NULL);
+
+  gtk_image_set_from_texture (image, texture);
+
+  return GTK_WIDGET (image);  
+}
+
+/**
  * gtk_image_new_from_surface:
  * @surface: (allow-none): a #cairo_surface_t, or %NULL
  *
@@ -809,7 +836,7 @@ gtk_image_set_from_resource (GtkImage    *image,
  *
  * See gtk_image_new_from_pixbuf() for details.
  *
- * Note: This is a helper for gtk_image_new_from_texture, and you can't
+ * Note: This is a helper for gtk_image_set_from_texture(), and you can't
  * get back the exact pixbuf once this is called, only a texture.
  *
  **/


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