void FillConfigurations (Gtk.TreeIter configIter)
		{
			foreach (string name in test.GetConfigurations ()) {
				Properties configNodeProperties = new Properties();
				configNodeProperties.Set ("UnitTest", test);
				configNodeProperties.Set ("Config", name);
				foreach (OptionsDialogSection section in configurationNode.ChildNodes) {
					OptionsDialogSection s = (OptionsDialogSection)section.Clone ();
					if (firstSection == null)
						firstSection = s;
					s.Label = StringParserService.Parse (section.Label, new string[,] { { "Configuration", name } });
					AddSection (configIter, s, configNodeProperties);
				}
			}
		}
		MimeTypePanelData AddPanel (string mt)
		{
			MimeTypePanelData data = new MimeTypePanelData ();
			OptionsDialogSection sec = new OptionsDialogSection (typeof(MimeTypePolicyOptionsSection));
			sec.Fill = true;
			Gdk.Pixbuf icon = DesktopService.GetPixbufForType (mt, Gtk.IconSize.Menu);
			sec.Icon = ImageService.GetStockId (icon, Gtk.IconSize.Menu);
			data.Section = sec;
			data.MimeType = mt;
			data.TypeDescription = DesktopService.GetMimeTypeDescription (mt);
			if (string.IsNullOrEmpty (data.TypeDescription))
				data.TypeDescription = mt;
			data.DataObject = DataObject;
			data.PolicyContainer = policyContainer;
			sec.Label = data.TypeDescription;
			LoadPolicyTypeData (data, mt);
			typeSections [mt] = data;
			ParentDialog.AddChildSection (this, sec, data);
			return data;
		}
		MimeTypePanelData AddPanel (string mt)
		{
			var chain = new List<string> (DesktopService.GetMimeTypeInheritanceChain (mt).Where (x => mimeTypesWithPolicies.Contains (x)));
			if (chain.Count == 0)
				return null;
			MimeTypePanelData data = new MimeTypePanelData ();
			OptionsDialogSection sec = new OptionsDialogSection (typeof(MimeTypePolicyOptionsSection));
			sec.Fill = true;
			Gdk.Pixbuf icon = DesktopService.GetPixbufForType (mt, Gtk.IconSize.Menu);
			sec.Icon = ImageService.GetStockId (icon, Gtk.IconSize.Menu);
			data.Section = sec;
			data.MimeType = mt;
			data.TypeDescription = DesktopService.GetMimeTypeDescription (mt);
			if (string.IsNullOrEmpty (data.TypeDescription))
				data.TypeDescription = mt;
			data.DataObject = DataObject;
			data.PolicyContainer = policyContainer;
			sec.Label = data.TypeDescription;
			LoadPolicyTypeData (data, mt, chain);
			typeSections [mt] = data;
			ParentDialog.AddChildSection (this, sec, data);
			return data;
		}
Beispiel #4
0
		SectionPage CreatePage (TreeIter it, OptionsDialogSection section, object dataObject)
		{
			SectionPage page;
			if (pages.TryGetValue (section, out page))
				return page;
			
			page = new SectionPage ();
			page.Iter = it;
			page.Panels = new List<PanelInstance> ();
			pages [section] = page;
			
			List<OptionsPanelNode> nodes = new List<OptionsPanelNode> ();
			if (!string.IsNullOrEmpty (section.TypeName) || section.CustomNode)
				nodes.Add (section);
			
			if (!section.CustomNode) {
				foreach (ExtensionNode nod in section.ChildNodes) {
					OptionsPanelNode node = nod as OptionsPanelNode;
					if (node != null && !(node is OptionsDialogSection))
						nodes.Add (node);
				}
			}
			
			foreach (OptionsPanelNode node in nodes)
			{
				PanelInstance pi = null;
				if (panels.TryGetValue (node, out pi)) {
					if (pi.DataObject == dataObject) {
						// The panel can be reused
						if (!pi.Panel.IsVisible ())
							continue;
					} else {
						// If the data object has changed, this panel instance can't be
						// reused anymore. Destroy it.
						panels.Remove (node);
						if (pi.Widget != null)
							pi.Widget.Destroy ();
						IDisposable d = pi.Panel as IDisposable;
						if (d != null)
							d.Dispose ();
						pi = null;
					}
				}
				if (pi == null) {
					IOptionsPanel panel = node.CreatePanel ();
					pi = new PanelInstance ();
					pi.Panel = panel;
					pi.Node = node;
					pi.DataObject = dataObject;
					page.Panels.Add (pi);
					panel.Initialize (this, dataObject);
					if (!panel.IsVisible ()) {
						page.Panels.Remove (pi);
						continue;
					}
					panels [node] = pi;
				} else
					page.Panels.Add (pi);
			}
			return page;
		}
