コード例 #1
0
		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, Styles.BaseBackgroundColor.ToGdkColor ());
			
			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.InternalContent.Initialized && 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 ();
		}
コード例 #2
0
		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, 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.GetPixbuf (pad.Icon.Name ?? MonoDevelop.Ide.Gui.Stock.MiscFiles, 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.Pixbuf = 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;
			documentList.NextItem (true);
			documentList.RequestClose += delegate(object sender, DocumentList.RequestActionEventArgs e) {
				try {
					if (e.SelectItem) {
						if (documentList.ActiveItem.Tag is Pad) {
							((Pad)documentList.ActiveItem.Tag).BringToFront (true);
						} else {
							((MonoDevelop.Ide.Gui.Document)documentList.ActiveItem.Tag).Select ();
						}
					}
				} finally {
					DestroyWindow ();
				}
			};
			
			this.ShowAll ();
			documentList.GrabFocus ();
			this.GrabDefault ();
		}
コード例 #3
0
        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.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, 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.GetPixbuf(pad.Icon.Name ?? MonoDevelop.Ide.Gui.Stock.MiscFiles, 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.Pixbuf  = 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
                {
                    Destroy();
                    return;
                }
            }

            documentList.ActiveItem = activeItem;
            documentList.NextItem();
            documentList.RequestClose += delegate {
                if (documentList.ActiveItem.Tag is Pad)
                {
                    ((Pad)documentList.ActiveItem.Tag).BringToFront(true);
                }
                else
                {
                    ((MonoDevelop.Ide.Gui.Document)documentList.ActiveItem.Tag).Select();
                }
                Destroy();
            };

            this.ShowAll();
            documentList.GrabFocus();
            this.GrabDefault();
        }
コード例 #4
0
        public DocumentSwitcher(Gtk.Window parent, string category, bool startWithNext, out bool dialogHasContent) : base(Gtk.WindowType.Toplevel)
        {
            if (string.IsNullOrEmpty(category))
            {
                category = GettextCatalog.GetString("Documents");
            }

            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, Styles.BaseBackgroundColor.ToGdkColor());

            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 (category == padCategory.Title)
                {
                    if (activeItem == null || (pad.InternalContent.Initialized && pad.Window.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 (category == padCategory.Title)
                {
                    if (activeItem == null || 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
                {
                    // We can't destroy the window in the constructor
                    // so we need to let the caller know that there are no items
                    dialogHasContent = false;
                    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();

            dialogHasContent = true;
        }