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;
119
110
feedbackButton.ClickOnRelease = true;
120
111
FeedbackService.FeedbackPositionGetter = delegate {
122
feedbackButton.GdkWindow.GetOrigin (out x, out y);
123
x += feedbackButton.Allocation.Width;
113
if (feedbackButton.GdkWindow != null) {
114
feedbackButton.GdkWindow.GetOrigin (out x, out y);
115
x += feedbackButton.Allocation.Width;
125
120
return new Gdk.Point (x, y);
126
CustomFrame dfr = new CustomFrame (0, 0, 1, 0);
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);
134
mainBox.PackStart (dfr, false, false, 0);
138
resizeGrip.WidthRequest = ResizeGripWidth;
139
resizeGrip.HeightRequest = 0;
140
mainBox.PackStart (resizeGrip, false, false, 0);
139
progressBar = new ProgressBar ();
140
progressBar.PulseStep = 0.1;
141
progressBar.SizeRequest ();
142
progressBar.HeightRequest = 1;
144
144
statusBox = new HBox (false, 0);
145
145
statusBox.BorderWidth = 0;
147
statusLabel = new Label ();
148
147
statusLabel.SetAlignment (0, 0.5f);
149
148
statusLabel.Wrap = false;
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 ();
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;
163
textStatusBarPanel.BorderWidth = 0;
164
textStatusBarPanel.ShadowType = ShadowType.None;
165
textStatusBarPanel.Add (statusBox);
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);
181
statusIconBox = new HBox ();
182
statusIconBox.BorderWidth = 0;
183
statusIconBox.Spacing = 3;
184
statusBox.PackEnd (statusIconBox, false, false, 4);
186
this.PackStart (textStatusBarPanel, true, true, 0);
189
Gtk.Box.BoxChild boxChild = (Gtk.Box.BoxChild)this[textStatusBarPanel];
190
boxChild.Position = 0;
191
boxChild.Expand = boxChild.Fill = true;
193
// boxChild = (Gtk.Box.BoxChild)this[originalFrame];
194
// boxChild.Padding = 0;
195
// boxChild.Expand = boxChild.Fill = false;
197
this.progressBar.Fraction = 0.0;
199
statusIconBox.HideAll ();
201
originalFrame.HideAll ();
202
progressBar.Visible = false;
204
StatusBarContext completionStatus = null;
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));
216
CompletionWindowManager.WindowClosed += delegate {
217
if (completionStatus != null) {
218
completionStatus.Dispose ();
219
completionStatus = null;
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));
224
185
[System.Runtime.InteropServices.DllImport ("libc")]
320
234
if (modeLabel.Text != "")
321
235
modeLabel.Text = "";
324
public void ShowReady ()
326
ShowMessage (GettextCatalog.GetString ("Ready"));
329
public void ShowError (string error)
331
ShowMessage (new Image (MonoDevelop.Ide.Gui.Stock.Error, IconSize.Menu), error);
334
public void ShowWarning (string warning)
336
DispatchService.AssertGuiThread ();
337
ShowMessage (new Gtk.Image (MonoDevelop.Ide.Gui.Stock.Warning, IconSize.Menu), warning);
340
public void ShowMessage (string message)
342
ShowMessage (null, message, false);
345
public void ShowMessage (string message, bool isMarkup)
347
ShowMessage (null, message, isMarkup);
350
public void ShowMessage (Image image, string message)
352
ShowMessage (image, message, false);
354
string lastText = null;
355
public void ShowMessage (Image image, string message, bool isMarkup)
357
if (message == lastText)
361
DispatchService.AssertGuiThread ();
362
if (currentStatusImage != image) {
363
if (currentStatusImage != null)
364
messageBox.Remove (currentStatusImage);
365
currentStatusImage = image;
367
image.SetPadding (0, 0);
368
messageBox.PackStart (image, false, false, 3);
369
messageBox.ReorderChild (image, 1);
374
string txt = !String.IsNullOrEmpty (message) ? " " + message.Replace ("\n", " ") : "";
376
statusLabel.Markup = txt;
378
statusLabel.Text = txt;
382
public void SetMessageSourcePad (Pad pad)
387
public StatusBarIcon ShowStatusIcon (Gdk.Pixbuf pixbuf)
389
DispatchService.AssertGuiThread ();
390
StatusIcon icon = new StatusIcon (this, pixbuf);
391
statusIconBox.PackEnd (icon.box);
392
statusIconBox.ShowAll ();
396
void HideStatusIcon (StatusIcon icon)
398
statusIconBox.Remove (icon.EventBox);
399
icon.EventBox.Destroy ();
402
#region Progress Monitor implementation
403
public void BeginProgress (string name)
406
this.progressBar.Visible = true;
409
public void BeginProgress (Image image, string name)
411
ShowMessage (image, name);
412
this.progressBar.Visible = true;
415
public void SetProgressFraction (double work)
417
DispatchService.AssertGuiThread ();
418
this.progressBar.Fraction = work;
421
public void EndProgress ()
424
this.progressBar.Fraction = 0.0;
425
this.progressBar.Visible = false;
431
DispatchService.AssertGuiThread ();
432
this.progressBar.Visible = true;
433
this.progressBar.Pulse ();
436
public bool AutoPulse {
437
get { return autoPulseTimeoutId != 0; }
439
DispatchService.AssertGuiThread ();
441
this.progressBar.Visible = true;
442
if (autoPulseTimeoutId == 0) {
443
autoPulseTimeoutId = GLib.Timeout.Add (100, delegate {
444
this.progressBar.Pulse ();
449
if (autoPulseTimeoutId != 0) {
450
GLib.Source.Remove (autoPulseTimeoutId);
451
autoPulseTimeoutId = 0;
458
public class StatusIcon : StatusBarIcon
460
MonoDevelopStatusBar statusBar;
461
internal EventBox box;
471
public StatusIcon (MonoDevelopStatusBar statusBar, Gdk.Pixbuf icon)
473
this.statusBar = statusBar;
475
box = new EventBox ();
476
image = new Image (icon);
477
image.SetPadding (0, 0);
481
public void Dispose ()
483
statusBar.HideStatusIcon (this);
484
if (images != null) {
485
foreach (Gdk.Pixbuf img in images) {
489
if (animation != 0) {
490
GLib.Source.Remove (animation);
495
public string ToolTip {
498
box.TooltipText = tip = value;
502
public EventBox EventBox {
506
public Gdk.Pixbuf Image {
514
public void SetAlertMode (int seconds)
517
alertEnd = DateTime.Now.AddSeconds (seconds);
520
GLib.Source.Remove (animation);
522
animation = GLib.Timeout.Add (60, new GLib.TimeoutHandler (AnimateIcon));
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);
533
if (DateTime.Now >= alertEnd && astep == 0) {
539
image.Pixbuf = images [astep];
541
image.Pixbuf = images [20 - astep - 1];
543
astep = (astep + 1) % 20;
239
public bool HasResizeGrip {
240
get { return hasResizeGrip; }
241
set { hasResizeGrip = value; resizeGrip.Visible = hasResizeGrip; }
548
244
Gdk.Rectangle GetGripRect ()
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;
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);
577
public void NotifyShadedAreasChanged ()
579
if (AreasChanged != null)
580
AreasChanged (this, EventArgs.Empty);
583
public IEnumerable<Gdk.Rectangle> GetShadedAreas ()
586
yield return GetGripRect ();
589
public event EventHandler AreasChanged;
593
/// The MonoDevelop status bar.
595
public interface StatusBar: StatusBarContextBase
598
/// Show caret state information
600
void ShowCaretState (int line, int column, int selectedChars, bool isInInsertMode);
603
/// Hides the caret state information
605
void ClearCaretState ();
608
/// Shows a status icon in the toolbar. The icon can be removed by disposing
609
/// the StatusBarIcon instance.
611
StatusBarIcon ShowStatusIcon (Gdk.Pixbuf pixbuf);
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.
618
StatusBarContext CreateContext ();
620
// Clears the status bar information
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.
627
void SetMessageSourcePad (Pad pad);
630
/// When set to true, the resize grip is shown
632
bool HasResizeGrip { get; set; }
635
public interface StatusBarContextBase: IDisposable
638
/// Shows a message with an error icon
640
void ShowError (string error);
643
/// Shows a message with a warning icon
645
void ShowWarning (string warning);
648
/// Shows a message in the status bar
650
void ShowMessage (string message);
653
/// Shows a message in the status bar
655
void ShowMessage (string message, bool isMarkup);
658
/// Shows a message in the status bar
660
void ShowMessage (Image image, string message);
663
/// Shows a progress bar, with the provided label next to it
665
void BeginProgress (string name);
668
/// Shows a progress bar, with the provided label and icon next to it
670
void BeginProgress (Image image, string name);
673
/// Sets the progress fraction. It can only be used after calling BeginProgress.
675
void SetProgressFraction (double work);
678
/// Hides the progress bar shown with BeginProgress
683
/// Pulses the progress bar shown with BeginProgress
688
/// When set, the status bar progress will be automatically pulsed at short intervals
690
bool AutoPulse { get; set; }
693
public interface StatusBarContext: StatusBarContextBase
695
Pad StatusSourcePad { get; set; }
698
public interface StatusBarIcon : IDisposable
701
/// Tooltip of the status icon
703
string ToolTip { get; set; }
706
/// Event box which can be used to subscribe mouse events on the icon
708
EventBox EventBox { get; }
713
Gdk.Pixbuf Image { get; set; }
716
/// Sets alert mode. The icon will flash for the provided number of seconds.
718
void SetAlertMode (int seconds);
721
class StatusBarContextImpl: StatusBarContext
726
double progressFraction;
730
protected MonoDevelopStatusBar statusBar;
732
internal bool StatusChanged { get; set; }
734
internal StatusBarContextImpl (MonoDevelopStatusBar statusBar)
736
this.statusBar = statusBar;
739
public void Dispose ()
741
statusBar.Remove (this);
744
public void ShowError (string error)
746
ShowMessage (new Image (MonoDevelop.Ide.Gui.Stock.Error, IconSize.Menu), error);
749
public void ShowWarning (string warning)
751
ShowMessage (new Gtk.Image (MonoDevelop.Ide.Gui.Stock.Warning, IconSize.Menu), warning);
754
public void ShowMessage (string message)
756
ShowMessage (null, message, false);
759
public void ShowMessage (string message, bool isMarkup)
761
ShowMessage (null, message, isMarkup);
764
public void ShowMessage (Image image, string message)
766
ShowMessage (image, message, false);
771
if (!StatusChanged) {
772
StatusChanged = true;
773
statusBar.UpdateActiveContext ();
779
public void ShowMessage (Image image, string message, bool isMarkup)
782
this.message = message;
783
this.isMarkup = isMarkup;
786
if (statusBar.IsCurrentContext (this)) {
788
statusBar.ShowMessage (image, message, isMarkup);
789
statusBar.SetMessageSourcePad (sourcePad);
793
public void BeginProgress (string name)
797
progressFraction = 0;
802
if (statusBar.IsCurrentContext (this)) {
804
statusBar.BeginProgress (name);
805
statusBar.SetMessageSourcePad (sourcePad);
809
public void BeginProgress (Image image, string name)
813
progressFraction = 0;
818
if (statusBar.IsCurrentContext (this)) {
820
statusBar.BeginProgress (name);
821
statusBar.SetMessageSourcePad (sourcePad);
825
public void SetProgressFraction (double work)
827
progressFraction = work;
830
if (statusBar.IsCurrentContext (this))
831
statusBar.SetProgressFraction (work);
834
public void EndProgress ()
836
showProgress = false;
837
message = string.Empty;
838
progressFraction = 0;
841
if (statusBar.IsCurrentContext (this))
842
statusBar.EndProgress ();
850
if (statusBar.IsCurrentContext (this))
854
public bool AutoPulse {
864
if (statusBar.IsCurrentContext (this))
865
statusBar.AutoPulse = value;
870
internal void Update ()
873
statusBar.BeginProgress (image, message);
874
statusBar.SetProgressFraction (progressFraction);
875
statusBar.AutoPulse = autoPulse;
876
statusBar.SetMessageSourcePad (sourcePad);
878
statusBar.EndProgress ();
879
statusBar.ShowMessage (image, message, isMarkup);
880
statusBar.SetMessageSourcePad (sourcePad);
884
public Pad StatusSourcePad {
893
protected virtual void OnMessageChanged ()
898
class MainStatusBarContextImpl: StatusBarContextImpl, StatusBar
900
public MainStatusBarContextImpl (MonoDevelopStatusBar statusBar): base (statusBar)
902
StatusChanged = true;
905
public void ShowCaretState (int line, int column, int selectedChars, bool isInInsertMode)
907
statusBar.ShowCaretState (line, column, selectedChars, isInInsertMode);
910
public void ClearCaretState ()
912
statusBar.ClearCaretState ();
915
public StatusBarIcon ShowStatusIcon (Gdk.Pixbuf pixbuf)
917
return statusBar.ShowStatusIcon (pixbuf);
920
public StatusBarContext CreateContext ()
922
return statusBar.CreateContext ();
925
public void ShowReady ()
927
statusBar.ShowReady ();
930
public void SetMessageSourcePad (Pad pad)
932
StatusSourcePad = pad;
933
if (statusBar.IsCurrentContext (this))
934
statusBar.SetMessageSourcePad (pad);
937
protected override void OnMessageChanged ()
939
StatusSourcePad = null;
942
public bool HasResizeGrip {
944
return statusBar.HasResizeGrip;
947
statusBar.HasResizeGrip = value;
948
statusBar.NotifyShadedAreasChanged ();