Ejemplo n.º 1
0
        public override List <AppResult> Children(bool recursive = true)
        {
            if (resultIter == null || !resultIter.HasValue)
            {
                List <AppResult> children = new List <AppResult> ();
                TModel.Foreach((m, p, i) => {
                    children.Add(new GtkTreeModelResult(ParentWidget, TModel, Column, i));
                    return(false);
                });
                return(children);
            }

            TreeIter currentIter = (TreeIter)resultIter;

            if (!TModel.IterHasChild(currentIter))
            {
                return(null);
            }

            List <AppResult> newList = new List <AppResult> ();

            for (int i = 0; i < TModel.IterNChildren(currentIter); i++)
            {
                TreeIter childIter;
                if (TModel.IterNthChild(out childIter, currentIter, i))
                {
                    newList.Add(new GtkTreeModelResult(ParentWidget, TModel, Column, childIter));
                }
            }
            return(newList);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Fill a list of events from a list of paths, if the first and unique path is an EventType the list
        /// is filled with al the child events in this EventType category.
        /// </summary>
        /// <param name = "model">Model.</param>
        /// <param name="events">Events.</param>
        /// <param name="paths">Paths.</param>
        public static List<TimelineEventLongoMatch> EventsListFromPaths(TreeModel model, TreePath[] paths)
        {
            List<TimelineEventLongoMatch> events = new List<TimelineEventLongoMatch> ();

            // If it's an EventType or a Player, traverse all children to fill the list
            if (paths.Length == 1 && !(model.GetValue (paths [0]) is TimelineEventLongoMatch)) {
                TreeIter parentIter;
                TreeIter child;
                bool hasChild;

                model.GetIter (out parentIter, paths [0]);
                hasChild = model.IterHasChild (parentIter);
                model.IterChildren (out child, parentIter);
                while (hasChild) {
                    TimelineEventLongoMatch evt = model.GetValue (child, 0) as TimelineEventLongoMatch;
                    if (evt != null) {
                        events.Add (evt);
                    }
                    hasChild = model.IterNext (ref child);
                }
            } else {
                foreach (var path in paths) {
                    TimelineEventLongoMatch evt = model.GetValue (path) as TimelineEventLongoMatch;
                    if (evt != null) {
                        events.Add (evt);
                    }
                }
            }
            return events;
        }
        static void RenderIcon(TreeViewColumn col, CellRenderer cell, TreeModel model, TreeIter iter)
        {
            var pixbufCellRenderer = (CellRendererImage)cell;

            if (model.IterHasChild(iter))
            {
                pixbufCellRenderer.Image = ImageService.GetIcon(((TreeView)col.TreeView).GetRowExpanded(model.GetPath(iter)) ? MonoDevelop.Ide.Gui.Stock.OpenFolder : MonoDevelop.Ide.Gui.Stock.ClosedFolder, IconSize.Menu);
            }
            else
            {
                pixbufCellRenderer.Image = ImageService.GetIcon(MonoDevelop.Ide.Gui.Stock.Property, IconSize.Menu);
            }
        }
Ejemplo n.º 4
0
        internal void ExpandeSelectedItem()
        {
            if (_parent._tvArtists.Selection.GetSelected(out selectedModel, out selectedIter))
            {
                string selectedType = selectedModel.GetValue(selectedIter, 3).ToString();
                string selectedId   = selectedModel.GetValue(selectedIter, 2).ToString();

                if (selectedType == "artist")
                {
                    if (!_parent._tvArtists.GetRowExpanded(selectedModel.GetPath(selectedIter)))
                    {
                        if (!selectedModel.IterHasChild(selectedIter))
                        {
                            _parent._tvArtists.Model = this.GetArtistAlbums(tsArtists.GetValue(selectedIter, 2).ToString());
                            _parent._tvArtists.ShowAll();

                            if (albumCount == 0)
                            {
                                _parent.oFileBrowser.ShowFiles(selectedType, selectedId);
                            }
                            else
                            {
                                _parent.oFileBrowser.Clear();
                            }

                            albumCount = 0;
                        }

                        _parent._tvArtists.ExpandRow(selectedModel.GetPath(selectedIter), false);
                    }
                    else
                    {
                        _parent._tvArtists.CollapseRow(selectedModel.GetPath(selectedIter));
                    }
                }
                else if (selectedType == "album")
                {
                    _parent.oFileBrowser.ShowFiles(selectedType, selectedId);
                }
            }
        }
Ejemplo n.º 5
0
        List <AppResult> FetchIterChildren(TreeIter iter, GtkTreeModelResult result, bool recursive)
        {
            List <AppResult> newList = new List <AppResult> ();

            if (!TModel.IterHasChild(iter))
            {
                return(newList);
            }

            GtkTreeModelResult previousSibling = null;

            for (int i = 0; i < TModel.IterNChildren(iter); i++)
            {
                TreeIter childIter;
                if (TModel.IterNthChild(out childIter, iter, i))
                {
                    var child = new GtkTreeModelResult(ParentWidget, TModel, Column, childIter);

                    child.ParentNode      = this;
                    child.PreviousSibling = previousSibling;
                    if (previousSibling != null)
                    {
                        previousSibling.NextSibling = child;
                    }

                    newList.Add(child);
                    if (recursive)
                    {
                        var childrenIter = FetchIterChildren(childIter, child, recursive);
                        newList.AddRange(childrenIter);
                        child.FirstChild = childrenIter.FirstOrDefault();
                    }

                    previousSibling = child;
                }
            }
            result.FirstChild = newList.FirstOrDefault();
            DisposeWithResult(result.FirstChild);
            return(newList);
        }
Ejemplo n.º 6
0
        /// <summary>
        /// Fill a list of events from a list of paths, if the first and unique path is an EventType the list
        /// is filled with al the child events in this EventType category.
        /// </summary>
        /// <param name = "model">Model.</param>
        /// <param name="events">Events.</param>
        /// <param name="paths">Paths.</param>
        public static List <LMTimelineEvent> EventsListFromPaths(TreeModel model, TreePath[] paths)
        {
            List <LMTimelineEvent> events = new List <LMTimelineEvent> ();

            // If it's an EventType or a Player, traverse all children to fill the list
            if (paths.Length == 1 && !(model.GetValue(paths [0]) is LMTimelineEvent))
            {
                TreeIter parentIter;
                TreeIter child;
                bool     hasChild;

                model.GetIter(out parentIter, paths [0]);
                hasChild = model.IterHasChild(parentIter);
                model.IterChildren(out child, parentIter);
                while (hasChild)
                {
                    LMTimelineEvent evt = model.GetValue(child, 0) as LMTimelineEvent;
                    if (evt != null)
                    {
                        events.Add(evt);
                    }
                    hasChild = model.IterNext(ref child);
                }
            }
            else
            {
                foreach (var path in paths)
                {
                    LMTimelineEvent evt = model.GetValue(path) as LMTimelineEvent;
                    if (evt != null)
                    {
                        events.Add(evt);
                    }
                }
            }
            return(events);
        }
		void RenderIcon (TreeViewColumn col, CellRenderer cell, TreeModel model, TreeIter iter) 
		{
			var pixbufCellRenderer = (CellRendererPixbuf)cell;
			if (model.IterHasChild (iter)) {
				pixbufCellRenderer.Pixbuf = ImageService.GetPixbuf (((TreeView)col.TreeView).GetRowExpanded (model.GetPath (iter)) ? MonoDevelop.Ide.Gui.Stock.OpenFolder : MonoDevelop.Ide.Gui.Stock.ClosedFolder, IconSize.Menu);
			} else {
				pixbufCellRenderer.Pixbuf = ImageService.GetPixbuf (MonoDevelop.Ide.Gui.Stock.Property, IconSize.Menu);
			}
		}
Ejemplo n.º 8
0
 public static void IsCapitalSensitive(CellLayout cellLayout, CellRenderer cell, TreeModel treeModel, TreeIter iter)
 {
     cell.Sensitive = !treeModel.IterHasChild (iter);
 }