csssection: Make printing functions public

This commit is contained in:
Benjamin Otte
2019-04-10 17:23:14 +02:00
parent 085d34cbb0
commit 04d24b7cd2
10 changed files with 47 additions and 49 deletions

View File

@@ -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

View File

@@ -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"

View File

@@ -20,7 +20,6 @@
#include "gtkcssnodeprivate.h"
#include "gtkcssanimatedstyleprivate.h"
#include "gtkcsssectionprivate.h"
#include "gtkcssstylepropertyprivate.h"
#include "gtkintl.h"
#include "gtkmarshalers.h"

View File

@@ -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,

View File

@@ -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 &section->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);
}

View File

@@ -46,6 +46,12 @@ GtkCssSection * gtk_css_section_ref (GtkCssSection *se
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

View File

@@ -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__ */

View File

@@ -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"

View File

@@ -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, " */");
}

View File

@@ -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;
}