summaryrefslogtreecommitdiff
path: root/gtk/gtkcssprovider.c
diff options
context:
space:
mode:
authorAlexander Larsson <alexl@redhat.com>2012-02-03 15:50:49 +0100
committerAlexander Larsson <alexl@redhat.com>2012-02-03 15:50:49 +0100
commit57386285fa23db6879efaccd2cfa7ed501b6056f (patch)
treeb45708be748e862af824c82ab4e7e1ec4f6b4f44 /gtk/gtkcssprovider.c
parent35db0819fff665407890028d8ed0ed9874a3822b (diff)
downloadgtk+-57386285fa23db6879efaccd2cfa7ed501b6056f.tar.gz
Support a gtk.gresource file in themes
This lets themes install a .gresource for efficient loading of resources. This resource file will (if it exists) be automatically loaded (mmaped) when the theme is used and unloaded when not used.
Diffstat (limited to 'gtk/gtkcssprovider.c')
-rw-r--r--gtk/gtkcssprovider.c20
1 files changed, 20 insertions, 0 deletions
diff --git a/gtk/gtkcssprovider.c b/gtk/gtkcssprovider.c
index dbbf92a00b..e499db5d94 100644
--- a/gtk/gtkcssprovider.c
+++ b/gtk/gtkcssprovider.c
@@ -985,6 +985,7 @@ struct _GtkCssProviderPrivate
GHashTable *symbolic_colors;
GArray *rulesets;
+ GResource *resource;
};
enum {
@@ -1591,6 +1592,13 @@ gtk_css_provider_finalize (GObject *object)
if (priv->symbolic_colors)
g_hash_table_destroy (priv->symbolic_colors);
+ if (priv->resource)
+ {
+ g_resources_unregister (priv->resource);
+ g_resource_unref (priv->resource);
+ priv->resource = NULL;
+ }
+
G_OBJECT_CLASS (gtk_css_provider_parent_class)->finalize (object);
}
@@ -2901,8 +2909,20 @@ gtk_css_provider_get_named (const gchar *name,
if (path)
{
+ char *dir, *resource_file;
+ GResource *resource;
+
provider = gtk_css_provider_new ();
+ dir = g_path_get_dirname (path);
+ resource_file = g_build_filename (dir, "gtk.gresource", NULL);
+ resource = g_resource_load (resource_file, NULL);
+ if (resource != NULL)
+ {
+ provider->priv->resource = resource;
+ g_resources_register (resource);
+ }
+
if (!gtk_css_provider_load_from_path (provider, path, NULL))
{
g_object_unref (provider);