Inheritance: Stetic.Editor.ActionItem
Ejemplo n.º 1
0
        public void Delete()
        {
            ActionMenuItem menuItem = SelectedActionMenuItem;

            if (menuItem != null)
            {
                Delete(SelectedActionMenuItem);
            }
        }
Ejemplo n.º 2
0
        public void Select(ActionTreeNode node)
        {
            ActionMenuItem item = FindMenuItem(node);

            if (item != null)
            {
                item.Select();
            }
        }
Ejemplo n.º 3
0
        public void Cut()
        {
            ActionMenuItem menuItem = SelectedActionMenuItem;

            if (menuItem != null)
            {
                Cut(SelectedActionMenuItem);
            }
        }
Ejemplo n.º 4
0
        protected override bool OnDragMotion(Gdk.DragContext context, int x, int y, uint time)
        {
            ActionPaletteItem dragItem = DND.DragWidget as ActionPaletteItem;

            if (dragItem == null)
            {
                return(false);
            }

            if (actionTree.Children.Count > 0)
            {
                ActionMenuItem item = LocateWidget(x, y);
                if (item != null)
                {
                    Widget wrapper = Widget.Lookup(this);

                    // Show the submenu to allow droping to it, but avoid
                    // droping a submenu inside itself
                    if (item.HasSubmenu && item.Node != dragItem.Node)
                    {
                        item.ShowSubmenu(wrapper.GetDesignArea(), item);
                    }

                    // Look for the index where to insert the new item
                    dropIndex = actionTree.Children.IndexOf(item.Node);
                    int mpos = item.Allocation.X + item.Allocation.Width / 2;
                    if (x > mpos)
                    {
                        dropIndex++;
                    }

                    // Calculate the drop position, used to show the drop bar
                    if (dropIndex == 0)
                    {
                        dropPosition = item.Allocation.X;
                    }
                    else if (dropIndex == menuItems.Count)
                    {
                        dropPosition = item.Allocation.Right;
                    }
                    else
                    {
                        item = (ActionMenuItem)menuItems [dropIndex];
                        ActionMenuItem prevItem = (ActionMenuItem)menuItems [dropIndex - 1];
                        dropPosition = prevItem.Allocation.Right + (item.Allocation.X - prevItem.Allocation.Right) / 2;
                    }
                }
            }
            else
            {
                dropIndex = 0;
            }

            QueueDraw();
            return(base.OnDragMotion(context, x, y, time));
        }
Ejemplo n.º 5
0
        void IMenuItemContainer.ShowContextMenu(ActionItem aitem)
        {
            ActionMenuItem menuItem = aitem as ActionMenuItem;

            Gtk.Menu     m    = new Gtk.Menu();
            Gtk.MenuItem item = new Gtk.MenuItem(Catalog.GetString("Insert Before"));
            m.Add(item);
            item.Activated += delegate(object s, EventArgs a) {
                InsertActionAt(menuItem, false, false);
            };
            item = new Gtk.MenuItem(Catalog.GetString("Insert After"));
            m.Add(item);
            item.Activated += delegate(object s, EventArgs a) {
                InsertActionAt(menuItem, true, false);
            };
            item = new Gtk.MenuItem(Catalog.GetString("Insert Separator Before"));
            m.Add(item);
            item.Activated += delegate(object s, EventArgs a) {
                InsertActionAt(menuItem, false, true);
            };
            item = new Gtk.MenuItem(Catalog.GetString("Insert Separator After"));
            m.Add(item);
            item.Activated += delegate(object s, EventArgs a) {
                InsertActionAt(menuItem, true, true);
            };

            m.Add(new Gtk.SeparatorMenuItem());

            item = new Gtk.ImageMenuItem(Gtk.Stock.Cut, null);
            m.Add(item);
            item.Activated += delegate(object s, EventArgs a) {
                menuItem.Cut();
            };
            item.Visible = false;               // No copy & paste for now
            item         = new Gtk.ImageMenuItem(Gtk.Stock.Copy, null);
            m.Add(item);
            item.Activated += delegate(object s, EventArgs a) {
                menuItem.Copy();
            };
            item.Visible = false;
            item         = new Gtk.ImageMenuItem(Gtk.Stock.Paste, null);
            m.Add(item);
            item.Activated += delegate(object s, EventArgs a) {
                Paste(menuItem);
            };
            item.Visible = false;

            item = new Gtk.ImageMenuItem(Gtk.Stock.Delete, null);
            m.Add(item);
            item.Activated += delegate(object s, EventArgs a) {
                DeleteAction(menuItem);
            };
            m.ShowAll();
            m.Popup();
        }
