static void UpdateInstrumentationIcon() { if (IdeApp.Preferences.EnableInstrumentation) { if (instrumentationStatusIcon == null) { instrumentationStatusIcon = IdeApp.Workbench.StatusBar.ShowStatusIcon(ImageService.GetIcon(MonoDevelop.Ide.Gui.Stock.Information)); instrumentationStatusIcon.ToolTip = "Instrumentation service enabled"; instrumentationStatusIcon.Clicked += delegate { InstrumentationService.StartMonitor(); }; } } else if (instrumentationStatusIcon != null) { instrumentationStatusIcon.Dispose(); } }
public DocumentSwitcher(Gtk.Window parent, bool startWithNext) : base(Gtk.WindowType.Toplevel) { IdeApp.CommandService.IsEnabled = false; this.documents = new List <MonoDevelop.Ide.Gui.Document> ( IdeApp.Workbench.Documents.OrderByDescending(d => d.LastTimeActive)); this.TransientFor = parent; this.Decorated = false; this.DestroyWithParent = true; this.CanDefault = true; this.Modal = true; this.WindowPosition = Gtk.WindowPosition.CenterOnParent; this.TypeHint = WindowTypeHint.Dialog; this.ModifyBg(StateType.Normal, this.Style.Base(StateType.Normal)); VBox vBox = new VBox(); HBox hBox = new HBox(); var hBox2 = new HBox(); hBox2.PackStart(hBox, false, false, 8); hBox.PackStart(imageTitle.ToGtkWidget(), true, false, 2); labelTitle.Xalign = 0; labelTitle.HeightRequest = 24; hBox.PackStart(labelTitle, true, true, 2); vBox.PackStart(hBox2, false, false, 6); labelType.Xalign = 0; labelType.HeightRequest = 16; hBox = new HBox(); hBox.PackStart(labelType, false, false, 8); vBox.PackStart(hBox, false, false, 2); hBox = new HBox(); hBox.PackStart(documentList, true, true, 1); vBox.PackStart(hBox, false, false, 0); labelFileName.Xalign = 0; labelFileName.Ellipsize = Pango.EllipsizeMode.Start; hBox = new HBox(); hBox.PackStart(labelFileName, true, true, 8); vBox.PackEnd(hBox, false, false, 6); Add(vBox); var padCategory = new DocumentList.Category(GettextCatalog.GetString("Pads")); DocumentList.Item activeItem = null; foreach (Pad pad in IdeApp.Workbench.Pads) { if (!pad.Visible) { continue; } var item = new DocumentList.Item() { Icon = ImageService.GetIcon(pad.Icon.Name ?? MonoDevelop.Ide.Gui.Stock.GenericFile, IconSize.Menu), Title = pad.Title, Tag = pad }; if (pad.Window.Content.Control.HasFocus) { activeItem = item; } padCategory.AddItem(item); } documentList.AddCategory(padCategory); var documentCategory = new DocumentList.Category(GettextCatalog.GetString("Documents")); foreach (var doc in documents) { var item = new DocumentList.Item() { Icon = GetIconForDocument(doc, IconSize.Menu), Title = System.IO.Path.GetFileName(doc.Name), ListTitle = doc.Window.Title, Description = doc.Window.DocumentType, Path = doc.Name, Tag = doc }; if (doc.Window.ActiveViewContent.Control.HasFocus) { activeItem = item; } documentCategory.AddItem(item); } documentList.AddCategory(documentCategory); documentList.ActiveItemChanged += delegate { if (documentList.ActiveItem == null) { labelFileName.Text = labelType.Text = labelTitle.Text = ""; return; } imageTitle.Image = documentList.ActiveItem.Icon; labelFileName.Text = documentList.ActiveItem.Path; labelType.Markup = "<span size=\"small\">" + documentList.ActiveItem.Description + "</span>"; labelTitle.Markup = "<span size=\"xx-large\" weight=\"bold\">" + documentList.ActiveItem.Title + "</span>"; }; if (activeItem == null) { if (documentCategory.Items.Count > 0) { activeItem = documentCategory.Items [0]; } else if (padCategory.Items.Count > 0) { activeItem = padCategory.Items [0]; } else { DestroyWindow(); return; } } documentList.ActiveItem = activeItem; ModifierType modifiers; if (Gtk.Global.GetCurrentEventState(out modifiers) && modifiers.HasFlag(ModifierType.ShiftMask)) { documentList.PrevItem(true); } else { documentList.NextItem(true); } documentList.RequestClose += delegate(object sender, DocumentList.RequestActionEventArgs e) { object item = e.SelectItem ? documentList.ActiveItem.Tag : null; DestroyWindow(); // The selected document has to be focused *after* this window is destroyed, becasuse the window // destruction focuses its parent window. if (item != null) { if (item is Pad) { ((Pad)item).BringToFront(true); } else { ((MonoDevelop.Ide.Gui.Document)item).Select(); } } }; this.ShowAll(); documentList.GrabFocus(); this.GrabDefault(); }