forked from AuroraMiddleware/gtk
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.
This commit is contained in:
parent
8b93ea9238
commit
146b921246
@ -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"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -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);
|
||||
|
@ -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;
|
||||
@ -402,14 +400,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);
|
||||
|
@ -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);
|
||||
|
@ -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;
|
||||
|
@ -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)
|
||||
@ -1432,13 +1426,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 (>K_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 (>K_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, '.'))
|
||||
@ -1564,13 +1558,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 (>K_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 (>K_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, '.'))
|
||||
|
@ -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);
|
||||
|
@ -120,5 +120,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));
|
||||
}
|
||||
|
@ -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);
|
||||
|
@ -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);
|
||||
|
@ -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");
|
||||
|
@ -575,7 +575,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)));
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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));
|
||||
|
@ -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;
|
||||
|
@ -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);
|
||||
|
||||
|
@ -1795,7 +1795,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);
|
||||
@ -4024,7 +4024,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);
|
||||
@ -4215,7 +4215,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);
|
||||
|
@ -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);
|
||||
|
||||
|
@ -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:
|
||||
|
@ -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);
|
||||
|
@ -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);
|
||||
|
||||
@ -5643,7 +5643,7 @@ gtk_widget_set_name (GtkWidget *widget,
|
||||
g_free (priv->name);
|
||||
priv->name = g_strdup (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]);
|
||||
}
|
||||
@ -11199,7 +11199,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
|
||||
@ -11222,7 +11222,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
|
||||
|
@ -1829,7 +1829,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);
|
||||
|
@ -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:
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user