Ejemplo n.º 6
0
        void Fill()
        {
            IDesignArea designArea = GetDesignArea();

            if (designArea == null)
            {
                return;
            }

            Wrapper.Action selAction = null;

            foreach (ActionMenuItem item in items)
            {
                if (designArea.IsSelected(item))
                {
                    selAction = item.Node.Action;
                }
                item.Node.Dispose();
                item.Detach();
                item.Destroy();
            }
            items.Clear();

            if (actionGroup != null)
            {
                Wrapper.Action[] sortedActions = new Wrapper.Action [actionGroup.Actions.Count];
                actionGroup.Actions.CopyTo(sortedActions, 0);
                Array.Sort(sortedActions, new ActionComparer());
                for (int n = 0; n < sortedActions.Length; n++)
                {
                    Wrapper.Action action = (Wrapper.Action)sortedActions [n];
                    ActionMenuItem item   = InsertAction(action, n);
                    if (selAction == action)
                    {
                        item.Select();
                    }
                }

                if (selAction == null)
                {
                    designArea.SetSelection(null, null);
                }

                headerLabel.Sensitive = true;
                PlaceAddLabel(actionGroup.Actions.Count);
            }
            else
            {
                HideAddLabel();
                headerLabel.Text      = Catalog.GetString("No selection");
                headerLabel.Sensitive = false;
            }
            ShowAll();
        }
Ejemplo n.º 7
0
        void OnAddClicked(object s, Gtk.ButtonPressEventArgs args)
        {
            Wrapper.Action ac   = (Wrapper.Action)ObjectWrapper.Create(project, new Gtk.Action("", "", null, null));
            ActionMenuItem item = InsertAction(ac, actionGroup.Actions.Count);

            item.EditingDone += OnEditDone;
            item.Select();
            item.StartEditing();
            HideAddLabel();
            ShowAll();
        }
Ejemplo n.º 8
0
        void Delete(ActionMenuItem menuItem)
        {
            string msg = string.Format(Catalog.GetString("Are you sure you want to delete the action '{0}'? It will be removed from all menus and toolbars."), menuItem.Node.Action.Name);

            Gtk.MessageDialog md = new Gtk.MessageDialog(null, Gtk.DialogFlags.Modal, Gtk.MessageType.Question, Gtk.ButtonsType.YesNo, msg);
            if (md.Run() == (int)Gtk.ResponseType.Yes)
            {
                menuItem.Node.Action.Delete();
                darea.SetSelection(null, null);
            }
            md.Destroy();
        }
        void DeleteAction(ActionMenuItem item)
        {
            int pos = menuItems.IndexOf(item);

            item.Delete();
            if (pos >= menuItems.Count)
            {
                SelectLastItem();
            }
            else
            {
                ((ActionMenuItem)menuItems [pos]).Select();
            }
        }
Ejemplo n.º 10
0
        void AddItem(ActionMenuItem aitem, int pos)
        {
            Gtk.Table t = new Gtk.Table(1, 3, false);
            aitem.Attach(t, 0, 0);
            aitem.KeyPressEvent += OnItemKeyPress;
            t.ShowAll();

            CustomMenuBarItem it = new CustomMenuBarItem();

            it.ActionMenuItem = aitem;
            aitem.Bind(it);
            it.Child = t;
            it.ShowAll();
            Insert(it, pos);
        }
        public bool RepositionSubmenu()
        {
            if (openSubmenu == null)
            {
                return(false);
            }

            ActionMenuItem item = FindMenuItem(openSubmenu.parentNode);

            if (item != null)
            {
                openSubmenu.TrackWidgetPosition(item, false);
            }
            return(false);
        }
