Commit 9dfba95f authored by Carlos Garnacho's avatar Carlos Garnacho

GtkCssProvider: Add gtk_css_provider_load_from_path()

parent 0ce649e9
......@@ -1686,6 +1686,45 @@ gtk_css_provider_load_from_file (GtkCssProvider *css_provider,
return TRUE;
}
gboolean
gtk_css_provider_load_from_path (GtkCssProvider *css_provider,
const gchar *path,
GError **error)
{
GtkCssProviderPrivate *priv;
GError *internal_error = NULL;
gchar *data;
gsize length;
g_return_val_if_fail (GTK_IS_CSS_PROVIDER (css_provider), FALSE);
g_return_val_if_fail (path != NULL, FALSE);
priv = css_provider->priv;
if (g_file_get_contents (path, &data, &length,
&internal_error))
{
g_propagate_error (error, internal_error);
return FALSE;
}
if (priv->selectors_info->len > 0)
g_ptr_array_remove_range (priv->selectors_info, 0, priv->selectors_info->len);
g_free (priv->filename);
priv->filename = g_strdup (path);
css_provider_reset_parser (css_provider);
priv->scanner->input_name = priv->filename;
g_scanner_input_text (priv->scanner, data, (guint) length);
parse_stylesheet (css_provider);
g_free (data);
return TRUE;
}
GtkCssProvider *
gtk_css_provider_get_default (void)
{
......@@ -1762,5 +1801,26 @@ gtk_css_provider_get_default (void)
return provider;
}
GtkCssProvider *
gtk_css_provider_get_named (const gchar *name)
{
static GHashTable *themes = NULL;
GtkCssProvider *provider;
if (G_UNLIKELY (!themes))
themes = g_hash_table_new (g_str_hash, g_str_equal);
provider = g_hash_table_lookup (themes, name);
if (!provider)
{
g_hash_table_insert (themes, g_strdup (name), provider);
}
return provider;
}
#define __GTK_CSS_PROVIDER_C__
#include "gtkaliasdef.c"
......@@ -56,6 +56,9 @@ gboolean gtk_css_provider_load_from_data (GtkCssProvider *css_provider,
gboolean gtk_css_provider_load_from_file (GtkCssProvider *css_provider,
GFile *file,
GError **error);
gboolean gtk_css_provider_load_from_path (GtkCssProvider *css_provider,
const gchar *path,
GError **error);
GtkCssProvider * gtk_css_provider_get_default (void);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment