Inheritance: IDisposable
Beispiel #1
0
 public void Remove(ActionTreeNode node)
 {
     if (List.Contains(node))
     {
         List.Remove(node);
     }
 }
Beispiel #2
0
 internal ActionToolItem(Widget wrapper, ActionToolbar parent, ActionTreeNode node, uint itemSpacing)
     : base(node, parent, itemSpacing)
 {
     this.parentToolbar = parent;
     this.wrapper = wrapper;
     CreateControls ();
 }
Beispiel #3
0
 public ActionPaletteItem(ActionTreeNode node)
 {
     this.node = node;
     Spacing   = 3;
     if (node.Type == Gtk.UIManagerItemType.Menu)
     {
         PackStart(new Gtk.Label(Mono.Unix.Catalog.GetString("Menu")), true, true, 0);
     }
     else if (node.Action != null && node.Action.GtkAction != null)
     {
         if (node.Action.GtkAction.StockId != null)
         {
             PackStart(node.Action.CreateIcon(Gtk.IconSize.Menu), true, true, 0);
         }
         PackStart(new Gtk.Label(node.Action.GtkAction.Label), true, true, 0);
     }
     else if (node.Type == Gtk.UIManagerItemType.Separator)
     {
         PackStart(new Gtk.Label(Mono.Unix.Catalog.GetString("Separator")), true, true, 0);
     }
     else
     {
         PackStart(new Gtk.Label(Mono.Unix.Catalog.GetString("Empty Action")), true, true, 0);
     }
     ShowAll();
 }
		protected override void OnDestroyed ()
		{
			parentNode.ChildNodeAdded -= OnChildAdded;
			parentNode.ChildNodeRemoved -= OnChildRemoved;
			parentNode = null;
			
			base.OnDestroyed ();
		}
Beispiel #5
0
        public void Read(Wrapper.Widget baseWidget, XmlElement elem)
        {
            name = elem.GetAttribute("name");
            if (elem.HasAttribute("type"))
            {
                type = (Gtk.UIManagerItemType)Enum.Parse(typeof(Gtk.UIManagerItemType), elem.GetAttribute("type"));
            }

            // The name of an action may be empty in some situations (e.g. when adding a new action but before entering the name)
            XmlAttribute actionAt = elem.Attributes ["action"];

            if (actionAt != null)
            {
                string aname = actionAt.Value;
                foreach (ActionGroup grp in baseWidget.LocalActionGroups)
                {
                    action = grp.GetAction(aname);
                    if (action != null)
                    {
                        break;
                    }
                }
                if (action == null)
                {
                    foreach (ActionGroup group in baseWidget.Project.ActionGroups)
                    {
                        action = group.GetAction(aname);
                        if (action != null)
                        {
                            break;
                        }
                    }
                }
                if (action != null)
                {
                    lastActionName        = action.Name;
                    action.Deleted       += OnActionDeleted;
                    action.ObjectChanged += OnActionChanged;
                }
            }

            try
            {
                loading = true;
                foreach (XmlElement child in elem.SelectNodes("node"))
                {
                    ActionTreeNode node = new ActionTreeNode();
                    node.Read(baseWidget, child);
                    Children.Add(node);
                }
            }
            finally
            {
                loading = false;
            }
        }
Beispiel #6
0
 internal void NotifyChildRemoved(ActionTreeNode node)
 {
     node.parentNode = null;
     if (!loading)
     {
         NotifyChanged();
         if (ChildNodeRemoved != null)
         {
             ChildNodeRemoved(this, new ActionTreeNodeArgs(node));
         }
     }
 }
Beispiel #7
0
		public ActionItem (ActionTreeNode node, IMenuItemContainer parent, uint itemSpacing)
		{
			DND.SourceSet (this);
			this.parentMenu = parent;
			this.node = node;
			this.VisibleWindow = false;
			this.CanFocus = true;
			this.Events |= Gdk.EventMask.KeyPressMask;
			this.itemSpacing = itemSpacing;
			if (node.Action != null)
				node.Action.ObjectChanged += OnActionChanged;
		}
Beispiel #8
0
 public void DropMenu(ActionTreeNode node)
 {
     ActionMenuItem item = FindMenuItem (node);
     if (item != null) {
         if (item.HasSubmenu) {
             item.ShowSubmenu ();
             if (openSubmenu != null)
                 openSubmenu.Select (null);
         }
         else
             item.Select ();
     }
 }
		public void Select (ActionTreeNode node)
		{
			if (node != null) {
				ActionMenuItem item = FindMenuItem (node);
				if (item != null)
					item.Select ();
			} else {
				if (menuItems.Count > 0)
					((ActionMenuItem)menuItems [0]).Select ();
				else
					InsertAction (0);
			}
		}