Ejemplo n.º 12
0
        public void FillMenu(ActionTree actionTree)
        {
            addLabel = null;

            if (this.actionTree != null)
            {
                this.actionTree.ChildNodeAdded   -= OnChildAdded;
                this.actionTree.ChildNodeRemoved -= OnChildRemoved;
            }

            this.actionTree = actionTree;
            if (actionTree == null)
            {
                AddSpacerItem();
                return;
            }

            actionTree.ChildNodeAdded   += OnChildAdded;
            actionTree.ChildNodeRemoved += OnChildRemoved;

            HideSpacerItem();
            menuItems.Clear();
            Widget wrapper = Widget.Lookup(this);

            foreach (Gtk.Widget w in Children)
            {
                Remove(w);
                w.Destroy();
                w.Dispose();
            }

            foreach (ActionTreeNode node in actionTree.Children)
            {
                ActionMenuItem aitem = new ActionMenuItem(wrapper, this, node);
                AddItem(aitem, -1);
                menuItems.Add(aitem);
            }

            if (showPlaceholder)
            {
                AddCreateItemLabel();
            }
            else if (actionTree.Children.Count == 0)
            {
                // Give some height to the toolbar
                AddSpacerItem();
            }
        }
Ejemplo n.º 13
0
        public object SaveStatus()
        {
            ArrayList status = new ArrayList();

            for (int n = 0; n < menuItems.Count; n++)
            {
                ActionMenuItem item = (ActionMenuItem)menuItems [n];
                if (item.IsSubmenuVisible)
                {
                    status.Add(n);
                    OpenSubmenu.SaveStatus(status);
                    break;
                }
            }
            return(status);
        }
Ejemplo n.º 14
0
        void OnEditingDone(object ob, EventArgs args)
        {
            ActionMenuItem item = (ActionMenuItem)ob;

            item.EditingDone -= OnEditingDone;
            Widget wrapper = Widget.Lookup(this);

            if (item.Node.Action.GtkAction.Label.Length == 0 && item.Node.Action.GtkAction.StockId == null)
            {
                IDesignArea area = wrapper.GetDesignArea();
                area.ResetSelection(item);
                using (wrapper.UndoManager.AtomicChange) {
                    actionTree.Children.Remove(item.Node);
                    wrapper.LocalActionGroups [0].Actions.Remove(item.Node.Action);
                }
            }
        }
        void Fill()
        {
            menuItems.Clear();

            uint           n        = 0;
            ActionMenuItem editItem = null;

            if (nodes.Count > 0)
            {
                foreach (ActionTreeNode node in nodes)
                {
                    ActionMenuItem item = new ActionMenuItem(wrapper, this, node);
                    item.KeyPressEvent += OnItemKeyPress;
                    item.Attach(table, n++, 0);
                    menuItems.Add(item);
                    // If adding an action with an empty name, select and start editing it
//					if (node.Action != null && node.Action.Name.Length == 0)
//						editItem = item;
                }
            }

            emptyLabel = new Gtk.EventBox();
            emptyLabel.VisibleWindow = false;
            Gtk.Label label = new Gtk.Label();
            label.Xalign = 0;
            label.Markup = "<i><span foreground='darkgrey'>" + Catalog.GetString("Click to create action") + "</span></i>";
            emptyLabel.Add(label);
            emptyLabel.ButtonPressEvent += OnAddClicked;
            table.Attach(emptyLabel, 1, 2, n, n + 1);

            ShowAll();

            if (editItem != null)
            {
                // If there is an item with an empty action, it means that it was an item that was
                // being edited. Restart the editing now.
                GLib.Timeout.Add(200, delegate
                {
                    editItem.Select();
                    editItem.EditingDone += OnEditingDone;
                    editItem.StartEditing();
                    return(false);
                });
            }
        }
 internal void SaveStatus(ArrayList status)
 {
     for (int n = 0; n < menuItems.Count; n++)
     {
         ActionMenuItem item = (ActionMenuItem)menuItems [n];
         if (item.IsSelected)
         {
             status.Add(n);
             return;
         }
         if (item.IsSubmenuVisible)
         {
             status.Add(n);
             OpenSubmenu.SaveStatus(status);
             return;
         }
     }
 }
Ejemplo n.º 17
0
        void OnItemKeyPress(object s, Gtk.KeyPressEventArgs args)
        {
            int            pos  = menuItems.IndexOf(s);
            ActionMenuItem item = (ActionMenuItem)s;

            switch (args.Event.Key)
            {
            case Gdk.Key.Left:
                if (pos > 0)
                {
                    ((ActionMenuItem)menuItems[pos - 1]).Select();
                }
                break;

            case Gdk.Key.Right:
                if (pos < menuItems.Count - 1)
                {
                    ((ActionMenuItem)menuItems[pos + 1]).Select();
                }
                else if (pos == menuItems.Count - 1)
                {
                    InsertAction(menuItems.Count);
                }
                break;

            case Gdk.Key.Down:
                if (item.HasSubmenu)
                {
                    item.ShowSubmenu();
                    if (openSubmenu != null)
                    {
                        openSubmenu.Select(null);
                    }
                }
                break;

            case Gdk.Key.Up:
                OpenSubmenu = null;
                break;
            }
            args.RetVal = true;
        }
