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

« back to all changes in this revision

Viewing changes to src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui/MonoDevelopStatusBar.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:
35
35
using MonoDevelop.Components.Docking;
36
36
using MonoDevelop.Ide.Gui.Dialogs;
37
37
using MonoDevelop.Components;
 
38
using MonoDevelop.Components.MainToolbar;
 
39
 
 
40
using StockIcons = MonoDevelop.Ide.Gui.Stock;
38
41
 
39
42
namespace MonoDevelop.Ide
40
43
{
41
 
        class MonoDevelopStatusBar : Gtk.Statusbar, StatusBar, IShadedWidget
 
44
        class MonoDevelopStatusBar : Gtk.HBox
42
45
        {
43
 
                ProgressBar progressBar = new ProgressBar ();
44
 
                Frame textStatusBarPanel = new Frame ();
45
 
                
46
 
                Label statusLabel;
47
46
                Label modeLabel;
48
47
                Label cursorLabel;
49
48
                MiniButton feedbackButton;
50
 
                
 
49
                Gtk.Widget resizeGrip = new Gtk.Label ("");
 
50
 
 
51
                const int ResizeGripWidth = 14;
 
52
 
51
53
                HBox statusBox;
52
 
                HBox messageBox;
53
 
                Image currentStatusImage;
54
 
                
55
 
                HBox statusIconBox;
56
 
                
57
 
                List<StatusBarContextImpl> contexts = new List<StatusBarContextImpl> ();
58
 
                MainStatusBarContextImpl mainContext;
59
 
                StatusBarContextImpl activeContext;
60
 
                Pad sourcePad;
61
 
                uint autoPulseTimeoutId;
62
 
                
63
 
                public StatusBar MainContext {
64
 
                        get { return mainContext; }
65
 
                }
66
 
                
 
54
 
 
55
                readonly Label statusLabel = new Label ();
 
56
                public readonly static HBox messageBox = new HBox ();
 
57
 
67
58
                /// <summary>
68
59
                /// For small size changes the caret label is grow only. That ensures that normal caret movement doesn't
69
60
                /// update the whole status bar all the time. But for big jumps in size a resize is done.
85
76
 
86
77
                internal MonoDevelopStatusBar ()
87
78
                {
88
 
                        mainContext = new MainStatusBarContextImpl (this);
89
 
                        activeContext = mainContext;
90
 
                        contexts.Add (mainContext);
91
 
                        
92
 
                        Frame originalFrame = (Frame)Children [0];
93
 
//                      originalFrame.WidthRequest = 8;
94
 
//                      originalFrame.Shadow = ShadowType.In;
95
 
//                      originalFrame.BorderWidth = 0;
96
 
                        
97
79
                        BorderWidth = 0;
98
80
                        Spacing = 0;
 
81
                        HasResizeGrip = true;
 
82
 
 
83
                        HeaderBox hb = new HeaderBox (1, 0, 0, 0);
 
84
                        hb.BorderColor = Styles.DockSeparatorColor;
 
85
                        var mainBox = new HBox ();
 
86
                        mainBox.PackStart (new Label (""), true, true, 0);
 
87
                        hb.Add (mainBox);
 
88
                        hb.ShowAll ();
 
89
                        PackStart (hb, true, true, 0);
99
90
                        
100
91
                        // Feedback button
101
92
                        
102
93
                        if (FeedbackService.Enabled) {
103
 
                                CustomFrame fr = new CustomFrame (0, 0, 1, 1);
 
94
                                CustomFrame fr = new CustomFrame (0, 0, 1, 0);
104
95
                                Gdk.Pixbuf px = Gdk.Pixbuf.LoadFromResource ("balloon.png");
105
96
                                HBox b = new HBox (false, 3);
106
97
                                b.PackStart (new Gtk.Image (px));
112
103
                                feedbackButton = new MiniButton (al);
113
104
                                //feedbackButton.BackroundColor = new Gdk.Color (200, 200, 255);
114
105
                                fr.Add (feedbackButton);
115
 
                                PackStart (fr, false, false, 0);
 
106
                                mainBox.PackStart (fr, false, false, 0);
116
107
                                feedbackButton.Clicked += HandleFeedbackButtonClicked;
117
108
                                feedbackButton.ButtonPressEvent += HandleFeedbackButtonButtonPressEvent;
118
109
                                ;
119
110
                                feedbackButton.ClickOnRelease = true;
120
111
                                FeedbackService.FeedbackPositionGetter = delegate {
121
112
                                        int x, y;
122
 
                                        feedbackButton.GdkWindow.GetOrigin (out x, out y);
123
 
                                        x += feedbackButton.Allocation.Width;
124
 
                                        y -= 6;
 
113
                                        if (feedbackButton.GdkWindow != null) {
 
114
                                                feedbackButton.GdkWindow.GetOrigin (out x, out y);
 
115
                                                x += feedbackButton.Allocation.Width;
 
116
                                                y -= 6;
 
117
                                        } else {
 
118
                                                x = y = -1;
 
119
                                        }
125
120
                                        return new Gdk.Point (x, y);
126
121
                                };
127
122
                        }
128
123
                        
129
124
                        // Dock area
130
125
                        
 
126
                        CustomFrame dfr = new CustomFrame (0, 0, 1, 0);
 
127
                        dfr.ShowAll ();
131
128
                        DefaultWorkbench wb = (DefaultWorkbench)IdeApp.Workbench.RootWindow;
132
 
                        wb.DockFrame.ShadedContainer.Add (this);
133
 
                        Gtk.Widget dockBar = wb.DockFrame.ExtractDockBar (PositionType.Bottom);
 
129
                        var dockBar = wb.DockFrame.ExtractDockBar (PositionType.Bottom);
 
130
                        dockBar.AlignToEnd = true;
 
131
                        dockBar.ShowBorder = false;
134
132
                        dockBar.NoShowAll = true;
135
 
                        PackStart (dockBar, false, false, 0);
136
 
                        
 
133
                        dfr.Add (dockBar);
 
134
                        mainBox.PackStart (dfr, false, false, 0);
 
135
 
 
136
                        // Resize grip
 
137
 
 
138
                        resizeGrip.WidthRequest = ResizeGripWidth;
 
139
                        resizeGrip.HeightRequest = 0;
 
140
                        mainBox.PackStart (resizeGrip, false, false, 0);
 
141
 
137
142
                        // Status panels
138
 
                        
139
 
                        progressBar = new ProgressBar ();
140
 
                        progressBar.PulseStep = 0.1;
141
 
                        progressBar.SizeRequest ();
142
 
                        progressBar.HeightRequest = 1;
143
 
                        
 
143
 
144
144
                        statusBox = new HBox (false, 0);
145
145
                        statusBox.BorderWidth = 0;
146
146
                        
147
 
                        statusLabel = new Label ();
148
147
                        statusLabel.SetAlignment (0, 0.5f);
149
148
                        statusLabel.Wrap = false;
150
149
                        int w, h;
151
150
                        Gtk.Icon.SizeLookup (IconSize.Menu, out w, out h);
152
151
                        statusLabel.HeightRequest = h;
153
152
                        statusLabel.SetPadding (0, 0);
 
153
                        statusLabel.ShowAll ();
154
154
                        
155
 
                        EventBox eventMessageBox = new EventBox ();
156
 
                        messageBox = new HBox ();
157
 
                        messageBox.PackStart (progressBar, false, false, 0);
158
155
                        messageBox.PackStart (statusLabel, true, true, 0);
159
 
                        eventMessageBox.Add (messageBox);
160
 
                        statusBox.PackStart (eventMessageBox, true, true, 0);
161
 
                        eventMessageBox.ButtonPressEvent += HandleEventMessageBoxButtonPressEvent;
162
 
                        
163
 
                        textStatusBarPanel.BorderWidth = 0;
164
 
                        textStatusBarPanel.ShadowType = ShadowType.None;
165
 
                        textStatusBarPanel.Add (statusBox);
166
 
                        
 
156
 
167
157
                        var eventCaretBox = new EventBox ();
168
158
                        var caretStatusBox = new HBox ();
169
159
                        modeLabel = new Label (" ");
178
168
                        eventCaretBox.Add (caretStatusBox);
179
169
                        statusBox.PackEnd (eventCaretBox, false, false, 0);
180
170
                        
181
 
                        statusIconBox = new HBox ();
182
 
                        statusIconBox.BorderWidth = 0;
183
 
                        statusIconBox.Spacing = 3;
184
 
                        statusBox.PackEnd (statusIconBox, false, false, 4);
185
 
                        
186
 
                        this.PackStart (textStatusBarPanel, true, true, 0);
187
 
                        
188
 
                        ShowReady ();
189
 
                        Gtk.Box.BoxChild boxChild = (Gtk.Box.BoxChild)this[textStatusBarPanel];
190
 
                        boxChild.Position = 0;
191
 
                        boxChild.Expand = boxChild.Fill = true;
192
 
                        
193
 
        //              boxChild = (Gtk.Box.BoxChild)this[originalFrame];
194
 
        //              boxChild.Padding = 0;
195
 
        //              boxChild.Expand = boxChild.Fill = false;
196
 
                        
197
 
                        this.progressBar.Fraction = 0.0;
198
171
                        this.ShowAll ();
199
 
                        statusIconBox.HideAll ();
200
 
                        
201
 
                        originalFrame.HideAll ();
202
 
                        progressBar.Visible = false;
203
 
                        
204
 
                        StatusBarContext completionStatus = null;
205
 
                        
206
 
                        // todo: Move this to the CompletionWindowManager when it's possible.
207
 
                        CompletionWindowManager.WindowShown += delegate {
208
 
                                CompletionListWindow wnd = CompletionWindowManager.Wnd;
209
 
                                if (wnd != null && wnd.List != null && wnd.List.CategoryCount > 1) {
210
 
                                        if (completionStatus == null)
211
 
                                                completionStatus = CreateContext ();
212
 
                                        completionStatus.ShowMessage (string.Format (GettextCatalog.GetString ("To toggle categorized completion mode press {0}."), IdeApp.CommandService.GetCommandInfo (Commands.TextEditorCommands.ShowCompletionWindow).AccelKey));
213
 
                                }
214
 
                        };
215
 
                        
216
 
                        CompletionWindowManager.WindowClosed += delegate {
217
 
                                if (completionStatus != null) {
218
 
                                        completionStatus.Dispose ();
219
 
                                        completionStatus = null;
220
 
                                }
221
 
                        };
 
172
 
 
173
//                      // todo: Move this to the CompletionWindowManager when it's possible.
 
174
//                      StatusBarContext completionStatus = null;
 
175
//                      CompletionWindowManager.WindowShown += delegate {
 
176
//                              CompletionListWindow wnd = CompletionWindowManager.Wnd;
 
177
//                              if (wnd != null && wnd.List != null && wnd.List.CategoryCount > 1) {
 
178
//                                      if (completionStatus == null)
 
179
//                                              completionStatus = CreateContext ();
 
180
//                                      completionStatus.ShowMessage (string.Format (GettextCatalog.GetString ("To toggle categorized completion mode press {0}."), IdeApp.CommandService.GetCommandInfo (Commands.TextEditorCommands.ShowCompletionWindow).AccelKey));
 
181
//                              }
 
182
//                      };
222
183
                }
223
184
                
224
185
                [System.Runtime.InteropServices.DllImport ("libc")]
254
215
                        ignoreFeedbackButtonClick = false;
255
216
                }
256
217
 
257
 
                void HandleEventMessageBoxButtonPressEvent (object o, ButtonPressEventArgs args)
258
 
                {
259
 
                        if (sourcePad != null)
260
 
                                sourcePad.BringToFront (true);
261
 
                }
262
 
                
263
 
                internal bool IsCurrentContext (StatusBarContextImpl ctx)
264
 
                {
265
 
                        return ctx == activeContext;
266
 
                }
267
 
                
268
 
                internal void Remove (StatusBarContextImpl ctx)
269
 
                {
270
 
                        if (ctx == mainContext)
271
 
                                return;
272
 
                        
273
 
                        StatusBarContextImpl oldActive = activeContext;
274
 
                        contexts.Remove (ctx);
275
 
                        UpdateActiveContext ();
276
 
                        if (oldActive != activeContext) {
277
 
                                // Removed the active context. Update the status bar.
278
 
                                activeContext.Update ();
279
 
                        }
280
 
                }
281
 
                
282
 
                internal void UpdateActiveContext ()
283
 
                {
284
 
                        for (int n = contexts.Count - 1; n >= 0; n--) {
285
 
                                StatusBarContextImpl ctx = contexts [n];
286
 
                                if (ctx.StatusChanged) {
287
 
                                        if (ctx != activeContext) {
288
 
                                                activeContext = ctx;
289
 
                                                activeContext.Update ();
290
 
                                        }
291
 
                                        return;
292
 
                                }
293
 
                        }
294
 
                        throw new InvalidOperationException (); // There must be at least the main context
295
 
                }
296
 
                
297
 
                public StatusBarContext CreateContext ()
298
 
                {
299
 
                        StatusBarContextImpl ctx = new StatusBarContextImpl (this);
300
 
                        contexts.Add (ctx);
301
 
                        return ctx;
302
 
                }
303
 
                
304
218
                public void ShowCaretState (int line, int column, int selectedChars, bool isInInsertMode)
305
219
                {
306
220
                        DispatchService.AssertGuiThread ();
320
234
                        if (modeLabel.Text != "")
321
235
                                modeLabel.Text = "";
322
236
                }
323
 
                
324
 
                public void ShowReady ()
325
 
                {
326
 
                        ShowMessage (GettextCatalog.GetString ("Ready"));       
327
 
                }
328
 
                
329
 
                public void ShowError (string error)
330
 
                {
331
 
                        ShowMessage (new Image (MonoDevelop.Ide.Gui.Stock.Error, IconSize.Menu), error);
332
 
                }
333
 
                
334
 
                public void ShowWarning (string warning)
335
 
                {
336
 
                        DispatchService.AssertGuiThread ();
337
 
                        ShowMessage (new Gtk.Image (MonoDevelop.Ide.Gui.Stock.Warning, IconSize.Menu), warning);
338
 
                }
339
 
                
340
 
                public void ShowMessage (string message)
341
 
                {
342
 
                        ShowMessage (null, message, false);
343
 
                }
344
 
                
345
 
                public void ShowMessage (string message, bool isMarkup)
346
 
                {
347
 
                        ShowMessage (null, message, isMarkup);
348
 
                }
349
 
                
350
 
                public void ShowMessage (Image image, string message)
351
 
                {
352
 
                        ShowMessage (image, message, false);
353
 
                }
354
 
                string lastText = null;
355
 
                public void ShowMessage (Image image, string message, bool isMarkup)
356
 
                {
357
 
                        if (message == lastText)
358
 
                                return;
359
 
                        sourcePad = null;
360
 
                        lastText = message;
361
 
                        DispatchService.AssertGuiThread ();
362
 
                        if (currentStatusImage != image) {
363
 
                                if (currentStatusImage != null) 
364
 
                                        messageBox.Remove (currentStatusImage);
365
 
                                currentStatusImage = image;
366
 
                                if (image != null) {
367
 
                                        image.SetPadding (0, 0);
368
 
                                        messageBox.PackStart (image, false, false, 3);
369
 
                                        messageBox.ReorderChild (image, 1);
370
 
                                        image.Show ();
371
 
                                }
372
 
                        }
373
 
                        
374
 
                        string txt = !String.IsNullOrEmpty (message) ? " " + message.Replace ("\n", " ") : "";
375
 
                        if (isMarkup) {
376
 
                                statusLabel.Markup = txt;
377
 
                        } else {
378
 
                                statusLabel.Text = txt;
379
 
                        }
380
 
                }
381
 
                
382
 
                public void SetMessageSourcePad (Pad pad)
383
 
                {
384
 
                        sourcePad = pad;
385
 
                }
386
 
                
387
 
                public StatusBarIcon ShowStatusIcon (Gdk.Pixbuf pixbuf)
388
 
                {
389
 
                        DispatchService.AssertGuiThread ();
390
 
                        StatusIcon icon = new StatusIcon (this, pixbuf);
391
 
                        statusIconBox.PackEnd (icon.box);
392
 
                        statusIconBox.ShowAll ();
393
 
                        return icon;
394
 
                }
395
 
                
396
 
                void HideStatusIcon (StatusIcon icon)
397
 
                {
398
 
                        statusIconBox.Remove (icon.EventBox);
399
 
                        icon.EventBox.Destroy ();
400
 
                }
401
 
                
402
 
                #region Progress Monitor implementation
403
 
                public void BeginProgress (string name)
404
 
                {
405
 
                        ShowMessage (name);
406
 
                        this.progressBar.Visible = true;
407
 
                }
408
 
                
409
 
                public void BeginProgress (Image image, string name)
410
 
                {
411
 
                        ShowMessage (image, name);
412
 
                        this.progressBar.Visible = true;
413
 
                }
414
 
 
415
 
                public void SetProgressFraction (double work)
416
 
                {
417
 
                        DispatchService.AssertGuiThread ();
418
 
                        this.progressBar.Fraction = work;
419
 
                }
420
 
                
421
 
                public void EndProgress ()
422
 
                {
423
 
                        ShowMessage ("");
424
 
                        this.progressBar.Fraction = 0.0;
425
 
                        this.progressBar.Visible = false;
426
 
                        AutoPulse = false;
427
 
                }
428
 
 
429
 
                public void Pulse ()
430
 
                {
431
 
                        DispatchService.AssertGuiThread ();
432
 
                        this.progressBar.Visible = true;
433
 
                        this.progressBar.Pulse ();
434
 
                }
435
 
 
436
 
                public bool AutoPulse {
437
 
                        get { return autoPulseTimeoutId != 0; }
438
 
                        set {
439
 
                                DispatchService.AssertGuiThread ();
440
 
                                if (value) {
441
 
                                        this.progressBar.Visible = true;
442
 
                                        if (autoPulseTimeoutId == 0) {
443
 
                                                autoPulseTimeoutId = GLib.Timeout.Add (100, delegate {
444
 
                                                        this.progressBar.Pulse ();
445
 
                                                        return true;
446
 
                                                });
447
 
                                        }
448
 
                                } else {
449
 
                                        if (autoPulseTimeoutId != 0) {
450
 
                                                GLib.Source.Remove (autoPulseTimeoutId);
451
 
                                                autoPulseTimeoutId = 0;
452
 
                                        }
453
 
                                }
454
 
                        }
455
 
                }
456
 
                #endregion
457
 
                
458
 
                public class StatusIcon : StatusBarIcon
459
 
                {
460
 
                        MonoDevelopStatusBar statusBar;
461
 
                        internal EventBox box;
462
 
                        string tip;
463
 
                        DateTime alertEnd;
464
 
                        Gdk.Pixbuf icon;
465
 
                        uint animation;
466
 
                        Gtk.Image image;
467
 
                        
468
 
                        int astep;
469
 
                        Gdk.Pixbuf[] images;
470
 
                        
471
 
                        public StatusIcon (MonoDevelopStatusBar statusBar, Gdk.Pixbuf icon)
472
 
                        {
473
 
                                this.statusBar = statusBar;
474
 
                                this.icon = icon;
475
 
                                box = new EventBox ();
476
 
                                image = new Image (icon);
477
 
                                image.SetPadding (0, 0);
478
 
                                box.Child = image;
479
 
                        }
480
 
                        
481
 
                        public void Dispose ()
482
 
                        {
483
 
                                statusBar.HideStatusIcon (this);
484
 
                                if (images != null) {
485
 
                                        foreach (Gdk.Pixbuf img in images) {
486
 
                                                img.Dispose ();
487
 
                                        }
488
 
                                }
489
 
                                if (animation != 0) {
490
 
                                        GLib.Source.Remove (animation);
491
 
                                        animation = 0;
492
 
                                }
493
 
                        }
494
 
                        
495
 
                        public string ToolTip {
496
 
                                get { return tip; }
497
 
                                set {
498
 
                                        box.TooltipText = tip = value;
499
 
                                }
500
 
                        }
501
 
                        
502
 
                        public EventBox EventBox {
503
 
                                get { return box; }
504
 
                        }
505
 
                        
506
 
                        public Gdk.Pixbuf Image {
507
 
                                get { return icon; }
508
 
                                set {
509
 
                                        icon = value;
510
 
                                        image.Pixbuf = icon;
511
 
                                }
512
 
                        }
513
 
                        
514
 
                        public void SetAlertMode (int seconds)
515
 
                        {
516
 
                                astep = 0;
517
 
                                alertEnd = DateTime.Now.AddSeconds (seconds);
518
 
                                
519
 
                                if (animation != 0)
520
 
                                        GLib.Source.Remove (animation);
521
 
                                
522
 
                                animation = GLib.Timeout.Add (60, new GLib.TimeoutHandler (AnimateIcon));
523
 
                                
524
 
                                if (images == null) {
525
 
                                        images = new Gdk.Pixbuf [10];
526
 
                                        for (int n=0; n<10; n++)
527
 
                                                images [n] = ImageService.MakeTransparent (icon, ((double)(9-n))/10.0);
528
 
                                }
529
 
                        }
530
 
                        
531
 
                        bool AnimateIcon ()
532
 
                        {
533
 
                                if (DateTime.Now >= alertEnd && astep == 0) {
534
 
                                        image.Pixbuf = icon;
535
 
                                        animation = 0;
536
 
                                        return false;
537
 
                                }
538
 
                                if (astep < 10)
539
 
                                        image.Pixbuf = images [astep];
540
 
                                else
541
 
                                        image.Pixbuf = images [20 - astep - 1];
542
 
                                        
543
 
                                astep = (astep + 1) % 20;
544
 
                                return true;
545
 
                        }
546
 
                }
547
 
                
 
237
 
 
238
                bool hasResizeGrip;
 
239
                public bool HasResizeGrip {
 
240
                        get { return hasResizeGrip; }
 
241
                        set { hasResizeGrip = value; resizeGrip.Visible = hasResizeGrip; }
 
242
                }
 
243
 
548
244
                Gdk.Rectangle GetGripRect ()
549
245
                {
550
 
                        Gdk.Rectangle rect = new Gdk.Rectangle (0, 0, 18, Allocation.Height);
 
246
                        Gdk.Rectangle rect = new Gdk.Rectangle (0, 0, ResizeGripWidth, Allocation.Height);
551
247
                        if (rect.Width > Allocation.Width)
552
248
                                rect.Width = Allocation.Width;
553
249
                        rect.Y = Allocation.Y + Allocation.Height - rect.Height;
562
258
                {
563
259
                        bool ret = base.OnExposeEvent (evnt);
564
260
                        if (HasResizeGrip) {
565
 
                                DefaultWorkbench wb = (DefaultWorkbench) IdeApp.Workbench.RootWindow;
566
 
                                wb.DockFrame.ShadedContainer.DrawBackground (this, GetGripRect ());
567
261
                                Gdk.Rectangle rect = GetGripRect ();
568
262
                                int w = rect.Width - Style.Xthickness;
569
263
                                int h = Allocation.Height - Style.YThickness;
571
265
                                Gdk.WindowEdge edge = Direction == TextDirection.Ltr ? Gdk.WindowEdge.SouthEast : Gdk.WindowEdge.SouthWest;
572
266
                                Gtk.Style.PaintResizeGrip (Style, GdkWindow, State, evnt.Area, this, "statusbar", edge, rect.X, rect.Y, w, h);
573
267
                        }
574
 
                        return ret;
575
 
                }
576
 
                
577
 
                public void NotifyShadedAreasChanged ()
578
 
                {
579
 
                        if (AreasChanged != null)
580
 
                                AreasChanged (this, EventArgs.Empty);
581
 
                }
582
 
                
583
 
                public IEnumerable<Gdk.Rectangle> GetShadedAreas ()
584
 
                {
585
 
                        if (HasResizeGrip)
586
 
                                yield return GetGripRect ();
587
 
                }
588
 
                
589
 
                public event EventHandler AreasChanged;
590
 
        }
591
 
        
592
 
        /// <summary>
593
 
        /// The MonoDevelop status bar.
594
 
        /// </summary>
595
 
        public interface StatusBar: StatusBarContextBase
596
 
        {
597
 
                /// <summary>
598
 
                /// Show caret state information
599
 
                /// </summary>
600
 
                void ShowCaretState (int line, int column, int selectedChars, bool isInInsertMode);
601
 
                
602
 
                /// <summary>
603
 
                /// Hides the caret state information
604
 
                /// </summary>
605
 
                void ClearCaretState ();
606
 
                
607
 
                /// <summary>
608
 
                /// Shows a status icon in the toolbar. The icon can be removed by disposing
609
 
                /// the StatusBarIcon instance.
610
 
                /// </summary>
611
 
                StatusBarIcon ShowStatusIcon (Gdk.Pixbuf pixbuf);
612
 
                
613
 
                /// <summary>
614
 
                /// Creates a status bar context. The returned context can be used to show status information
615
 
                /// which will be cleared when the context is disposed. When several contexts are created,
616
 
                /// the status bar will show the status of the latest created context.
617
 
                /// </summary>
618
 
                StatusBarContext CreateContext ();
619
 
                
620
 
                // Clears the status bar information
621
 
                void ShowReady ();
622
 
                
623
 
                /// <summary>
624
 
                /// Sets a pad which has detailed information about the status message. When clicking on the
625
 
                /// status bar, this pad will be activated. This source pad is reset at every ShowMessage call.
626
 
                /// </summary>
627
 
                void SetMessageSourcePad (Pad pad);
628
 
                
629
 
                /// <summary>
630
 
                /// When set to true, the resize grip is shown
631
 
                /// </summary>
632
 
                bool HasResizeGrip { get; set; }
633
 
        }
634
 
        
635
 
        public interface StatusBarContextBase: IDisposable
636
 
        {
637
 
                /// <summary>
638
 
                /// Shows a message with an error icon
639
 
                /// </summary>
640
 
                void ShowError (string error);
641
 
                
642
 
                /// <summary>
643
 
                /// Shows a message with a warning icon
644
 
                /// </summary>
645
 
                void ShowWarning (string warning);
646
 
                
647
 
                /// <summary>
648
 
                /// Shows a message in the status bar
649
 
                /// </summary>
650
 
                void ShowMessage (string message);
651
 
                
652
 
                /// <summary>
653
 
                /// Shows a message in the status bar
654
 
                /// </summary>
655
 
                void ShowMessage (string message, bool isMarkup);
656
 
                
657
 
                /// <summary>
658
 
                /// Shows a message in the status bar
659
 
                /// </summary>
660
 
                void ShowMessage (Image image, string message);
661
 
                
662
 
                /// <summary>
663
 
                /// Shows a progress bar, with the provided label next to it
664
 
                /// </summary>
665
 
                void BeginProgress (string name);
666
 
                
667
 
                /// <summary>
668
 
                /// Shows a progress bar, with the provided label and icon next to it
669
 
                /// </summary>
670
 
                void BeginProgress (Image image, string name);
671
 
                
672
 
                /// <summary>
673
 
                /// Sets the progress fraction. It can only be used after calling BeginProgress.
674
 
                /// </summary>
675
 
                void SetProgressFraction (double work);
676
 
 
677
 
                /// <summary>
678
 
                /// Hides the progress bar shown with BeginProgress
679
 
                /// </summary>
680
 
                void EndProgress ();
681
 
                
682
 
                /// <summary>
683
 
                /// Pulses the progress bar shown with BeginProgress
684
 
                /// </summary>
685
 
                void Pulse ();
686
 
                
687
 
                /// <summary>
688
 
                /// When set, the status bar progress will be automatically pulsed at short intervals
689
 
                /// </summary>
690
 
                bool AutoPulse { get; set; }
691
 
        }
692
 
        
693
 
        public interface StatusBarContext: StatusBarContextBase
694
 
        {
695
 
                Pad StatusSourcePad { get; set; }
696
 
        }
697
 
        
698
 
        public interface StatusBarIcon : IDisposable
699
 
        {
700
 
                /// <summary>
701
 
                /// Tooltip of the status icon
702
 
                /// </summary>
703
 
                string ToolTip { get; set; }
704
 
                
705
 
                /// <summary>
706
 
                /// Event box which can be used to subscribe mouse events on the icon
707
 
                /// </summary>
708
 
                EventBox EventBox { get; }
709
 
                
710
 
                /// <summary>
711
 
                /// The icon
712
 
                /// </summary>
713
 
                Gdk.Pixbuf Image { get; set; }
714
 
                
715
 
                /// <summary>
716
 
                /// Sets alert mode. The icon will flash for the provided number of seconds.
717
 
                /// </summary>
718
 
                void SetAlertMode (int seconds);
719
 
        }
720
 
        
721
 
        class StatusBarContextImpl: StatusBarContext
722
 
        {
723
 
                Image image;
724
 
                string message;
725
 
                bool isMarkup;
726
 
                double progressFraction;
727
 
                bool showProgress;
728
 
                Pad sourcePad;
729
 
                bool autoPulse;
730
 
                protected MonoDevelopStatusBar statusBar;
731
 
                
732
 
                internal bool StatusChanged { get; set; }
733
 
                
734
 
                internal StatusBarContextImpl (MonoDevelopStatusBar statusBar)
735
 
                {
736
 
                        this.statusBar = statusBar;
737
 
                }
738
 
                
739
 
                public void Dispose ()
740
 
                {
741
 
                        statusBar.Remove (this);
742
 
                }
743
 
                
744
 
                public void ShowError (string error)
745
 
                {
746
 
                        ShowMessage (new Image (MonoDevelop.Ide.Gui.Stock.Error, IconSize.Menu), error);
747
 
                }
748
 
                
749
 
                public void ShowWarning (string warning)
750
 
                {
751
 
                        ShowMessage (new Gtk.Image (MonoDevelop.Ide.Gui.Stock.Warning, IconSize.Menu), warning);
752
 
                }
753
 
                
754
 
                public void ShowMessage (string message)
755
 
                {
756
 
                        ShowMessage (null, message, false);
757
 
                }
758
 
                
759
 
                public void ShowMessage (string message, bool isMarkup)
760
 
                {
761
 
                        ShowMessage (null, message, isMarkup);
762
 
                }
763
 
                
764
 
                public void ShowMessage (Image image, string message)
765
 
                {
766
 
                        ShowMessage (image, message, false);
767
 
                }
768
 
                
769
 
                bool InitialSetup ()
770
 
                {
771
 
                        if (!StatusChanged) {
772
 
                                StatusChanged = true;
773
 
                                statusBar.UpdateActiveContext ();
774
 
                                return true;
775
 
                        } else
776
 
                                return false;
777
 
                }
778
 
                
779
 
                public void ShowMessage (Image image, string message, bool isMarkup)
780
 
                {
781
 
                        this.image = image;
782
 
                        this.message = message;
783
 
                        this.isMarkup = isMarkup;
784
 
                        if (InitialSetup ())
785
 
                                return;
786
 
                        if (statusBar.IsCurrentContext (this)) {
787
 
                                OnMessageChanged ();
788
 
                                statusBar.ShowMessage (image, message, isMarkup);
789
 
                                statusBar.SetMessageSourcePad (sourcePad);
790
 
                        }
791
 
                }
792
 
                
793
 
                public void BeginProgress (string name)
794
 
                {
795
 
                        image = null;
796
 
                        isMarkup = false;
797
 
                        progressFraction = 0;
798
 
                        message = name;
799
 
                        showProgress = true;
800
 
                        if (InitialSetup ())
801
 
                                return;
802
 
                        if (statusBar.IsCurrentContext (this)) {
803
 
                                OnMessageChanged ();
804
 
                                statusBar.BeginProgress (name);
805
 
                                statusBar.SetMessageSourcePad (sourcePad);
806
 
                        }
807
 
                }
808
 
                
809
 
                public void BeginProgress (Image image, string name)
810
 
                {
811
 
                        this.image = image;
812
 
                        isMarkup = false;
813
 
                        progressFraction = 0;
814
 
                        message = name;
815
 
                        showProgress = true;
816
 
                        if (InitialSetup ())
817
 
                                return;
818
 
                        if (statusBar.IsCurrentContext (this)) {
819
 
                                OnMessageChanged ();
820
 
                                statusBar.BeginProgress (name);
821
 
                                statusBar.SetMessageSourcePad (sourcePad);
822
 
                        }
823
 
                }
824
 
                
825
 
                public void SetProgressFraction (double work)
826
 
                {
827
 
                        progressFraction = work;
828
 
                        if (InitialSetup ())
829
 
                                return;
830
 
                        if (statusBar.IsCurrentContext (this))
831
 
                                statusBar.SetProgressFraction (work);
832
 
                }
833
 
                
834
 
                public void EndProgress ()
835
 
                {
836
 
                        showProgress = false;
837
 
                        message = string.Empty;
838
 
                        progressFraction = 0;
839
 
                        if (InitialSetup ())
840
 
                                return;
841
 
                        if (statusBar.IsCurrentContext (this))
842
 
                                statusBar.EndProgress ();
843
 
                }
844
 
                
845
 
                public void Pulse ()
846
 
                {
847
 
                        showProgress = true;
848
 
                        if (InitialSetup ())
849
 
                                return;
850
 
                        if (statusBar.IsCurrentContext (this))
851
 
                                statusBar.Pulse ();
852
 
                }
853
 
                
854
 
                public bool AutoPulse {
855
 
                        get {
856
 
                                return autoPulse;
857
 
                        }
858
 
                        set {
859
 
                                if (value)
860
 
                                        showProgress = true;
861
 
                                autoPulse = value;
862
 
                                if (InitialSetup ())
863
 
                                        return;
864
 
                                if (statusBar.IsCurrentContext (this))
865
 
                                        statusBar.AutoPulse = value;
866
 
                        }
867
 
                }
868
 
                
869
 
                
870
 
                internal void Update ()
871
 
                {
872
 
                        if (showProgress) {
873
 
                                statusBar.BeginProgress (image, message);
874
 
                                statusBar.SetProgressFraction (progressFraction);
875
 
                                statusBar.AutoPulse = autoPulse;
876
 
                                statusBar.SetMessageSourcePad (sourcePad);
877
 
                        } else {
878
 
                                statusBar.EndProgress ();
879
 
                                statusBar.ShowMessage (image, message, isMarkup);
880
 
                                statusBar.SetMessageSourcePad (sourcePad);
881
 
                        }
882
 
                }
883
 
                
884
 
                public Pad StatusSourcePad {
885
 
                        get {
886
 
                                return sourcePad;
887
 
                        }
888
 
                        set {
889
 
                                sourcePad = value;
890
 
                        }
891
 
                }
892
 
                
893
 
                protected virtual void OnMessageChanged ()
894
 
                {
895
 
                }
896
 
        }
897
 
        
898
 
        class MainStatusBarContextImpl: StatusBarContextImpl, StatusBar
899
 
        {
900
 
                public MainStatusBarContextImpl (MonoDevelopStatusBar statusBar): base (statusBar)
901
 
                {
902
 
                        StatusChanged = true;
903
 
                }
904
 
                
905
 
                public void ShowCaretState (int line, int column, int selectedChars, bool isInInsertMode)
906
 
                {
907
 
                        statusBar.ShowCaretState (line, column, selectedChars, isInInsertMode);
908
 
                }
909
 
                
910
 
                public void ClearCaretState ()
911
 
                {
912
 
                        statusBar.ClearCaretState ();
913
 
                }
914
 
                
915
 
                public StatusBarIcon ShowStatusIcon (Gdk.Pixbuf pixbuf)
916
 
                {
917
 
                        return statusBar.ShowStatusIcon (pixbuf);
918
 
                }
919
 
                
920
 
                public StatusBarContext CreateContext ()
921
 
                {
922
 
                        return statusBar.CreateContext ();
923
 
                }
924
 
                
925
 
                public void ShowReady ()
926
 
                {
927
 
                        statusBar.ShowReady ();
928
 
                }
929
 
                
930
 
                public void SetMessageSourcePad (Pad pad)
931
 
                {
932
 
                        StatusSourcePad = pad;
933
 
                        if (statusBar.IsCurrentContext (this))
934
 
                                statusBar.SetMessageSourcePad (pad);
935
 
                }
936
 
                
937
 
                protected override void OnMessageChanged ()
938
 
                {
939
 
                        StatusSourcePad = null;
940
 
                }
941
 
                
942
 
                public bool HasResizeGrip {
943
 
                        get {
944
 
                                return statusBar.HasResizeGrip;
945
 
                        }
946
 
                        set {
947
 
                                statusBar.HasResizeGrip = value;
948
 
                                statusBar.NotifyShadedAreasChanged ();
949
 
                        }
950
 
                }
951
 
                
 
268
                        return ret;
 
269
                }
952
270
        }
953
271
}