~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/SplashScreen.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:
9
9
 
10
10
namespace MonoDevelop.Ide.Gui.Dialogs {
11
11
        
12
 
        public class SplashScreenForm : Gtk.Window, IProgressMonitor, IDisposable
 
12
        public class SplashScreenForm : Window, IProgressMonitor, IDisposable
13
13
        {
 
14
                ConsoleProgressMonitor monitor = new ConsoleProgressMonitor ();
 
15
 
14
16
                const int SplashFontSize = 10;
15
 
                const string SplashFontFamily = "sans-serif"; 
16
 
                
17
 
                static SplashScreenForm splashScreen;
18
 
                static ProgressBar progress;
19
 
                static VBox vbox;
20
 
                ProgressTracker tracker = new ProgressTracker ();
 
17
                const string SplashFontFamily = "sans-serif";
 
18
 
21
19
                Gdk.Pixbuf bitmap;
22
 
                static Gtk.Label label;
23
20
                bool showVersionInfo;
24
 
                
25
 
                public static SplashScreenForm SplashScreen {
26
 
                        get {
27
 
                                if (splashScreen == null)
28
 
                                        splashScreen = new SplashScreenForm();
29
 
                                return splashScreen;
30
 
                        }
31
 
                }
32
 
                
 
21
 
33
22
                //this is a popup so it behaves like other splashes on Windows, i.e. doesn't show up as a second window in the taskbar.
34
 
                public SplashScreenForm () : base (Gtk.WindowType.Popup)
 
23
                public SplashScreenForm () : base (WindowType.Popup)
35
24
                {
36
25
                        AppPaintable = true;
37
26
                        this.Decorated = false;
38
27
                        this.WindowPosition = WindowPosition.Center;
39
28
                        this.TypeHint = Gdk.WindowTypeHint.Splashscreen;
40
29
                        this.showVersionInfo = BrandingService.GetBool ("SplashScreen", "ShowVersionInfo") ?? true;
41
 
                        try {
42
 
                                using (var stream = BrandingService.GetStream ("SplashScreen.png", true))
43
 
                                        bitmap = new Gdk.Pixbuf (stream);
44
 
                        } catch (Exception e) {
45
 
                                LoggingService.LogError ("Can't load splash screen pixbuf 'SplashScreen.png'.", e);
46
 
                        }
47
 
                        progress = new ProgressBar();
48
 
                        progress.Fraction = 0.00;
49
 
                        progress.HeightRequest = 6;
50
 
 
51
 
                        vbox = new VBox();
52
 
                        vbox.BorderWidth = 12;
53
 
                        label = new Gtk.Label ();
54
 
                        label.UseMarkup = true;
55
 
                        label.Xalign = 0;
56
 
                        vbox.PackEnd (progress, false, true, 0);
57
 
                        vbox.PackEnd (label, false, true, 3);
58
 
                        this.Add (vbox);
59
 
                        if (bitmap != null)
60
 
                                this.Resize (bitmap.Width, bitmap.Height);
 
30
                        using (var stream = BrandingService.GetStream ("SplashScreen.png", true))
 
31
                                bitmap = new Gdk.Pixbuf (stream);
 
32
                        this.Resize (bitmap.Width, bitmap.Height);
61
33
                }
62
34
                
63
35
                protected override void OnDestroyed ()
164
136
                        c.Color = new Cairo.Color (161 / 255.0, 40 / 255.0, 48 / 255.0);
165
137
                        c.Fill ();
166
138
                }
167
 
 
168
 
                public static void SetProgress (double Percentage)
169
 
                {
170
 
                        progress.Fraction = Percentage;
171
 
                        RunMainLoop ();
172
 
                }
173
 
 
174
 
                public void SetMessage (string Message)
175
 
                {
176
 
                        if (bitmap == null) {
177
 
                                label.Text = Message;
178
 
                        } else {
179
 
                                label.Markup = "<span size='small' foreground='white'>" + Message + "</span>";
180
 
                        }
181
 
                        RunMainLoop ();
182
 
                }
183
139
                
184
140
                static void RunMainLoop ()
185
141
                {
188
144
                
189
145
                void IProgressMonitor.BeginTask (string name, int totalWork)
190
146
                {
191
 
                        tracker.BeginTask (name, totalWork);
192
 
                        SetMessage (tracker.CurrentTask);
 
147
                        monitor.BeginTask (name, totalWork);
 
148
                        RunMainLoop ();
193
149
                }
194
150
                
195
151
                void IProgressMonitor.BeginStepTask (string name, int totalWork, int stepSize)
196
152
                {
197
 
                        tracker.BeginStepTask (name, totalWork, stepSize);
198
 
                        SetMessage (tracker.CurrentTask);
 
153
                        monitor.BeginStepTask (name, totalWork, stepSize);
 
154
                        RunMainLoop ();
199
155
                }
200
156
                
201
157
                void IProgressMonitor.EndTask ()
202
158
                {
203
 
                        tracker.EndTask ();
204
 
                        SetProgress (tracker.GlobalWork);
205
 
                        SetMessage (tracker.CurrentTask);
 
159
                        monitor.EndTask ();
 
160
                        RunMainLoop ();
206
161
                }
207
162
                
208
163
                void IProgressMonitor.Step (int work)
209
164
                {
210
 
                        tracker.Step (work);
211
 
                        SetProgress (tracker.GlobalWork);
 
165
                        monitor.Step (work);
 
166
                        RunMainLoop ();
212
167
                }
213
168
                
214
169
                TextWriter IProgressMonitor.Log {
215
 
                        get { return Console.Out; }
 
170
                        get { return monitor.Log; }
216
171
                }
217
172
                
218
173
                void IProgressMonitor.ReportWarning (string message)
219
174
                {
 
175
                        monitor.ReportWarning (message);
220
176
                }
221
177
                
222
178
                void IProgressMonitor.ReportSuccess (string message)
223
179
                {
 
180
                        monitor.ReportSuccess (message);
224
181
                }
225
182
                
226
183
                void IProgressMonitor.ReportError (string message, Exception exception)
227
184
                {
 
185
                        monitor.ReportError (message, exception);
228
186
                }
229
187
                
230
188
                bool IProgressMonitor.IsCancelRequested {
238
196
                
239
197
                // The returned IAsyncOperation object must be thread safe
240
198
                IAsyncOperation IProgressMonitor.AsyncOperation {
241
 
                        get { return null; }
 
199
                        get { return monitor.AsyncOperation; }
242
200
                }
243
201
                
244
202
                object IProgressMonitor.SyncRoot {
245
 
                        get { return this; }
 
203
                        get { return monitor.SyncRoot; }
246
204
                }
247
205
                
248
206
                void IDisposable.Dispose ()
249
207
                {
250
208
                        Destroy ();
251
 
                        splashScreen = null;
252
209
                }
253
210
        }
254
211
}