private TreeIndex getIndexFromBits(List <String> bits, TreeIndex base_node) { TreeIndex output = null; foreach (TreeIndex i in base_node.content) // Look through the base_nodes's contents to find a node with the right name { if (i.label == bits[0]) { output = i; break; } } if (output == null) { throw new System.IO.DirectoryNotFoundException("Cannot find node at path " + string.Join("/", bits)); } bits.RemoveAt(0); if (bits.Count < 1) // Nothing left in the path { return(output); } else // Something left in the path: call this function again { return(getIndexFromBits(bits, output)); } }
bool sorter(object model, Gtk.TreeIter iter) { TreeIndex index = getIndexFromIter(iter, "root").Item2; // sbar.Buffer.Text return(hasStringInIt(index, sbar.Buffer.Text).Item1); }
public void flush() { // Removes the old tree, and replaces it with a brand new one. fileTree.Remove(ref root.iter); Gdk.Pixbuf icon = new Gdk.Pixbuf(System.IO.File.ReadAllBytes(AppDomain.CurrentDomain.BaseDirectory + Path.DirectorySeparatorChar + "SmallFolder.png")); icon = icon.ScaleSimple(26, 26, Gdk.InterpType.Bilinear); Gtk.TreeIter iter = fileTree.AppendValues(icon, "root"); root = new TreeIndex(IndexTypes.Folder, "root", new List <TreeIndex>(), iter, null, "", "root"); }
public TreeIndex(IndexTypes _type, String _label, List <TreeIndex> _content, TreeIter _iter, TreeIndex _parent, String _path, String _tree_path) { type = _type; label = _label; content = _content; iter = _iter; parent = _parent; path = _path; tree_path = _tree_path; }
public TreeIndex addNode(String path, String name, IndexTypes type, String filename) { String fname = ""; switch (type) { case IndexTypes.Page: { fname = AppDomain.CurrentDomain.BaseDirectory + Path.DirectorySeparatorChar + "SmallPage.png"; break; } case IndexTypes.Module: { fname = AppDomain.CurrentDomain.BaseDirectory + Path.DirectorySeparatorChar + "SmallModule.png"; break; } case IndexTypes.Function: { fname = AppDomain.CurrentDomain.BaseDirectory + Path.DirectorySeparatorChar + "SmallFunction.png"; break; } case IndexTypes.Class: { fname = AppDomain.CurrentDomain.BaseDirectory + Path.DirectorySeparatorChar + "SmallClass.png"; break; } case IndexTypes.Folder: { fname = AppDomain.CurrentDomain.BaseDirectory + Path.DirectorySeparatorChar + "SmallFolder.png"; break; } } log.info($"Adding node at path {filename}"); TreeIndex parent = getIndexAtPath(path); if (!active) { TreeIndex ndex = new TreeIndex(type, name, new List <TreeIndex>(), new TreeIter(), parent, filename, path + "/" + name); log.info($"Node path from TreeIndex: {ndex.path}"); parent.content.Add(ndex); return(ndex); } Gdk.Pixbuf icon = new Gdk.Pixbuf(System.IO.File.ReadAllBytes(fname)); icon = icon.ScaleSimple(26, 26, Gdk.InterpType.Bilinear); TreeIter iter = fileTree.AppendValues(parent.iter, icon, name); TreeIndex index = new TreeIndex(type, name, new List <TreeIndex>(), iter, parent, filename, path + "/" + name); log.info($"Node path from TreeIndex: {index.path}"); parent.content.Add(index); return(index); }
private (bool, TreeIndex) hasStringInIt(TreeIndex index, String thing) { if (index.label.ToLower().Contains(thing.ToLower())) { return(true, index); } foreach (TreeIndex t in index.content) { (bool, TreeIndex)a = hasStringInIt(t, thing); if (a.Item1 == true) { return(a); } } return(false, index); }
public FileTree(bool active, TreeView _tree = null, Entry _sbar = null) { log = new Logger("FileTree"); sbar = _sbar; this.active = active; tree = _tree; if (active == false) { root = new TreeIndex(IndexTypes.Folder, "root", new List <TreeIndex>(), new TreeIter(), null, "", "root"); return; } fileTree = new Gtk.TreeStore(typeof(Gdk.Pixbuf), typeof(string)); tree.RowActivated += callCallback; // Create a column for the file names Gtk.TreeViewColumn pbColumn = new Gtk.TreeViewColumn(); pbColumn.Title = "Icon"; // Create the text cell that will display the artist name Gtk.CellRendererPixbuf pbCell = new Gtk.CellRendererPixbuf(); // Add the cell to the column pbColumn.PackStart(pbCell, true); tree.AppendColumn(pbColumn); // Create a column for the file names Gtk.TreeViewColumn fileColumn = new Gtk.TreeViewColumn(); fileColumn.Title = "FileName"; // Create the text cell that will display the artist name Gtk.CellRendererText filenameCell = new Gtk.CellRendererText(); // Add the cell to the column fileColumn.PackStart(filenameCell, true); tree.AppendColumn(fileColumn); fileColumn.AddAttribute(filenameCell, "text", 1); pbColumn.AddAttribute(pbCell, "pixbuf", 0); Gtk.TreeIter iter = fileTree.AppendValues("root"); root = new TreeIndex(IndexTypes.Folder, "root", new List <TreeIndex>(), iter, null, "", "root"); filter = new Gtk.TreeModelFilter(fileTree, null); // Specify the function that determines which rows to filter out and which ones to display filter.VisibleFunc = sorter; tree.Model = filter; sbar.Activated += refilter; }
public void removeNode(TreeIndex index) { index.parent.content.Remove(index); fileTree.Remove(ref index.iter); }