Ejemplo n.º 18
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);
        }
Ejemplo n.º 19
0
        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);
            }
        }
        internal void ResetSelection()
        {
            if (OpenSubmenu != null)
            {
                OpenSubmenu.ResetSelection();
            }
            IDesignArea area = wrapper.GetDesignArea();

            if (area != null)
            {
                foreach (Gtk.Widget w in table.Children)
                {
                    ActionMenuItem ami = w as ActionMenuItem;
                    if (ami != null)
                    {
                        area.ResetSelection(w);
                    }
                }
            }
        }
Ejemplo n.º 21
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();
                }
            }
        }
Ejemplo n.º 22
0
        void OnEditDone(object sender, EventArgs args)
        {
            ActionMenuItem item = (ActionMenuItem)sender;

            item.EditingDone -= OnEditDone;
            if (item.Node.Action.GtkAction.Label.Length > 0 || item.Node.Action.GtkAction.StockId != null)
            {
                actionGroup.Actions.Add(item.Node.Action);
            }
            else
            {
                IDesignArea designArea = GetDesignArea();
                designArea.ResetSelection(item);
                item.Detach();
                item.Node.Dispose();
                items.Remove(item);
                item.Destroy();
                PlaceAddLabel(actionGroup.Actions.Count);
                ShowAll();
            }
        }
Ejemplo n.º 23
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);
            }
        }
Ejemplo n.º 24
0
		public void FillMenu (ActionTree actionTree)
		{
			addLabel = null;

			if (this.actionTree != null) {
				this.actionTree.ChildNodeAdded -= OnChildAdded;
				this.actionTree.ChildNodeRemoved -= OnChildRemoved;
			}
			
			this.actionTree = actionTree;
			if (actionTree == null) {
				AddSpacerItem ();
				return;
			}
				
			actionTree.ChildNodeAdded += OnChildAdded;
			actionTree.ChildNodeRemoved += OnChildRemoved;
			
			HideSpacerItem ();
			menuItems.Clear ();
			Widget wrapper = Widget.Lookup (this);
			
			foreach (Gtk.Widget w in Children) {
				Remove (w);
				w.Destroy ();
			}

			foreach (ActionTreeNode node in actionTree.Children) {
				ActionMenuItem aitem = new ActionMenuItem (wrapper, this, node);
				AddItem (aitem, -1);
				menuItems.Add (aitem);
			}

			if (showPlaceholder) {
				AddCreateItemLabel ();
			} else if (actionTree.Children.Count == 0) {
				// Give some height to the toolbar
				AddSpacerItem ();
			}
		}
Ejemplo n.º 25
0
        public void RestoreStatus(object data)
        {
            ArrayList status = (ArrayList)data;

            if (status.Count == 0)
            {
                return;
            }

            int pos = (int)status [0];

            if (pos >= menuItems.Count)
            {
                return;
            }

            ActionMenuItem item = (ActionMenuItem)menuItems [pos];

            if (status.Count == 1)
            {
                // The last position in the status is the selected item
                item.Select();
                if (item.Node.Action != null && item.Node.Action.Name.Length == 0)
                {
                    // Then only case when there can have an action when an empty name
                    // is when the user clicked on the "add action" link. In this case,
                    // start editing the item again
                    item.EditingDone += OnEditingDone;
                    item.StartEditing();
                }
            }
            else
            {
                item.ShowSubmenu();
                if (OpenSubmenu != null)
                {
                    OpenSubmenu.RestoreStatus(status, 1);
                }
            }
        }
 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);
         }
     }
 }
        void OnChildRemoved(object ob, ActionTreeNodeArgs args)
        {
            IDesignArea      area   = wrapper.GetDesignArea();
            IObjectSelection asel   = area.GetSelection();
            ActionMenuItem   curSel = asel != null ? asel.DataObject as ActionMenuItem : null;
            int pos = menuItems.IndexOf(curSel);

            ActionMenuItem mi = FindMenuItem(args.Node);

            if (mi != null)
            {
                // Remove the table row that contains the menu item
                Gtk.Table.TableChild tc = (Gtk.Table.TableChild)table [mi];
                uint row = tc.TopAttach;
                mi.Detach();
                menuItems.Remove(mi);
                foreach (Gtk.Widget w in table.Children)
                {
                    tc = (Gtk.Table.TableChild)table [w];
                    if (tc.TopAttach >= row)
                    {
                        tc.TopAttach--;
                    }
                    if (tc.BottomAttach > row)
                    {
                        tc.BottomAttach--;
                    }
                }
                if (pos != -1 && pos < menuItems.Count)
                {
                    ((ActionMenuItem)menuItems[pos]).Select();
                }
                else
                {
                    SelectLastItem();
                }
                GLib.Timeout.Add(50, new GLib.TimeoutHandler(RepositionSubmenu));
            }
        }
