* MonoDevelop.Ide.Gui.Dialogs/CommonAboutDialog.cs: Fixed Bug 447428
[monodevelop.git] / main / src / core / MonoDevelop.Ide / MonoDevelop.Ide.Gui.Dialogs / CommonAboutDialog.cs
blob5ed9575204e50d6e92175676cd15491372a74e4b
1 // CommonAboutDialog.cs
2 //
3 // This file was derived from a file from #Develop.
4 //
5 // Copyright (C) 2001-2007 Mike Krüger <mkrueger@novell.com>
6 //
7 // This program is free software; you can redistribute it and/or modify
8 // it under the terms of the GNU General Public License as published by
9 // the Free Software Foundation; either version 2 of the License, or
10 // (at your option) any later version.
11 //
12 // This program is distributed in the hope that it will be useful,
13 // but WITHOUT ANY WARRANTY; without even the implied warranty of
14 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 // GNU General Public License for more details.
16 //
17 // You should have received a copy of the GNU General Public License
18 // along with this program; if not, write to the Free Software
19 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21 using System;
22 using System.Text;
24 using MonoDevelop.Core.Gui;
25 using MonoDevelop.Core;
26 using MonoDevelop.Ide.Gui;
28 using Gdk;
29 using Gtk;
30 using GLib;
31 using Pango;
33 namespace MonoDevelop.Ide.Gui.Dialogs
35 internal class ScrollBox : DrawingArea
37 Pixbuf image;
38 Pixbuf monoPowered;
39 int scroll;
40 Pango.Layout layout;
41 int monoLogoSpacing = 30;
42 int textTop;
43 int scrollPause;
44 int scrollStart;
46 internal uint TimerHandle;
48 string[] authors = new string[]
50 "Aaron Bockover",
51 "Alberto Paro",
52 "Alejandro Serrano",
53 "Alexandre Gomes",
54 "Alex Graveley",
55 "Andrés G. Aragoneses",
56 "Andre Filipe de Assuncao e Brito",
57 "Antonio Ognio",
58 "Ankit Jain",
59 "Ben Maurer",
60 "Ben Motmans",
61 "Christian Hergert",
62 "Daniel Kornhauser",
63 "Daniel Morgan",
64 "David Makovský",
65 "Eric Butler",
66 "Erik Dasque",
67 "Franciso Martinez",
68 "Geoff Norton",
69 "Gustavo Giráldez",
70 "Iain McCoy",
71 "Inigo Illan",
72 "Jacob Ilsø Christensen",
73 "James Fitzsimons",
74 "Jeff Stedfast",
75 "Jérémie Laval",
76 "Jeroen Zwartepoorte",
77 "John BouAnton",
78 "John Luke",
79 "Joshua Tauberer",
80 "Jonathan Hernández Velasco",
81 "Levi Bard",
82 "Lluis Sanchez Gual",
83 "Marcos David Marín Amador",
84 "Martin Willemoes Hansen",
85 "Marek Sieradzki",
86 "Matej Urbas",
87 "Maurício de Lemos Rodrigues Collares Neto",
88 "Michael Hutchinson",
89 "Miguel de Icaza",
90 "Mike Krüger",
91 "Muthiah Annamalai",
92 "Nick Drochak",
93 "nricciar",
94 "Paco Martínez",
95 "Pawel Rozanski",
96 "Pedro Abelleira Seco",
97 "Peter Johanson",
98 "Philip Turnbull",
99 "Richard Torkar",
100 "Scott Ellington",
101 "Todd Berman",
102 "Vincent Daron",
103 "Wade Berrier",
104 "Yan-ren Tsai",
105 "Zach Lute"
108 public ScrollBox ()
110 this.SetSizeRequest (450, 220);
111 this.Realized += new EventHandler (OnRealized);
112 this.ExposeEvent += new ExposeEventHandler (OnExposed);
114 image = new Gdk.Pixbuf (GetType().Assembly, "AboutImage.png");
115 monoPowered = new Gdk.Pixbuf (GetType().Assembly, "mono-powered.png");
117 TimerHandle = GLib.Timeout.Add (50, new TimeoutHandler (ScrollDown));
120 string CreditText {
121 get {
122 StringBuilder sb = new StringBuilder ();
123 sb.Append (GettextCatalog.GetString ("<b>Ported and developed by:</b>\n"));
125 for (int n=0; n<authors.Length; n++) {
126 sb.Append (authors [n]);
127 if (n % 2 == 1)
128 sb.Append ("\n");
129 else
130 sb.Append (", ");
133 string trans = GettextCatalog.GetString ("translator-credits");
134 if (trans != "translator-credits")
136 sb.Append (GettextCatalog.GetString ("\n\n<b>Translated by:</b>\n"));
137 sb.Append (trans);
139 return sb.ToString ();
143 bool ScrollDown ()
145 if (scrollPause > 0) {
146 if (--scrollPause == 0)
147 ++scroll;
148 } else
149 ++scroll;
150 int w, h;
151 this.GdkWindow.GetSize (out w, out h);
152 this.QueueDrawArea (0, 0, w, 220);
153 return true;
156 private void DrawImage ()
158 if (image != null) {
159 int w, h;
160 this.GdkWindow.GetSize (out w, out h);
161 this.GdkWindow.DrawPixbuf (this.Style.BackgroundGC (StateType.Normal), image, 0, 0, (w - image.Width) / 2, 0, -1, -1, RgbDither.Normal, 0, 0);
165 // int GetTextHeight ()
166 // {
167 // int w, h;
168 // layout.GetPixelSize (out w, out h);
169 // return h;
170 // }
172 private void DrawText ()
174 int w, h;
175 this.GdkWindow.GetSize (out w, out h);
176 int tw, maxHeight;
177 layout.GetPixelSize (out tw, out maxHeight);
179 this.GdkWindow.DrawLayout (this.Style.BlackGC, 0, textTop - scroll, layout);
180 this.GdkWindow.DrawPixbuf (this.Style.BackgroundGC (StateType.Normal), monoPowered, 0, 0, (w/2) - (monoPowered.Width/2), textTop - scroll + maxHeight + monoLogoSpacing, -1, -1, RgbDither.Normal, 0, 0);
182 if (scroll == maxHeight && scrollPause == 0)
183 scrollPause = 60;
184 if (scroll > maxHeight + monoLogoSpacing + monoPowered.Height)
185 scroll = scrollStart;
188 protected void OnExposed (object o, ExposeEventArgs args)
190 int w, h;
191 this.GdkWindow.GetSize (out w, out h);
192 this.GdkWindow.DrawRectangle (this.Style.WhiteGC, true, 0, 0, w, h);
193 this.DrawText ();
194 this.DrawImage ();
195 this.GdkWindow.DrawRectangle (this.Style.WhiteGC, true, 0, 210, w, 10);
198 protected void OnRealized (object o, EventArgs args)
200 int x, y;
201 int w, h;
202 GdkWindow.GetOrigin (out x, out y);
203 GdkWindow.GetSize (out w, out h);
205 textTop = y + image.Height - 30;
206 scrollStart = -(220 - textTop);
207 scroll = scrollStart;
209 layout = new Pango.Layout (this.PangoContext);
210 // FIXME: this seems wrong but works
211 layout.Width = w * (int)Pango.Scale.PangoScale;
212 layout.Wrap = Pango.WrapMode.Word;
213 layout.Alignment = Pango.Alignment.Center;
214 FontDescription fd = FontDescription.FromString ("Tahoma 10");
215 layout.FontDescription = fd;
216 layout.SetMarkup (CreditText);
220 internal class CommonAboutDialog : Dialog
223 ScrollBox aboutPictureScrollBox;
225 public CommonAboutDialog ()
227 HasSeparator = false;
228 this.VBox.BorderWidth = 0;
230 AllowGrow = false;
231 this.Title = GettextCatalog.GetString ("About MonoDevelop");
232 this.TransientFor = IdeApp.Workbench.RootWindow;
233 aboutPictureScrollBox = new ScrollBox ();
235 this.VBox.PackStart (aboutPictureScrollBox, false, false, 0);
237 Notebook nb = new Notebook ();
238 nb.BorderWidth = 6;
239 // nb.SetSizeRequest (440, 240);
240 this.ModifyBg (Gtk.StateType.Normal, new Gdk.Color (255, 255, 255));
241 // nb.ModifyBg (Gtk.StateType.Normal, new Gdk.Color (255, 255, 255));
242 VersionInformationTabPage vinfo = new VersionInformationTabPage ();
244 nb.AppendPage (new AboutMonoDevelopTabPage (), new Label (GettextCatalog.GetString ("About MonoDevelop")));
246 nb.AppendPage (vinfo, new Label (GettextCatalog.GetString ("Version Info")));
247 this.VBox.PackStart (nb, true, true, 0);
248 this.AddButton (Gtk.Stock.Close, (int) ResponseType.Close);
249 this.ShowAll ();
252 public new int Run ()
254 int tmp = base.Run ();
255 GLib.Source.Remove (aboutPictureScrollBox.TimerHandle);
256 return tmp;