Rename GtkIcon widget to GtkBuiltinIcon
authorAlexander Larsson <alexl@redhat.com>
Tue, 28 Jan 2020 14:03:42 +0000 (15:03 +0100)
committerAlexander Larsson <alexl@redhat.com>
Thu, 30 Jan 2020 09:53:33 +0000 (10:53 +0100)
This is an internal widget whose name is not very important, and we
want to rename GtkIconInfo to GtkIcon, so lets rename this.

15 files changed:
gtk/gtkbuiltinicon.c [new file with mode: 0644]
gtk/gtkbuiltiniconprivate.h [new file with mode: 0644]
gtk/gtkcheckbutton.c
gtk/gtkcombobox.c
gtk/gtkexpander.c
gtk/gtkicon.c [deleted file]
gtk/gtkiconprivate.h [deleted file]
gtk/gtkmenusectionbox.c
gtk/gtkmodelbutton.c
gtk/gtknotebook.c
gtk/gtktreepopover.c
gtk/inspector/object-tree.c
gtk/inspector/recorder.c
gtk/meson.build
gtk/ui/gtkcombobox.ui

diff --git a/gtk/gtkbuiltinicon.c b/gtk/gtkbuiltinicon.c
new file mode 100644 (file)
index 0000000..26f81a0
--- /dev/null
@@ -0,0 +1,124 @@
+
+/*
+ * Copyright © 2015 Endless Mobile, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library. If not, see <http://www.gnu.org/licenses/>.
+ *
+ * Authors: Cosimo Cecchi <cosimoc@gnome.org>
+ */
+
+#include "config.h"
+
+#include "gtkcssnodeprivate.h"
+#include "gtkstylecontextprivate.h"
+#include "gtkcssnumbervalueprivate.h"
+#include "gtkbuiltiniconprivate.h"
+#include "gtkwidgetprivate.h"
+#include "gtkrendericonprivate.h"
+#include "gtksnapshot.h"
+
+/* GtkBuiltinIcon 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.
+ */
+
+struct _GtkBuiltinIcon
+{
+  GtkWidget parent;
+};
+
+G_DEFINE_TYPE (GtkBuiltinIcon, gtk_builtin_icon, GTK_TYPE_WIDGET)
+
+static void
+gtk_builtin_icon_snapshot (GtkWidget   *widget,
+                           GtkSnapshot *snapshot)
+{
+  GtkCssStyle *style = gtk_css_node_get_style (gtk_widget_get_css_node (widget));
+  int width, height;
+
+  width = gtk_widget_get_width (widget);
+  height = gtk_widget_get_height (widget);
+
+  if (width > 0 && height > 0)
+    gtk_css_style_snapshot_icon (style, snapshot, width, height);
+}
+
+static void
+gtk_builtin_icon_style_updated (GtkWidget *widget)
+{
+  GtkStyleContext *context;
+  GtkCssStyleChange *change = NULL;
+
+  context = gtk_widget_get_style_context (widget);
+  change = gtk_style_context_get_change (context);
+
+  GTK_WIDGET_CLASS (gtk_builtin_icon_parent_class)->style_updated (widget);
+
+  if (change == NULL ||
+      gtk_css_style_change_affects (change, GTK_CSS_AFFECTS_ICON_SIZE))
+    {
+      gtk_widget_queue_resize (widget);
+    }
+  else if (gtk_css_style_change_affects (change, GTK_CSS_AFFECTS_ICON_TEXTURE) ||
+           gtk_css_style_change_affects (change, GTK_CSS_AFFECTS_ICON_REDRAW))
+    {
+      gtk_widget_queue_draw (widget);
+    }
+}
+
+static void
+gtk_builtin_icon_measure (GtkWidget      *widget,
+                          GtkOrientation  orientation,
+                          int             for_size,
+                          int            *minimum,
+                          int            *natural,
+                          int            *minimum_baseline,
+                          int            *natural_baseline)
+{
+  GtkCssValue *icon_size;
+
+  icon_size = _gtk_style_context_peek_property (gtk_widget_get_style_context (widget), GTK_CSS_PROPERTY_ICON_SIZE);
+  *minimum = *natural = _gtk_css_number_value_get (icon_size, 100);
+}
+
+static void
+gtk_builtin_icon_class_init (GtkBuiltinIconClass *klass)
+{
+  GtkWidgetClass *wclass = GTK_WIDGET_CLASS (klass);
+
+  wclass->snapshot = gtk_builtin_icon_snapshot;
+  wclass->measure = gtk_builtin_icon_measure;
+  wclass->style_updated = gtk_builtin_icon_style_updated;
+}
+
+static void
+gtk_builtin_icon_init (GtkBuiltinIcon *self)
+{
+}
+
+GtkWidget *
+gtk_builtin_icon_new (const char *css_name)
+{
+  return g_object_new (GTK_TYPE_BUILTIN_ICON,
+                       "css-name", css_name,
+                       NULL);
+}
+
+void
+gtk_builtin_icon_set_css_name (GtkBuiltinIcon *self,
+                               const char *css_name)
+{
+  gtk_css_node_set_name (gtk_widget_get_css_node (GTK_WIDGET (self)),
+                         g_quark_from_string (css_name));
+}
diff --git a/gtk/gtkbuiltiniconprivate.h b/gtk/gtkbuiltiniconprivate.h
new file mode 100644 (file)
index 0000000..ba8accd
--- /dev/null
@@ -0,0 +1,38 @@
+/*
+ * Copyright © 2015 Endless Mobile, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library. If not, see <http://www.gnu.org/licenses/>.
+ *
+ * Authors: Cosimo Cecchi <cosimoc@gnome.org>
+ */
+
+#ifndef __GTK_BUILTIN_ICON_PRIVATE_H__
+#define __GTK_BUILTIN_ICON_PRIVATE_H__
+
+#include "gtkwidget.h"
+#include "gtkcsstypesprivate.h"
+
+G_BEGIN_DECLS
+
+#define GTK_TYPE_BUILTIN_ICON (gtk_builtin_icon_get_type ())
+
+G_DECLARE_FINAL_TYPE (GtkBuiltinIcon, gtk_builtin_icon, GTK, BUILTIN_ICON, GtkWidget)
+
+GtkWidget *  gtk_builtin_icon_new              (const char      *css_name);
+void         gtk_builtin_icon_set_css_name     (GtkBuiltinIcon *self,
+                                                const char      *css_name);
+
+G_END_DECLS
+
+#endif /* __GTK_BUILTIN_ICON_PRIVATE_H__ */
index f26733b9b3cea333ab24698818d468ae47a42899..ac3d8c9e6f5a1ec91352170d08b7d891cccf0675 100644 (file)
@@ -37,7 +37,7 @@
 #include "gtkstylecontextprivate.h"
 #include "gtkcssnumbervalueprivate.h"
 #include "gtkradiobutton.h"
