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.
This commit is contained in:
Alexander Larsson 2012-02-09 23:16:03 +01:00
parent 7de0672650
commit cdc6e82720
5 changed files with 29 additions and 30 deletions

View File

@ -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

View File

@ -1,3 +0,0 @@
/*
* This theme is the default theme if no other theme is selected.
*/

View File

@ -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>

View File

@ -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,27 +2848,37 @@ 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;

View File

@ -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)