[gtk+/wip/baedert/drawing: 54/129] icon: Remove gadget



commit 9f8f975f4cd2f8cd9a48d7b364563bb83620ba29
Author: Timm Bäder <mail baedert org>
Date:   Sun May 7 21:30:02 2017 +0200

    icon: Remove gadget

 gtk/gtkicon.c        |  145 +++++---------------------------------------------
 gtk/gtkiconprivate.h |    3 -
 2 files changed, 13 insertions(+), 135 deletions(-)
---
diff --git a/gtk/gtkicon.c b/gtk/gtkicon.c
index 1ea9fd3..c8c0c6e 100644
--- a/gtk/gtkicon.c
+++ b/gtk/gtkicon.c
@@ -24,154 +24,50 @@
 #include "gtkcssnodeprivate.h"
 #include "gtkiconprivate.h"
 #include "gtkwidgetprivate.h"
+#include "gtkrendericonprivate.h"
 
-/* GtkIcon is a minimal widget wrapped around a GtkBuiltinIcon gadget,
+/* GtkIcon was a minimal widget wrapped around a GtkBuiltinIcon gadget,
  * It should be used whenever builtin-icon functionality is desired
  * but a widget is needed for other reasons.
  */
-enum {
-  PROP_0,
-  PROP_CSS_NAME,
-  NUM_PROPERTIES
-};
 
-static GParamSpec *icon_props[NUM_PROPERTIES] = { NULL, };
-
-typedef struct _GtkIconPrivate GtkIconPrivate;
-struct _GtkIconPrivate {
-  GtkCssGadget *gadget;
-};
-
-G_DEFINE_TYPE_WITH_PRIVATE (GtkIcon, gtk_icon, GTK_TYPE_WIDGET)
-
-static void
-gtk_icon_finalize (GObject *object)
-{
-  GtkIcon *self = GTK_ICON (object);
-  GtkIconPrivate *priv = gtk_icon_get_instance_private (self);
-
-  g_clear_object (&priv->gadget);
-
-  G_OBJECT_CLASS (gtk_icon_parent_class)->finalize (object);
-}
-
-static void
-gtk_icon_get_property (GObject      *object,
-                       guint         property_id,
-                       GValue       *value,
-                       GParamSpec   *pspec)
-{
-  GtkIcon *self = GTK_ICON (object);
-
-  switch (property_id)
-    {
-    case PROP_CSS_NAME:
-      g_value_set_string (value, gtk_icon_get_css_name (self));
-      break;
-    default:
-      G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
-      break;
-    }
-}
-
-static void
-gtk_icon_set_property (GObject      *object,
-                       guint         property_id,
-                       const GValue *value,
-                       GParamSpec   *pspec)
-{
-  GtkIcon *self = GTK_ICON (object);
-
-  switch (property_id)
-    {
-    case PROP_CSS_NAME:
-      gtk_icon_set_css_name (self, g_value_get_string (value));
-      break;
-    default:
-      G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
-      break;
-    }
-}
-
-static void
-gtk_icon_measure (GtkWidget *widget,
-                  GtkOrientation  orientation,
-                  int             for_size,
-                  int            *minimum,
-                  int            *natural,
-                  int            *minimum_baseline,
-                  int            *natural_baseline)
-{
-  GtkIcon *self = GTK_ICON (widget);
-  GtkIconPrivate *priv = gtk_icon_get_instance_private (self);
-
-  gtk_css_gadget_get_preferred_size (priv->gadget,
-                                     orientation,
-                                     for_size,
-                                     minimum, natural,
-                                     minimum_baseline, natural_baseline);
-}
+G_DEFINE_TYPE (GtkIcon, gtk_icon, GTK_TYPE_WIDGET)
 
 static void
 gtk_icon_size_allocate (GtkWidget     *widget,
                         GtkAllocation *allocation)
 {
-  GtkIcon *self = GTK_ICON (widget);
-  GtkIconPrivate *priv = gtk_icon_get_instance_private (self);
-  GtkAllocation clip = *allocation;
-
-  gtk_css_gadget_allocate (priv->gadget, allocation,
-                           gtk_widget_get_allocated_baseline (widget),
-                           &clip);
-
-  gtk_widget_set_clip (widget, &clip);
+  gtk_widget_set_clip (widget, allocation);
 }
 
 static void
 gtk_icon_snapshot (GtkWidget   *widget,
                    GtkSnapshot *snapshot)
 {
-  GtkIcon *self = GTK_ICON (widget);
-  GtkIconPrivate *priv = gtk_icon_get_instance_private (self);
+  GtkCssStyle *style = gtk_css_node_get_style (gtk_widget_get_css_node (widget));
+  GtkAllocation alloc;
+
+  gtk_widget_get_allocation (widget, &alloc);
 
-  gtk_css_gadget_snapshot (priv->gadget, snapshot);
+  gtk_css_style_snapshot_icon (style,
+                               snapshot,
+                               alloc.width, alloc.height,
+                               GTK_CSS_IMAGE_BUILTIN_NONE);
 }
 
 static void
 gtk_icon_class_init (GtkIconClass *klass)
 {
-  GObjectClass *oclass = G_OBJECT_CLASS (klass);
   GtkWidgetClass *wclass = GTK_WIDGET_CLASS (klass);
 
-  oclass->get_property = gtk_icon_get_property;
-  oclass->set_property = gtk_icon_set_property;
-  oclass->finalize = gtk_icon_finalize;
-
   wclass->size_allocate = gtk_icon_size_allocate;
-  wclass->measure = gtk_icon_measure;
   wclass->snapshot = gtk_icon_snapshot;
-
-  icon_props[PROP_CSS_NAME] =
-    g_param_spec_string ("css-name", "CSS name",
-                         "CSS name",
-                         NULL,
-                         G_PARAM_READWRITE |
-                         G_PARAM_EXPLICIT_NOTIFY | G_PARAM_STATIC_STRINGS);
-
-  g_object_class_install_properties (oclass, NUM_PROPERTIES, icon_props);
 }
 
 static void
 gtk_icon_init (GtkIcon *self)
 {
-  GtkWidget *widget = GTK_WIDGET (self);
-  GtkIconPrivate *priv = gtk_icon_get_instance_private (self);
-  GtkCssNode *widget_node;
-
-  gtk_widget_set_has_window (widget, FALSE);
-
-  widget_node = gtk_widget_get_css_node (widget);
-  priv->gadget = gtk_builtin_icon_new_for_node (widget_node, widget);
+  gtk_widget_set_has_window (GTK_WIDGET (self), FALSE);
 }
 
 GtkWidget *
