[banshee] Forward port theme engine patch from stable-vis



commit 51748b290e05565c8e76bfc869ae90bd5cfe5e21
Author: Aaron Bockover <abockover novell com>
Date:   Fri May 15 22:38:29 2009 -0400

    Forward port theme engine patch from stable-vis
    
    This patch (cleaned up from stable-vis branch) allows Clients to set their
    own Hyena.Gui.Theming.Theme for rendering, instead of the default GtkTheme.
---
 .../Hyena.Data.Gui/ListView/ListView_Rendering.cs  |    2 +-
 .../Hyena.Gui/Hyena.Gui.Theming/ThemeEngine.cs     |   47 ++++++++++++++++++++
 .../Hyena.Gui/Hyena.Widgets/MessageBar.cs          |    2 +-
 .../Hyena.Gui/Hyena.Widgets/RoundedFrame.cs        |    2 +-
 src/Libraries/Hyena.Gui/Makefile.am                |    1 +
 5 files changed, 51 insertions(+), 3 deletions(-)

diff --git a/src/Libraries/Hyena.Gui/Hyena.Data.Gui/ListView/ListView_Rendering.cs b/src/Libraries/Hyena.Gui/Hyena.Data.Gui/ListView/ListView_Rendering.cs
index 386102c..d376eb7 100644
--- a/src/Libraries/Hyena.Gui/Hyena.Data.Gui/ListView/ListView_Rendering.cs
+++ b/src/Libraries/Hyena.Gui/Hyena.Data.Gui/ListView/ListView_Rendering.cs
@@ -67,7 +67,7 @@ namespace Hyena.Data.Gui
             
             base.OnStyleSet (old_style);
             RecomputeRowHeight = true;
-            theme = new GtkTheme (this);
+            theme = Hyena.Gui.Theming.ThemeEngine.CreateTheme (this);
 
             // Save the drawable so we can reuse it
             Gdk.Drawable drawable = cell_context != null ? cell_context.Drawable : null;
diff --git a/src/Libraries/Hyena.Gui/Hyena.Gui.Theming/ThemeEngine.cs b/src/Libraries/Hyena.Gui/Hyena.Gui.Theming/ThemeEngine.cs
new file mode 100644
index 0000000..9a0e8ac
--- /dev/null
+++ b/src/Libraries/Hyena.Gui/Hyena.Gui.Theming/ThemeEngine.cs
@@ -0,0 +1,47 @@
+// 
+// ThemeEngine.cs
+//  
+// Author:
+//     Aaron Bockover <abockover novell com>
+// 
+// Copyright 2009 Aaron Bockover
+// 
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+// 
+// The above copyright notice and this permission notice shall be included in
+// all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+// THE SOFTWARE.
+
+using System;
+
+namespace Hyena.Gui.Theming
+{
+    public static class ThemeEngine
+    {
+        private static Type theme_type;
+
+        public static void SetCurrentTheme<T> () where T : Theme
+        {
+            theme_type = typeof (T);
+        }
+
+        public static Theme CreateTheme (Gtk.Widget widget)
+        {
+            return theme_type == null
+                ? new GtkTheme (widget)
+                : (Theme)Activator.CreateInstance (theme_type, new object [] { widget });
+        }
+    }
+}
\ No newline at end of file
diff --git a/src/Libraries/Hyena.Gui/Hyena.Widgets/MessageBar.cs b/src/Libraries/Hyena.Gui/Hyena.Widgets/MessageBar.cs
index ce15542..8ea5c31 100644
--- a/src/Libraries/Hyena.Gui/Hyena.Widgets/MessageBar.cs
+++ b/src/Libraries/Hyena.Gui/Hyena.Widgets/MessageBar.cs
@@ -120,7 +120,7 @@ namespace Hyena.Widgets
         protected override void OnRealized ()
         {
             base.OnRealized ();
-            theme = new GtkTheme (this);
+            theme = Hyena.Gui.Theming.ThemeEngine.CreateTheme (this);
         }
         
         protected override void OnSizeAllocated (Gdk.Rectangle allocation)
diff --git a/src/Libraries/Hyena.Gui/Hyena.Widgets/RoundedFrame.cs b/src/Libraries/Hyena.Gui/Hyena.Widgets/RoundedFrame.cs
index da7d93e..ddee186 100644
--- a/src/Libraries/Hyena.Gui/Hyena.Widgets/RoundedFrame.cs
+++ b/src/Libraries/Hyena.Gui/Hyena.Widgets/RoundedFrame.cs
@@ -92,7 +92,7 @@ namespace Hyena.Widgets
         protected override void OnRealized ()
         {
             base.OnRealized ();
-            theme = new GtkTheme (this);
+            theme = Hyena.Gui.Theming.ThemeEngine.CreateTheme (this);
         }
 
         protected override void OnSizeRequested (ref Requisition requisition)
diff --git a/src/Libraries/Hyena.Gui/Makefile.am b/src/Libraries/Hyena.Gui/Makefile.am
index 91736bc..86a5731 100644
--- a/src/Libraries/Hyena.Gui/Makefile.am
+++ b/src/Libraries/Hyena.Gui/Makefile.am
@@ -40,6 +40,7 @@ SOURCES =  \
 	Hyena.Gui.Theming/GtkTheme.cs \
 	Hyena.Gui.Theming/Theme.cs \
 	Hyena.Gui.Theming/ThemeContext.cs \
+	Hyena.Gui.Theming/ThemeEngine.cs \
 	Hyena.Gui/CairoExtensions.cs \
 	Hyena.Gui/CleanRoomStartup.cs \
 	Hyena.Gui/CompositeUtils.cs \



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]