summaryrefslogtreecommitdiff
path: root/gtk/gtkcssselector.c
diff options
context:
space:
mode:
authorMatthias Clasen <mclasen@redhat.com>2016-01-24 10:56:23 -0500
committerMatthias Clasen <mclasen@redhat.com>2016-01-24 10:59:46 -0500
commit33bb1af277c7311dcf89dc85d45f5319d0edd8f6 (patch)
tree63dc0ec28bdf01e57009b408f1ee4ac2931e5b8f /gtk/gtkcssselector.c
parentf0439264aa3648a2c556b61294580deb8d566d02 (diff)
downloadgtk+-33bb1af277c7311dcf89dc85d45f5319d0edd8f6.tar.gz
css: Privately export a function to get pseudoclass names
This function centralizes the mapping for widget states to pseudoclass names in one place, for easier maintenance.
Diffstat (limited to 'gtk/gtkcssselector.c')
-rw-r--r--gtk/gtkcssselector.c27
1 files changed, 14 insertions, 13 deletions
diff --git a/gtk/gtkcssselector.c b/gtk/gtkcssselector.c
index 7616493582..b23e1fdc1c 100644
--- a/gtk/gtkcssselector.c
+++ b/gtk/gtkcssselector.c
@@ -726,11 +726,8 @@ comp_id (const GtkCssSelector *a,
DEFINE_SIMPLE_SELECTOR(id, ID, print_id, match_id, hash_id, comp_id, TRUE, FALSE, FALSE)
-/* PSEUDOCLASS FOR STATE */
-
-static void
-print_pseudoclass_state (const GtkCssSelector *selector,
- GString *string)
+const gchar *
+gtk_css_pseudoclass_name (GtkStateFlags state)
{
static const char * state_names[] = {
"active",
@@ -749,18 +746,22 @@ print_pseudoclass_state (const GtkCssSelector *selector,
};
guint i;
- g_string_append_c (string, ':');
-
for (i = 0; i < G_N_ELEMENTS (state_names); i++)
{
- if (selector->state.state == (1 << i))
- {
- g_string_append (string, state_names[i]);
- return;
- }
+ if (state == (1 << i))
+ return state_names[i];
}
- g_assert_not_reached ();
+ return NULL;
+}
+
+/* PSEUDOCLASS FOR STATE */
+static void
+print_pseudoclass_state (const GtkCssSelector *selector,
+ GString *string)
+{
+ g_string_append_c (string, ':');
+ g_string_append (string, gtk_css_pseudoclass_name (selector->state.state));
}
static gboolean