@@ -181,18 +77,3 @@ gtk_icon_new (const char *css_name)
                        "css-name", css_name,
                        NULL);
 }
-
-const char *
-gtk_icon_get_css_name (GtkIcon *self)
-{
-  GtkCssNode *widget_node = gtk_widget_get_css_node (GTK_WIDGET (self));
-  return gtk_css_node_get_name (widget_node);
-}
-
-void
-gtk_icon_set_css_name (GtkIcon    *self,
-                       const char *css_name)
-{
-  GtkCssNode *widget_node = gtk_widget_get_css_node (GTK_WIDGET (self));
-  gtk_css_node_set_name (widget_node, g_intern_string (css_name));
-}
diff --git a/gtk/gtkiconprivate.h b/gtk/gtkiconprivate.h
index 08f8b0f..81ae9a2 100644
--- a/gtk/gtkiconprivate.h
+++ b/gtk/gtkiconprivate.h
@@ -47,9 +47,6 @@ struct _GtkIconClass
 GType        gtk_icon_get_type               (void) G_GNUC_CONST;
 
 GtkWidget *  gtk_icon_new                    (const char *css_name);
-const char * gtk_icon_get_css_name           (GtkIcon    *icon);
-void         gtk_icon_set_css_name           (GtkIcon    *icon,
-                                              const char *css_name);
 
 G_END_DECLS
 


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