105
136
this.progressBar.Fraction = 0.0;
138
statusIconBox.HideAll ();
109
140
originalFrame.HideAll ();
110
141
progressBar.Visible = false;
112
// the Mac has a resize grip by default, and the GTK+ one breaks it
113
if (MonoDevelop.Core.PropertyService.IsMac)
114
HasResizeGrip = false;
143
StatusBarContext completionStatus = null;
145
// todo: Move this to the CompletionWindowManager when it's possible.
146
CompletionWindowManager.WindowShown += delegate {
147
CompletionListWindow wnd = CompletionWindowManager.Wnd;
148
if (wnd != null && wnd.List != null && wnd.List.CategoryCount > 1) {
149
if (completionStatus == null)
150
completionStatus = CreateContext ();
151
completionStatus.ShowMessage (string.Format (GettextCatalog.GetString ("To toggle categorized completion mode press {0}."), IdeApp.CommandService.GetCommandInfo (Commands.TextEditorCommands.ShowCompletionWindow).AccelKey));
155
CompletionWindowManager.WindowClosed += delegate {
156
if (completionStatus != null) {
157
completionStatus.Dispose ();
158
completionStatus = null;
163
void HandleEventMessageBoxButtonPressEvent (object o, ButtonPressEventArgs args)
165
if (sourcePad != null)
166
sourcePad.BringToFront (true);
169
internal bool IsCurrentContext (StatusBarContextImpl ctx)
171
return ctx == activeContext;
174
internal void Remove (StatusBarContextImpl ctx)
176
if (ctx == mainContext)
179
StatusBarContextImpl oldActive = activeContext;
180
contexts.Remove (ctx);
181
UpdateActiveContext ();
182
if (oldActive != activeContext) {
183
// Removed the active context. Update the status bar.
184
activeContext.Update ();
188
internal void UpdateActiveContext ()
190
for (int n = contexts.Count - 1; n >= 0; n--) {
191
StatusBarContextImpl ctx = contexts [n];
192
if (ctx.StatusChanged) {
193
if (ctx != activeContext) {
195
activeContext.Update ();
200
throw new InvalidOperationException (); // There must be at least the main context
203
public StatusBarContext CreateContext ()
205
StatusBarContextImpl ctx = new StatusBarContextImpl (this);
117
210
public void ShowCaretState (int line, int column, int selectedChars, bool isInInsertMode)
300
424
alertEnd = DateTime.Now.AddSeconds (seconds);
303
GLib.Timeout.Add (60, new GLib.TimeoutHandler (AnimateIcon));
305
images = new Gtk.Image [10];
306
for (int n=0; n<10; n++) {
307
images [n] = new Image (ImageService.MakeTransparent (icon, ((double)(9-n))/10.0));
308
images [n].SetPadding (0, 0);
427
GLib.Source.Remove (animation);
429
animation = GLib.Timeout.Add (60, new GLib.TimeoutHandler (AnimateIcon));
431
if (images == null) {
432
images = new Gdk.Pixbuf [10];
433
for (int n=0; n<10; n++)
434
images [n] = ImageService.MakeTransparent (icon, ((double)(9-n))/10.0);
313
public bool AnimateIcon ()
315
box.Remove (box.Child);
317
440
if (DateTime.Now >= alertEnd && astep == 0) {
318
Gtk.Image i = new Gtk.Image (icon);
326
box.Child = images [astep];
446
image.Pixbuf = images [astep];
328
box.Child = images [20 - astep - 1];
448
image.Pixbuf = images [20 - astep - 1];
330
450
astep = (astep + 1) % 20;
455
Gdk.Rectangle GetGripRect ()
457
Gdk.Rectangle rect = new Gdk.Rectangle (0, 0, 18, Allocation.Height);
458
if (rect.Width > Allocation.Width)
459
rect.Width = Allocation.Width;
460
rect.Y = Allocation.Y + Allocation.Height - rect.Height;
461
if (Direction == TextDirection.Ltr)
462
rect.X = Allocation.X + Allocation.Width - rect.Width;
464
rect.X = Allocation.X + Style.XThickness;
468
protected override bool OnExposeEvent (Gdk.EventExpose evnt)
470
bool ret = base.OnExposeEvent (evnt);
472
DefaultWorkbench wb = (DefaultWorkbench) IdeApp.Workbench.RootWindow;
473
wb.DockFrame.ShadedContainer.DrawBackground (this, GetGripRect ());
474
Gdk.Rectangle rect = GetGripRect ();
475
int w = rect.Width - Style.Xthickness;
476
int h = Allocation.Height - Style.YThickness;
477
if (h < 18 - Style.YThickness) h = 18 - Style.YThickness;
478
Gdk.WindowEdge edge = Direction == TextDirection.Ltr ? Gdk.WindowEdge.SouthEast : Gdk.WindowEdge.SouthWest;
479
Gtk.Style.PaintResizeGrip (Style, GdkWindow, State, evnt.Area, this, "statusbar", edge, rect.X, rect.Y, w, h);
484
public void NotifyShadedAreasChanged ()
486
if (AreasChanged != null)
487
AreasChanged (this, EventArgs.Empty);
490
public IEnumerable<Gdk.Rectangle> GetShadedAreas ()
493
yield return GetGripRect ();
496
public event EventHandler AreasChanged;
500
/// The MonoDevelop status bar.
502
public interface StatusBar: StatusBarContextBase
505
/// Show caret state information
507
void ShowCaretState (int line, int column, int selectedChars, bool isInInsertMode);
510
/// Hides the caret state information
512
void ClearCaretState ();
515
/// Shows a status icon in the toolbar. The icon can be removed by disposing
516
/// the StatusBarIcon instance.
518
StatusBarIcon ShowStatusIcon (Gdk.Pixbuf pixbuf);
521
/// Creates a status bar context. The returned context can be used to show status information
522
/// which will be cleared when the context is disposed. When several contexts are created,
523
/// the status bar will show the status of the latest created context.
525
StatusBarContext CreateContext ();
527
// Clears the status bar information
531
/// Sets a pad which has detailed information about the status message. When clicking on the
532
/// status bar, this pad will be activated. This source pad is reset at every ShowMessage call.
534
void SetMessageSourcePad (Pad pad);
537
/// When set to true, the resize grip is shown
539
bool HasResizeGrip { get; set; }
542
public interface StatusBarContextBase: IDisposable
545
/// Shows a message with an error icon
547
void ShowError (string error);
550
/// Shows a message with a warning icon
552
void ShowWarning (string warning);
555
/// Shows a message in the status bar
557
void ShowMessage (string message);
560
/// Shows a message in the status bar
562
void ShowMessage (string message, bool isMarkup);
565
/// Shows a message in the status bar
567
void ShowMessage (Image image, string message);
570
/// Shows a progress bar, with the provided label next to it
572
void BeginProgress (string name);
575
/// Shows a progress bar, with the provided label and icon next to it
577
void BeginProgress (Image image, string name);
580
/// Sets the progress fraction. It can only be used after calling BeginProgress.
582
void SetProgressFraction (double work);
585
/// Hides the progress bar shown with BeginProgress
590
/// Pulses the progress bar shown with BeginProgress
595
/// When set, the status bar progress will be automatically pulsed at short intervals
597
bool AutoPulse { get; set; }
600
public interface StatusBarContext: StatusBarContextBase
602
Pad StatusSourcePad { get; set; }
605
public interface StatusBarIcon : IDisposable
608
/// Tooltip of the status icon
610
string ToolTip { get; set; }
613
/// Event box which can be used to subscribe mouse events on the icon
615
EventBox EventBox { get; }
620
Gdk.Pixbuf Image { get; set; }
623
/// Sets alert mode. The icon will flash for the provided number of seconds.
625
void SetAlertMode (int seconds);
628
class StatusBarContextImpl: StatusBarContext
633
double progressFraction;
637
protected MonoDevelopStatusBar statusBar;
639
internal bool StatusChanged { get; set; }
641
internal StatusBarContextImpl (MonoDevelopStatusBar statusBar)
643
this.statusBar = statusBar;
646
public void Dispose ()
648
statusBar.Remove (this);
651
public void ShowError (string error)
653
ShowMessage (new Image (MonoDevelop.Ide.Gui.Stock.Error, IconSize.Menu), error);
656
public void ShowWarning (string warning)
658
ShowMessage (new Gtk.Image (MonoDevelop.Ide.Gui.Stock.Warning, IconSize.Menu), warning);
661
public void ShowMessage (string message)
663
ShowMessage (null, message, false);
666
public void ShowMessage (string message, bool isMarkup)
668
ShowMessage (null, message, isMarkup);
671
public void ShowMessage (Image image, string message)
673
ShowMessage (image, message, false);
678
if (!StatusChanged) {
679
StatusChanged = true;
680
statusBar.UpdateActiveContext ();
686
public void ShowMessage (Image image, string message, bool isMarkup)
689
this.message = message;
690
this.isMarkup = isMarkup;
693
if (statusBar.IsCurrentContext (this)) {
695
statusBar.ShowMessage (image, message, isMarkup);
696
statusBar.SetMessageSourcePad (sourcePad);
700
public void BeginProgress (string name)
704
progressFraction = 0;
709
if (statusBar.IsCurrentContext (this)) {
711
statusBar.BeginProgress (name);
712
statusBar.SetMessageSourcePad (sourcePad);
716
public void BeginProgress (Image image, string name)
720
progressFraction = 0;
725
if (statusBar.IsCurrentContext (this)) {
727
statusBar.BeginProgress (name);
728
statusBar.SetMessageSourcePad (sourcePad);
732
public void SetProgressFraction (double work)
734
progressFraction = work;
737
if (statusBar.IsCurrentContext (this))
738
statusBar.SetProgressFraction (work);
741
public void EndProgress ()
743
showProgress = false;
744
message = string.Empty;
745
progressFraction = 0;
748
if (statusBar.IsCurrentContext (this))
749
statusBar.EndProgress ();
757
if (statusBar.IsCurrentContext (this))
761
public bool AutoPulse {
771
if (statusBar.IsCurrentContext (this))
772
statusBar.AutoPulse = value;
777
internal void Update ()
780
statusBar.BeginProgress (image, message);
781
statusBar.SetProgressFraction (progressFraction);
782
statusBar.AutoPulse = autoPulse;
783
statusBar.SetMessageSourcePad (sourcePad);
785
statusBar.EndProgress ();
786
statusBar.ShowMessage (image, message, isMarkup);
787
statusBar.SetMessageSourcePad (sourcePad);
791
public Pad StatusSourcePad {
800
protected virtual void OnMessageChanged ()
805
class MainStatusBarContextImpl: StatusBarContextImpl, StatusBar
807
public MainStatusBarContextImpl (MonoDevelopStatusBar statusBar): base (statusBar)
809
StatusChanged = true;
812
public void ShowCaretState (int line, int column, int selectedChars, bool isInInsertMode)
814
statusBar.ShowCaretState (line, column, selectedChars, isInInsertMode);
817
public void ClearCaretState ()
819
statusBar.ClearCaretState ();
822
public StatusBarIcon ShowStatusIcon (Gdk.Pixbuf pixbuf)
824
return statusBar.ShowStatusIcon (pixbuf);
827
public StatusBarContext CreateContext ()
829
return statusBar.CreateContext ();
832
public void ShowReady ()
834
statusBar.ShowReady ();
837
public void SetMessageSourcePad (Pad pad)
839
StatusSourcePad = pad;
840
if (statusBar.IsCurrentContext (this))
841
statusBar.SetMessageSourcePad (pad);
844
protected override void OnMessageChanged ()
846
StatusSourcePad = null;
849
public bool HasResizeGrip {
851
return statusBar.HasResizeGrip;
854
statusBar.HasResizeGrip = value;
855
statusBar.NotifyShadedAreasChanged ();