mirror of
https://gitlab.gnome.org/GNOME/gtk.git
synced 2025-01-13 05:50:10 +00:00
gsk: Avoid using gtk css types in public api
Using GtkCssSection in public headers here may be ok from the C perspective, since it all ends up in the same library anyway. But it causes circular dependency problems for our gir files that are still split by namespace. To avoid this problem, copy the GtkCssLocation struct struct as GskParseLocation, and pass take two of them instead of a GtkCssSection in the error callback. Update all users. Fixes: #2454
This commit is contained in:
parent
2c9bf55eea
commit
121e61cf01
@ -102,12 +102,11 @@ text_buffer_remove_all_tags (GtkTextBuffer *buffer)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
deserialize_error_func (const GtkCssSection *section,
|
deserialize_error_func (const GskParseLocation *start_location,
|
||||||
const GError *error,
|
const GskParseLocation *end_location,
|
||||||
gpointer user_data)
|
const GError *error,
|
||||||
|
gpointer user_data)
|
||||||
{
|
{
|
||||||
const GtkCssLocation *start_location = gtk_css_section_get_start_location (section);
|
|
||||||
const GtkCssLocation *end_location = gtk_css_section_get_end_location (section);
|
|
||||||
NodeEditorWindow *self = user_data;
|
NodeEditorWindow *self = user_data;
|
||||||
GtkTextIter start_iter, end_iter;
|
GtkTextIter start_iter, end_iter;
|
||||||
TextViewError text_view_error;
|
TextViewError text_view_error;
|
||||||
|
@ -54,18 +54,31 @@ struct _GskShadow
|
|||||||
float radius;
|
float radius;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
typedef struct _GskParseLocation GskParseLocation;
|
||||||
|
|
||||||
|
struct _GskParseLocation
|
||||||
|
{
|
||||||
|
gsize bytes;
|
||||||
|
gsize chars;
|
||||||
|
gsize lines;
|
||||||
|
gsize line_bytes;
|
||||||
|
gsize line_chars;
|
||||||
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* GskParseErrorFunc:
|
* GskParseErrorFunc:
|
||||||
* @section: the #GtkCssSection where the error occurred
|
* @start: start of the error location
|
||||||
* @error: the error
|
* @end: end of the error location
|
||||||
|
* @error: the error
|
||||||
* @user_data: user data
|
* @user_data: user data
|
||||||
*
|
*
|
||||||
* The type of callback that is called when a parse error occurs
|
* The type of callback that is called when a parse error occurs
|
||||||
* during deserialization of node data.
|
* during deserialization of node data.
|
||||||
*/
|
*/
|
||||||
typedef void (* GskParseErrorFunc) (const GtkCssSection *section,
|
typedef void (* GskParseErrorFunc) (const GskParseLocation *start,
|
||||||
const GError *error,
|
const GskParseLocation *end,
|
||||||
gpointer user_data);
|
const GError *error,
|
||||||
|
gpointer user_data);
|
||||||
|
|
||||||
GDK_AVAILABLE_IN_ALL
|
GDK_AVAILABLE_IN_ALL
|
||||||
GType gsk_render_node_get_type (void) G_GNUC_CONST;
|
GType gsk_render_node_get_type (void) G_GNUC_CONST;
|
||||||
|
@ -1859,12 +1859,10 @@ gsk_render_node_parser_error (GtkCssParser *parser,
|
|||||||
} *error_func_pair = user_data;
|
} *error_func_pair = user_data;
|
||||||
|
|
||||||
if (error_func_pair->error_func)
|
if (error_func_pair->error_func)
|
||||||
{
|
error_func_pair->error_func ((const GskParseLocation *)start,
|
||||||
GtkCssSection *section = gtk_css_section_new (gtk_css_parser_get_file (parser), start, end);
|
(const GskParseLocation *)end,
|
||||||
|
error,
|
||||||
error_func_pair->error_func (section, error, error_func_pair->user_data);
|
error_func_pair->user_data);
|
||||||
gtk_css_section_unref (section);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
GskRenderNode *
|
GskRenderNode *
|
||||||
|
@ -14,15 +14,26 @@ static GOptionEntry options[] = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
static void
|
static void
|
||||||
deserialize_error_func (const GtkCssSection *section,
|
deserialize_error_func (const GskParseLocation *start,
|
||||||
const GError *error,
|
const GskParseLocation *end,
|
||||||
gpointer user_data)
|
const GError *error,
|
||||||
|
gpointer user_data)
|
||||||
{
|
{
|
||||||
char *section_str = gtk_css_section_to_string (section);
|
GString *string = g_string_new ("<data>");
|
||||||
|
|
||||||
g_warning ("Error at %s: %s", section_str, error->message);
|
g_string_append_printf (string, ":%zu:%zu",
|
||||||
|
start->lines + 1, start->line_chars + 1);
|
||||||
|
if (start->lines != end->lines || start->line_chars != end->line_chars)
|
||||||
|
{
|
||||||
|
g_string_append (string, "-");
|
||||||
|
if (start->lines != end->lines)
|
||||||
|
g_string_append_printf (string, "%zu:", end->lines + 1);
|
||||||
|
g_string_append_printf (string, "%zu", end->line_chars + 1);
|
||||||
|
}
|
||||||
|
|
||||||
g_free (section_str);
|
g_warning ("Error at %s: %s", string->str, error->message);
|
||||||
|
|
||||||
|
g_string_free (string, TRUE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -102,15 +102,26 @@ gtk_node_view_class_init (GtkNodeViewClass *klass)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
deserialize_error_func (const GtkCssSection *section,
|
deserialize_error_func (const GskParseLocation *start,
|
||||||
const GError *error,
|
const GskParseLocation *end,
|
||||||
gpointer user_data)
|
const GError *error,
|
||||||
|
gpointer user_data)
|
||||||
{
|
{
|
||||||
char *section_str = gtk_css_section_to_string (section);
|
GString *string = g_string_new ("<data>");
|
||||||
|
|
||||||
g_warning ("Error at %s: %s", section_str, error->message);
|
g_string_append_printf (string, ":%zu:%zu",
|
||||||
|
start->lines + 1, start->line_chars + 1);
|
||||||
|
if (start->lines != end->lines || start->line_chars != end->line_chars)
|
||||||
|
{
|
||||||
|
g_string_append (string, "-");
|
||||||
|
if (start->lines != end->lines)
|
||||||
|
g_string_append_printf (string, "%zu:", end->lines + 1);
|
||||||
|
g_string_append_printf (string, "%zu", end->line_chars + 1);
|
||||||
|
}
|
||||||
|
|
||||||
g_free (section_str);
|
g_warning ("Error at %s: %s", string->str, error->message);
|
||||||
|
|
||||||
|
g_string_free (string, TRUE);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -111,16 +111,26 @@ save_image (cairo_surface_t *surface,
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
deserialize_error_func (const GtkCssSection *section,
|
deserialize_error_func (const GskParseLocation *start,
|
||||||
const GError *error,
|
const GskParseLocation *end,
|
||||||
gpointer user_data)
|
const GError *error,
|
||||||
|
gpointer user_data)
|
||||||
{
|
{
|
||||||
char *section_str = gtk_css_section_to_string (section);
|
GString *string = g_string_new ("<data>");
|
||||||
|
|
||||||
g_print ("Error at %s: %s", section_str, error->message);
|
g_string_append_printf (string, ":%zu:%zu",
|
||||||
*((gboolean *) user_data) = FALSE;
|
start->lines + 1, start->line_chars + 1);
|
||||||
|
if (start->lines != end->lines || start->line_chars != end->line_chars)
|
||||||
|
{
|
||||||
|
g_string_append (string, "-");
|
||||||
|
if (start->lines != end->lines)
|
||||||
|
g_string_append_printf (string, "%zu:", end->lines + 1);
|
||||||
|
g_string_append_printf (string, "%zu", end->line_chars + 1);
|
||||||
|
}
|
||||||
|
|
||||||
free (section_str);
|
g_warning ("Error at %s: %s", string->str, error->message);
|
||||||
|
|
||||||
|
g_string_free (string, TRUE);
|
||||||
}
|
}
|
||||||
|
|
||||||
static const GOptionEntry options[] = {
|
static const GOptionEntry options[] = {
|
||||||
|
@ -122,19 +122,26 @@ append_error_value (GString *string,
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
deserialize_error_func (const GtkCssSection *section,
|
deserialize_error_func (const GskParseLocation *start,
|
||||||
const GError *error,
|
const GskParseLocation *end,
|
||||||
gpointer user_data)
|
const GError *error,
|
||||||
|
gpointer user_data)
|
||||||
{
|
{
|
||||||
GString *errors = user_data;
|
GString *errors = user_data;
|
||||||
char *section_string;
|
GString *string = g_string_new ("<data>");
|
||||||
|
|
||||||
section_string = gtk_css_section_to_string (section);
|
g_string_append_printf (string, ":%zu:%zu",
|
||||||
|
start->lines + 1, start->line_chars + 1);
|
||||||
|
if (start->lines != end->lines || start->line_chars != end->line_chars)
|
||||||
|
{
|
||||||
|
g_string_append (string, "-");
|
||||||
|
if (start->lines != end->lines)
|
||||||
|
g_string_append_printf (string, "%zu:", end->lines + 1);
|
||||||
|
g_string_append_printf (string, "%zu", end->line_chars + 1);
|
||||||
|
}
|
||||||
|
|
||||||
g_string_append_printf (errors,
|
g_string_append_printf (errors, "%s: error: ", string->str);
|
||||||
"%s: error: ",
|
g_string_free (string, TRUE);
|
||||||
section_string);
|
|
||||||
g_free (section_string);
|
|
||||||
|
|
||||||
if (error->domain == GTK_CSS_PARSER_ERROR)
|
if (error->domain == GTK_CSS_PARSER_ERROR)
|
||||||
append_error_value (errors, GTK_TYPE_CSS_PARSER_ERROR, error->code);
|
append_error_value (errors, GTK_TYPE_CSS_PARSER_ERROR, error->code);
|
||||||
|
Loading…
Reference in New Issue
Block a user