[gtk/wip/otte/css: 3146/3150] cssnode: Convert name + id from interned string to GQuark



commit 71b564a83cb36e1ce02efd850e9cc0ec212b63f7
Author: Benjamin Otte <otte redhat com>
Date:   Fri Jan 24 00:43:26 2020 +0100

    cssnode: Convert name + id from interned string to GQuark
    
    The reason for this is simply that I want to get hash functions that
    have their values close together, so they can fit in a smaller range
    (the goal here is 12 bits). By using GQuark, we get consecutive numbers
    starting with 1 (and applications have <1000 quarks usually), whereas
    interned strings can be all over the place.
    
    As a side effect we also save 64 bytes per declaration.

 gtk/gtkcheckbutton.c               |  8 ++++----
 gtk/gtkcssnode.c                   | 20 ++++++++++----------
 gtk/gtkcssnodedeclaration.c        | 24 +++++++++++-------------
 gtk/gtkcssnodedeclarationprivate.h |  8 ++++----
 gtk/gtkcssnodeprivate.h            |  8 ++++----
 gtk/gtkcssselector.c               | 30 ++++++++++++------------------
 gtk/gtkflowbox.c                   |  2 +-
 gtk/gtkicon.c                      |  2 +-
 gtk/gtkiconview.c                  |  4 ++--
 gtk/gtklabel.c                     |  4 ++--
 gtk/gtkmodelbutton.c               | 38 +++++++++++++++++++-------------------
 gtk/gtkpopover.c                   |  2 +-
 gtk/gtkprintunixdialog.c           |  4 ++--
 gtk/gtkradiobutton.c               |  4 ++--
 gtk/gtkscrolledwindow.c            |  4 ++--
 gtk/gtksizerequest.c               |  6 +++---
 gtk/gtkstylecontext.c              |  6 +++---
 gtk/gtktext.c                      |  6 +++---
 gtk/gtktextview.c                  |  4 ++--
 gtk/gtktextviewchild.c             | 10 +++++-----
 gtk/gtktreeview.c                  |  6 +++---
 gtk/gtkwidget.c                    | 14 +++++++-------
 gtk/gtkwindow.c                    |  2 +-
 gtk/inspector/css-node-tree.c      |  4 ++--
 gtk/inspector/prop-editor.c        |  6 +++---
 25 files changed, 109 insertions(+), 117 deletions(-)
---
diff --git a/gtk/gtkcheckbutton.c b/gtk/gtkcheckbutton.c
index e57fa71b89..f26733b9b3 100644
--- a/gtk/gtkcheckbutton.c
+++ b/gtk/gtkcheckbutton.c
@@ -363,12 +363,12 @@ draw_indicator_changed (GtkCheckButton *check_button)
       if (GTK_IS_RADIO_BUTTON (check_button))
         {
           gtk_css_node_remove_class (widget_node, g_quark_from_static_string ("radio"));
-          gtk_css_node_set_name (widget_node, I_("radiobutton"));
+          gtk_css_node_set_name (widget_node, g_quark_from_static_string ("radiobutton"));
         }
       else if (GTK_IS_CHECK_BUTTON (check_button))
         {
           gtk_css_node_remove_class (widget_node, g_quark_from_static_string ("check"));
-          gtk_css_node_set_name (widget_node, I_("checkbutton"));
+          gtk_css_node_set_name (widget_node, g_quark_from_static_string ("checkbutton"));
         }
     }
   else
@@ -378,12 +378,12 @@ draw_indicator_changed (GtkCheckButton *check_button)
       if (GTK_IS_RADIO_BUTTON (check_button))
         {
           gtk_css_node_add_class (widget_node, g_quark_from_static_string ("radio"));
-          gtk_css_node_set_name (widget_node, I_("button"));
+          gtk_css_node_set_name (widget_node, g_quark_from_static_string ("button"));
         }
       else if (GTK_IS_CHECK_BUTTON (check_button))
         {
           gtk_css_node_add_class (widget_node, g_quark_from_static_string ("check"));
-          gtk_css_node_set_name (widget_node, I_("button"));
+          gtk_css_node_set_name (widget_node, g_quark_from_static_string ("button"));
         }
     }
 }
