[gtk+/gtk-style-context: 198/533] GtkCssProvider: Add gtk_css_provider_load_from_path()
- From: Carlos Garnacho <carlosg src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+/gtk-style-context: 198/533] GtkCssProvider: Add gtk_css_provider_load_from_path()
- Date: Wed, 1 Dec 2010 02:22:24 +0000 (UTC)
commit 21c98fcc9987900670fe1e6568cae8ade26ff03a
Author: Carlos Garnacho <carlosg gnome org>
Date: Fri Aug 20 11:50:39 2010 +0200
GtkCssProvider: Add gtk_css_provider_load_from_path()
gtk/gtkcssprovider.c | 60 ++++++++++++++++++++++++++++++++++++++++++++++++++
gtk/gtkcssprovider.h | 3 ++
2 files changed, 63 insertions(+), 0 deletions(-)
---
diff --git a/gtk/gtkcssprovider.c b/gtk/gtkcssprovider.c
index c9c5a17..f9780c2 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 18364ea..2b8dd9d 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);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]