cssprovider: Introduce gtk_css_provider_take_error_full()
Emits the error without the need for a scanner. Also simplifies gtk_css_provider_take_error() because we now can assert an available scanner at all times.
This commit is contained in:
parent
f937d0275a
commit
5bedc822ec
@ -846,9 +846,6 @@ static gboolean gtk_css_provider_load_from_path_internal (GtkCssProvider *css_p
|
|||||||
const gchar *path,
|
const gchar *path,
|
||||||
gboolean reset,
|
gboolean reset,
|
||||||
GError **error);
|
GError **error);
|
||||||
static void gtk_css_provider_take_error (GtkCssProvider *provider,
|
|
||||||
GScanner *scanner,
|
|
||||||
GError *error);
|
|
||||||
|
|
||||||
GQuark
|
GQuark
|
||||||
gtk_css_provider_error_quark (void)
|
gtk_css_provider_error_quark (void)
|
||||||
@ -926,6 +923,27 @@ gtk_css_provider_class_init (GtkCssProviderClass *klass)
|
|||||||
g_type_class_add_private (object_class, sizeof (GtkCssProviderPrivate));
|
g_type_class_add_private (object_class, sizeof (GtkCssProviderPrivate));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
gtk_css_provider_take_error_full (GtkCssProvider *provider,
|
||||||
|
GFile *file,
|
||||||
|
guint line,
|
||||||
|
guint position,
|
||||||
|
GError *error)
|
||||||
|
{
|
||||||
|
char *filename;
|
||||||
|
|
||||||
|
if (file)
|
||||||
|
filename = g_file_get_path (file);
|
||||||
|
else
|
||||||
|
filename = NULL;
|
||||||
|
|
||||||
|
g_signal_emit (provider, css_provider_signals[PARSING_ERROR], 0,
|
||||||
|
filename, line, position, error);
|
||||||
|
|
||||||
|
g_free (filename);
|
||||||
|
g_error_free (error);
|
||||||
|
}
|
||||||
|
|
||||||
static SelectorPath *
|
static SelectorPath *
|
||||||
selector_path_new (void)
|
selector_path_new (void)
|
||||||
{
|
{
|
||||||
@ -1582,7 +1600,11 @@ gtk_css_provider_get_style_property (GtkStyleProvider *provider,
|
|||||||
if (found)
|
if (found)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
gtk_css_provider_take_error (GTK_CSS_PROVIDER (provider), NULL, error);
|
/* error location should be _way_ better */
|
||||||
|
gtk_css_provider_take_error_full (GTK_CSS_PROVIDER (provider),
|
||||||
|
NULL,
|
||||||
|
0, 0,
|
||||||
|
error);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1634,31 +1656,13 @@ gtk_css_provider_take_error (GtkCssProvider *provider,
|
|||||||
GScanner *scanner,
|
GScanner *scanner,
|
||||||
GError *error)
|
GError *error)
|
||||||
{
|
{
|
||||||
char *filename;
|
GtkCssScannerPrivate *priv = scanner->user_data;
|
||||||
guint line, position;
|
|
||||||
|
|
||||||
if (scanner)
|
gtk_css_provider_take_error_full (provider,
|
||||||
{
|
priv->file,
|
||||||
GtkCssScannerPrivate *priv = scanner->user_data;
|
scanner->line,
|
||||||
if (priv->file)
|
scanner->position,
|
||||||
filename = g_file_get_path (priv->file);
|
error);
|
||||||
else
|
|
||||||
filename = NULL;
|
|
||||||
line = scanner->line;
|
|
||||||
position = scanner->position;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
filename = NULL;
|
|
||||||
line = 0;
|
|
||||||
position = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
g_signal_emit (provider, css_provider_signals[PARSING_ERROR], 0,
|
|
||||||
filename, line, position, error);
|
|
||||||
|
|
||||||
g_free (filename);
|
|
||||||
g_error_free (error);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
Loading…
Reference in New Issue
Block a user