diff --git a/gtk/gtkcssnode.c b/gtk/gtkcssnode.c
index 1bf56b0646..013e9a26f5 100644
--- a/gtk/gtkcssnode.c
+++ b/gtk/gtkcssnode.c
@@ -171,11 +171,11 @@ gtk_css_node_get_property (GObject    *object,
       break;
 
     case PROP_ID:
-      g_value_set_string (value, gtk_css_node_get_id (cssnode));
+      g_value_set_string (value, g_quark_to_string (gtk_css_node_get_id (cssnode)));
       break;
 
     case PROP_NAME:
-      g_value_set_string (value, gtk_css_node_get_name (cssnode));
+      g_value_set_string (value, g_quark_to_string (gtk_css_node_get_name (cssnode)));
       break;
 
     case PROP_STATE:
@@ -206,11 +206,11 @@ gtk_css_node_set_property (GObject      *object,
       break;
 
     case PROP_ID:
-      gtk_css_node_set_id (cssnode, g_value_get_string (value));
+      gtk_css_node_set_id (cssnode, g_quark_from_string (g_value_get_string (value)));
       break;
 
     case PROP_NAME:
-      gtk_css_node_set_name (cssnode, g_value_get_string (value));
+      gtk_css_node_set_name (cssnode, g_quark_from_string (g_value_get_string (value)));
       break;
 
     case PROP_STATE:
@@ -1070,8 +1070,8 @@ gtk_css_node_get_visible (GtkCssNode *cssnode)
 }
 
 void
-gtk_css_node_set_name (GtkCssNode              *cssnode,
-                       /*interned*/ const char *name)
+gtk_css_node_set_name (GtkCssNode *cssnode,
+                       GQuark      name)
 {
   if (gtk_css_node_declaration_set_name (&cssnode->decl, name))
     {
@@ -1080,15 +1080,15 @@ gtk_css_node_set_name (GtkCssNode              *cssnode,
     }
 }
 
-/* interned */ const char *
+GQuark
 gtk_css_node_get_name (GtkCssNode *cssnode)
 {
   return gtk_css_node_declaration_get_name (cssnode->decl);
 }
 
 void
-gtk_css_node_set_id (GtkCssNode                *cssnode,
-                     /* interned */ const char *id)
+gtk_css_node_set_id (GtkCssNode *cssnode,
+                     GQuark      id)
 {
   if (gtk_css_node_declaration_set_id (&cssnode->decl, id))
     {
@@ -1097,7 +1097,7 @@ gtk_css_node_set_id (GtkCssNode                *cssnode,
     }
 }
 
-/* interned */ const char *
+GQuark
 gtk_css_node_get_id (GtkCssNode *cssnode)
 {
   return gtk_css_node_declaration_get_id (cssnode->decl);
diff --git a/gtk/gtkcssnodedeclaration.c b/gtk/gtkcssnodedeclaration.c
index 8757268367..513696d9fb 100644
--- a/gtk/gtkcssnodedeclaration.c
+++ b/gtk/gtkcssnodedeclaration.c
@@ -23,8 +23,8 @@
 
 struct _GtkCssNodeDeclaration {
   guint refcount;
-  const /* interned */ char *name;
-  const /* interned */ char *id;
+  GQuark name;
+  GQuark id;
   GtkStateFlags state;
   guint n_classes;
   /* GQuark classes[n_classes]; */
@@ -97,8 +97,8 @@ gtk_css_node_declaration_new (void)
 {
   static GtkCssNodeDeclaration empty = {
     1, /* need to own a ref ourselves so the copy-on-write path kicks in when people change things */
-    NULL,
-    NULL,
+    0,
+    0,
     0,
     0
   };
@@ -125,8 +125,8 @@ gtk_css_node_declaration_unref (GtkCssNodeDeclaration *decl)
 }
 
 gboolean
-gtk_css_node_declaration_set_name (GtkCssNodeDeclaration   **decl,
-                                   /*interned*/ const char  *name)
+gtk_css_node_declaration_set_name (GtkCssNodeDeclaration **decl,
+                                   GQuark                  name)
 {
   if ((*decl)->name == name)
     return FALSE;
@@ -137,7 +137,7 @@ gtk_css_node_declaration_set_name (GtkCssNodeDeclaration   **decl,
   return TRUE;
 }
 
-/*interned*/ const char *
+GQuark
 gtk_css_node_declaration_get_name (const GtkCssNodeDeclaration *decl)
 {
   return decl->name;
@@ -145,10 +145,8 @@ gtk_css_node_declaration_get_name (const GtkCssNodeDeclaration *decl)
 
 gboolean
 gtk_css_node_declaration_set_id (GtkCssNodeDeclaration **decl,
-                                 const char             *id)
+                                 GQuark                  id)
 {
-  id = g_intern_string (id);
-
   if ((*decl)->id == id)
     return FALSE;
 
@@ -158,7 +156,7 @@ gtk_css_node_declaration_set_id (GtkCssNodeDeclaration **decl,
   return TRUE;
 }
 
-const char *
+GQuark
 gtk_css_node_declaration_get_id (const GtkCssNodeDeclaration *decl)
 {
   return decl->id;
@@ -417,14 +415,14 @@ gtk_css_node_declaration_print (const GtkCssNodeDeclaration *decl,
   char **classnames;
 
   if (decl->name)
-    g_string_append (string, decl->name);
+    g_string_append (string, g_quark_to_string (decl->name));
   else
     g_string_append (string, "*");
 
   if (decl->id)
     {
       g_string_append_c (string, '#');
-      g_string_append (string, decl->id);
+      g_string_append (string, g_quark_to_string (decl->id));
     }
 
   classes = get_classes (decl);
diff --git a/gtk/gtkcssnodedeclarationprivate.h b/gtk/gtkcssnodedeclarationprivate.h
index 8609e4cac3..d0dd6e43fa 100644
--- a/gtk/gtkcssnodedeclarationprivate.h
+++ b/gtk/gtkcssnodedeclarationprivate.h
@@ -28,11 +28,11 @@ GtkCssNodeDeclaration * gtk_css_node_declaration_ref                    (GtkCssN
 void                    gtk_css_node_declaration_unref                  (GtkCssNodeDeclaration         
*decl);
 
 gboolean                gtk_css_node_declaration_set_name               (GtkCssNodeDeclaration        **decl,
-                                                                         /*interned*/ const char       
*name);
-/*interned*/ const char*gtk_css_node_declaration_get_name               (const GtkCssNodeDeclaration   
*decl);
+                                                                         GQuark                         
name);
+GQuark                  gtk_css_node_declaration_get_name               (const GtkCssNodeDeclaration   
*decl);
 gboolean                gtk_css_node_declaration_set_id                 (GtkCssNodeDeclaration        **decl,
-                                                                         const char                    *id);
-const char *            gtk_css_node_declaration_get_id                 (const GtkCssNodeDeclaration   
*decl);
+                                                                         GQuark                         id);
+GQuark                  gtk_css_node_declaration_get_id                 (const GtkCssNodeDeclaration   
*decl);
 gboolean                gtk_css_node_declaration_set_state              (GtkCssNodeDeclaration        **decl,
                                                                          GtkStateFlags                  
flags);
 GtkStateFlags           gtk_css_node_declaration_get_state              (const GtkCssNodeDeclaration   
*decl);
diff --git a/gtk/gtkcssnodeprivate.h b/gtk/gtkcssnodeprivate.h
index 9f49e09b65..0dab08ab72 100644
--- a/gtk/gtkcssnodeprivate.h
+++ b/gtk/gtkcssnodeprivate.h
@@ -114,11 +114,11 @@ void                    gtk_css_node_set_visible        (GtkCssNode            *
 gboolean                gtk_css_node_get_visible        (GtkCssNode            *cssnode) G_GNUC_PURE;
 
 void                    gtk_css_node_set_name           (GtkCssNode            *cssnode,
-                                                         /*interned*/const char*name);
-/*interned*/const char *gtk_css_node_get_name           (GtkCssNode            *cssnode) G_GNUC_PURE;
+                                                         GQuark                 name);
+GQuark                  gtk_css_node_get_name           (GtkCssNode            *cssnode) G_GNUC_PURE;
 void                    gtk_css_node_set_id             (GtkCssNode            *cssnode,
-                                                         /*interned*/const char*id);
-/*interned*/const char *gtk_css_node_get_id             (GtkCssNode            *cssnode) G_GNUC_PURE;
+                                                         GQuark                 id);
+GQuark                  gtk_css_node_get_id             (GtkCssNode            *cssnode) G_GNUC_PURE;
 void                    gtk_css_node_set_state          (GtkCssNode            *cssnode,
                                                          GtkStateFlags          state_flags);
 GtkStateFlags           gtk_css_node_get_state          (GtkCssNode            *cssnode) G_GNUC_PURE;
diff --git a/gtk/gtkcssselector.c b/gtk/gtkcssselector.c
index 998ed78b58..88cde68d66 100644
--- a/gtk/gtkcssselector.c
+++ b/gtk/gtkcssselector.c
@@ -94,7 +94,7 @@ union _GtkCssSelector
   const GtkCssSelectorClass     *class;         /* type of check this selector does */
   struct {
     const GtkCssSelectorClass   *class;
-    const char                  *name;          /* interned */
+    GQuark                       name;
   }                              id;
   struct {
     const GtkCssSelectorClass   *class;
@@ -102,7 +102,7 @@ union _GtkCssSelector
   }                              style_class;
   struct {
     const GtkCssSelectorClass   *class;
-    const char                  *name;          /* interned */
+    GQuark                       name;
   }                              name;
   struct {
     const GtkCssSelectorClass   *class;
@@ -597,7 +597,7 @@ static void
 print_name (const GtkCssSelector *selector,
             GString              *string)
 {
-  g_string_append (string, selector->name.name);
+  g_string_append (string, g_quark_to_string (selector->name.name));
 }
 
 static gboolean
@@ -610,15 +610,14 @@ match_name (const GtkCssSelector *selector,
 static guint
 hash_name (const GtkCssSelector *a)
 {
-  return g_str_hash (a->name.name);
+  return a->name.name;
 }
 
 static int
 comp_name (const GtkCssSelector *a,
            const GtkCssSelector *b)
 {
-  return strcmp (a->name.name,
-                b->name.name);
+  return a->name.name - b->name.name;
 }
 
 DEFINE_SIMPLE_SELECTOR(name, NAME, print_name, match_name, hash_name, comp_name, FALSE, FALSE, TRUE, FALSE)
@@ -667,7 +666,7 @@ print_id (const GtkCssSelector *selector,
           GString              *string)
 {
   g_string_append_c (string, '#');
-  g_string_append (string, selector->id.name);
+  g_string_append (string, g_quark_to_string (selector->id.name));
 }
 
 static gboolean
@@ -680,19 +679,14 @@ match_id (const GtkCssSelector *selector,
 static guint
 hash_id (const GtkCssSelector *a)
 {
-  return GPOINTER_TO_UINT (a->id.name);
+  return a->id.name;
 }
 
 static int
 comp_id (const GtkCssSelector *a,
         const GtkCssSelector *b)
 {
-  if (a->id.name < b->id.name)
-    return -1;
-  else if (a->id.name > b->id.name)
-    return 1;
-  else
-    return 0;
+  return a->id.name - b->id.name;
 }
 
 DEFINE_SIMPLE_SELECTOR(id, ID, print_id, match_id, hash_id, comp_id, TRUE, FALSE, FALSE, FALSE)
@@ -1462,13 +1456,13 @@ gtk_css_selector_parse_selector_pseudo_class (GtkCssParser   *parser,
               else if (gtk_css_token_is (token, GTK_CSS_TOKEN_IDENT))
                 {
                   selector = gtk_css_selector_new (&GTK_CSS_SELECTOR_NOT_NAME, selector);
-                  selector->name.name = g_intern_string (token->string.string);
+                  selector->name.name = g_quark_from_string (token->string.string);
                   gtk_css_parser_consume_token (parser);
                 }
               else if (gtk_css_token_is (token, GTK_CSS_TOKEN_HASH_ID))
                 {
                   selector = gtk_css_selector_new (&GTK_CSS_SELECTOR_NOT_ID, selector);
-                  selector->id.name = g_intern_string (token->string.string);
+                  selector->id.name = g_quark_from_string (token->string.string);
                   gtk_css_parser_consume_token (parser);
                 }
               else if (gtk_css_token_is_delim (token, '.'))
@@ -1594,13 +1588,13 @@ gtk_css_selector_parse_simple_selector (GtkCssParser   *parser,
       else if (!parsed_something && gtk_css_token_is (token, GTK_CSS_TOKEN_IDENT))
         {
           selector = gtk_css_selector_new (&GTK_CSS_SELECTOR_NAME, selector);
-          selector->name.name = g_intern_string (token->string.string);
+          selector->name.name = g_quark_from_string (token->string.string);
           gtk_css_parser_consume_token (parser);
         }
       else if (gtk_css_token_is (token, GTK_CSS_TOKEN_HASH_ID))
         {
           selector = gtk_css_selector_new (&GTK_CSS_SELECTOR_ID, selector);
-          selector->id.name = g_intern_string (token->string.string);
+          selector->id.name = g_quark_from_string (token->string.string);
           gtk_css_parser_consume_token (parser);
         }
       else if (gtk_css_token_is_delim (token, '.'))
diff --git a/gtk/gtkflowbox.c b/gtk/gtkflowbox.c
index b662946f35..1844943f80 100644
--- a/gtk/gtkflowbox.c
+++ b/gtk/gtkflowbox.c
@@ -2607,7 +2607,7 @@ gtk_flow_box_drag_gesture_update (GtkGestureDrag *gesture,
   
       widget_node = gtk_widget_get_css_node (GTK_WIDGET (box));
       priv->rubberband_node = gtk_css_node_new ();
-      gtk_css_node_set_name (priv->rubberband_node, I_("rubberband"));
+      gtk_css_node_set_name (priv->rubberband_node, g_quark_from_static_string ("rubberband"));
       gtk_css_node_set_parent (priv->rubberband_node, widget_node);
       gtk_css_node_set_state (priv->rubberband_node, gtk_css_node_get_state (widget_node));
       g_object_unref (priv->rubberband_node);
diff --git a/gtk/gtkicon.c b/gtk/gtkicon.c
index 8661a69943..39261bf707 100644
--- a/gtk/gtkicon.c
+++ b/gtk/gtkicon.c
@@ -96,5 +96,5 @@ 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_intern_string (css_name));
+                         g_quark_from_string (css_name));
 }
diff --git a/gtk/gtkiconview.c b/gtk/gtkiconview.c
index c662156488..f34cc5fa90 100644
--- a/gtk/gtkiconview.c
+++ b/gtk/gtkiconview.c
@@ -2385,7 +2385,7 @@ gtk_icon_view_start_rubberbanding (GtkIconView  *icon_view,
 
   widget_node = gtk_widget_get_css_node (GTK_WIDGET (icon_view));
   priv->rubberband_node = gtk_css_node_new ();
-  gtk_css_node_set_name (priv->rubberband_node, I_("rubberband"));
+  gtk_css_node_set_name (priv->rubberband_node, g_quark_from_static_string ("rubberband"));
   gtk_css_node_set_parent (priv->rubberband_node, widget_node);
   gtk_css_node_set_state (priv->rubberband_node, gtk_css_node_get_state (widget_node));
   g_object_unref (priv->rubberband_node);
@@ -6467,7 +6467,7 @@ gtk_icon_view_enable_model_drag_dest (GtkIconView       *icon_view,
 
   widget_node = gtk_widget_get_css_node (GTK_WIDGET (icon_view));
   icon_view->priv->dndnode = gtk_css_node_new ();
-  gtk_css_node_set_name (icon_view->priv->dndnode, I_("dndtarget"));
+  gtk_css_node_set_name (icon_view->priv->dndnode, g_quark_from_static_string ("dndtarget"));
   gtk_css_node_set_parent (icon_view->priv->dndnode, widget_node);
   gtk_css_node_set_state (icon_view->priv->dndnode, gtk_css_node_get_state (widget_node));
   g_object_unref (icon_view->priv->dndnode);
diff --git a/gtk/gtklabel.c b/gtk/gtklabel.c
index d9c04fe292..6e76d8ae3f 100644
--- a/gtk/gtklabel.c
+++ b/gtk/gtklabel.c
@@ -2400,7 +2400,7 @@ start_element_handler (GMarkupParseContext  *context,
 
       widget_node = gtk_widget_get_css_node (GTK_WIDGET (pdata->label));
       link->cssnode = gtk_css_node_new ();
-      gtk_css_node_set_name (link->cssnode, I_("link"));
+      gtk_css_node_set_name (link->cssnode, g_quark_from_static_string ("link"));
       gtk_css_node_set_parent (link->cssnode, widget_node);
       if (class)
         gtk_css_node_add_class (link->cssnode, g_quark_from_string (class));
@@ -5214,7 +5214,7 @@ gtk_label_select_region_index (GtkLabel *label,
 
               widget_node = gtk_widget_get_css_node (GTK_WIDGET (label));
               priv->select_info->selection_node = gtk_css_node_new ();
-              gtk_css_node_set_name (priv->select_info->selection_node, I_("selection"));
+              gtk_css_node_set_name (priv->select_info->selection_node, g_quark_from_static_string 
("selection"));
               gtk_css_node_set_parent (priv->select_info->selection_node, widget_node);
               gtk_css_node_set_state (priv->select_info->selection_node, gtk_css_node_get_state 
(widget_node));
               g_object_unref (priv->select_info->selection_node);
diff --git a/gtk/gtkmodelbutton.c b/gtk/gtkmodelbutton.c
index 6cd10e13bf..07bf8c25c2 100644
--- a/gtk/gtkmodelbutton.c
+++ b/gtk/gtkmodelbutton.c
@@ -454,28 +454,28 @@ update_node_name (GtkModelButton *self)
     {
     case GTK_BUTTON_ROLE_TITLE:
       a11y_role = ATK_ROLE_PUSH_BUTTON;
-      start_name = I_("arrow");
-      end_name = I_("none");
+      start_name = "arrow";
+      end_name = NULL;
       break;
     case GTK_BUTTON_ROLE_NORMAL:
       a11y_role = ATK_ROLE_PUSH_BUTTON;
-      start_name = I_("none");
+      start_name = NULL;
       if (self->menu_name || self->popover)
-        end_name = I_("arrow");
+        end_name = "arrow";
       else
-        end_name = I_("none");
+        end_name = NULL;
       break;
 
     case GTK_BUTTON_ROLE_CHECK:
       a11y_role = ATK_ROLE_CHECK_BOX;
-      start_name = I_("check");
-      end_name = I_("none");
+      start_name = "check";
+      end_name = NULL;
       break;
 
     case GTK_BUTTON_ROLE_RADIO:
       a11y_role = ATK_ROLE_RADIO_BUTTON;
-      start_name = I_("radio");
-      end_name = I_("none");
+      start_name = "radio";
+      end_name = NULL;
       break;
 
     default:
@@ -484,13 +484,13 @@ update_node_name (GtkModelButton *self)
 
   if (self->iconic)
     {
-      start_name = I_("none");
-      end_name = I_("none");
+      start_name = NULL;
+      end_name = NULL;
     }
 
   atk_object_set_role (accessible, a11y_role);
 
-  if (start_name != I_("none") && !self->start_indicator)
+  if (start_name && !self->start_indicator)
     {
       self->start_indicator = gtk_icon_new (start_name);
       gtk_widget_set_halign (self->start_indicator, GTK_ALIGN_CENTER);
@@ -499,9 +499,9 @@ update_node_name (GtkModelButton *self)
 
       gtk_container_add (GTK_CONTAINER (self->start_box), self->start_indicator);
     }
-  else if (start_name != I_("none"))
+  else if (start_name)
     {
-      gtk_css_node_set_name (gtk_widget_get_css_node (self->start_indicator), start_name);
+      gtk_css_node_set_name (gtk_widget_get_css_node (self->start_indicator), g_quark_from_static_string 
(start_name));
     }
   else if (self->start_indicator)
     {
@@ -509,7 +509,7 @@ update_node_name (GtkModelButton *self)
       self->start_indicator = NULL;
     }
 
-  if (end_name != I_("none") && !self->end_indicator)
+  if (end_name && !self->end_indicator)
     {
       self->end_indicator = gtk_icon_new (end_name);
       gtk_widget_set_halign (self->end_indicator, GTK_ALIGN_CENTER);
@@ -517,9 +517,9 @@ update_node_name (GtkModelButton *self)
       gtk_widget_set_parent (self->end_indicator, GTK_WIDGET (self));
       update_end_indicator (self);
     }
-  else if (end_name != I_("none"))
+  else if (end_name)
     {
-      gtk_css_node_set_name (gtk_widget_get_css_node (self->end_indicator), end_name);
+      gtk_css_node_set_name (gtk_widget_get_css_node (self->end_indicator), g_quark_from_static_string 
(end_name));
     }
   else
     {
@@ -665,7 +665,7 @@ gtk_model_button_set_iconic (GtkModelButton *self,
   if (iconic)
     {
       gtk_widget_hide (self->start_box);
-      gtk_css_node_set_name (widget_node, I_("button"));
+      gtk_css_node_set_name (widget_node, g_quark_from_static_string ("button"));
       gtk_style_context_add_class (context, "model");
       gtk_style_context_add_class (context, "image-button");
       gtk_style_context_remove_class (context, "flat");
@@ -673,7 +673,7 @@ gtk_model_button_set_iconic (GtkModelButton *self,
   else
     {
       gtk_widget_show (self->start_box);
-      gtk_css_node_set_name (widget_node, I_("modelbutton"));
+      gtk_css_node_set_name (widget_node, g_quark_from_static_string ("modelbutton"));
       gtk_style_context_remove_class (context, "model");
       gtk_style_context_remove_class (context, "image-button");
       gtk_style_context_add_class (context, "flat");
diff --git a/gtk/gtkpopover.c b/gtk/gtkpopover.c
index a963b35110..b37effb017 100644
--- a/gtk/gtkpopover.c
+++ b/gtk/gtkpopover.c
@@ -574,7 +574,7 @@ gtk_popover_init (GtkPopover *popover)
   gtk_widget_add_controller (GTK_WIDGET (popover), controller);
 
   priv->arrow_node = gtk_css_node_new ();
-  gtk_css_node_set_name (priv->arrow_node, I_("arrow"));
+  gtk_css_node_set_name (priv->arrow_node, g_quark_from_static_string ("arrow"));
   gtk_css_node_set_parent (priv->arrow_node, gtk_widget_get_css_node (widget));
   gtk_css_node_set_state (priv->arrow_node,
                           gtk_css_node_get_state (gtk_widget_get_css_node (widget)));
diff --git a/gtk/gtkprintunixdialog.c b/gtk/gtkprintunixdialog.c
index 4028aedde5..2d3d4703e6 100644
--- a/gtk/gtkprintunixdialog.c
+++ b/gtk/gtkprintunixdialog.c
@@ -809,8 +809,8 @@ gtk_print_unix_dialog_init (GtkPrintUnixDialog *dialog)
                                   draw_page,
                                   dialog, NULL);
 
-  gtk_css_node_set_name (gtk_widget_get_css_node (priv->collate_image), I_("drawing"));
-  gtk_css_node_set_name (gtk_widget_get_css_node (priv->page_layout_preview), I_("drawing"));
+  gtk_css_node_set_name (gtk_widget_get_css_node (priv->collate_image), g_quark_from_static_string 
("drawing"));
+  gtk_css_node_set_name (gtk_widget_get_css_node (priv->page_layout_preview), g_quark_from_static_string 
("drawing"));
 }
 
 static void
diff --git a/gtk/gtkradiobutton.c b/gtk/gtkradiobutton.c
index 712c49010e..45f3cf2ab5 100644
--- a/gtk/gtkradiobutton.c
+++ b/gtk/gtkradiobutton.c
@@ -247,9 +247,9 @@ gtk_radio_button_init (GtkRadioButton *self)
   priv->group = g_slist_prepend (NULL, self);
 
   css_node = gtk_widget_get_css_node (widget);
-  gtk_css_node_set_name (css_node, I_("radiobutton"));
+  gtk_css_node_set_name (css_node, g_quark_from_static_string ("radiobutton"));
   css_node = gtk_check_button_get_indicator_node (GTK_CHECK_BUTTON (self));
-  gtk_css_node_set_name (css_node, I_("radio"));
+  gtk_css_node_set_name (css_node, g_quark_from_static_string ("radio"));
 }
 
 static void
diff --git a/gtk/gtkscrolledwindow.c b/gtk/gtkscrolledwindow.c
index dbcda6083c..83b4c1e285 100644
--- a/gtk/gtkscrolledwindow.c
+++ b/gtk/gtkscrolledwindow.c
@@ -1991,14 +1991,14 @@ gtk_scrolled_window_init (GtkScrolledWindow *scrolled_window)
   for (i = 0; i < 4; i++)
     {
       priv->overshoot_node[i] = gtk_css_node_new ();
-      gtk_css_node_set_name (priv->overshoot_node[i], I_("overshoot"));
+      gtk_css_node_set_name (priv->overshoot_node[i], g_quark_from_static_string ("overshoot"));
       gtk_css_node_add_class (priv->overshoot_node[i], classes[i]);
       gtk_css_node_set_parent (priv->overshoot_node[i], widget_node);
       gtk_css_node_set_state (priv->overshoot_node[i], gtk_css_node_get_state (widget_node));
       g_object_unref (priv->overshoot_node[i]);
 
       priv->undershoot_node[i] = gtk_css_node_new ();
-      gtk_css_node_set_name (priv->undershoot_node[i], I_("undershoot"));
+      gtk_css_node_set_name (priv->undershoot_node[i], g_quark_from_static_string ("undershoot"));
       gtk_css_node_add_class (priv->undershoot_node[i], classes[i]);
       gtk_css_node_set_parent (priv->undershoot_node[i], widget_node);
       gtk_css_node_set_state (priv->undershoot_node[i], gtk_css_node_get_state (widget_node));
diff --git a/gtk/gtksizerequest.c b/gtk/gtksizerequest.c
index 82621700a9..ecc6642ada 100644
--- a/gtk/gtksizerequest.c
+++ b/gtk/gtksizerequest.c
@@ -306,14 +306,14 @@ gtk_widget_query_size_for_orientation (GtkWidget        *widget,
             {
               g_warning ("%s %p (%s) reported min width %d and natural width %d in measure() with 
for_size=%d; natural size must be >= min size",
                          G_OBJECT_TYPE_NAME (widget), widget,
-                         gtk_css_node_get_name (gtk_widget_get_css_node (widget)),
+                         g_quark_to_string (gtk_css_node_get_name (gtk_widget_get_css_node (widget))),
                          min_size, nat_size, for_size);
             }
           else
             {
               g_warning ("%s %p (%s) reported min height %d and natural height %d in measure() with 
for_size=%d; natural size must be >= min size",
                          G_OBJECT_TYPE_NAME (widget), widget,
-                         gtk_css_node_get_name (gtk_widget_get_css_node (widget)),
+                         g_quark_to_string (gtk_css_node_get_name (gtk_widget_get_css_node (widget))),
                          min_size, nat_size, for_size);
 
             }
@@ -324,7 +324,7 @@ gtk_widget_query_size_for_orientation (GtkWidget        *widget,
         {
           g_warning ("%s %p (%s) reported min %s %d, but sizes must be >= 0",
                      G_OBJECT_TYPE_NAME (widget), widget,
-                     gtk_css_node_get_name (gtk_widget_get_css_node (widget)),
+                     g_quark_to_string (gtk_css_node_get_name (gtk_widget_get_css_node (widget))),
                      orientation == GTK_ORIENTATION_HORIZONTAL ? "width" : "height",
                      min_size);
           min_size = 0;
diff --git a/gtk/gtkstylecontext.c b/gtk/gtkstylecontext.c
index 11134cf6fc..cb2b62b5ab 100644
--- a/gtk/gtkstylecontext.c
+++ b/gtk/gtkstylecontext.c
@@ -807,7 +807,7 @@ gtk_style_context_set_id (GtkStyleContext *context,
 
   g_return_if_fail (GTK_IS_STYLE_CONTEXT (context));
 
-  gtk_css_node_set_id (priv->cssnode, id);
+  gtk_css_node_set_id (priv->cssnode, g_quark_from_string (id));
 }
 
 /*
@@ -825,7 +825,7 @@ gtk_style_context_get_id (GtkStyleContext *context)
 
   g_return_val_if_fail (GTK_IS_STYLE_CONTEXT (context), NULL);
 
-  return gtk_css_node_get_id (priv->cssnode);
+  return g_quark_to_string (gtk_css_node_get_id (priv->cssnode));
 }
 
 /**
@@ -1028,7 +1028,7 @@ gtk_style_context_save_named (GtkStyleContext *context,
   cssnode = gtk_css_transient_node_new (priv->cssnode);
   gtk_css_node_set_parent (cssnode, gtk_style_context_get_root (context));
   if (name)
-    gtk_css_node_set_name (cssnode, g_intern_string (name));
+    gtk_css_node_set_name (cssnode, g_quark_from_string (name));
 
   gtk_style_context_save_to_node (context, cssnode);
 
diff --git a/gtk/gtktext.c b/gtk/gtktext.c
index 45b9b3c82c..9f2164655e 100644
--- a/gtk/gtktext.c
+++ b/gtk/gtktext.c
@@ -1796,7 +1796,7 @@ gtk_text_init (GtkText *self)
   for (i = 0; i < 2; i++)
     {
       priv->undershoot_node[i] = gtk_css_node_new ();
-      gtk_css_node_set_name (priv->undershoot_node[i], I_("undershoot"));
+      gtk_css_node_set_name (priv->undershoot_node[i], g_quark_from_static_string ("undershoot"));
       gtk_css_node_add_class (priv->undershoot_node[i], g_quark_from_static_string (i == 0 ? 
GTK_STYLE_CLASS_LEFT : GTK_STYLE_CLASS_RIGHT));
       gtk_css_node_set_parent (priv->undershoot_node[i], widget_node);
       gtk_css_node_set_state (priv->undershoot_node[i], gtk_css_node_get_state (widget_node) & 
~GTK_STATE_FLAG_DROP_ACTIVE);
@@ -4025,7 +4025,7 @@ gtk_text_toggle_overwrite (GtkText *self)
           GtkCssNode *widget_node = gtk_widget_get_css_node (GTK_WIDGET (self));
 
           priv->block_cursor_node = gtk_css_node_new ();
-          gtk_css_node_set_name (priv->block_cursor_node, I_("block-cursor"));
+          gtk_css_node_set_name (priv->block_cursor_node, g_quark_from_static_string ("block-cursor"));
           gtk_css_node_set_parent (priv->block_cursor_node, widget_node);
           gtk_css_node_set_state (priv->block_cursor_node, gtk_css_node_get_state (widget_node));
           g_object_unref (priv->block_cursor_node);
@@ -4216,7 +4216,7 @@ gtk_text_set_positions (GtkText *self,
           GtkCssNode *widget_node = gtk_widget_get_css_node (GTK_WIDGET (self));
 
           priv->selection_node = gtk_css_node_new ();
-          gtk_css_node_set_name (priv->selection_node, I_("selection"));
+          gtk_css_node_set_name (priv->selection_node, g_quark_from_static_string ("selection"));
           gtk_css_node_set_parent (priv->selection_node, widget_node);
           gtk_css_node_set_state (priv->selection_node, gtk_css_node_get_state (widget_node));
           g_object_unref (priv->selection_node);
diff --git a/gtk/gtktextview.c b/gtk/gtktextview.c
index baad3043c4..b405f0e187 100644
--- a/gtk/gtktextview.c
+++ b/gtk/gtktextview.c
@@ -1710,7 +1710,7 @@ gtk_text_view_init (GtkTextView *text_view)
   gtk_widget_add_controller (widget, priv->key_controller);
 
   priv->selection_node = gtk_css_node_new ();
-  gtk_css_node_set_name (priv->selection_node, I_("selection"));
+  gtk_css_node_set_name (priv->selection_node, g_quark_from_static_string ("selection"));
   gtk_css_node_set_parent (priv->selection_node, priv->text_window->css_node);
   gtk_css_node_set_state (priv->selection_node,
                           gtk_css_node_get_state (priv->text_window->css_node) & 
~GTK_STATE_FLAG_DROP_ACTIVE);
@@ -9016,7 +9016,7 @@ text_window_new (GtkWidget *widget)
   gtk_css_node_set_parent (win->css_node, widget_node);
   gtk_css_node_set_state (win->css_node, gtk_css_node_get_state (widget_node));
   g_signal_connect_object (win->css_node, "style-changed", G_CALLBACK (node_style_changed_cb), widget, 0);
-  gtk_css_node_set_name (win->css_node, I_("text"));
+  gtk_css_node_set_name (win->css_node, g_quark_from_static_string ("text"));
 
   g_object_unref (win->css_node);
 
diff --git a/gtk/gtktextviewchild.c b/gtk/gtktextviewchild.c
index 062424d341..a51ddfe3ac 100644
--- a/gtk/gtktextviewchild.c
+++ b/gtk/gtktextviewchild.c
@@ -306,27 +306,27 @@ gtk_text_view_child_constructed (GObject *object)
   switch (self->window_type)
     {
     case GTK_TEXT_WINDOW_LEFT:
-      gtk_css_node_set_name (css_node, "border");
+      gtk_css_node_set_name (css_node, g_quark_from_static_string ("border"));
       gtk_css_node_add_class (css_node, g_quark_from_static_string (GTK_STYLE_CLASS_LEFT));
       break;
 
     case GTK_TEXT_WINDOW_RIGHT:
-      gtk_css_node_set_name (css_node, "border");
+      gtk_css_node_set_name (css_node, g_quark_from_static_string ("border"));
       gtk_css_node_add_class (css_node, g_quark_from_static_string (GTK_STYLE_CLASS_RIGHT));
       break;
 
     case GTK_TEXT_WINDOW_TOP:
-      gtk_css_node_set_name (css_node, "border");
+      gtk_css_node_set_name (css_node, g_quark_from_static_string ("border"));
       gtk_css_node_add_class (css_node, g_quark_from_static_string (GTK_STYLE_CLASS_TOP));
       break;
 
     case GTK_TEXT_WINDOW_BOTTOM:
-      gtk_css_node_set_name (css_node, "border");
+      gtk_css_node_set_name (css_node, g_quark_from_static_string ("border"));
       gtk_css_node_add_class (css_node, g_quark_from_static_string (GTK_STYLE_CLASS_BOTTOM));
       break;
 
     case GTK_TEXT_WINDOW_TEXT:
-      gtk_css_node_set_name (css_node, "text");
+      gtk_css_node_set_name (css_node, g_quark_from_static_string ("text"));
       break;
 
     case GTK_TEXT_WINDOW_WIDGET:
diff --git a/gtk/gtktreeview.c b/gtk/gtktreeview.c
index c687ada1be..40de39aae4 100644
--- a/gtk/gtktreeview.c
+++ b/gtk/gtktreeview.c
@@ -1785,7 +1785,7 @@ gtk_tree_view_init (GtkTreeView *tree_view)
 
   widget_node = gtk_widget_get_css_node (GTK_WIDGET (tree_view));
   tree_view->header_node = gtk_css_node_new ();
-  gtk_css_node_set_name (tree_view->header_node, I_("header"));
+  gtk_css_node_set_name (tree_view->header_node, g_quark_from_static_string ("header"));
   gtk_css_node_set_parent (tree_view->header_node, widget_node);
   gtk_css_node_set_state (tree_view->header_node, gtk_css_node_get_state (widget_node));
   g_object_unref (tree_view->header_node);
@@ -4121,7 +4121,7 @@ gtk_tree_view_drag_gesture_update (GtkGestureDrag *gesture,
 
       widget_node = gtk_widget_get_css_node (GTK_WIDGET (tree_view));
       tree_view->rubber_band_cssnode = gtk_css_node_new ();
-      gtk_css_node_set_name (tree_view->rubber_band_cssnode, I_("rubberband"));
+      gtk_css_node_set_name (tree_view->rubber_band_cssnode, g_quark_from_static_string ("rubberband"));
       gtk_css_node_set_parent (tree_view->rubber_band_cssnode, widget_node);
       gtk_css_node_set_state (tree_view->rubber_band_cssnode, gtk_css_node_get_state (widget_node));
       g_object_unref (tree_view->rubber_band_cssnode);
@@ -12920,7 +12920,7 @@ gtk_tree_view_enable_model_drag_dest (GtkTreeView       *tree_view,
 
   widget_node = gtk_widget_get_css_node (GTK_WIDGET (tree_view));
   di->cssnode = gtk_css_node_new ();
-  gtk_css_node_set_name (di->cssnode, I_("dndtarget"));
+  gtk_css_node_set_name (di->cssnode, g_quark_from_static_string ("dndtarget"));
   gtk_css_node_set_parent (di->cssnode, widget_node);
   gtk_css_node_set_state (di->cssnode, gtk_css_node_get_state (widget_node));
   g_object_unref (di->cssnode);
diff --git a/gtk/gtkwidget.c b/gtk/gtkwidget.c
index 44e70c3945..a094eef8b7 100644
--- a/gtk/gtkwidget.c
+++ b/gtk/gtkwidget.c
@@ -495,7 +495,7 @@ struct _GtkWidgetClassPrivate
   GtkWidgetTemplate *template;
   GType accessible_type;
   AtkRole accessible_role;
-  const char *css_name;
+  GQuark css_name;
   GType layout_manager_type;
   GPtrArray *actions;
 };
@@ -1905,7 +1905,7 @@ gtk_widget_set_property (GObject         *object,
       break;
     case PROP_CSS_NAME:
       if (g_value_get_string (value) != NULL)
-        gtk_css_node_set_name (priv->cssnode, g_intern_string (g_value_get_string (value)));
+        gtk_css_node_set_name (priv->cssnode, g_quark_from_string (g_value_get_string (value)));
       break;
     case PROP_LAYOUT_MANAGER:
       gtk_widget_set_layout_manager (widget, g_value_dup_object (value));
@@ -2051,7 +2051,7 @@ gtk_widget_get_property (GObject         *object,
       g_value_set_int (value, gtk_widget_get_scale_factor (widget));
       break;
     case PROP_CSS_NAME:
-      g_value_set_string (value, gtk_css_node_get_name (priv->cssnode));
+      g_value_set_string (value, g_quark_to_string (gtk_css_node_get_name (priv->cssnode)));
       break;
     case PROP_LAYOUT_MANAGER:
       g_value_set_object (value, gtk_widget_get_layout_manager (widget));
@@ -4010,7 +4010,7 @@ gtk_widget_allocate (GtkWidget    *widget,
   if (adjusted.width < 0 || adjusted.height < 0)
     {
       g_warning ("gtk_widget_size_allocate(): attempt to allocate %s %s %p with width %d and height %d",
-                 G_OBJECT_TYPE_NAME (widget), gtk_css_node_get_name (priv->cssnode), widget,
+                 G_OBJECT_TYPE_NAME (widget), g_quark_to_string (gtk_css_node_get_name (priv->cssnode)), 
widget,
                  adjusted.width,
                  adjusted.height);
 
@@ -5646,7 +5646,7 @@ gtk_widget_set_name (GtkWidget     *widget,
   if (priv->context)
     gtk_style_context_set_id (priv->context, priv->name);
 
-  gtk_css_node_set_id (priv->cssnode, priv->name);
+  gtk_css_node_set_id (priv->cssnode, g_quark_from_string (priv->name));
 
   g_object_notify_by_pspec (G_OBJECT (widget), widget_props[PROP_NAME]);
 }
@@ -11198,7 +11198,7 @@ gtk_widget_class_set_css_name (GtkWidgetClass *widget_class,
 
   priv = widget_class->priv;
 
-  priv->css_name = g_intern_string (name);
+  priv->css_name = g_quark_from_string (name);
 }
 
 static gboolean
@@ -11221,7 +11221,7 @@ gtk_widget_class_get_css_name (GtkWidgetClass *widget_class)
 {
   g_return_val_if_fail (GTK_IS_WIDGET_CLASS (widget_class), NULL);
 
-  return widget_class->priv->css_name;
+  return g_quark_to_string (widget_class->priv->css_name);
 }
 
 void
diff --git a/gtk/gtkwindow.c b/gtk/gtkwindow.c
index dbdff29526..7dd919afd6 100644
--- a/gtk/gtkwindow.c
+++ b/gtk/gtkwindow.c
@@ -1828,7 +1828,7 @@ gtk_window_init (GtkWindow *window)
 
   widget_node = gtk_widget_get_css_node (GTK_WIDGET (window));
   priv->decoration_node = gtk_css_node_new ();
-  gtk_css_node_set_name (priv->decoration_node, I_("decoration"));
+  gtk_css_node_set_name (priv->decoration_node, g_quark_from_static_string ("decoration"));
   gtk_css_node_set_parent (priv->decoration_node, widget_node);
   gtk_css_node_set_state (priv->decoration_node, gtk_css_node_get_state (widget_node));
   g_signal_connect_object (priv->decoration_node, "style-changed", G_CALLBACK (node_style_changed_cb), 
window, 0);
diff --git a/gtk/inspector/css-node-tree.c b/gtk/inspector/css-node-tree.c
index 11741e7c79..c465f7a5a9 100644
--- a/gtk/inspector/css-node-tree.c
+++ b/gtk/inspector/css-node-tree.c
@@ -314,7 +314,7 @@ gtk_inspector_css_node_tree_get_node_value (GtkTreeModelCssNode *model,
   switch (column)
     {
     case COLUMN_NODE_NAME:
-      g_value_set_string (value, gtk_css_node_get_name (node));
+      g_value_set_string (value, g_quark_to_string (gtk_css_node_get_name (node)));
       break;
 
     case COLUMN_NODE_VISIBLE:
@@ -330,7 +330,7 @@ gtk_inspector_css_node_tree_get_node_value (GtkTreeModelCssNode *model,
       break;
 
     case COLUMN_NODE_ID:
-      g_value_set_string (value, gtk_css_node_get_id (node));
+      g_value_set_string (value, g_quark_to_string (gtk_css_node_get_id (node)));
       break;
 
     case COLUMN_NODE_STATE:
diff --git a/gtk/inspector/prop-editor.c b/gtk/inspector/prop-editor.c
index 6c7471b0e3..72dc14c2a8 100644
--- a/gtk/inspector/prop-editor.c
+++ b/gtk/inspector/prop-editor.c
@@ -351,11 +351,11 @@ intern_string_modified (GtkEntry *entry, ObjectProperty *p)
 {
   const gchar *s;
 
-  s = g_intern_string (gtk_editable_get_text (GTK_EDITABLE (entry)));
+  s = gtk_editable_get_text (GTK_EDITABLE (entry));
   if (g_str_equal (p->spec->name, "id"))
-    gtk_css_node_set_id (GTK_CSS_NODE (p->obj), s);
+    gtk_css_node_set_id (GTK_CSS_NODE (p->obj), g_quark_from_string (s));
   else if (g_str_equal (p->spec->name, "name"))
-    gtk_css_node_set_name (GTK_CSS_NODE (p->obj), s);
+    gtk_css_node_set_name (GTK_CSS_NODE (p->obj), g_quark_from_string (s));
 }
 
 static void



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