Beispiel #10
0
 public ActionPaletteItem(ActionTreeNode node)
 {
     this.node = node;
     Spacing = 3;
     if (node.Type == Gtk.UIManagerItemType.Menu) {
         PackStart (new Gtk.Label ("Menu"), true, true, 0);
     } else if (node.Action != null && node.Action.GtkAction != null) {
         if (node.Action.GtkAction.StockId != null)
             PackStart (node.Action.CreateIcon (Gtk.IconSize.Menu), true, true, 0);
         PackStart (new Gtk.Label (node.Action.GtkAction.Label), true, true, 0);
     } else if (node.Type == Gtk.UIManagerItemType.Separator) {
         PackStart (new Gtk.Label ("Separator"), true, true, 0);
     } else {
         PackStart (new Gtk.Label ("Empty Action"), true, true, 0);
     }
     ShowAll ();
 }
		internal ActionMenu (Widget wrapper, IMenuItemContainer parentMenu, ActionTreeNode node)
		{
			DND.DestSet (this, true);
			parentNode = node;
			this.parentMenu = parentMenu;
			this.wrapper = wrapper;
			this.nodes = node.Children;
			table = new Gtk.Table (0, 0, false);
			table.ColumnSpacing = 5;
			table.RowSpacing = 5;
			table.BorderWidth = 5;
			this.AppPaintable = true;
			
			Add (table);
			
			Fill ();
			
			parentNode.ChildNodeAdded += OnChildAdded;
			parentNode.ChildNodeRemoved += OnChildRemoved;
		}
Beispiel #12
0
 public ActionTreeNodeCollection(ActionTreeNode parent)
 {
     this.parent = parent;
 }
Beispiel #13
0
        void InsertActionAt(ActionMenuItem item, bool after, bool separator)
        {
            int pos = menuItems.IndexOf (item);
            if (pos == -1)
                return;

            if (after)
                pos++;

            if (separator) {
                ActionTreeNode newNode = new ActionTreeNode (Gtk.UIManagerItemType.Separator, null, null);
                actionTree.Children.Insert (pos, newNode);
            } else
                InsertAction (pos);
        }
Beispiel #14
0
 ActionMenuItem FindMenuItem(ActionTreeNode node)
 {
     foreach (ActionMenuItem mi in menuItems) {
         if (mi.Node == node)
             return mi;
     }
     return null;
 }
Beispiel #15
0
		internal ActionMenuItem (IDesignArea designArea, IProject project, IMenuItemContainer parent, ActionTreeNode node)
		: this (null, parent, node, 6)
		{
			this.project = project;
			this.designArea = designArea;
		}
Beispiel #16
0
        public void Read(Wrapper.Widget baseWidget, XmlElement elem)
        {
            name = elem.GetAttribute ("name");
            if (elem.HasAttribute ("type"))
                type = (Gtk.UIManagerItemType) Enum.Parse (typeof(Gtk.UIManagerItemType), elem.GetAttribute ("type"));

            // The name of an action may be empty in some situations (e.g. when adding a new action but before entering the name)
            XmlAttribute actionAt = elem.Attributes ["action"];
            if (actionAt != null) {
                string aname = actionAt.Value;
                foreach (ActionGroup grp in baseWidget.LocalActionGroups) {
                    action = grp.GetAction (aname);
                    if (action != null)
                        break;
                }
                if (action == null) {
                    foreach (ActionGroup group in baseWidget.Project.ActionGroups) {
                        action = group.GetAction (aname);
                        if (action != null)
                            break;
                    }
                }
                if (action != null) {
                    lastActionName = action.Name;
                    action.Deleted += OnActionDeleted;
                    action.ObjectChanged += OnActionChanged;
                }
            }

            try {
                loading = true;
                foreach (XmlElement child in elem.SelectNodes ("node")) {
                    ActionTreeNode node = new ActionTreeNode ();
                    node.Read (baseWidget, child);
                    Children.Add (node);
                }
            } finally {
                loading = false;
            }
        }
Beispiel #17
0
 public ActionTreeNodeCollection(ActionTreeNode parent)
 {
     this.parent = parent;
 }
Beispiel #18
0
 public void Remove(ActionTreeNode node)
 {
     List.Remove (node);
 }
Beispiel #19
0
 internal void NotifyChildRemoved(ActionTreeNode node)
 {
     node.parentNode = null;
     if (!loading) {
         NotifyChanged ();
         if (ChildNodeRemoved != null)
             ChildNodeRemoved (this, new ActionTreeNodeArgs (node));
     }
 }
Beispiel #20
0
 public void Insert(int index, ActionTreeNode node)
 {
     List.Insert (index, node);
 }
Beispiel #21
0
 public int IndexOf(ActionTreeNode node)
 {
     return List.IndexOf (node);
 }
