summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCarlos Garnacho <carlosg@gnome.org>2010-08-20 11:50:39 +0200
committerCarlos Garnacho <carlosg@gnome.org>2010-12-04 15:38:09 +0100
commit9dfba95f095667b425a8f676c48c5749ab6c4c18 (patch)
treef58fdff4c3e81e865f9893cac951a9ed09bf2722
parent0ce649e965560863d585393f70c7212a4f9cffbc (diff)
downloadgtk+-9dfba95f095667b425a8f676c48c5749ab6c4c18.tar.gz
GtkCssProvider: Add gtk_css_provider_load_from_path()
-rw-r--r--gtk/gtkcssprovider.c60
-rw-r--r--gtk/gtkcssprovider.h3
2 files changed, 63 insertions, 0 deletions
diff --git a/gtk/gtkcssprovider.c b/gtk/gtkcssprovider.c
index c9c5a17aed..f9780c2420 100644
--- a/gtk/gtkcssprovider.c
+++ b/gtk/gtkcssprovider.c
@@ -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"
diff --git a/gtk/gtkcssprovider.h b/gtk/gtkcssprovider.h
index 18364eaea8..2b8dd9dcfe 100644
--- a/gtk/gtkcssprovider.h
+++ b/gtk/gtkcssprovider.h
@@ -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);