[gtk+] Remove all default css and make Raleigh a pure fallback theme
- From: Alexander Larsson <alexl src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+] Remove all default css and make Raleigh a pure fallback theme
- Date: Thu, 9 Feb 2012 22:20:25 +0000 (UTC)
commit cdc6e827202059e7aabb112bdc385c0fc826e13e
Author: Alexander Larsson <alexl redhat com>
Date: Thu Feb 9 23:16:03 2012 +0100
Remove all default css and make Raleigh a pure fallback theme
It was problematic to maintain Raleigh going forward, as any
changes in it affected all themes. Also, its more robust if
each theme is a full standalone css rather than relying on
an inherited css base.
So, this changes Raleigh to a standalone theme that we can tweak
without accidentally breaking other themes, and makes the
default theme empty. In fact, we don't even add the default
provider anymore as its always empty.
gtk/Makefile.am | 2 --
gtk/gtk.css.raleigh | 3 ---
gtk/gtk.gresource.xml | 2 +-
gtk/gtkcssprovider.c | 42 ++++++++++++++++++++++++------------------
gtk/gtksettings.c | 10 ++++------
5 files changed, 29 insertions(+), 30 deletions(-)
---
diff --git a/gtk/Makefile.am b/gtk/Makefile.am
index 17a6a0b..dd8db33 100644
--- a/gtk/Makefile.am
+++ b/gtk/Makefile.am
@@ -1108,8 +1108,6 @@ dist-hook: ../build/win32/vs9/gtk.vcproj ../build/win32/vs10/gtk.vcxproj ../buil
# Install a RC file for the default GTK+ theme, and key themes
install-data-local: install-ms-lib install-def-file install-mac-key-theme
- $(mkdir_p) $(DESTDIR)$(datadir)/themes/Raleigh/gtk-3.0
- $(INSTALL_DATA) $(srcdir)/gtk.css.raleigh $(DESTDIR)$(datadir)/themes/Raleigh/gtk-3.0/gtk.css
$(mkdir_p) $(DESTDIR)$(datadir)/themes/Default/gtk-3.0
$(INSTALL_DATA) $(srcdir)/gtk-keys.css.default $(DESTDIR)$(datadir)/themes/Default/gtk-3.0/gtk-keys.css
$(mkdir_p) $(DESTDIR)$(datadir)/themes/Emacs/gtk-3.0
diff --git a/gtk/gtk.gresource.xml b/gtk/gtk.gresource.xml
index 880c101..cabb173 100644
--- a/gtk/gtk.gresource.xml
+++ b/gtk/gtk.gresource.xml
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<gresources>
<gresource prefix="/org/gtk/libgtk">
- <file>gtk-default.css</file>
+ <file alias="Raleigh.css">gtk-default.css</file>
<file>gtk-win32.css</file>
<file alias="cursor/dnd-ask.png">cursor_dnd_ask.png</file>
<file alias="cursor/dnd-link.png">cursor_dnd_link.png</file>
diff --git a/gtk/gtkcssprovider.c b/gtk/gtkcssprovider.c
index a637eee..5140e20 100644
--- a/gtk/gtkcssprovider.c
+++ b/gtk/gtkcssprovider.c
@@ -2808,10 +2808,6 @@ gtk_css_provider_get_default (void)
if (G_UNLIKELY (!provider))
{
provider = gtk_css_provider_new ();
- if (!_gtk_css_provider_load_from_resource (provider, "/org/gtk/libgtk/gtk-default.css"))
- {
- g_error ("Failed to load the internal default CSS.");
- }
}
return provider;
@@ -2852,29 +2848,39 @@ gtk_css_provider_get_named (const gchar *name,
GtkCssProvider *provider;
gchar *key;
- if (G_UNLIKELY (!themes))
- {
- themes = g_hash_table_new (g_str_hash, g_str_equal);
-
- provider = gtk_css_provider_new ();
- if (!_gtk_css_provider_load_from_resource (provider, "/org/gtk/libgtk/gtk-win32.css"))
- {
- g_warning ("Failed to load the internal win32 default CSS.");
- g_object_unref (provider);
- }
- else
- g_hash_table_insert (themes, "gtk-win32", provider);
- }
-
if (variant == NULL)
key = (gchar *)name;
else
key = g_strconcat (name, "-", variant, NULL);
+ if (G_UNLIKELY (!themes))
+ themes = g_hash_table_new (g_str_hash, g_str_equal);
+
provider = g_hash_table_lookup (themes, key);
if (!provider)
{
+ gchar *resource_path = NULL;
+
+ if (variant)
+ resource_path = g_strdup_printf ("/org/gtk/libgtk/%s-%s.css", name, variant);
+ else
+ resource_path = g_strdup_printf ("/org/gtk/libgtk/%s.css", name);
+
+ if (g_resources_get_info (resource_path, 0, NULL, NULL, NULL))
+ {
+ provider = gtk_css_provider_new ();
+ if (!_gtk_css_provider_load_from_resource (provider, resource_path))
+ {
+ g_object_unref (provider);
+ provider = NULL;
+ }
+ }
+ g_free (resource_path);
+ }
+
+ if (!provider)
+ {
const gchar *home_dir;
gchar *subpath, *path = NULL;
diff --git a/gtk/gtksettings.c b/gtk/gtksettings.c
index ac90cdd..34dc38c 100644
--- a/gtk/gtksettings.c
+++ b/gtk/gtksettings.c
@@ -1521,7 +1521,6 @@ settings_init_style (GtkSettings *settings)
static GtkCssProvider *css_provider = NULL;
GdkScreen *screen = settings->priv->screen;
- GtkCssProvider *default_provider;
/* Add provider for user file */
if (G_UNLIKELY (!css_provider))
@@ -1545,11 +1544,6 @@ settings_init_style (GtkSettings *settings)
GTK_STYLE_PROVIDER (css_provider),
GTK_STYLE_PROVIDER_PRIORITY_USER);
- default_provider = gtk_css_provider_get_default ();
- gtk_style_context_add_provider_for_screen (screen,
- GTK_STYLE_PROVIDER (default_provider),
- GTK_STYLE_PROVIDER_PRIORITY_FALLBACK);
-
gtk_style_context_add_provider_for_screen (screen,
GTK_STYLE_PROVIDER (settings),
GTK_STYLE_PROVIDER_PRIORITY_SETTINGS);
@@ -2873,6 +2867,10 @@ settings_update_theme (GtkSettings *settings)
provider = gtk_css_provider_get_named (theme_name, NULL);
}
+ /* If we didn't find the named theme, fall back */
+ if (!provider)
+ provider = gtk_css_provider_get_named ("Raleigh", NULL);
+
settings_update_provider (priv->screen, &priv->theme_provider, provider);
if (theme_name && *theme_name)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]