Ejemplo n.º 28
0
        void OnEditingDone(object ob, MenuItemEditEventArgs args)
        {
            ActionMenuItem item = (ActionMenuItem)ob;

            item.EditingDone -= OnEditingDone;
            if (item.Node.Action.GtkAction.Label.Length == 0 && item.Node.Action.GtkAction.StockId == null)
            {
                IDesignArea area = wrapper.GetDesignArea();
                area.ResetSelection(item);
                using (wrapper.UndoManager.AtomicChange) {
                    nodes.Remove(item.Node);
                    wrapper.LocalActionGroups [0].Actions.Remove(item.Node.Action);
                }
                SelectLastItem();
            }
            else
            {
                if (args.ExitKey == Gdk.Key.Up || args.ExitKey == Gdk.Key.Down)
                {
                    ProcessKey(item, args.ExitKey, Gdk.ModifierType.None);
                }
            }
        }
Ejemplo n.º 29
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);
            }
        }
Ejemplo n.º 30
0
		void DeleteAction (ActionMenuItem item)
		{
			int pos = menuItems.IndexOf (item);
			item.Delete ();
			if (pos >= menuItems.Count)
				SelectLastItem ();
			else
				((ActionMenuItem)menuItems [pos]).Select ();
		}
Ejemplo n.º 31
0
		void Fill ()
		{
			menuItems.Clear ();

			uint n = 0;
			ActionMenuItem editItem = null;
			
			if (nodes.Count > 0) {
				foreach (ActionTreeNode node in nodes) {
					ActionMenuItem item = new ActionMenuItem (wrapper, this, node);
					item.KeyPressEvent += OnItemKeyPress;
					item.Attach (table, n++, 0);
					menuItems.Add (item);
					// If adding an action with an empty name, select and start editing it
//					if (node.Action != null && node.Action.Name.Length == 0)
//						editItem = item;
				}
			}
			
			emptyLabel = new Gtk.EventBox ();
			emptyLabel.VisibleWindow = false;
			Gtk.Label label = new Gtk.Label ();
			label.Xalign = 0;
			label.Markup = "<i><span foreground='darkgrey'>" + Catalog.GetString ("Click to create action") + "</span></i>";
			emptyLabel.Add (label);
			emptyLabel.ButtonPressEvent += OnAddClicked;
			table.Attach (emptyLabel, 1, 2, n, n + 1);
			
			ShowAll ();
			
			if (editItem != null) {
				// If there is an item with an empty action, it means that it was an item that was
				// being edited. Restart the editing now.
				GLib.Timeout.Add (200, delegate {
					editItem.Select ();
					editItem.EditingDone += OnEditingDone;
					editItem.StartEditing ();
					return false;
				});
			}
		}
Ejemplo n.º 32
0
 void Cut(ActionMenuItem menuItem)
 {
 }
Ejemplo n.º 33
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);
        }
Ejemplo n.º 34
0
 void Delete(ActionMenuItem menuItem)
 {
     string msg = string.Format (Catalog.GetString ("Are you sure you want to delete the action '{0}'? It will be removed from all menus and toolbars."), menuItem.Node.Action.Name);
     Gtk.MessageDialog md = new Gtk.MessageDialog (null, Gtk.DialogFlags.Modal, Gtk.MessageType.Question, Gtk.ButtonsType.YesNo, msg);
     if (md.Run () == (int) Gtk.ResponseType.Yes) {
         menuItem.Node.Action.Delete ();
         darea.SetSelection (null, null);
     }
     md.Destroy ();
 }
