changeset 28:73c1e3372b52

Re #47: Add translatable GTK# widgets * Add translatable button now that we know how to use it (with work-around for losing stock icon)
author IBBoard <dev@ibboard.co.uk>
date Thu, 30 Dec 2010 20:58:47 +0000
parents 2d76577e28ff
children bcb437c04685
files IBBoard.GtkSharp.csproj Translatable/TranslatableButton.cs
diffstat 2 files changed, 44 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/IBBoard.GtkSharp.csproj	Wed Dec 29 19:48:35 2010 +0000
+++ b/IBBoard.GtkSharp.csproj	Thu Dec 30 20:58:47 2010 +0000
@@ -39,6 +39,7 @@
     <Compile Include="Lang\ITranslatableWithActions.cs" />
     <Compile Include="Translatable\TranslatableWindowWithActions.cs" />
     <Compile Include="Translatable\TranslatableLabel.cs" />
+    <Compile Include="Translatable\TranslatableButton.cs" />
   </ItemGroup>
   <ItemGroup>
     <None Include="COPYING.GPL" />
@@ -47,6 +48,7 @@
   <ItemGroup>
     <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" />
   </ItemGroup>
   <Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
   <ItemGroup>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Translatable/TranslatableButton.cs	Thu Dec 30 20:58:47 2010 +0000
@@ -0,0 +1,42 @@
+//  This file (TranslatableButton.cs) is a part of the IBBoard.GtkSharp project and is copyright 2010 IBBoard
+//
+// // The file and the library/program it is in are licensed and distributed, without warranty, under the GNU LGPL license, either version 3 of the License or (at your option) any later version. Please see COPYING for more information and the full license.
+
+using System;
+using Gtk;
+using IBBoard.Lang;
+
+namespace IBBoard.GtkSharp.Translatable
+{
+	[System.ComponentModel.ToolboxItem(true)]
+	[System.ComponentModel.Category("Translatable")]
+	public class TranslatableButton : Button, ITranslatable
+	{
+		public string Text
+		{
+			get
+			{
+				return Label;
+			}
+			set
+			{
+				Image origIcon = this.Image as Image;
+				string stock = null;
+
+				if (origIcon != null)
+				{
+					stock = origIcon.Stock;
+				}
+
+				this.Label = value;
+				this.Image = origIcon;
+
+				if (origIcon != null)
+				{
+					origIcon.Stock = stock;
+				}
+			}
+		}
+	}
+}
+