[banshee/gtk3] Port the custom gtkrc handling to the new CSS-based theming
- From: Bertrand Lorentz <blorentz src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [banshee/gtk3] Port the custom gtkrc handling to the new CSS-based theming
- Date: Mon, 1 Aug 2011 16:06:03 +0000 (UTC)
commit 39499be5a0d616b62265da088c3d0afdeed3f282
Author: Bertrand Lorentz <bertrand lorentz gmail com>
Date: Sun Jul 31 13:15:23 2011 +0200
Port the custom gtkrc handling to the new CSS-based theming
The customization is now done by putting CSS statements in a gtk.css
file. This file must be loaded after GTK is initialized, because we need
the default GDK screen.
Rename the two related command-line option to no-gtkcss and
debug-gtkcss, and add a description for debug-gtkcss.
src/Clients/Booter/Booter/Entry.cs | 11 ++++--
.../Banshee.Gui/GtkBaseClient.cs | 32 ++++++++++++--------
2 files changed, 26 insertions(+), 17 deletions(-)
---
diff --git a/src/Clients/Booter/Booter/Entry.cs b/src/Clients/Booter/Booter/Entry.cs
index 26b3385..ee7d24c 100644
--- a/src/Clients/Booter/Booter/Entry.cs
+++ b/src/Clients/Booter/Booter/Entry.cs
@@ -148,6 +148,9 @@ namespace Booter
Console.WriteLine ("Usage: {0} [options...] [files|URIs...]", "banshee");
Console.WriteLine ();
+ string css_file = Path.Combine (Paths.ApplicationData, "gtk.css").Replace (
+ Environment.GetFolderPath (Environment.SpecialFolder.Personal), "~");
+
Layout commands = new Layout (
new LayoutGroup ("help", Catalog.GetString ("Help Options"),
new LayoutOption ("help", Catalog.GetString ("Show this help")),
@@ -220,10 +223,10 @@ namespace Booter
new LayoutOption ("uninstalled", Catalog.GetString ("Optimize instance for running uninstalled; " +
"most notably, this will create an alternate Mono.Addins database in the working directory")),
new LayoutOption ("disable-dbus", Catalog.GetString ("Disable DBus support completely")),
- new LayoutOption ("no-gtkrc", String.Format (Catalog.GetString (
- "Skip loading a custom gtkrc file ({0}) if it exists"),
- Path.Combine (Paths.ApplicationData, "gtkrc").Replace (
- Environment.GetFolderPath (Environment.SpecialFolder.Personal), "~")))
+ new LayoutOption ("no-gtkcss", String.Format (Catalog.GetString (
+ "Skip loading a custom gtk.css file ({0}) if it exists"), css_file)),
+ new LayoutOption ("debug-gtkcss", String.Format (Catalog.GetString (
+ "Reload the custom gtk.css file ({0}) every 5 seconds"), css_file))
)
);
diff --git a/src/Core/Banshee.ThickClient/Banshee.Gui/GtkBaseClient.cs b/src/Core/Banshee.ThickClient/Banshee.Gui/GtkBaseClient.cs
index 7d2c2aa..133619a 100644
--- a/src/Core/Banshee.ThickClient/Banshee.Gui/GtkBaseClient.cs
+++ b/src/Core/Banshee.ThickClient/Banshee.Gui/GtkBaseClient.cs
@@ -45,24 +45,20 @@ namespace Banshee.Gui
{
static GtkBaseClient () {
Application.InitializePaths ();
- user_gtkrc = Path.Combine (Paths.ApplicationData, "gtkrc");
+ user_css = Path.Combine (Paths.ApplicationData, "gtk.css");
}
private static Type client_type;
- private static string user_gtkrc;
+ private static string user_css;
+
+ private Gtk.CssProvider custom_provider;
public static void Startup<T> (string [] args) where T : GtkBaseClient
{
Hyena.Log.InformationFormat ("Running Banshee {0}: [{1}]", Application.Version,
Application.BuildDisplayInfo);
- // This could go into GtkBaseClient, but it's probably something we
- // should really only support at each client level
- if (File.Exists (user_gtkrc) && !ApplicationContext.CommandLine.Contains ("no-gtkrc")) {
- Gtk.Rc.AddDefaultFile (user_gtkrc);
- }
-
// Boot the client
Banshee.Gui.GtkBaseClient.Startup<T> ();
}
@@ -109,12 +105,22 @@ namespace Banshee.Gui
}
Gtk.Application.Init ();
- if (ApplicationContext.CommandLine.Contains ("debug-gtkrc")) {
- Log.Information ("Note: gtkrc files will be checked for reload every 5 seconds!");
+ // This could go into GtkBaseClient, but it's probably something we
+ // should really only support at each client level
+ if (File.Exists (user_css) && !ApplicationContext.CommandLine.Contains ("no-gtkcss")) {
+ custom_provider = new Gtk.CssProvider ();
+ custom_provider.LoadFromPath (user_css);
+ Gtk.StyleContext.AddProviderForScreen (Gdk.Screen.Default, (Gtk.StyleProvider)custom_provider,
+ 600 /* GTK_STYLE_PROVIDER_PRIORITY_APPLICATION*/ );
+ }
+
+ if (ApplicationContext.CommandLine.Contains ("debug-gtkcss")) {
+ Log.Information ("Note: gtk.css file will be checked for reload every 5 seconds!");
GLib.Timeout.Add (5000, delegate {
- if (Gtk.Rc.ReparseAll ()) {
- Gtk.Rc.ResetStyles (Gtk.Settings.Default);
- Log.Information ("gtkrc has been reloaded");
+ if (custom_provider != null) {
+ custom_provider.LoadFromPath (user_css);
+ Gtk.StyleContext.ResetWidgets (Gdk.Screen.Default);
+ Log.Information ("gtk.css has been reloaded");
}
return true;
});
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]