~ubuntu-branches/ubuntu/trusty/monodevelop/trusty-proposed

« back to all changes in this revision

Viewing changes to src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui.Dialogs/AboutMonoDevelopTabPage.cs

  • Committer: Package Import Robot
  • Author(s): Jo Shields
  • Date: 2013-05-12 09:46:03 UTC
  • mto: This revision was merged to the branch mainline in revision 29.
  • Revision ID: package-import@ubuntu.com-20130512094603-mad323bzcxvmcam0
Tags: upstream-4.0.5+dfsg
ImportĀ upstreamĀ versionĀ 4.0.5+dfsg

Show diffs side-by-side

added added

removed removed

Lines of Context:
30
30
using System.IO;
31
31
using System.Text;
32
32
 
 
33
using MonoDevelop.Components;
33
34
using MonoDevelop.Core;
34
35
using MonoDevelop.Ide.Gui;
35
36
 
43
44
{
44
45
        class AboutMonoDevelopTabPage: VBox
45
46
        {
46
 
                ScrollBox aboutPictureScrollBox;
47
47
                Pixbuf imageSep;
48
48
 
49
49
                public AboutMonoDevelopTabPage ()
50
50
                {
51
51
                        BorderWidth = 0;
52
52
 
53
 
                        aboutPictureScrollBox = new ScrollBox ();
54
 
 
55
 
                        PackStart (aboutPictureScrollBox, false, false, 0);
56
 
                        using (var stream = BrandingService.GetStream ("AboutImageSep.png", true))
 
53
                        using (var stream = BrandingService.GetStream ("AboutImage.png", true))
57
54
                                imageSep = new Pixbuf (stream);
58
55
                        PackStart (new Gtk.Image (imageSep), false, false, 0);
59
 
                        
60
 
                        var label = new Label ();
61
 
                        label.Markup = string.Format (
62
 
                                "<b>{0}</b>\n    {1}", 
63
 
                                GettextCatalog.GetString ("Version"), 
64
 
                                BuildVariables.PackageVersion == BuildVariables.PackageVersionLabel ? BuildVariables.PackageVersionLabel : String.Format ("{0} ({1})", 
65
 
                                BuildVariables.PackageVersionLabel, 
66
 
                                BuildVariables.PackageVersion));
67
 
                        
68
 
                        var hBoxVersion = new HBox ();
69
 
                        hBoxVersion.PackStart (label, false, false, 5);
70
 
                        this.PackStart (hBoxVersion, false, true, 0);
71
 
                        
72
 
                        label = null;
73
 
                        label = new Label ();
74
 
                        label.Markup = GettextCatalog.GetString ("<b>License</b>\n    {0}", GettextCatalog.GetString ("Released under the GNU Lesser General Public License."));
75
 
                        var hBoxLicense = new HBox ();
76
 
                        hBoxLicense.PackStart (label, false, false, 5);
77
 
                        this.PackStart (hBoxLicense, false, true, 5);
78
 
                        
79
 
                        label = null;
80
 
                        label = new Label ();
81
 
                        label.Markup = GettextCatalog.GetString ("<b>Copyright</b>\n    (c) 2004-{0} by MonoDevelop contributors", DateTime.Now.Year);
82
 
                        var hBoxCopyright = new HBox ();
83
 
                        hBoxCopyright.PackStart (label, false, false, 5);
84
 
                        this.PackStart (hBoxCopyright, false, true, 5);
85
 
                        
 
56
 
 
57
                        Xwt.VBox infoBox = new Xwt.VBox ();
 
58
                        infoBox.Spacing = 6;
 
59
                        infoBox.Margin = 12;
 
60
                        PackStart (infoBox.ToGtkWidget (), false, false, 0);
 
61
 
 
62
                        infoBox.PackStart (new Xwt.Label () {
 
63
                                Text = GettextCatalog.GetString ("Version"),
 
64
                                Font = infoBox.Font.WithWeight (Xwt.Drawing.FontWeight.Bold)
 
65
                        });
 
66
                        infoBox.PackStart (new Xwt.Label () {
 
67
                                Text = IdeVersionInfo.MonoDevelopVersion,
 
68
                                MarginLeft = 12
 
69
                        });
 
70
 
 
71
                        infoBox.PackStart (new Xwt.Label () {
 
72
                                Text = GettextCatalog.GetString ("License"),
 
73
                                Font = infoBox.Font.WithWeight (Xwt.Drawing.FontWeight.Bold)
 
74
                        });
 
75
                        infoBox.PackStart (new Xwt.Label () {
 
76
                                Text = GettextCatalog.GetString ("Released under the GNU Lesser General Public License."),
 
77
                                MarginLeft = 12
 
78
                        });
 
79
 
 
80
                        infoBox.PackStart (new Xwt.Label () {
 
81
                                Text = GettextCatalog.GetString ("Copyright"),
 
82
                                Font = infoBox.Font.WithWeight (Xwt.Drawing.FontWeight.Bold)
 
83
                        });
 
84
                        var cbox = new Xwt.HBox () {
 
85
                                Spacing = 0,
 
86
                                MarginLeft = 12
 
87
                        };
 
88
                        cbox.PackStart (new Xwt.Label ("Ā© 2011-2012 "));
 
89
                        cbox.PackStart (new Xwt.LinkLabel () {
 
90
                                Text = string.Format ("Xamarin Inc."),
 
91
                                Uri = new Uri ("http://www.xamarin.com")
 
92
                        });
 
93
                        infoBox.PackStart (cbox);
 
94
                        infoBox.PackStart (new Xwt.Label () {
 
95
                                Text = "Ā© 2004-2012 MonoDevelop contributors",
 
96
                                MarginLeft = 12
 
97
                        });
 
98
 
 
99
                        cbox = new Xwt.HBox () {
 
100
                                Spacing = 0,
 
101
                                MarginLeft = 12
 
102
                        };
 
103
                        cbox.PackStart (new Xwt.Label ("Some icons by "));
 
104
                        cbox.PackStart (new Xwt.LinkLabel () {
 
105
                                Text = string.Format ("Yusuke Kamiyamane"),
 
106
                                Uri = new Uri ("http://p.yusukekamiyamane.com")
 
107
                        });
 
108
                        infoBox.PackStart (cbox);
 
109
 
 
110
                        cbox = new Xwt.HBox () {
 
111
                                Spacing = 0,
 
112
                                MarginLeft = 12
 
113
                        };
 
114
                        cbox.PackStart (new Xwt.Label ("Some icons from the "));
 
115
                        cbox.PackStart (new Xwt.LinkLabel () {
 
116
                                Text = string.Format ("Silk icon set"),
 
117
                                Uri = new Uri ("http://www.famfamfam.com/")
 
118
                        });
 
119
                        infoBox.PackStart (cbox);
 
120
 
86
121
                        this.ShowAll ();
87
122
                }
88
 
                
89
 
                internal class ScrollBox : DrawingArea
90
 
                {
91
 
                        Pixbuf image;
92
 
                        Pixbuf imageBg;
93
 
                        int imageHeight, imageWidth;
94
 
                        Pixbuf monoPowered;
95
 
                        Pango.Layout layout;
96
 
                        int monoLogoSpacing = 80;
97
 
                        Gdk.GC backGc;
98
 
                        
99
 
                        int scrollHeightPx, scrollStartPx, scrolledUpPx;
100
 
                        long startTicks;
101
 
                        const int fps = 20;
102
 
                        const int pixelsPerFrame = 1;
103
 
                        const int pauseSeconds = 5;
104
 
                        
105
 
                        internal uint TimerHandle;
106
 
                        string[] authors = new string[] {
107
 
                                "Lluis Sanchez Gual",
108
 
                                "Michael Hutchinson",
109
 
                                "Mike KrĆ¼ger",
110
 
                                "Jeff Stedfast",
111
 
                                "Alan McGovern",
112
 
                                "Mike Kestner",
113
 
                                "Ankit Jain",
114
 
                                "Jonathan Pobst",
115
 
                                "Christian Hergert",
116
 
                                "Levi Bard",
117
 
                                "Carlo Kok",
118
 
                                "Viktoria Dudka",
119
 
                                "Marc Christensen",
120
 
                                "Andrew Jorgensen",
121
 
                                "JĆ©rĆ©mie Laval",
122
 
                                "Luciano N. Callero",
123
 
                                "Zach Lute",
124
 
                                "Andrea KrĆ¼ger",
125
 
                                "Jakub Steiner"
126
 
                        };
127
 
                        
128
 
                        string[] oldAuthors = new string[] {
129
 
                                "Aaron Bockover",
130
 
                                "Alberto Paro",
131
 
                                "Alejandro Serrano",
132
 
                                "Alexandre Gomes",
133
 
                                "Alex Graveley",
134
 
                                "Alfonso Santos Luaces",
135
 
                                "Andre Filipe de Assuncao e Brito",
136
 
                                "Andrea KrĆ¼ger",
137
 
                                "AndrĆ©s G. Aragoneses",
138
 
                                "Andrew Jorgensen",
139
 
                                "Ankit Jain",
140
 
                                "Antonio Ognio",
141
 
                                "Ben Maurer",
142
 
                                "Ben Motmans",
143
 
                                "Carlo Kok",
144
 
                                "Christian Hergert",
145
 
                                "Daniel Kornhauser",
146
 
                                "Daniel Morgan",
147
 
                                "David MakovskĆ½",
148
 
                                "Eric Butler",
149
 
                                "Erik Dasque",
150
 
                                "Geoff Norton",
151
 
                                "Gustavo GirĆ”ldez",
152
 
                                "Iain McCoy",
153
 
                                "Inigo Illan",
154
 
                                "Jacob IlsĆø Christensen",
155
 
                                "Jakub Steiner",
156
 
                                "James Fitzsimons",
157
 
                                "JĆ©rĆ©mie Laval",
158
 
                                "Jeroen Zwartepoorte",
159
 
                                "John BouAnton",
160
 
                                "John Luke",
161
 
                                "Joshua Tauberer",
162
 
                                "Jonathan HernĆ”ndez Velasco",
163
 
                                "Jonathan Pobst",
164
 
                                "Levi Bard",
165
 
                                "Lluis Sanchez Gual",
166
 
                                "Luciano N. Callero",
167
 
                                "Marc Christensen",
168
 
                                "Marcos David MarĆ­n Amador",
169
 
                                "Martin Willemoes Hansen",
170
 
                                "Marek Sieradzki",
171
 
                                "Matej Urbas",
172
 
                                "MaurĆ­cio de Lemos Rodrigues Collares Neto",
173
 
                                "Michael Hutchinson",
174
 
                                "Miguel de Icaza",
175
 
                                "Mike KrĆ¼ger",
176
 
                                "Mike Kestner",
177
 
                                "Mitchell Wheeler",
178
 
                                "Muthiah Annamalai",
179
 
                                "Nick Drochak",
180
 
                                "Nikhil Sarda",
181
 
                                "nricciar",
182
 
                                "Paco MartĆ­nez",
183
 
                                "Pawel Rozanski",
184
 
                                "Pedro Abelleira Seco",
185
 
                                "Peter Johanson",
186
 
                                "Philip Turnbull",
187
 
                                "Richard Torkar",
188
 
                                "Rolf Bjarne Kvinge",
189
 
                                "Rusty Howell",
190
 
                                "Sanjoy Das",
191
 
                                "Scott Ellington",
192
 
                                "Thomas Wiest",
193
 
                                "Todd Berman",
194
 
                                "Vincent Daron",
195
 
                                "Vinicius Depizzol",
196
 
                                "Viktoria Dudka",
197
 
                                "Wade Berrier",
198
 
                                "Yan-ren Tsai",
199
 
                                "Zach Lute"
200
 
                        };
201
 
                        
202
 
                        Gdk.Color bgColor = new Gdk.Color (49, 49, 74);
203
 
                        Gdk.Color textColor = new Gdk.Color (0xFF, 0xFF, 0xFF);
204
 
                        
205
 
                        void LoadBranding ()
206
 
                        {
207
 
                                try {
208
 
                                        var textColStr = BrandingService.GetString ("AboutBox", "TextColor");
209
 
                                        if (textColStr != null)
210
 
                                                Gdk.Color.Parse (textColStr, ref textColor);
211
 
                                        var bgColStr = BrandingService.GetString ("AboutBox", "BackgroundColor");
212
 
                                        if (bgColStr != null)
213
 
                                                Gdk.Color.Parse (bgColStr, ref bgColor);
214
 
                                        
215
 
                                        //branders may provide either fg image or bg image, or both
216
 
                                        using (var stream = BrandingService.GetStream ("AboutImage.png", false)) {
217
 
                                                image = (stream != null ? new Gdk.Pixbuf (stream) : null);
218
 
                                        }
219
 
                                        using (var streamBg = BrandingService.GetStream ("AboutImageBg.png", false)) {
220
 
                                                imageBg = (streamBg != null ? new Gdk.Pixbuf (streamBg) : null);
221
 
                                        }
222
 
                                        
223
 
                                        //if branding did not provide any image, use the built-in one
224
 
                                        if (imageBg == null && image == null) {
225
 
                                                image = Gdk.Pixbuf.LoadFromResource ("AboutImage.png");
226
 
                                        }
227
 
                                } catch (Exception ex) {
228
 
                                        LoggingService.LogError ("Error loading about box branding", ex);
229
 
                                }
230
 
                        }
231
 
                        
232
 
                        public ScrollBox ()
233
 
                        {
234
 
                                LoadBranding ();
235
 
                                this.Realized += new EventHandler (OnRealized);
236
 
                                this.ModifyBg (Gtk.StateType.Normal, bgColor);
237
 
                                this.ModifyText (Gtk.StateType.Normal, textColor);
238
 
                                
239
 
                                if (image != null) {
240
 
                                        imageHeight = image.Height;
241
 
                                        imageWidth = image.Width;
242
 
                                }
243
 
                                if (imageBg != null) {
244
 
                                        imageHeight = Math.Max (imageHeight, imageBg.Height);
245
 
                                        imageWidth = Math.Max (imageWidth, imageBg.Width);
246
 
                                }
247
 
                                
248
 
                                monoPowered = Gdk.Pixbuf.LoadFromResource ("mono-powered.png");
249
 
                                this.SetSizeRequest (imageWidth, imageHeight - 1);
250
 
                                
251
 
                                uint timeout = 1000 / (uint)fps;
252
 
                                TimerHandle = GLib.Timeout.Add (timeout, delegate {
253
 
                                        this.QueueDrawArea (0, 0, Allocation.Width, imageHeight);
254
 
                                        return true;
255
 
                                });
256
 
                                
257
 
                                this.startTicks = DateTime.Now.Ticks;
258
 
                        }
259
 
                        
260
 
                        string CreditText {
261
 
                                get {
262
 
                                        var sb = new StringBuilder ();
263
 
                                        sb.Append (GettextCatalog.GetString ("<b>Contributors to this Release</b>\n\n"));
264
 
                                        
265
 
                                        for (int n = 0; n < authors.Length; n++) {
266
 
                                                sb.Append (authors [n]);
267
 
                                                if (n % 2 == 1)
268
 
                                                        sb.Append ("\n");
269
 
                                                else if (n < authors.Length - 1)
270
 
                                                        sb.Append (",  ");
271
 
                                        }
272
 
                                        
273
 
                                        sb.Append ("\n\n<b>" + GettextCatalog.GetString ("Previous Contributors") + "</b>\n\n");
274
 
                                        for (int n = 0; n < oldAuthors.Length; n++) {
275
 
                                                sb.Append (oldAuthors [n]);
276
 
                                                if (n % 2 == 1)
277
 
                                                        sb.Append ("\n");
278
 
                                                else if (n < oldAuthors.Length - 1)
279
 
                                                        sb.Append (",  ");
280
 
                                        }
281
 
        
282
 
                                        string trans = GettextCatalog.GetString ("translator-credits");
283
 
                                        if (trans != "translator-credits") {
284
 
                                                sb.Append (GettextCatalog.GetString ("\n\n<b>Translated by:</b>\n\n"));
285
 
                                                sb.Append (trans);
286
 
                                        }
287
 
                                        sb.AppendLine ();
288
 
                                        sb.AppendLine ();
289
 
                                        sb.AppendLine (GettextCatalog.GetString ("<b>Using some icons from:</b>"));
290
 
                                        sb.AppendLine ();
291
 
                                        sb.Append ("http://www.famfamfam.com/lab/icons/silk");
292
 
                                        return sb.ToString ();
293
 
                                }
294
 
                        }
295
 
                        
296
 
                        void UpdateScrollPosition ()
297
 
                        {
298
 
                                long elapsed = DateTime.Now.Ticks - startTicks;
299
 
                                long pauseTicks = pauseSeconds * TimeSpan.TicksPerSecond;
300
 
                                long ticksPerPixel = TimeSpan.TicksPerSecond / (pixelsPerFrame * fps);
301
 
                                long totalScrollTicks = scrollHeightPx * ticksPerPixel  + pauseTicks;
302
 
                                long tickPosition = elapsed % totalScrollTicks;
303
 
                                scrolledUpPx = (int) Math.Min ((tickPosition / ticksPerPixel), scrollHeightPx);
304
 
                        }
305
 
                        
306
 
                        void DrawText (Drawable window)
307
 
                        {
308
 
                                var alloc = Allocation;
309
 
                                int pos = scrollStartPx - scrolledUpPx;
310
 
                                window.DrawLayout (Style.TextGC (StateType.Normal), 0, pos, layout);
311
 
                                int logoPos = pos + scrollHeightPx - monoPowered.Height / 2 - imageHeight / 2;
312
 
                                window.DrawPixbuf (backGc, monoPowered, 0, 0, (alloc.Width / 2) - (monoPowered.Width / 2),
313
 
                                        logoPos, -1, -1, RgbDither.Normal, 0, 0);
314
 
                        }
315
 
                        
316
 
                        protected override bool OnExposeEvent (Gdk.EventExpose evnt)
317
 
                        {
318
 
                                UpdateScrollPosition ();
319
 
                                
320
 
                                var alloc = this.Allocation;
321
 
                                if (imageBg != null) {
322
 
                                        evnt.Window.DrawPixbuf (backGc, imageBg, 0, 0,
323
 
                                                (alloc.Width - imageBg.Width) / 2, 0,
324
 
                                                -1, -1, RgbDither.Normal, 0, 0);
325
 
                                }
326
 
                                DrawText (evnt.Window);
327
 
                                if (this.image != null) {
328
 
                                        evnt.Window.DrawPixbuf (backGc, image, 0, 0,
329
 
                                                (alloc.Width - image.Width) / 2, 0,
330
 
                                                -1, -1, RgbDither.Normal, 0, 0);
331
 
                                }
332
 
                                return false;
333
 
                        }
334
 
                        
335
 
                        protected void OnRealized (object o, EventArgs args)
336
 
                        {
337
 
                                scrollStartPx = imageHeight;
338
 
                                
339
 
                                layout = new Pango.Layout (this.PangoContext);
340
 
                                // FIXME: this seems wrong but works
341
 
                                layout.Width = Allocation.Width * (int)Pango.Scale.PangoScale;
342
 
                                layout.Wrap = Pango.WrapMode.Word;
343
 
                                layout.Alignment = Pango.Alignment.Center;
344
 
                                FontDescription fd = FontDescription.FromString ("Tahoma 10");
345
 
                                layout.FontDescription = fd;
346
 
                                layout.SetMarkup (CreditText);
347
 
                                
348
 
                                int widthPx, heightPx;
349
 
                                layout.GetPixelSize (out widthPx, out heightPx);
350
 
                                
351
 
                                this.scrollHeightPx = heightPx + monoLogoSpacing + monoPowered.Height + imageHeight / 2;
352
 
                                
353
 
                                backGc = new Gdk.GC (GdkWindow);
354
 
                                backGc.RgbBgColor = bgColor;
355
 
                        }
356
 
                        
357
 
                        protected override void OnDestroyed ()
358
 
                        {
359
 
                                base.OnDestroyed ();
360
 
                                backGc.Dispose ();
361
 
                                GLib.Source.Remove (TimerHandle);
362
 
                        }
363
 
                }
364
123
        }
365
124
}
 
 
b'\\ No newline at end of file'