-#include "gtkiconprivate.h"
+#include "gtkbuiltiniconprivate.h"
 
 
 /**
@@ -356,7 +356,7 @@ draw_indicator_changed (GtkCheckButton *check_button)
 
   if (priv->draw_indicator)
     {
-      priv->indicator_widget = gtk_icon_new ("check");
+      priv->indicator_widget = gtk_builtin_icon_new ("check");
       gtk_widget_set_halign (priv->indicator_widget, GTK_ALIGN_CENTER);
       gtk_widget_set_valign (priv->indicator_widget, GTK_ALIGN_CENTER);
       gtk_widget_set_parent (priv->indicator_widget, GTK_WIDGET (check_button));
index bbb7dba9b1ecd63bf65ed2332fec694473207a12..b9c6bbee8a5612f3774eb2e5bd6aa141e626cf26 100644 (file)
@@ -27,7 +27,7 @@
 #include "gtkcellview.h"
 #include "gtkeventcontrollerscroll.h"
 #include "gtkframe.h"
-#include "gtkiconprivate.h"
+#include "gtkbuiltiniconprivate.h"
 #include "gtkintl.h"
 #include "gtkliststore.h"
 #include "gtkmain.h"
@@ -844,7 +844,7 @@ gtk_combo_box_init (GtkComboBox *combo_box)
   priv->text_renderer = NULL;
   priv->id_column = -1;
 
-  g_type_ensure (GTK_TYPE_ICON);
+  g_type_ensure (GTK_TYPE_BUILTIN_ICON);
   g_type_ensure (GTK_TYPE_TREE_POPOVER);
   gtk_widget_init_template (GTK_WIDGET (combo_box));
 
index f1a38acc487b17531a0953bb9a6f457b2c7f7a97..04525612a57cf14e26afdd5fdd971706da6deb09 100644 (file)
 #include "gtkbuildable.h"
 #include "gtkcontainerprivate.h"
 #include "gtkdragdest.h"
-#include "gtkiconprivate.h"
+#include "gtkbuiltiniconprivate.h"
 #include "gtkgestureclick.h"
 #include "gtkgesturesingle.h"
 #include "gtkintl.h"
@@ -369,7 +369,7 @@ gtk_expander_init (GtkExpander *expander)
                                      NULL);
   gtk_container_add (GTK_CONTAINER (priv->box), priv->title_widget);
 
-  priv->arrow_widget = gtk_icon_new ("expander");
+  priv->arrow_widget = gtk_builtin_icon_new ("expander");
   gtk_style_context_add_class (gtk_widget_get_style_context (priv->arrow_widget),
                                GTK_STYLE_CLASS_HORIZONTAL);
   gtk_container_add (GTK_CONTAINER (priv->title_widget), priv->arrow_widget);
diff --git a/gtk/gtkicon.c b/gtk/gtkicon.c
deleted file mode 100644 (file)
index 970b61e..0000000
+++ /dev/null
@@ -1,124 +0,0 @@
-
-/*
- * Copyright © 2015 Endless Mobile, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library. If not, see <http://www.gnu.org/licenses/>.
- *
- * Authors: Cosimo Cecchi <cosimoc@gnome.org>
- */
-
-#include "config.h"
-
-#include "gtkcssnodeprivate.h"
-#include "gtkstylecontextprivate.h"
-#include "gtkcssnumbervalueprivate.h"
-#include "gtkiconprivate.h"
-#include "gtkwidgetprivate.h"
-#include "gtkrendericonprivate.h"
-#include "gtksnapshot.h"
-
-/* 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.
- */
-
-struct _GtkIcon
-{
-  GtkWidget parent;
-};
-
-G_DEFINE_TYPE (GtkIcon, gtk_icon, GTK_TYPE_WIDGET)
-
-static void
-gtk_icon_snapshot (GtkWidget   *widget,
-                   GtkSnapshot *snapshot)
-{
-  GtkCssStyle *style = gtk_css_node_get_style (gtk_widget_get_css_node (widget));
-  int width, height;
-
-  width = gtk_widget_get_width (widget);
-  height = gtk_widget_get_height (widget);
-
-  if (width > 0 && height > 0)
-    gtk_css_style_snapshot_icon (style, snapshot, width, height);
-}
-
-static void
-gtk_icon_style_updated (GtkWidget *widget)
-{
-  GtkStyleContext *context;
-  GtkCssStyleChange *change = NULL;
-
-  context = gtk_widget_get_style_context (widget);
-  change = gtk_style_context_get_change (context);
-
-  GTK_WIDGET_CLASS (gtk_icon_parent_class)->style_updated (widget);
-
-  if (change == NULL ||
-      gtk_css_style_change_affects (change, GTK_CSS_AFFECTS_ICON_SIZE))
-    {
-      gtk_widget_queue_resize (widget);
-    }
-  else if (gtk_css_style_change_affects (change, GTK_CSS_AFFECTS_ICON_TEXTURE) ||
-           gtk_css_style_change_affects (change, GTK_CSS_AFFECTS_ICON_REDRAW))
-    {
-      gtk_widget_queue_draw (widget);
-    }
-}
-
-static void
-gtk_icon_measure (GtkWidget      *widget,
-                  GtkOrientation  orientation,
-                  int             for_size,
-                  int            *minimum,
-                  int            *natural,
-                  int            *minimum_baseline,
-                  int            *natural_baseline)
-{
-  GtkCssValue *icon_size;
-
-  icon_size = _gtk_style_context_peek_property (gtk_widget_get_style_context (widget), GTK_CSS_PROPERTY_ICON_SIZE);
-  *minimum = *natural = _gtk_css_number_value_get (icon_size, 100);
-}
-
-static void
-gtk_icon_class_init (GtkIconClass *klass)
-{
-  GtkWidgetClass *wclass = GTK_WIDGET_CLASS (klass);
-
-  wclass->snapshot = gtk_icon_snapshot;
-  wclass->measure = gtk_icon_measure;
-  wclass->style_updated = gtk_icon_style_updated;
-}
-
-static void
-gtk_icon_init (GtkIcon *self)
-{
-}
-
-GtkWidget *
-gtk_icon_new (const char *css_name)
-{
-  return g_object_new (GTK_TYPE_ICON,
-                       "css-name", css_name,
-                       NULL);
-}
-
-void
-gtk_icon_set_css_name (GtkIcon    *self,
-                       const char *css_name)
-{
-  gtk_css_node_set_name (gtk_widget_get_css_node (GTK_WIDGET (self)),
-                         g_quark_from_string (css_name));
-}
diff --git a/gtk/gtkiconprivate.h b/gtk/gtkiconprivate.h
deleted file mode 100644 (file)
index 2bc0255..0000000
+++ /dev/null
@@ -1,39 +0,0 @@
-/*
- * Copyright © 2015 Endless Mobile, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library. If not, see <http://www.gnu.org/licenses/>.
- *
- * Authors: Cosimo Cecchi <cosimoc@gnome.org>
- */
-
-#ifndef __GTK_ICON_PRIVATE_H__
-#define __GTK_ICON_PRIVATE_H__
-
-#include "gtkwidget.h"
-#include "gtkcsstypesprivate.h"
-
-G_BEGIN_DECLS
-
-#define GTK_TYPE_ICON (gtk_icon_get_type ())
-
-G_DECLARE_FINAL_TYPE (GtkIcon, gtk_icon, GTK, ICON, GtkWidget)
-
-GtkWidget *  gtk_icon_new                    (const char *css_name);
-
-void         gtk_icon_set_css_name           (GtkIcon    *self,
-                                              const char *css_name);
-
-G_END_DECLS
-
-#endif /* __GTK_ICON_PRIVATE_H__ */
index eee0659e0e4aba08a25a37989308231502acf9aa..fd462230deb06ecc35650be10c35ce2118f747d9 100644 (file)
@@ -32,7 +32,7 @@
 #include "gtkstylecontext.h"
 #include "gtkpopovermenuprivate.h"
 #include "gtkorientable.h"
