Commit 9e61e6a91230d75ab6c77d270c62fa5c6f6930f0

  • avatar
  • Kristian Høgsberg <krh @red…at.com> (Committer)
  • Fri Apr 24 04:31:51 GMT 2009
  • avatar
  • Aaron Bockover <abockover @nov…ll.com> (Author)
  • Thu Apr 23 22:04:46 UTC 2009
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.
src/Libraries/Hyena.Gui/Hyena.Data.Gui/ListView/ListView_Rendering.cs
(1 / 1)
  
6767
6868 base.OnStyleSet (old_style);
6969 RecomputeRowHeight = true;
70 theme = new GtkTheme (this);
70 theme = Hyena.Gui.Theming.ThemeEngine.CreateTheme (this);
7171
7272 // Save the drawable so we can reuse it
7373 Gdk.Drawable drawable = cell_context != null ? cell_context.Drawable : null;
src/Libraries/Hyena.Gui/Hyena.Gui.Theming/ThemeEngine.cs
(67 / 0)
  
1//
2// ThemeEngine.cs
3//
4// Author:
5// Aaron Bockover <abockover@novell.com>
6//
7// Copyright 2009 Aaron Bockover
8//
9// Permission is hereby granted, free of charge, to any person obtaining a copy
10// of this software and associated documentation files (the "Software"), to deal
11// in the Software without restriction, including without limitation the rights
12// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
13// copies of the Software, and to permit persons to whom the Software is
14// furnished to do so, subject to the following conditions:
15//
16// The above copyright notice and this permission notice shall be included in
17// all copies or substantial portions of the Software.
18//
19// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
24// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
25// THE SOFTWARE.
26
27using System;
28
29namespace Hyena.Gui.Theming
30{
31 internal class SuperHackThemeEngineProviderArgs : EventArgs
32 {
33 private Gtk.Widget widget;
34 public Gtk.Widget Widget {
35 get { return widget; }
36 set { widget = value; }
37 }
38
39 private Theme theme;
40 public Theme Theme {
41 set { theme = value; }
42 get { return theme; }
43 }
44 }
45
46 public static class ThemeEngine
47 {
48 private static EventHandler provider;
49
50 public static void SetProvider (EventHandler provider)
51 {
52 ThemeEngine.provider = provider;
53 }
54
55 public static Theme CreateTheme (Gtk.Widget widget)
56 {
57 if (provider == null) {
58 return new GtkTheme (widget);
59 }
60
61 SuperHackThemeEngineProviderArgs args = new SuperHackThemeEngineProviderArgs ();
62 args.Widget = widget;
63 provider (null, args);
64 return args.Theme ?? new GtkTheme (widget);
65 }
66 }
67}
src/Libraries/Hyena.Gui/Hyena.Gui.csproj
(2 / 2)
  
2929 <Reference Include="System" />
3030 <Reference Include="gtk-sharp, Version=2.12.0.0, Culture=neutral, PublicKeyToken=35e10195dab3c99f" />
3131 <Reference Include="gdk-sharp, Version=2.12.0.0, Culture=neutral, PublicKeyToken=35e10195dab3c99f" />
32 <Reference Include="Mono.Cairo, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=0738eb9f132ed756" />
32 <Reference Include="Mono.Cairo" />
3333 <Reference Include="pango-sharp, Version=2.12.0.0, Culture=neutral, PublicKeyToken=35e10195dab3c99f" />
3434 <Reference Include="glib-sharp, Version=2.12.0.0, Culture=neutral, PublicKeyToken=35e10195dab3c99f" />
3535 <Reference Include="System.Xml" />
127127 <Compile Include="Hyena.Gui.Theatrics\Pulsator.cs" />
128128 <Compile Include="Hyena.Gui\PixbufImageSurface.cs" />
129129 <Compile Include="Hyena.Widgets\TextViewEditable.cs" />
130 <Compile Include="Hyena.Gui.Theming\ThemeEngine.cs" />
130131 </ItemGroup>
131132 <Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
132133 <ProjectExtensions>
133134 <MonoDevelop>
134135 <Properties>
135136 <Deployment.LinuxDeployData generateScript="false" />
136 <GtkDesignInfo />
137137 <MonoDevelop.Autotools.MakefileInfo IntegrationEnabled="true" RelativeMakefileName="Makefile.am">
138138 <BuildFilesVar Sync="true" Name="SOURCES" />
139139 <DeployFilesVar />
src/Libraries/Hyena.Gui/Hyena.Widgets/MessageBar.cs
(1 / 1)
  
111111 protected override void OnRealized ()
112112 {
113113 base.OnRealized ();
114 theme = new GtkTheme (this);
114 theme = Hyena.Gui.Theming.ThemeEngine.CreateTheme (this);
115115 }
116116
117117 protected override void OnSizeAllocated (Gdk.Rectangle allocation)
src/Libraries/Hyena.Gui/Hyena.Widgets/RoundedFrame.cs
(1 / 1)
  
9292 protected override void OnRealized ()
9393 {
9494 base.OnRealized ();
95 theme = new GtkTheme (this);
95 theme = Hyena.Gui.Theming.ThemeEngine.CreateTheme (this);
9696 }
9797
9898 protected override void OnSizeRequested (ref Requisition requisition)
src/Libraries/Hyena.Gui/Makefile.am
(1 / 0)
  
4040 Hyena.Gui.Theming/GtkTheme.cs \
4141 Hyena.Gui.Theming/Theme.cs \
4242 Hyena.Gui.Theming/ThemeContext.cs \
43 Hyena.Gui.Theming/ThemeEngine.cs \
4344 Hyena.Gui/CairoExtensions.cs \
4445 Hyena.Gui/CleanRoomStartup.cs \
4546 Hyena.Gui/CompositeUtils.cs \

Comments

Add a new comment:

Login or create an account to post a comment

Add your comment