Example #1
0
		AppResult GenerateChildrenForContainer (Gtk.Container container, List<AppResult> resultSet)
		{
			AppResult firstChild = null, lastChild = null;

			foreach (var child in container.Children) {
				AppResult node = new GtkWidgetResult (child) { SourceQuery = ToString () };
				resultSet.Add (node);

				// FIXME: Do we need to recreate the tree structure of the AppResults?
				if (firstChild == null) {
					firstChild = node;
					lastChild = node;
				} else {
					lastChild.NextSibling = node;
					node.PreviousSibling = lastChild;
					lastChild = node;
				}

				if (child is Gtk.Container) {
					AppResult children = GenerateChildrenForContainer ((Gtk.Container)child, resultSet);
					node.FirstChild = children;
				}
			}

			return firstChild;
		}
Example #2
0
		protected ObjectProperties GetProperties (object resultObject)
		{
			var propertiesObject = new ObjectProperties ();
			if (resultObject != null) {
				var properties = resultObject.GetType ().GetProperties (
					BindingFlags.Public | BindingFlags.Instance | BindingFlags.Static);
				foreach (var property in properties) {
					try {
						var value = GetPropertyValue (property.Name, resultObject);
						AppResult result = null;

						var gtkNotebookValue = value as Gtk.Notebook;
						if (gtkNotebookValue != null)
							result = new GtkNotebookResult (gtkNotebookValue);
						var gtkTreeviewValue = value as Gtk.TreeView;
						if (gtkTreeviewValue != null && result == null)
							result = new GtkTreeModelResult (gtkTreeviewValue, gtkTreeviewValue.Model, 0);
						var gtkWidgetValue = value as Gtk.Widget;
						if (gtkWidgetValue != null && result == null)
							result = new GtkWidgetResult (gtkWidgetValue);
						#if MAC
						var nsObjectValue = value as Foundation.NSObject;
						if (nsObjectValue != null && result == null)
							result = new NSObjectResult (nsObjectValue);
						#endif
						if (result == null)
							result = new ObjectResult (value);
						propertiesObject.Add (property.Name, result, property);
					} catch (Exception e) {
						MonoDevelop.Core.LoggingService.LogInfo ("Failed to fetch property '{0}' on '{1}' with Exception: {2}", property, resultObject, e);
					}
				}
			}

			return propertiesObject;
		}
Example #3
0
		List<AppResult> ResultSetFromWindows ()
		{
			Gtk.Window[] windows = Gtk.Window.ListToplevels ();

			// null for AppResult signifies root node
			rootNode = new GtkWidgetResult (null) { SourceQuery = ToString () };
			List<AppResult> fullResultSet = new List<AppResult> ();

			// Build the tree and full result set recursively
			AppResult lastChild = null;
			foreach (var window in windows) {
				AppResult node = new GtkWidgetResult (window) { SourceQuery = ToString () };
				fullResultSet.Add (node);

				if (rootNode.FirstChild == null) {
					rootNode.FirstChild = node;
					lastChild = node;
				} else {
					// Add the new node into the chain
					lastChild.NextSibling = node;
					node.PreviousSibling = lastChild;
					lastChild = node;
				}

				// Create the children list and link them onto the node
				AppResult children = GenerateChildrenForContainer ((Gtk.Container) window, fullResultSet);
				node.FirstChild = children;
			}

#if MAC
			NSWindow[] nswindows = NSApplication.SharedApplication.Windows;
			if (nswindows != null) {
				foreach (var window in nswindows) {
					AppResult node = new NSObjectResult (window) { SourceQuery = ToString () };
					AppResult nsWindowLastNode = null;
					fullResultSet.Add (node);

					if (rootNode.FirstChild == null) {
						rootNode.FirstChild = node;
						lastChild = node;
					} else {
						lastChild.NextSibling = node;
						node.PreviousSibling = lastChild;
						lastChild = node;
					}

					foreach (var child in window.ContentView.Subviews) {
						AppResult childNode = new NSObjectResult (child) { SourceQuery = ToString () };
						fullResultSet.Add (childNode);

						if (node.FirstChild == null) {
							node.FirstChild = childNode;
							nsWindowLastNode = childNode;
						} else {
							nsWindowLastNode.NextSibling = childNode;
							childNode.PreviousSibling = nsWindowLastNode;
							nsWindowLastNode = childNode;
						}

						if (child.Subviews != null) {
							AppResult children = GenerateChildrenForNSView (child, fullResultSet);
							childNode.FirstChild = children;
						}
					}

					NSToolbar toolbar = window.Toolbar;
					AppResult toolbarNode = new NSObjectResult (toolbar) { SourceQuery = ToString () };

					if (node.FirstChild == null) {
						node.FirstChild = toolbarNode;
						nsWindowLastNode = toolbarNode;
					} else {
						nsWindowLastNode.NextSibling = toolbarNode;
						toolbarNode.PreviousSibling = nsWindowLastNode;
						nsWindowLastNode = toolbarNode;
					}

					if (toolbar != null) {
						AppResult lastItemNode = null;
						foreach (var item in toolbar.Items) {
							if (item.View != null) {
								AppResult itemNode = new NSObjectResult (item.View) { SourceQuery = ToString () };
								fullResultSet.Add (itemNode);

								if (toolbarNode.FirstChild == null) {
									toolbarNode.FirstChild = itemNode;
									lastItemNode = itemNode;
								} else {
									lastItemNode.NextSibling = itemNode;
									itemNode.PreviousSibling = lastItemNode;
									lastItemNode = itemNode;
								}

								if (item.View.Subviews != null) {
									AppResult children = GenerateChildrenForNSView (item.View, fullResultSet);
									itemNode.FirstChild = children;
								}
							}
						}
					}
				}
			}
#endif
			return fullResultSet;
		}
Example #4
0
		protected ObjectProperties GetProperties (object resultObject)
		{
			var propertiesObject = new ObjectProperties ();
			if (resultObject != null) {
				var properties = resultObject.GetType ().GetProperties (
					BindingFlags.Public | BindingFlags.Instance | BindingFlags.Static);
				foreach (var property in properties) {
					var value = GetPropertyValue (property.Name, resultObject);
					AppResult result = null;

					var gtkNotebookValue = value as Gtk.Notebook;
					if (gtkNotebookValue != null)
						result = new GtkNotebookResult (gtkNotebookValue);
					var gtkTreeviewValue = value as Gtk.TreeView;
					if (gtkTreeviewValue != null && result == null)
						result = new GtkTreeModelResult (gtkTreeviewValue, gtkTreeviewValue.Model, 0);
					var gtkWidgetValue = value as Gtk.Widget;
					if (gtkWidgetValue != null && result == null)
						result = new GtkWidgetResult (gtkWidgetValue);
					#if MAC
					var nsObjectValue = value as Foundation.NSObject;
					if (nsObjectValue != null && result == null)
						result = new NSObjectResult (nsObjectValue);
					#endif
					if (result == null)
						result = new ObjectResult (value);

					propertiesObject.Add (property.Name, result, property);
				}
			}

			return propertiesObject;
		}