[banshee/stable] Instantiate Hyena.Gui themes from the ThemeEngine, not GtkTheme directly
- From: Aaron Bockover <abock src gnome org>
- To: svn-commits-list gnome org
- Subject: [banshee/stable] Instantiate Hyena.Gui themes from the ThemeEngine, not GtkTheme directly
- Date: Thu, 23 Apr 2009 18:40:16 -0400 (EDT)
commit 1f846e8f991e76b91bdee5e509ce7f41bed4c527
Author: Aaron Bockover <abockover novell com>
Date: Thu Apr 23 18:04:46 2009 -0400
Instantiate Hyena.Gui themes from the ThemeEngine, not GtkTheme directly
This patch allows Hyena.Gui controls to use a theme other than the built in GtkTheme by way of a new ThemeEngine class. This allows other clients to provide their own themes. This patch also updates built-in controls to load their theme from the new ThemeEngine API instead of instantiating a new GtkTheme directly.
---
.../Hyena.Data.Gui/ListView/ListView_Rendering.cs | 2 +-
.../Hyena.Gui/Hyena.Gui.Theming/ThemeEngine.cs | 67 ++++++++++++++++++++
src/Libraries/Hyena.Gui/Hyena.Gui.csproj | 4 +-
.../Hyena.Gui/Hyena.Widgets/MessageBar.cs | 2 +-
.../Hyena.Gui/Hyena.Widgets/RoundedFrame.cs | 2 +-
src/Libraries/Hyena.Gui/Makefile.am | 1 +
6 files changed, 73 insertions(+), 5 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 359e815..13ef716 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..983b530
--- /dev/null
+++ b/src/Libraries/Hyena.Gui/Hyena.Gui.Theming/ThemeEngine.cs
@@ -0,0 +1,67 @@
+//
+// 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
+{
+ internal class SuperHackThemeEngineProviderArgs : EventArgs
+ {
+ private Gtk.Widget widget;
+ public Gtk.Widget Widget {
+ get { return widget; }
+ set { widget = value; }
+ }
+
+ private Theme theme;
+ public Theme Theme {
+ set { theme = value; }
+ get { return theme; }
+ }
+ }
+
+ public static class ThemeEngine
+ {
+ private static EventHandler provider;
+
+ public static void SetProvider (EventHandler provider)
+ {
+ ThemeEngine.provider = provider;
+ }
+
+ public static Theme CreateTheme (Gtk.Widget widget)
+ {
+ if (provider == null) {
+ return new GtkTheme (widget);
+ }
+
+ SuperHackThemeEngineProviderArgs args = new SuperHackThemeEngineProviderArgs ();
+ args.Widget = widget;
+ provider (null, args);
+ return args.Theme ?? new GtkTheme (widget);
+ }
+ }
+}
diff --git a/src/Libraries/Hyena.Gui/Hyena.Gui.csproj b/src/Libraries/Hyena.Gui/Hyena.Gui.csproj
index 170d7de..b86e566 100644
--- a/src/Libraries/Hyena.Gui/Hyena.Gui.csproj
+++ b/src/Libraries/Hyena.Gui/Hyena.Gui.csproj
@@ -29,7 +29,7 @@
<Reference Include="System" />
<Reference Include="gtk-sharp, Version=2.12.0.0, Culture=neutral, PublicKeyToken=35e10195dab3c99f" />
<Reference Include="gdk-sharp, Version=2.12.0.0, Culture=neutral, PublicKeyToken=35e10195dab3c99f" />
- <Reference Include="Mono.Cairo, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=0738eb9f132ed756" />
+ <Reference Include="Mono.Cairo" />
<Reference Include="pango-sharp, Version=2.12.0.0, Culture=neutral, PublicKeyToken=35e10195dab3c99f" />
<Reference Include="glib-sharp, Version=2.12.0.0, Culture=neutral, PublicKeyToken=35e10195dab3c99f" />
<Reference Include="System.Xml" />
@@ -127,13 +127,13 @@
<Compile Include="Hyena.Gui.Theatrics\Pulsator.cs" />
<Compile Include="Hyena.Gui\PixbufImageSurface.cs" />
<Compile Include="Hyena.Widgets\TextViewEditable.cs" />
+ <Compile Include="Hyena.Gui.Theming\ThemeEngine.cs" />
</ItemGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
<ProjectExtensions>
<MonoDevelop>
<Properties>
<Deployment.LinuxDeployData generateScript="false" />
- <GtkDesignInfo />
<MonoDevelop.Autotools.MakefileInfo IntegrationEnabled="true" RelativeMakefileName="Makefile.am">
<BuildFilesVar Sync="true" Name="SOURCES" />
<DeployFilesVar />
diff --git a/src/Libraries/Hyena.Gui/Hyena.Widgets/MessageBar.cs b/src/Libraries/Hyena.Gui/Hyena.Widgets/MessageBar.cs
index 4a0a320..8e7e7b4 100644
--- a/src/Libraries/Hyena.Gui/Hyena.Widgets/MessageBar.cs
+++ b/src/Libraries/Hyena.Gui/Hyena.Widgets/MessageBar.cs
@@ -111,7 +111,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]