Beispiel #5
0
		public void ShowPage (OptionsDialogSection section)
		{
			if (!IsRealized) {
				// Defer this until the dialog is realized due to the sizing logic in CreatePageWidget.
				EventHandler deferredShowPage = null;
				deferredShowPage = delegate {
					ShowPage (section);
					Realized -= deferredShowPage;
				};
				Realized += deferredShowPage;
				return;
			}
			SectionPage page;
			if (!pages.TryGetValue (section, out page))
				return;
			
			if (page.Panels.Count == 0) {
				foreach (ExtensionNode node in section.ChildNodes) {
					if (node is OptionsDialogSection) {
						if (HasVisiblePanel ((OptionsDialogSection) node)) {
							ShowPage ((OptionsDialogSection) node);
							return;
						}
					}
				}
			}
			
			foreach (Gtk.Widget w in pageFrame.Children) {
				Container cc = w as Gtk.Container;
				if (cc != null) {
					foreach (Gtk.Widget cw in cc)
						cw.Hide ();
				}
				pageFrame.Remove (w);
			}
			
			if (page.Widget == null)
				CreatePageWidget (page);
			
			labelTitle.Markup = "<span weight=\"bold\" size=\"large\">" + GLib.Markup.EscapeText (section.Label) + "</span>";
			
			//HACK: mimetype panels can't provide stock ID for mimetype images. Give this some awareness of mimetypes.
			var mimeSection = section as MonoDevelop.Ide.Projects.OptionPanels.MimetypeOptionsDialogSection;
			if (mimeSection != null && !string.IsNullOrEmpty (mimeSection.MimeType)) {
				var pix = DesktopService.GetPixbufForType (mimeSection.MimeType, headerIconSize);
				if (pix != null) {
					image.Pixbuf = pix;
				} else {
					image.Pixbuf = ImageService.GetPixbuf (emptyCategoryIcon, headerIconSize);
				}
			} else {
				string icon = section.Icon.IsNull? emptyCategoryIcon : section.Icon.ToString ();
				image.Pixbuf = ImageService.GetPixbuf (icon, headerIconSize);
			}

/*			var algn = new HeaderBox ();
			algn.SetPadding (12, 12, 12, 12);
			if (page.Widget.Parent != null)
				((Gtk.Container)page.Widget).Remove (page.Widget);
			algn.Add (page.Widget);*/
			pageFrame.PackStart (page.Widget, true, true, 0);
			
			// Ensures that the Shown event is fired for each panel
			Container c = page.Widget as Gtk.Container;
			if (c != null) {
				foreach (Gtk.Widget cw in c)
					cw.Show ();
				//HACK: weird bug - switching page away and back selects last tab. should preserve the selection.
				if (c is Notebook)
					((Notebook)c).Page = 0;
			}
			
			tree.ExpandToPath (store.GetPath (page.Iter));
			tree.Selection.SelectIter (page.Iter);
		}
Beispiel #6
0
		bool HasVisiblePanel (OptionsDialogSection section)
		{
			SectionPage page;
			if (!pages.TryGetValue (section, out page))
				return false;
			if (page.Panels.Count > 0)
				return true;
			foreach (ExtensionNode node in section.ChildNodes) {
				if (node is OptionsDialogSection) {
					if (HasVisiblePanel ((OptionsDialogSection) node))
						return true;
				}
			}
			return false;
		}
Beispiel #7
0
		protected virtual void AddChildSections (TreeIter parentIter, OptionsDialogSection section, object dataObject)
		{
			foreach (ExtensionNode nod in section.ChildNodes) {
				if (nod is OptionsDialogSection)
					AddSection (parentIter, (OptionsDialogSection) nod, dataObject);
			}
		}
