[gtk+/wip/baedert/drawing: 154/241] icon: Add _set_image



commit efd5fba7929c8c054e1afe003255eaaa177cec97
Author: Timm Bäder <mail baedert org>
Date:   Thu May 11 07:48:00 2017 +0200

    icon: Add _set_image

 gtk/gtkicon.c        |   11 ++++++++++-
 gtk/gtkiconprivate.h |    7 ++++++-
 2 files changed, 16 insertions(+), 2 deletions(-)
---
diff --git a/gtk/gtkicon.c b/gtk/gtkicon.c
index 691f7ad..7b5327a 100644
--- a/gtk/gtkicon.c
+++ b/gtk/gtkicon.c
@@ -44,6 +44,7 @@ static void
 gtk_icon_snapshot (GtkWidget   *widget,
                    GtkSnapshot *snapshot)
 {
+  GtkIcon *self = GTK_ICON (widget);
   GtkCssStyle *style = gtk_css_node_get_style (gtk_widget_get_css_node (widget));
   GtkAllocation alloc;
 
@@ -52,7 +53,7 @@ gtk_icon_snapshot (GtkWidget   *widget,
   gtk_css_style_snapshot_icon (style,
                                snapshot,
                                alloc.width, alloc.height,
-                               GTK_CSS_IMAGE_BUILTIN_NONE);
+                               self->image);
 }
 
 static void
@@ -68,6 +69,7 @@ static void
 gtk_icon_init (GtkIcon *self)
 {
   gtk_widget_set_has_window (GTK_WIDGET (self), FALSE);
+  self->image = GTK_CSS_IMAGE_BUILTIN_NONE;
 }
 
 GtkWidget *
@@ -77,3 +79,10 @@ gtk_icon_new (const char *css_name)
                        "css-name", css_name,
                        NULL);
 }
+
+void
+gtk_icon_set_image (GtkIcon                *self,
+                    GtkCssImageBuiltinType  image)
+{
+  self->image = image;
+}
diff --git a/gtk/gtkiconprivate.h b/gtk/gtkiconprivate.h
index 81ae9a2..dcbb6d7 100644
--- a/gtk/gtkiconprivate.h
+++ b/gtk/gtkiconprivate.h
@@ -20,7 +20,8 @@
 #ifndef __GTK_ICON_PRIVATE_H__
 #define __GTK_ICON_PRIVATE_H__
 
-#include "gtk/gtkwidget.h"
+#include "gtkwidget.h"
+#include "gtkcsstypesprivate.h"
 
 G_BEGIN_DECLS
 
@@ -37,6 +38,7 @@ typedef struct _GtkIconClass      GtkIconClass;
 struct _GtkIcon
 {
   GtkWidget parent;
+  GtkCssImageBuiltinType image;
 };
 
 struct _GtkIconClass
@@ -48,6 +50,9 @@ GType        gtk_icon_get_type               (void) G_GNUC_CONST;
 
 GtkWidget *  gtk_icon_new                    (const char *css_name);
 
+void         gtk_icon_set_image              (GtkIcon                *self,
+                                              GtkCssImageBuiltinType  image);
+
 G_END_DECLS
 
 #endif /* __GTK_ICON_PRIVATE_H__ */


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