diff --git a/gtk/inspector/css-editor.c b/gtk/inspector/css-editor.c index e8515a4bea..fe16f3b13f 100644 --- a/gtk/inspector/css-editor.c +++ b/gtk/inspector/css-editor.c @@ -47,6 +47,7 @@ struct _GtkInspectorCssEditorPrivate GtkToggleButton *disable_button; guint timeout; GList *errors; + gboolean show_deprecations; }; typedef struct { @@ -94,6 +95,12 @@ query_tooltip_cb (GtkWidget *widget, { CssError *css_error = l->data; + if (g_error_matches (css_error->error, + GTK_CSS_PARSER_WARNING, + GTK_CSS_PARSER_WARNING_DEPRECATED) && + !ce->priv->show_deprecations) + continue; + if (gtk_text_iter_in_range (&iter, &css_error->start, &css_error->end)) { gtk_tooltip_set_text (tooltip, css_error->error->message); @@ -170,6 +177,29 @@ disable_toggled (GtkToggleButton *button, GTK_STYLE_PROVIDER_PRIORITY_USER); } +static void +toggle_deprecations (GtkToggleButton *button, + GtkInspectorCssEditor *ce) +{ + GtkTextTagTable *tags; + GtkTextTag *tag; + PangoUnderline underline; + + if (!ce->priv->display) + return; + + ce->priv->show_deprecations = gtk_toggle_button_get_active (button); + + tags = gtk_text_buffer_get_tag_table (GTK_TEXT_BUFFER (ce->priv->text)); + tag = gtk_text_tag_table_lookup (tags, "deprecation"); + if (ce->priv->show_deprecations) + underline = PANGO_UNDERLINE_SINGLE; + else + underline = PANGO_UNDERLINE_NONE; + + g_object_set (tag, "underline", underline, NULL); +} + static char * get_current_text (GtkTextBuffer *buffer) { @@ -316,7 +346,12 @@ show_parsing_error (GtkCssProvider *provider, end->line_bytes); if (error->domain == GTK_CSS_PARSER_WARNING) - tag_name = "warning"; + { + if (error->code == GTK_CSS_PARSER_WARNING_DEPRECATED) + tag_name = "deprecation"; + else + tag_name = "warning"; + } else tag_name = "error"; @@ -407,6 +442,7 @@ gtk_inspector_css_editor_class_init (GtkInspectorCssEditorClass *klass) gtk_widget_class_bind_template_child_private (widget_class, GtkInspectorCssEditor, view); gtk_widget_class_bind_template_child_private (widget_class, GtkInspectorCssEditor, disable_button); gtk_widget_class_bind_template_callback (widget_class, disable_toggled); + gtk_widget_class_bind_template_callback (widget_class, toggle_deprecations); gtk_widget_class_bind_template_callback (widget_class, save_clicked); gtk_widget_class_bind_template_callback (widget_class, text_changed); gtk_widget_class_bind_template_callback (widget_class, query_tooltip_cb); diff --git a/gtk/inspector/css-editor.ui b/gtk/inspector/css-editor.ui index 7663af860b..7500f95860 100644 --- a/gtk/inspector/css-editor.ui +++ b/gtk/inspector/css-editor.ui @@ -7,6 +7,13 @@ darkorange + + + deprecation + none + blue + + error @@ -39,6 +46,13 @@ + + + Show deprecations + dialog-information-symbolic + + +