[gtk+] css provider: Issue deprecation warnings for style properties
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+] css provider: Issue deprecation warnings for style properties
- Date: Mon, 16 Nov 2015 20:15:09 +0000 (UTC)
commit 08c4bc8aa555db6378311d7fb4d050e96b4ff28a
Author: Matthias Clasen <mclasen redhat com>
Date: Mon Nov 16 14:37:23 2015 -0500
css provider: Issue deprecation warnings for style properties
This makes G_PARAM_DEPRECATED useful for style properties.
gtk/gtkcssprovider.c | 51 ++++++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 51 insertions(+), 0 deletions(-)
---
diff --git a/gtk/gtkcssprovider.c b/gtk/gtkcssprovider.c
index 5c17936..da7564b 100644
--- a/gtk/gtkcssprovider.c
+++ b/gtk/gtkcssprovider.c
@@ -2409,6 +2409,55 @@ name_is_style_property (const char *name)
}
static void
+warn_if_deprecated (GtkCssScanner *scanner,
+ const gchar *name)
+{
+ gchar *n = NULL;
+ gchar *p;
+ const gchar *type_name;
+ const gchar *property_name;
+ GType type;
+ GTypeClass *class = NULL;
+ GParamSpec *pspec;
+
+ n = g_strdup (name);
+
+ /* skip initial - */
+ type_name = n + 1;
+
+ p = strchr (type_name, '-');
+ if (!p)
+ goto out;
+
+ p[0] = '\0';
+ property_name = p + 1;
+
+ type = g_type_from_name (type_name);
+ if (type == G_TYPE_INVALID ||
+ !g_type_is_a (type, GTK_TYPE_WIDGET))
+ goto out;
+
+ class = g_type_class_ref (type);
+ pspec = gtk_widget_class_find_style_property (GTK_WIDGET_CLASS (class), property_name);
+ if (!pspec)
+ goto out;
+
+ if (!(pspec->flags & G_PARAM_DEPRECATED))
+ goto out;
+
+ _gtk_css_parser_error_full (scanner->parser,
+ GTK_CSS_PROVIDER_ERROR_DEPRECATED,
+ "The style property %s:%s is deprecated and shouldn't be "
+ "used anymore. It will be removed in a future version",
+ g_type_name (pspec->owner_type), pspec->name);
+
+out:
+ g_free (n);
+ if (class)
+ g_type_class_unref (class);
+}
+
+static void
parse_declaration (GtkCssScanner *scanner,
GtkCssRuleset *ruleset)
{
@@ -2511,6 +2560,8 @@ parse_declaration (GtkCssScanner *scanner,
{
char *value_str;
+ warn_if_deprecated (scanner, name);
+
gtk_css_scanner_push_section (scanner, GTK_CSS_SECTION_VALUE);
value_str = _gtk_css_parser_read_value (scanner->parser);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]