Ejemplo n.º 35
0
        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 = dropped.Node;

            if (dropped.Node.Type == Gtk.UIManagerItemType.Toolitem)
            {
                newNode      = newNode.Clone();
                newNode.Type = Gtk.UIManagerItemType.Menuitem;
            }

            Widget 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 == dropped.Node)
                    {
                        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
                ActionMenuItem mi = (ActionMenuItem)menuItems [dropIndex];
                mi.Select();
            }

            return(base.OnDragDrop(context, x, y, time));
        }
Ejemplo n.º 36
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;
        }
Ejemplo n.º 37
0
		void ProcessKey (ActionMenuItem item, Gdk.Key key, Gdk.ModifierType modifier)
		{
			int pos = menuItems.IndexOf (item);
			
			switch (key) {
				case Gdk.Key.Up:
					if (pos > 0)
						((ActionMenuItem)menuItems[pos - 1]).Select ();
					else if (parentMenu.Widget is ActionMenuBar) {
						ActionMenuBar bar = (ActionMenuBar) parentMenu.Widget;
						bar.Select (parentNode);
					}
					break;
				case Gdk.Key.Down:
					if (pos < menuItems.Count - 1)
						((ActionMenuItem)menuItems[pos + 1]).Select ();
					else if (pos == menuItems.Count - 1) {
						InsertAction (menuItems.Count);
					}
					break;
				case Gdk.Key.Right:
					if ((modifier & Gdk.ModifierType.ControlMask) != 0 && item.Node.Type == Gtk.UIManagerItemType.Menuitem) {
						// Create a submenu
						using (item.Node.Action.UndoManager.AtomicChange) {
							item.Node.Type = Gtk.UIManagerItemType.Menu;
						}
						item.Node.Action.NotifyChanged ();
					}
					if (item.HasSubmenu) {
						item.ShowSubmenu ();
						if (openSubmenu != null)
							openSubmenu.Select (null);
					} else if (parentNode != null) {
						ActionMenuBar parentMB = parentMenu.Widget as ActionMenuBar;
						if (parentMB != null) {
							int i = parentNode.ParentNode.Children.IndexOf (parentNode);
							if (i < parentNode.ParentNode.Children.Count - 1)
								parentMB.DropMenu (parentNode.ParentNode.Children [i + 1]);
						}
					}
					break;
				case Gdk.Key.Left:
					if ((modifier & Gdk.ModifierType.ControlMask) != 0 && item.Node.Type == Gtk.UIManagerItemType.Menu) {
						// Remove the submenu
						OpenSubmenu = null;
						using (item.Node.Action.UndoManager.AtomicChange) {
							item.Node.Type = Gtk.UIManagerItemType.Menuitem;
							item.Node.Children.Clear ();
						}
						item.Node.Action.NotifyChanged ();
						break;
					}
					if (parentNode != null) {
						ActionMenu parentAM = parentMenu.Widget as ActionMenu;
						if (parentAM != null) {
							parentAM.Select (parentNode);
						}
						ActionMenuBar parentMB = parentMenu.Widget as ActionMenuBar;
						if (parentMB != null) {
							int i = parentNode.ParentNode.Children.IndexOf (parentNode);
							if (i > 0)
								parentMB.DropMenu (parentNode.ParentNode.Children [i - 1]);
						}
					}
					break;
				case Gdk.Key.Return:
					item.EditingDone += OnEditingDone;
					item.StartEditing ();
					break;
				case Gdk.Key.Insert:
					if ((modifier & Gdk.ModifierType.ControlMask) != 0)
						InsertActionAt (item, true, true);
					else
						InsertActionAt (item, false, false);
					break;
				case Gdk.Key.Delete:
					DeleteAction (item);
					break;
			}
		}
Ejemplo n.º 38
0
        void AddItem(ActionMenuItem aitem, int pos)
        {
            Gtk.Table t = new Gtk.Table (1, 3, false);
            aitem.Attach (t, 0, 0);
            aitem.KeyPressEvent += OnItemKeyPress;
            t.ShowAll ();

            CustomMenuBarItem it = new CustomMenuBarItem ();
            it.ActionMenuItem = aitem;
            aitem.Bind (it);
            it.Child = t;
            it.ShowAll ();
            Insert (it, pos);
        }
Ejemplo n.º 39
0
 void Paste(ActionMenuItem item)
 {
 }
Ejemplo n.º 40
0
 void Paste(ActionMenuItem item)
 {
 }
Ejemplo n.º 41
0
 void Copy(ActionMenuItem menuItem)
 {
 }