Beispiel #22
0
 public void Add(ActionTreeNode node)
 {
     List.Add (node);
 }
		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.Menu &&
				dropped.Node.Type != Gtk.UIManagerItemType.Toolitem &&
				dropped.Node.Type != Gtk.UIManagerItemType.Separator)
				return false;
			
			ActionTreeNode newNode = null;
			
			// Toolitems are copied, not moved
			
			using (wrapper.UndoManager.AtomicChange) {
				if (dropped.Node.ParentNode != null && dropped.Node.Type != Gtk.UIManagerItemType.Toolitem) {
					if (dropIndex < nodes.Count) {
						// Do nothing if trying to drop the node over the same node
						ActionTreeNode dropNode = nodes [dropIndex];
						if (dropNode == dropped.Node)
							return false;
							
						dropped.Node.ParentNode.Children.Remove (dropped.Node);
						
						// The drop position may have changed after removing the dropped node,
						// so get it again.
						dropIndex = nodes.IndexOf (dropNode);
						nodes.Insert (dropIndex, dropped.Node);
					} else {
						dropped.Node.ParentNode.Children.Remove (dropped.Node);
						nodes.Add (dropped.Node);
						dropIndex = nodes.Count - 1;
					}
				} else {
					newNode = new ActionTreeNode (Gtk.UIManagerItemType.Menuitem, null, dropped.Node.Action);
					nodes.Insert (dropIndex, newNode);
				}
				// Select the dropped node
				ActionMenuItem mi = (ActionMenuItem) menuItems [dropIndex];
				mi.Select ();
			}
			
			return base.OnDragDrop (context, x,	y, time);
		}
Beispiel #24
0
 public void Add(ActionTreeNode node)
 {
     List.Add(node);
 }
Beispiel #25
0
        ActionMenuItem InsertAction(Wrapper.Action action, int n)
        {
            uint row = (uint) n / columns;
            uint col = (uint) (n % columns) * 3;

            IDesignArea designArea = GetDesignArea ();
            ActionTreeNode node = new ActionTreeNode (Gtk.UIManagerItemType.Menuitem, "", action);
            ActionMenuItem aitem = new ActionMenuItem (designArea, project, this, node);
            aitem.KeyPressEvent += OnItemKeyPress;
            aitem.MinWidth = 150;
            aitem.Attach (table, row, col);

            Gtk.Frame fr = new Gtk.Frame ();
            fr.Shadow = Gtk.ShadowType.Out;
            aitem.Add (fr);

            items.Add (aitem);
            return aitem;
        }
		internal ActionToolItem (Widget wrapper, ActionToolbar parent, ActionTreeNode node)
		: this (wrapper, parent, node, 0)
		{
		}
Beispiel #27
0
		internal ActionMenuItem (Widget wrapper, IMenuItemContainer parent, ActionTreeNode node)
		: this (wrapper, parent, node, 0)
		{
		}
		public void Remove (ActionTreeNode node)
		{
			if (List.Contains (node))
				List.Remove (node);
		}
Beispiel #29
0
		internal ActionMenuItem (Widget wrapper, IMenuItemContainer parent, ActionTreeNode node, uint itemSpacing): base (node, parent, itemSpacing)
		{
			this.wrapper = wrapper;
			CreateControls ();
		}
Beispiel #30
0
        public override void Dispose()
        {
            foreach (Gtk.Widget w in table.Children) {
                table.Remove (w);
                w.Destroy ();
            }

            parentNode.ChildNodeAdded -= OnChildAdded;
            parentNode.ChildNodeRemoved -= OnChildRemoved;
            parentNode = null;
            base.Dispose ();
        }
Beispiel #31
0
 public void Select(ActionTreeNode node)
 {
     ActionMenuItem item = FindMenuItem (node);
     if (item != null)
         item.Select ();
 }
Beispiel #32
0
 public ActionTreeNodeArgs(ActionTreeNode node)
 {
     this.node = node;
 }
Beispiel #33
0
        void InsertAction(int pos)
        {
            Widget 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.Menu, "", ac);
                actionTree.Children.Insert (pos, node);

                ActionMenuItem aitem = FindMenuItem (node);
                aitem.EditingDone += OnEditingDone;
                aitem.Select ();
                aitem.StartEditing ();

                if (wrapper.LocalActionGroups.Count == 0)
                    wrapper.LocalActionGroups.Add (new ActionGroup ("Default"));
                wrapper.LocalActionGroups[0].Actions.Add (ac);
            }
        }
		ActionTreeNode InsertAction (int pos)
		{
			using (wrapper.UndoManager.AtomicChange) {
				Wrapper.Action ac = (Wrapper.Action) ObjectWrapper.Create (wrapper.Project, new Gtk.Action ("", "", null, null));
				ActionTreeNode newNode = new ActionTreeNode (Gtk.UIManagerItemType.Menuitem, null, ac);
				nodes.Insert (pos, newNode);
				ActionMenuItem item = FindMenuItem (newNode);
				item.EditingDone += OnEditingDone;
				item.Select ();
				item.StartEditing ();
				emptyLabel.Hide ();
				
				if (wrapper.LocalActionGroups.Count == 0)
					wrapper.LocalActionGroups.Add (new ActionGroup ("Default"));
				wrapper.LocalActionGroups [0].Actions.Add (ac);
				return newNode;
			}
		}
Beispiel #35
0
 public void Insert(int index, ActionTreeNode node)
 {
     List.Insert(index, node);
 }
Beispiel #36
0
 public ActionTreeNodeArgs(ActionTreeNode node)
 {
     this.node = node;
 }
Beispiel #37
0
 public int IndexOf(ActionTreeNode node)
 {
     return(List.IndexOf(node));
 }
Beispiel #38
0