Beispiel #8
0
		protected TreeIter AddSection (TreeIter parentIter, OptionsDialogSection section, object dataObject)
		{
			TreeIter it;
			if (parentIter.Equals (TreeIter.Zero)) {
				it = store.AppendValues (section);
			} else {
				it = store.AppendValues (parentIter,section);
			}
			
			if (!section.CustomNode)
				AddChildSections (it, section, dataObject);
			
			// Remove the section if it doesn't have children nor panels
			SectionPage page = CreatePage (it, section, dataObject);
			TreeIter cit;
			if (removeEmptySections && page.Panels.Count == 0 && !store.IterChildren (out cit, it)) {
				store.Remove (ref it);
				return TreeIter.Zero;
			}
			return it;
		}
Beispiel #9
0
		protected TreeIter AddSection (OptionsDialogSection section, object dataObject)
		{
			return AddSection (TreeIter.Zero, section, dataObject);
		}
Beispiel #10
0
		public void RemoveSection (OptionsDialogSection section)
		{
			SectionPage page;
			if (pages.TryGetValue (section, out page))
				RemoveSection (page.Iter);
		}
Beispiel #11
0
		public void AddChildSection (IOptionsPanel parent, OptionsDialogSection section, object dataObject)
		{
			foreach (SectionPage page in pages.Values) {
				foreach (PanelInstance pi in page.Panels) {
					if (pi.Panel == parent) {
						AddSection (page.Iter, section, dataObject);
						return;
					}
				}
			}
			throw new InvalidOperationException ("Parent options panel not found in the dialog.");
		}
		public void ShowPage (OptionsDialogSection section)
		{
			SectionPage page;
			if (!pages.TryGetValue (section, out page))
				return;
			
			if (page.Panels.Count == 0) {
				foreach (ExtensionNode node in section.ChildNodes) {
					if (node is OptionsDialogSection) {
						if (HasVisiblePanel ((OptionsDialogSection) node)) {
							ShowPage ((OptionsDialogSection) node);
							return;
						}
					}
				}
			}
			
			foreach (Gtk.Widget w in pageFrame.Children) {
				Container cc = w as Gtk.Container;
				if (cc != null) {
					foreach (Gtk.Widget cw in cc)
						cw.Hide ();
				}
				pageFrame.Remove (w);
			}
			
			if (page.Widget == null)
				CreatePageWidget (page);
			
			labelTitle.Markup = "<span weight=\"bold\" size=\"x-large\">" + GLib.Markup.EscapeText (section.Label) + "</span>";
			if (!string.IsNullOrEmpty (section.Icon))
				image.Stock = section.Icon;
			else
				image.Stock = "md-empty-category";
			pageFrame.PackStart (page.Widget, true, true, 0);
			
			// Ensures that the Shown event is fired for each panel
			Container c = page.Widget as Gtk.Container;
			if (c != null) {
				foreach (Gtk.Widget cw in c)
					cw.Show ();
				//HACK: weird bug - switching page away and back selects last tab. should preserve the selection.
				if (c is Notebook)
					((Notebook)c).Page = 0;
			}
			
			tree.ExpandToPath (store.GetPath (page.Iter));
			tree.Selection.SelectIter (page.Iter);
		}
		protected TreeIter AddSection (TreeIter parentIter, OptionsDialogSection section, object dataObject)
		{
			TreeIter it;
			if (parentIter.Equals (TreeIter.Zero)) {
				string sectionLabel = "<b>" + GLib.Markup.EscapeText (section.Label) + "</b>";
				it = store.AppendValues (section, null, sectionLabel, false, null);
			}
			else {
				string icon = section.Icon.IsNull ? "md-empty-category" : section.Icon.ToString ();
				it = store.AppendValues (parentIter, section, icon, section.Label, true, null);
			}
			
			if (!section.CustomNode)
				AddChildSections (it, section, dataObject);
			
			// Remove the section if it doesn't have children nor panels
			SectionPage page = CreatePage (it, section, dataObject);
			TreeIter cit;
			if (removeEmptySections && page.Panels.Count == 0 && !store.IterChildren (out cit, it)) {
				store.Remove (ref it);
				return TreeIter.Zero;
			}
			return it;
		}