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); }
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); }
private void BuildGroupButtonsView() { TreeIter iter; Logger.Debug("GroupWindow.BuildGroupButtonsView adding {0} groups", groupTreeModel.IterNChildren()); // Loop through the model, create buttons, and add them into the // groupButtonsVBox. if (groupTreeModel.GetIterFirst(out iter)) { do { PersonGroup group = groupTreeModel.GetValue(iter, 0) as PersonGroup; if (group == null) { continue; } AddGroupButton(new GroupButton(group), groupTreeModel.GetPath(iter)); } while (groupTreeModel.IterNext(ref iter)); } }
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); }
void RenderElement(TreeViewColumn column, CellRenderer cell, TreeModel model, TreeIter iter) { var item = model.GetValue(iter, 0); PlaysCellRenderer c = cell as PlaysCellRenderer; c.Item = item; c.Count = model.IterNChildren(iter); }
protected override void RenderPlaylist(TreeViewColumn column, CellRenderer cell, TreeModel model, TreeIter iter) { var item = model.GetValue(iter, 0); PlaysCellRenderer c = cell as PlaysCellRenderer; c.Item = item; c.Count = model.IterNChildren(iter); }
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); }
// Widget: tvBgList // Don't show sections that are empty private bool FilterEmptySections(TreeModel model, TreeIter iter) { TreeIter parent; string key = (string) model.GetValue(iter, 0); // Always draw all wallpapers if (key != null) return true; if (model.IterParent(out parent, iter)) { if (model.IterNChildren(parent) >= 2) return false; } return true; }
protected void RenderElement(TreeViewColumn column, CellRenderer cell, TreeModel model, TreeIter iter) { var item = model.GetValue (iter, 0); PlaysCellRenderer c = cell as PlaysCellRenderer; c.Item = item; c.Count = model.IterNChildren (iter); }
private void OnDataRowDeleted(object o, RowDeletedArgs args) { if (model == null || args.Path == null) { return; } bool sel_paths_changed = false; // Don't update the real n_cells, as doing this will // throw off ScrollToPath if called before SizeAllocate // is run int n_cells = model.IterNChildren(); for (int i = 0; i < selected_paths.Count; i++) { TreePath path = (TreePath)selected_paths[i]; int cmp = path.Compare(args.Path); if (cmp == 0) { selected_paths.RemoveAt(i); i--; sel_paths_changed = true; continue; } // decrement each path that follows the one we // just deleted if (cmp > 0) { path.Prev(); selected_paths[i] = path; continue; } } if (sel_paths_changed && SelectionChanged != null) { SelectionChanged(this, new EventArgs()); } if (focused_path != null && focused_path.Equals(args.Path)) { focused_path = focused_path.Copy(); // try to advance the focus forward focused_path.Next(); if (!PathIsValid(focused_path, n_cells) && !focused_path.Prev()) { focused_path = null; } } if (selection_anchor != null && selection_anchor.Equals(args.Path)) { selection_anchor = null; } QueueResize(); }
private void FocusHelper(bool move_next) { if (focused_path == null) { return; } TreeIter focused_iter; if (!model.GetIter(out focused_iter, focused_path)) { return; } int focus_x, focus_y; GetPlotPoint(focused_iter, out focus_x, out focus_y); // we can't just do focused_path.Prev () since there is // a disconnect between the order in the model and // where the axis has us place points. besides, we // need to clamp the focus region to the zoom rect. TreeIter iter; if (!model.GetIterFirst(out iter)) { return; } int total_height = (Allocation.Y + Allocation.Height); TreePath min_path = null; int min_x_delta = Int32.MaxValue; int min_y_delta = Int32.MaxValue; do { TreePath path = model.GetPath(iter); // don't try to focus the same point again if (path.Compare(focused_path) == 0) { continue; } int x, y; GetPlotPoint(iter, out x, out y); // if its out of bounds, throw it out if (IsBarOutOfBounds(x, y)) { continue; } int x_delta = 0, y_delta = 0; if (move_next) { // find the bar with the smallest positive x // delta, and smallest y, or if there // is a tie, the one that's larger on the y // axis x_delta = x - focus_x; y_delta = (focus_x != x) ? total_height - y : focus_y - y; } else { // find the bar with the smallest positive x // delta, and largest y, or if there // is a tie, the one that's larger on the y // axis x_delta = focus_x - x; y_delta = (focus_x != x) ? y : y - focus_y; } // don't go backward, and don't pick a bigger // delta than we already have if (x_delta < 0 || x_delta > min_x_delta) { continue; } if (x_delta == min_x_delta && y_delta >= min_y_delta) { continue; } // if we're at the same X value, make sure // we're moving forward in the y direction so // we don't get stuck in loops if (x_delta == 0 && y_delta < 0) { continue; } min_x_delta = x_delta; min_y_delta = y_delta; min_path = path; } while (model.IterNext(ref iter)); if (min_path != null) { focused_path = min_path; } else { if (move_next) { focused_path = TreePath.NewFirst(); } else { focused_path = new TreePath(new int[] { model.IterNChildren() - 1 }); } } if (Changed != null) { Changed(this, new EventArgs()); } }