diff options
-rw-r--r-- | docs/reference/gtk/gtk4-sections.txt | 2 | ||||
-rw-r--r-- | gtk/gtkcssanimatedstyle.c | 1 | ||||
-rw-r--r-- | gtk/gtkcssnode.c | 1 | ||||
-rw-r--r-- | gtk/gtkcssprovider.c | 4 | ||||
-rw-r--r-- | gtk/gtkcsssection.c | 40 | ||||
-rw-r--r-- | gtk/gtkcsssection.h | 6 | ||||
-rw-r--r-- | gtk/gtkcsssectionprivate.h | 33 | ||||
-rw-r--r-- | gtk/gtkcssstaticstyle.c | 1 | ||||
-rw-r--r-- | gtk/gtkcssstyle.c | 4 | ||||
-rw-r--r-- | gtk/inspector/css-node-tree.c | 4 |
10 files changed, 47 insertions, 49 deletions
diff --git a/docs/reference/gtk/gtk4-sections.txt b/docs/reference/gtk/gtk4-sections.txt index 9797298262..32a1ad59f7 100644 --- a/docs/reference/gtk/gtk4-sections.txt +++ b/docs/reference/gtk/gtk4-sections.txt @@ -5095,6 +5095,8 @@ GtkCssSection gtk_css_section_new gtk_css_section_ref gtk_css_section_unref +gtk_css_section_print +gtk_css_section_to_string gtk_css_section_get_file gtk_css_section_get_parent gtk_css_section_get_start_location diff --git a/gtk/gtkcssanimatedstyle.c b/gtk/gtkcssanimatedstyle.c index 54dfa3684a..c09ddb01ce 100644 --- a/gtk/gtkcssanimatedstyle.c +++ b/gtk/gtkcssanimatedstyle.c @@ -28,7 +28,6 @@ #include "gtkcssinheritvalueprivate.h" #include "gtkcssinitialvalueprivate.h" #include "gtkcssnumbervalueprivate.h" -#include "gtkcsssectionprivate.h" #include "gtkcssshorthandpropertyprivate.h" #include "gtkcssstaticstyleprivate.h" #include "gtkcssstringvalueprivate.h" diff --git a/gtk/gtkcssnode.c b/gtk/gtkcssnode.c index f940c53b5d..8bcf5faa92 100644 --- a/gtk/gtkcssnode.c +++ b/gtk/gtkcssnode.c @@ -20,7 +20,6 @@ #include "gtkcssnodeprivate.h" #include "gtkcssanimatedstyleprivate.h" -#include "gtkcsssectionprivate.h" #include "gtkcssstylepropertyprivate.h" #include "gtkintl.h" #include "gtkmarshalers.h" diff --git a/gtk/gtkcssprovider.c b/gtk/gtkcssprovider.c index c16bfcb94b..8f1bb22f3d 100644 --- a/gtk/gtkcssprovider.c +++ b/gtk/gtkcssprovider.c @@ -30,7 +30,7 @@ #include "gtkcsscolorvalueprivate.h" #include "gtkcsskeyframesprivate.h" #include "gtkcssparserprivate.h" -#include "gtkcsssectionprivate.h" +#include "gtkcsssection.h" #include "gtkcssselectorprivate.h" #include "gtkcssshorthandpropertyprivate.h" #include "gtksettingsprivate.h" @@ -162,7 +162,7 @@ gtk_css_provider_parsing_error (GtkCssProvider *provider, 0, TRUE)) { - char *s = _gtk_css_section_to_string (section); + char *s = gtk_css_section_to_string (section); g_warning ("Theme parsing error: %s: %s", s, diff --git a/gtk/gtkcsssection.c b/gtk/gtkcsssection.c index caf2b7509c..3134666796 100644 --- a/gtk/gtkcsssection.c +++ b/gtk/gtkcsssection.c @@ -17,7 +17,7 @@ #include "config.h" -#include "gtkcsssectionprivate.h" +#include "gtkcsssection.h" #include "gtkcssparserprivate.h" #include "gtkprivate.h" @@ -184,9 +184,18 @@ gtk_css_section_get_end_location (const GtkCssSection *section) return §ion->end_location; } +/** + * gtk_css_section_print: + * @section: a section + * @string: a #GString to print to + * + * Prints the @section into @string in a human-readable form. This + * is a form like `gtk.css:32:1-23` to denote line 32, characters + * 1 to 23 in the file gtk.css. + **/ void -_gtk_css_section_print (const GtkCssSection *section, - GString *string) +gtk_css_section_print (const GtkCssSection *section, + GString *string) { if (section->file) { @@ -210,19 +219,36 @@ _gtk_css_section_print (const GtkCssSection *section, } g_string_append_printf (string, ":%zu:%zu", - section->end_location.lines + 1, - section->end_location.line_chars + 1); + section->start_location.lines + 1, + section->start_location.line_chars + 1); + if (section->start_location.lines != section->end_location.lines || + section->start_location.line_chars != section->end_location.line_chars) + { + g_string_append (string, "-"); + if (section->start_location.lines != section->end_location.lines) + g_string_append_printf (string, "%zu:", section->end_location.lines + 1); + g_string_append_printf (string, "%zu", section->end_location.line_chars + 1); + } } +/** + * gtk_css_section_to_string: + * @section: a #GtkCssSection + * + * Prints the section into a human-readable text form using + * gtk_css_section_print(). + * + * Returns: (transfer full): A new string. + **/ char * -_gtk_css_section_to_string (const GtkCssSection *section) +gtk_css_section_to_string (const GtkCssSection *section) { GString *string; gtk_internal_return_val_if_fail (section != NULL, NULL); string = g_string_new (NULL); - _gtk_css_section_print (section, string); + gtk_css_section_print (section, string); return g_string_free (string, FALSE); } diff --git a/gtk/gtkcsssection.h b/gtk/gtkcsssection.h index 1fd56eab3f..fbca82105b 100644 --- a/gtk/gtkcsssection.h +++ b/gtk/gtkcsssection.h @@ -47,6 +47,12 @@ GDK_AVAILABLE_IN_ALL void gtk_css_section_unref (GtkCssSection *section); GDK_AVAILABLE_IN_ALL +void gtk_css_section_print (const GtkCssSection *section, + GString *string); +GDK_AVAILABLE_IN_ALL +char * gtk_css_section_to_string (const GtkCssSection *section); + +GDK_AVAILABLE_IN_ALL GtkCssSection * gtk_css_section_get_parent (const GtkCssSection *section); GDK_AVAILABLE_IN_ALL GFile * gtk_css_section_get_file (const GtkCssSection *section); diff --git a/gtk/gtkcsssectionprivate.h b/gtk/gtkcsssectionprivate.h deleted file mode 100644 index 863ee2bd4f..0000000000 --- a/gtk/gtkcsssectionprivate.h +++ /dev/null @@ -1,33 +0,0 @@ -/* GTK - The GIMP Toolkit - * Copyright (C) 2011 Red Hat, Inc. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library. If not, see <http://www.gnu.org/licenses/>. - */ - -#ifndef __GTK_CSS_SECTION_PRIVATE_H__ -#define __GTK_CSS_SECTION_PRIVATE_H__ - -#include "gtkcsssection.h" - -#include "gtkcssparserprivate.h" - -G_BEGIN_DECLS - -void _gtk_css_section_print (const GtkCssSection *section, - GString *string); -char * _gtk_css_section_to_string (const GtkCssSection *section); - -G_END_DECLS - -#endif /* __GTK_CSS_SECTION_PRIVATE_H__ */ diff --git a/gtk/gtkcssstaticstyle.c b/gtk/gtkcssstaticstyle.c index e257296fd0..d0557597a3 100644 --- a/gtk/gtkcssstaticstyle.c +++ b/gtk/gtkcssstaticstyle.c @@ -27,7 +27,6 @@ #include "gtkcssinheritvalueprivate.h" #include "gtkcssinitialvalueprivate.h" #include "gtkcssnumbervalueprivate.h" -#include "gtkcsssectionprivate.h" #include "gtkcssshorthandpropertyprivate.h" #include "gtkcssstringvalueprivate.h" #include "gtkcssstylepropertyprivate.h" diff --git a/gtk/gtkcssstyle.c b/gtk/gtkcssstyle.c index d896aebed3..89f4a102a1 100644 --- a/gtk/gtkcssstyle.c +++ b/gtk/gtkcssstyle.c @@ -29,7 +29,7 @@ #include "gtkcssinitialvalueprivate.h" #include "gtkcssnumbervalueprivate.h" #include "gtkcssrgbavalueprivate.h" -#include "gtkcsssectionprivate.h" +#include "gtkcsssection.h" #include "gtkcssshorthandpropertyprivate.h" #include "gtkcssstringvalueprivate.h" #include "gtkcssfontfeaturesvalueprivate.h" @@ -162,7 +162,7 @@ gtk_css_style_print (GtkCssStyle *style, if (section) { g_string_append (string, " /* "); - _gtk_css_section_print (section, string); + gtk_css_section_print (section, string); g_string_append (string, " */"); } diff --git a/gtk/inspector/css-node-tree.c b/gtk/inspector/css-node-tree.c index 6093c81d5f..a6d6a202bc 100644 --- a/gtk/inspector/css-node-tree.c +++ b/gtk/inspector/css-node-tree.c @@ -33,7 +33,7 @@ #include "gtk/gtkwidgetprivate.h" #include "gtkcssproviderprivate.h" #include "gtkcssstylepropertyprivate.h" -#include "gtkcsssectionprivate.h" +#include "gtkcsssection.h" #include "gtkcssstyleprivate.h" #include "gtkcssvalueprivate.h" #include "gtkcssselectorprivate.h" @@ -473,7 +473,7 @@ gtk_inspector_css_node_tree_update_style (GtkInspectorCssNodeTree *cnt, section = gtk_css_style_get_section (new_style, i); if (section) - location = _gtk_css_section_to_string (section); + location = gtk_css_section_to_string (section); else location = NULL; } |