Ejemplo n.º 1
0
        public static IEnumerable <TreeIter> Childs(this TreeModel model, TreeIter parent)
        {
            List <TreeIter> childs = new List <TreeIter>();

            if (parent.Equals(TreeIter.Zero))
            {
                for (int i = 0; i < model.IterNChildren(); i++)
                {
                    TreeIter iter;
                    if (model.IterNthChild(out iter, i))
                    {
                        childs.Add(iter);
                        childs.AddRange(model.Childs(iter));
                    }
                }
            }
            else
            {
                for (int i = 0; i < model.IterNChildren(parent); i++)
                {
                    TreeIter iter;
                    if (model.IterNthChild(out iter, parent, i))
                    {
                        childs.Add(iter);
                        childs.AddRange(model.Childs(iter));
                    }
                }
            }
            return(childs);
        }
Ejemplo n.º 2
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.º 3
0
        private bool GetPathAtRowAndCol(int r, int c, out TreePath path)
        {
            path = null;
            if (r > (rows - 1) || r < 0 ||
                c > (cols - 1) || c < 0)
            {
                return(false);
            }

            int index = (r * cols) + c;

            if (index >= n_cells)
            {
                return(false);
            }

            if (model == null)
            {
                return(false);
            }

            TreeIter iter;

            if (!model.IterNthChild(out iter, index))
            {
                return(false);
            }

            path = model.GetPath(iter);

            return(true);
        }
Ejemplo n.º 4
0
        private bool IsSelectionValid(TreeIter selectedRow)
        {
            if (selectedRow.Equals(TreeIter.Zero))
            {
                return(false);
            }

            TreeModel model = treeViewMenu.Model;

            if ((string)model.GetValue(selectedRow, 3) == KeyShortcuts.MENU_NEIGHBOURING_SHORTCUT)
            {
                int childrenCount = model.IterNChildren(selectedRow);
                for (int i = 0; i < childrenCount; i++)
                {
                    TreeIter row;
                    model.IterNthChild(out row, selectedRow, i);
                    if ((string)model.GetValue(row, 3) == KeyShortcuts.MENU_NEIGHBOURING_SHORTCUT &&
                        !((string)model.GetValue(row, 2)).Contains("/btn"))
                    {
                        return(false);
                    }
                }
            }
            return(true);
        }
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
        private bool TranslateCoords(int x, int y,
                                     out TreePath path, out GridViewColumn col)
        {
            int      c = orientation == Orientation.Vertical ? x : y;
            int      r = orientation == Orientation.Vertical ? y : x;
            TreeIter i;

            if (c >= visible.Count || !model.IterNthChild(out i, r))
            {
                col  = null;
                path = null;

                return(false);
            }
            else
            {
                col  = visible[c] as GridViewColumn;
                path = new TreePath(r.ToString());

                return(true);
            }
        }