private void DeleteLocations(TreePath path){ path.Down(); TreeModel model = ((TreeModelFilter)locationsView.Model).Model; TreeIter iter; while(model.GetIter(out iter,path) == true){ // we also need delete the children of the location DeleteLocations(path.Copy()); Location loc = (Location)model.GetValue(iter,0); // this won't delete the children Locations.Remove(loc); // do move to next, since the location is not removed from the positions yet path.Next(); } }
public Dialog(Image image, Drawable drawable, VariableSet variables) : base("Photoshop Actions", variables) { _image = image; _drawable = drawable; var vbox = new VBox(false, 12) {BorderWidth = 12}; VBox.PackStart(vbox, true, true, 0); var store = CreateActionTree(); var sw = new ScrolledWindow() {HeightRequest = 400}; vbox.PackStart(sw, true, true, 0); var view = new TreeView(store); sw.Add(view); var activeRenderer = new CellRendererToggle() {Activatable = true}; var columnOne = view.AppendColumn("Enabled", activeRenderer, new TreeCellDataFunc(RenderActive)); activeRenderer.Toggled += delegate(object o, ToggledArgs args) { TreeIter iter; var path = new TreePath(args.Path); if (store.GetIter(out iter, path)) { var executable = store.GetValue(iter, 1) as IExecutable; executable.IsEnabled = !executable.IsEnabled; path.Down(); while (store.GetIter(out iter, path)) { store.EmitRowChanged(path, iter); path.Next(); } } }; var textRenderer = new CellRendererText(); var column = view.AppendColumn("Set Name", textRenderer, new TreeCellDataFunc(RenderText)); var hbox = new HBox(); vbox.PackStart(hbox, false, true, 0); var play = new Button(Stock.Execute); play.Clicked += delegate { RenameToBackground(); var paths = view.Selection.GetSelectedRows(); var path = paths[0]; // Assume only 1 is selected var indices = path.Indices; var actions = _set[indices[0]]; if (indices.Length > 2) { actions.Execute(indices[1], indices[2]); path.Next(); view.Selection.SelectPath(path); } else { actions.Execute(indices[1]); } Gimp.DisplaysFlush(); }; hbox.PackStart(play, false, true, 0); view.Selection.Changed += delegate { var paths = view.Selection.GetSelectedRows(); var indices = paths[0].Indices; play.Sensitive = (indices.Length > 1); }; view.Selection.SetSelectFunction(delegate(TreeSelection selection, TreeModel model, TreePath path, bool path_currently_selected) { return path.Indices.Length <= 3; }, IntPtr.Zero, null); ActionEvent.ActionSetCollection = _set; }