-#include "gtkiconprivate.h"
+#include "gtkbuiltiniconprivate.h"
 
 typedef GtkBoxClass GtkMenuSectionBoxClass;
 
@@ -582,7 +582,7 @@ gtk_menu_section_box_new_section (GtkMenuTrackerItem *item,
       gtk_orientable_set_orientation (GTK_ORIENTABLE (box->item_box), GTK_ORIENTATION_HORIZONTAL);
       gtk_style_context_add_class (gtk_widget_get_style_context (GTK_WIDGET (box->item_box)), "inline-buttons");
 
-      spacer = gtk_icon_new ("none");
+      spacer = gtk_builtin_icon_new ("none");
       gtk_container_add (GTK_CONTAINER (box->item_box), spacer);
       gtk_size_group_add_widget (box->indicators, spacer);
 
index 07bf8c25c2ea2acdd739183765aad09f7dffc394..58f3dd764474820533a1df014ec5adcc2f1851b8 100644 (file)
@@ -38,7 +38,7 @@
 #include "gtkcsstypesprivate.h"
 #include "gtkstylecontextprivate.h"
 #include "gtkcontainerprivate.h"
-#include "gtkiconprivate.h"
+#include "gtkbuiltiniconprivate.h"
 #include "gtksizegroup.h"
 #include "gtkaccellabelprivate.h"
 #include "gtkactionable.h"
@@ -492,7 +492,7 @@ update_node_name (GtkModelButton *self)
 
   if (start_name && !self->start_indicator)
     {
-      self->start_indicator = gtk_icon_new (start_name);
+      self->start_indicator = gtk_builtin_icon_new (start_name);
       gtk_widget_set_halign (self->start_indicator, GTK_ALIGN_CENTER);
       gtk_widget_set_valign (self->start_indicator, GTK_ALIGN_CENTER);
       update_start_indicator (self);
@@ -511,7 +511,7 @@ update_node_name (GtkModelButton *self)
 
   if (end_name && !self->end_indicator)
     {
-      self->end_indicator = gtk_icon_new (end_name);
+      self->end_indicator = gtk_builtin_icon_new (end_name);
       gtk_widget_set_halign (self->end_indicator, GTK_ALIGN_CENTER);
       gtk_widget_set_valign (self->end_indicator, GTK_ALIGN_CENTER);
       gtk_widget_set_parent (self->end_indicator, GTK_WIDGET (self));
index 70c50793a3b9b8a5e1d49971cda82dd901fc7772..73486d71fb00ad19ee28f47dd3f0b067dedfb9eb 100644 (file)
@@ -38,7 +38,7 @@
 #include "gtkeventcontrollermotion.h"
 #include "gtkgestureclick.h"
 #include "gtkgizmoprivate.h"
-#include "gtkiconprivate.h"
+#include "gtkbuiltiniconprivate.h"
 #include "gtkintl.h"
 #include "gtklabel.h"
 #include "gtkmain.h"
index cf25dbe658e1d672f72d532a0681d4c4a04e2f7f..f4219c2cd951393d821618c7dacdf45de7789863 100644 (file)
@@ -29,7 +29,7 @@
 #include "gtkintl.h"
 #include "gtkprivate.h"
 #include "gtkgizmoprivate.h"
-#include "gtkiconprivate.h"
+#include "gtkbuiltiniconprivate.h"
 
 // TODO
 // positioning + sizing
@@ -686,14 +686,14 @@ gtk_tree_popover_create_item (GtkTreePopover *popover,
 
       if (header_item)
         {
-          indicator = gtk_icon_new ("arrow");
+          indicator = gtk_builtin_icon_new ("arrow");
           gtk_style_context_add_class (gtk_widget_get_style_context (indicator), "left");
           gtk_widget_set_parent (indicator, item);
         }
 
       gtk_widget_set_parent (view, item);
 
-      indicator = gtk_icon_new (has_submenu ? "arrow" : "none");
+      indicator = gtk_builtin_icon_new (has_submenu ? "arrow" : "none");
       gtk_style_context_add_class (gtk_widget_get_style_context (indicator), "right");
       gtk_widget_set_parent (indicator, item);
 
index c6f4665d8e51ed6e00ad1dc4d887f7c58994fa41..9fd04cdd30e26422b26e1433988b8c43d1595424 100644 (file)
@@ -37,7 +37,7 @@
 #include "gtkcomboboxprivate.h"
 #include "gtkfilterlistmodel.h"
 #include "gtkflattenlistmodel.h"
-#include "gtkiconprivate.h"
+#include "gtkbuiltiniconprivate.h"
 #include "gtkiconview.h"
 #include "gtklabel.h"
 #include "gtklistbox.h"
@@ -1028,7 +1028,7 @@ gtk_inspector_object_tree_create_list_widget (gpointer row_item,
       g_object_bind_property (row_item, "expanded", title, "active", G_BINDING_BIDIRECTIONAL | G_BINDING_SYNC_CREATE);
       gtk_container_add (GTK_CONTAINER (child), title);
 
-      arrow = gtk_icon_new ("expander");
+      arrow = gtk_builtin_icon_new ("expander");
       gtk_container_add (GTK_CONTAINER (title), arrow);
     }
   else
index 2ed3649edbef2679371660f9b43f2312d8218abd..a5412cc8ab0a12593e8bceb05747a472180fcd78 100644 (file)
@@ -38,7 +38,7 @@
 #include <glib/gi18n-lib.h>
 #include <gdk/gdktextureprivate.h>
 #include "gtk/gtkdebug.h"
-#include "gtk/gtkiconprivate.h"
+#include "gtk/gtkbuiltiniconprivate.h"
 #include "gtk/gtkrendernodepaintableprivate.h"
 
 #include "recording.h"
@@ -329,7 +329,7 @@ create_widget_for_render_node (gpointer row_item,
       gtk_container_add (GTK_CONTAINER (child), title);
       g_object_set_data_full (G_OBJECT (row), "make-sure-its-not-unreffed", g_object_ref (row_item), g_object_unref);
 
-      arrow = gtk_icon_new ("expander");
+      arrow = gtk_builtin_icon_new ("expander");
       gtk_container_add (GTK_CONTAINER (title), arrow);
     }
   else
index 4c42b008a0516fda0376fdd32ecda25b5444fff2..698235eeeccbac26d041a38dbb0d5df33e98ab57 100644 (file)
@@ -108,7 +108,7 @@ gtk_private_sources = files([
   'gtkgizmo.c',
   'gtkgladecatalog.c',
   'gtkhsla.c',
-  'gtkicon.c',
+  'gtkbuiltinicon.c',
   'gtkiconcache.c',
   'tools/gtkiconcachevalidator.c',
   'gtkiconhelper.c',
index 24cafedb21fa3f4f3da5da98148fead8db03c0ce..4739b3d35d960a7ecda9d1f7ad585f1679ec3fb9 100644 (file)
@@ -12,7 +12,7 @@
             <child>
               <object class="GtkBox">
                 <child>
-                  <object class="GtkIcon" id="arrow">
+                  <object class="GtkBuiltinIcon" id="arrow">
                     <property name="css-name">arrow</property>
                   </object>
                 </child>