void Refresh() { Widget wrapper = Stetic.Wrapper.Widget.Lookup(this); IDesignArea area = wrapper.GetDesignArea(); if (area == null) { return; } ActionTreeNode selNode = null; foreach (Gtk.Widget w in Children) { CustomToolbarItem it = w as CustomToolbarItem; if (it != null && area.IsSelected(it.ActionToolItem)) { selNode = it.ActionToolItem.Node; area.ResetSelection(it.ActionToolItem); } Remove(w); w.Destroy(); } FillMenu(actionTree); if (selNode != null) { ActionToolItem mi = FindMenuItem(selNode); if (mi != null) { mi.Select(); } } }
public void Select(ActionTreeNode node) { ActionToolItem item = FindMenuItem(node); if (item != null) { item.Select(); } }
void InsertAction(int pos) { Widget wrapper = Stetic.Wrapper.Widget.Lookup(this); using (wrapper.UndoManager.AtomicChange) { Wrapper.Action ac = (Wrapper.Action)ObjectWrapper.Create(wrapper.Project, new Gtk.Action("", "", null, null)); ActionTreeNode node = new ActionTreeNode(Gtk.UIManagerItemType.Toolitem, "", ac); actionTree.Children.Insert(pos, node); ActionToolItem aitem = FindMenuItem(node); aitem.EditingDone += OnEditingDone; aitem.Select(); aitem.StartEditing(false); //ShowInsertPlaceholder = false; if (wrapper.LocalActionGroups.Count == 0) { wrapper.LocalActionGroups.Add(new ActionGroup("Default")); } wrapper.LocalActionGroups[0].Actions.Add(ac); } }
protected override bool OnDragDrop(Gdk.DragContext context, int x, int y, uint time) { ActionPaletteItem dropped = DND.Drop(context, null, time) as ActionPaletteItem; if (dropped == null) { return(false); } if (dropped.Node.Type != Gtk.UIManagerItemType.Menuitem && dropped.Node.Type != Gtk.UIManagerItemType.Toolitem && dropped.Node.Type != Gtk.UIManagerItemType.Separator) { return(false); } ActionTreeNode newNode = dropped.Node; if (dropped.Node.Type == Gtk.UIManagerItemType.Menuitem) { newNode = newNode.Clone(); newNode.Type = Gtk.UIManagerItemType.Toolitem; } Widget wrapper = Stetic.Wrapper.Widget.Lookup(this); using (wrapper.UndoManager.AtomicChange) { if (dropIndex < actionTree.Children.Count) { // Do nothing if trying to drop the node over the same node ActionTreeNode dropNode = actionTree.Children [dropIndex]; if (dropNode == newNode) { return(false); } if (newNode.ParentNode != null) { newNode.ParentNode.Children.Remove(newNode); } // The drop position may have changed after removing the dropped node, // so get it again. dropIndex = actionTree.Children.IndexOf(dropNode); actionTree.Children.Insert(dropIndex, newNode); } else { if (newNode.ParentNode != null) { newNode.ParentNode.Children.Remove(newNode); } actionTree.Children.Add(newNode); dropIndex = actionTree.Children.Count - 1; } } // Select the dropped node ActionToolItem mi = (ActionToolItem)toolItems [dropIndex]; mi.Select(); return(base.OnDragDrop(context, x, y, time)); }