[gtk/wip/otte/css: 14/17] cssstylesheet: Move struct into .c file
- From: Benjamin Otte <otte src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk/wip/otte/css: 14/17] cssstylesheet: Move struct into .c file
- Date: Mon, 10 Feb 2020 03:02:37 +0000 (UTC)
commit 9b4b8a61c6d0cb043a9e7a8acbd823c050ea8e84
Author: Benjamin Otte <otte redhat com>
Date: Mon Feb 10 02:32:26 2020 +0100
cssstylesheet: Move struct into .c file
... and remove the private struct.
gtk/gtkcssstylesheet.c | 125 ++++++++++++++++++++++---------------------------
gtk/gtkcssstylesheet.h | 6 ---
2 files changed, 55 insertions(+), 76 deletions(-)
---
diff --git a/gtk/gtkcssstylesheet.c b/gtk/gtkcssstylesheet.c
index 371508b9d7..29feb1c3c5 100644
--- a/gtk/gtkcssstylesheet.c
+++ b/gtk/gtkcssstylesheet.c
@@ -113,8 +113,10 @@ struct _GtkCssScanner
GtkCssScanner *parent;
};
-struct _GtkCssStyleSheetPrivate
+struct _GtkCssStyleSheet
{
+ GObject parent_instance;
+
GScanner *scanner;
GHashTable *symbolic_colors;
@@ -148,7 +150,6 @@ gtk_css_style_sheet_load_internal (GtkCssStyleSheet *self,
GBytes *bytes);
G_DEFINE_TYPE_EXTENDED (GtkCssStyleSheet, gtk_css_style_sheet, G_TYPE_OBJECT, 0,
- G_ADD_PRIVATE (GtkCssStyleSheet)
G_IMPLEMENT_INTERFACE (GTK_TYPE_STYLE_PROVIDER,
gtk_css_style_provider_iface_init));
@@ -378,14 +379,12 @@ gtk_css_scanner_would_recurse (GtkCssScanner *scanner,
static void
gtk_css_style_sheet_init (GtkCssStyleSheet *self)
{
- GtkCssStyleSheetPrivate *priv = gtk_css_style_sheet_get_instance_private (self);
-
- priv->rulesets = g_array_new (FALSE, FALSE, sizeof (GtkCssRuleset));
+ self->rulesets = g_array_new (FALSE, FALSE, sizeof (GtkCssRuleset));
- priv->symbolic_colors = g_hash_table_new_full (g_str_hash, g_str_equal,
+ self->symbolic_colors = g_hash_table_new_full (g_str_hash, g_str_equal,
(GDestroyNotify) g_free,
(GDestroyNotify) _gtk_css_value_unref);
- priv->keyframes = g_hash_table_new_full (g_str_hash, g_str_equal,
+ self->keyframes = g_hash_table_new_full (g_str_hash, g_str_equal,
(GDestroyNotify) g_free,
(GDestroyNotify) _gtk_css_keyframes_unref);
}
@@ -396,16 +395,15 @@ verify_tree_match_results (GtkCssStyleSheet *self,
GPtrArray *tree_rules)
{
#ifdef VERIFY_TREE
- GtkCssStyleSheetPrivate *priv = gtk_css_style_sheet_get_instance_private (self);
GtkCssRuleset *ruleset;
gboolean should_match;
int i, j;
- for (i = 0; i < priv->rulesets->len; i++)
+ for (i = 0; i < self->rulesets->len; i++)
{
gboolean found = FALSE;
- ruleset = &g_array_index (priv->rulesets, GtkCssRuleset, i);
+ ruleset = &g_array_index (self->rulesets, GtkCssRuleset, i);
for (j = 0; j < tree_rules->len; j++)
{
@@ -432,9 +430,8 @@ gtk_css_style_provider_get_color (GtkStyleProvider *provider,
const char *name)
{
GtkCssStyleSheet *self = GTK_CSS_STYLE_SHEET (provider);
- GtkCssStyleSheetPrivate *priv = gtk_css_style_sheet_get_instance_private (self);
- return g_hash_table_lookup (priv->symbolic_colors, name);
+ return g_hash_table_lookup (self->symbolic_colors, name);
}
static GtkCssKeyframes *
@@ -442,9 +439,8 @@ gtk_css_style_provider_get_keyframes (GtkStyleProvider *provider,
const char *name)
{
GtkCssStyleSheet *self = GTK_CSS_STYLE_SHEET (provider);
- GtkCssStyleSheetPrivate *priv = gtk_css_style_sheet_get_instance_private (self);
- return g_hash_table_lookup (priv->keyframes, name);
+ return g_hash_table_lookup (self->keyframes, name);
}
static void
@@ -455,16 +451,15 @@ gtk_css_style_provider_lookup (GtkStyleProvider *provider,
GtkCssChange *change)
{
GtkCssStyleSheet *self = GTK_CSS_STYLE_SHEET (provider);
- GtkCssStyleSheetPrivate *priv = gtk_css_style_sheet_get_instance_private (self);
GtkCssRuleset *ruleset;
guint j;
int i;
GPtrArray *tree_rules;
- if (_gtk_css_selector_tree_is_empty (priv->tree))
+ if (_gtk_css_selector_tree_is_empty (self->tree))
return;
- tree_rules = _gtk_css_selector_tree_match_all (priv->tree, filter, node);
+ tree_rules = _gtk_css_selector_tree_match_all (self->tree, filter, node);
if (tree_rules)
{
verify_tree_match_results (self, node, tree_rules);
@@ -495,7 +490,7 @@ gtk_css_style_provider_lookup (GtkStyleProvider *provider,
}
if (change)
- *change = gtk_css_selector_tree_get_change_all (priv->tree, filter, node);
+ *change = gtk_css_selector_tree_get_change_all (self->tree, filter, node);
}
static void
@@ -511,26 +506,25 @@ static void
gtk_css_style_sheet_finalize (GObject *object)
{
GtkCssStyleSheet *self = GTK_CSS_STYLE_SHEET (object);
- GtkCssStyleSheetPrivate *priv = gtk_css_style_sheet_get_instance_private (self);
guint i;
- for (i = 0; i < priv->rulesets->len; i++)
- gtk_css_ruleset_clear (&g_array_index (priv->rulesets, GtkCssRuleset, i));
+ for (i = 0; i < self->rulesets->len; i++)
+ gtk_css_ruleset_clear (&g_array_index (self->rulesets, GtkCssRuleset, i));
- g_array_free (priv->rulesets, TRUE);
- _gtk_css_selector_tree_free (priv->tree);
+ g_array_free (self->rulesets, TRUE);
+ _gtk_css_selector_tree_free (self->tree);
- g_hash_table_destroy (priv->symbolic_colors);
- g_hash_table_destroy (priv->keyframes);
+ g_hash_table_destroy (self->symbolic_colors);
+ g_hash_table_destroy (self->keyframes);
- if (priv->resource)
+ if (self->resource)
{
- g_resources_unregister (priv->resource);
- g_resource_unref (priv->resource);
- priv->resource = NULL;
+ g_resources_unregister (self->resource);
+ g_resource_unref (self->resource);
+ self->resource = NULL;
}
- g_free (priv->path);
+ g_free (self->path);
G_OBJECT_CLASS (gtk_css_style_sheet_parent_class)->finalize (object);
}
@@ -554,7 +548,6 @@ css_style_sheet_commit (GtkCssStyleSheet *self,
guint n_selectors,
GtkCssRuleset *ruleset)
{
- GtkCssStyleSheetPrivate *priv = gtk_css_style_sheet_get_instance_private (self);
guint i;
if (ruleset->styles == NULL)
@@ -566,9 +559,9 @@ css_style_sheet_commit (GtkCssStyleSheet *self,
{
GtkCssRuleset *new;
- g_array_set_size (priv->rulesets, priv->rulesets->len + 1);
+ g_array_set_size (self->rulesets, self->rulesets->len + 1);
- new = &g_array_index (priv->rulesets, GtkCssRuleset, priv->rulesets->len - 1);
+ new = &g_array_index (self->rulesets, GtkCssRuleset, self->rulesets->len - 1);
gtk_css_ruleset_init_copy (new, ruleset, selectors[i]);
}
}
@@ -576,30 +569,29 @@ css_style_sheet_commit (GtkCssStyleSheet *self,
static void
gtk_css_style_sheet_reset (GtkCssStyleSheet *self)
{
- GtkCssStyleSheetPrivate *priv = gtk_css_style_sheet_get_instance_private (self);
guint i;
- if (priv->resource)
+ if (self->resource)
{
- g_resources_unregister (priv->resource);
- g_resource_unref (priv->resource);
- priv->resource = NULL;
+ g_resources_unregister (self->resource);
+ g_resource_unref (self->resource);
+ self->resource = NULL;
}
- if (priv->path)
+ if (self->path)
{
- g_free (priv->path);
- priv->path = NULL;
+ g_free (self->path);
+ self->path = NULL;
}
- g_hash_table_remove_all (priv->symbolic_colors);
- g_hash_table_remove_all (priv->keyframes);
+ g_hash_table_remove_all (self->symbolic_colors);
+ g_hash_table_remove_all (self->keyframes);
- for (i = 0; i < priv->rulesets->len; i++)
- gtk_css_ruleset_clear (&g_array_index (priv->rulesets, GtkCssRuleset, i));
- g_array_set_size (priv->rulesets, 0);
- _gtk_css_selector_tree_free (priv->tree);
- priv->tree = NULL;
+ for (i = 0; i < self->rulesets->len; i++)
+ gtk_css_ruleset_clear (&g_array_index (self->rulesets, GtkCssRuleset, i));
+ g_array_set_size (self->rulesets, 0);
+ _gtk_css_selector_tree_free (self->tree);
+ self->tree = NULL;
}
static gboolean
@@ -676,7 +668,6 @@ parse_import (GtkCssScanner *scanner)
static gboolean
parse_color_definition (GtkCssScanner *scanner)
{
- GtkCssStyleSheetPrivate *priv = gtk_css_style_sheet_get_instance_private (scanner->stylesheet);
GtkCssValue *color;
char *name;
@@ -703,7 +694,7 @@ parse_color_definition (GtkCssScanner *scanner)
return TRUE;
}
- g_hash_table_insert (priv->symbolic_colors, name, color);
+ g_hash_table_insert (scanner->stylesheet->symbolic_colors, name, color);
return TRUE;
}
@@ -711,7 +702,6 @@ parse_color_definition (GtkCssScanner *scanner)
static gboolean
parse_keyframes (GtkCssScanner *scanner)
{
- GtkCssStyleSheetPrivate *priv = gtk_css_style_sheet_get_instance_private (scanner->stylesheet);
GtkCssKeyframes *keyframes;
char *name;
@@ -732,7 +722,7 @@ parse_keyframes (GtkCssScanner *scanner)
keyframes = _gtk_css_keyframes_parse (scanner->parser);
if (keyframes != NULL)
- g_hash_table_insert (priv->keyframes, name, keyframes);
+ g_hash_table_insert (scanner->stylesheet->keyframes, name, keyframes);
if (!gtk_css_parser_has_token (scanner->parser, GTK_CSS_TOKEN_EOF))
gtk_css_parser_error_syntax (scanner->parser, "Expected '}' after declarations");
@@ -974,19 +964,18 @@ gtk_css_style_sheet_compare_rule (gconstpointer a_,
static void
gtk_css_style_sheet_postprocess (GtkCssStyleSheet *self)
{
- GtkCssStyleSheetPrivate *priv = gtk_css_style_sheet_get_instance_private (self);
GtkCssSelectorTreeBuilder *builder;
guint i;
gint64 before = g_get_monotonic_time ();
- g_array_sort (priv->rulesets, gtk_css_style_sheet_compare_rule);
+ g_array_sort (self->rulesets, gtk_css_style_sheet_compare_rule);
builder = _gtk_css_selector_tree_builder_new ();
- for (i = 0; i < priv->rulesets->len; i++)
+ for (i = 0; i < self->rulesets->len; i++)
{
GtkCssRuleset *ruleset;
- ruleset = &g_array_index (priv->rulesets, GtkCssRuleset, i);
+ ruleset = &g_array_index (self->rulesets, GtkCssRuleset, i);
_gtk_css_selector_tree_builder_add (builder,
ruleset->selector,
@@ -994,15 +983,15 @@ gtk_css_style_sheet_postprocess (GtkCssStyleSheet *self)
ruleset);
}
- priv->tree = _gtk_css_selector_tree_builder_build (builder);
+ self->tree = _gtk_css_selector_tree_builder_build (builder);
_gtk_css_selector_tree_builder_free (builder);
#ifndef VERIFY_TREE
- for (i = 0; i < priv->rulesets->len; i++)
+ for (i = 0; i < self->rulesets->len; i++)
{
GtkCssRuleset *ruleset;
- ruleset = &g_array_index (priv->rulesets, GtkCssRuleset, i);
+ ruleset = &g_array_index (self->rulesets, GtkCssRuleset, i);
_gtk_css_selector_free (ruleset->selector);
ruleset->selector = NULL;
@@ -1208,9 +1197,7 @@ gtk_get_theme_dir (void)
const gchar *
gtk_css_style_sheet_get_theme_dir (GtkCssStyleSheet *self)
{
- GtkCssStyleSheetPrivate *priv = gtk_css_style_sheet_get_instance_private (self);
-
- return priv->path;
+ return self->path;
}
#if (GTK_MINOR_VERSION % 2)
@@ -1351,7 +1338,6 @@ gtk_css_style_sheet_load_named (GtkCssStyleSheet *self,
path = _gtk_css_find_theme (name, variant);
if (path)
{
- GtkCssStyleSheetPrivate *priv = gtk_css_style_sheet_get_instance_private (self);
char *dir, *resource_file;
GResource *resource;
@@ -1366,8 +1352,8 @@ gtk_css_style_sheet_load_named (GtkCssStyleSheet *self,
gtk_css_style_sheet_load_from_path (self, path);
/* Only set this after load, as load_from_path will clear it */
- priv->resource = resource;
- priv->path = dir;
+ self->resource = resource;
+ self->path = dir;
g_free (path);
}
@@ -1507,7 +1493,6 @@ gtk_css_style_sheet_print_keyframes (GHashTable *keyframes,
char *
gtk_css_style_sheet_to_string (GtkCssStyleSheet *self)
{
- GtkCssStyleSheetPrivate *priv = gtk_css_style_sheet_get_instance_private (self);
GString *str;
guint i;
@@ -1515,14 +1500,14 @@ gtk_css_style_sheet_to_string (GtkCssStyleSheet *self)
str = g_string_new ("");
- gtk_css_style_sheet_print_colors (priv->symbolic_colors, str);
- gtk_css_style_sheet_print_keyframes (priv->keyframes, str);
+ gtk_css_style_sheet_print_colors (self->symbolic_colors, str);
+ gtk_css_style_sheet_print_keyframes (self->keyframes, str);
- for (i = 0; i < priv->rulesets->len; i++)
+ for (i = 0; i < self->rulesets->len; i++)
{
if (str->len != 0)
g_string_append (str, "\n");
- gtk_css_ruleset_print (&g_array_index (priv->rulesets, GtkCssRuleset, i), str);
+ gtk_css_ruleset_print (&g_array_index (self->rulesets, GtkCssRuleset, i), str);
}
return g_string_free (str, FALSE);
diff --git a/gtk/gtkcssstylesheet.h b/gtk/gtkcssstylesheet.h
index e1bdb7c034..068e9a339b 100644
--- a/gtk/gtkcssstylesheet.h
+++ b/gtk/gtkcssstylesheet.h
@@ -30,12 +30,6 @@ G_BEGIN_DECLS
typedef struct _GtkCssStyleSheet GtkCssStyleSheet;
typedef struct _GtkCssStyleSheetClass GtkCssStyleSheetClass;
-typedef struct _GtkCssStyleSheetPrivate GtkCssStyleSheetPrivate;
-
-struct _GtkCssStyleSheet
-{
- GObject parent_instance;
-};
GDK_AVAILABLE_IN_ALL
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]