Пример #1
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();
        }
Пример #2
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();
        }
Пример #3
0
        public object DeserializeChild(XmlElement data)
        {
            ObjectReader or = new ObjectReader(project, FileFormat.Native);

            if (data.LocalName == "action")
            {
                Wrapper.Action ac = new Wrapper.Action();
                ac.Read(or, data);
                return(ac);
            }
            else if (data.LocalName == "action-group")
            {
                ActionGroup ac = new ActionGroup();
                ac.Read(or, data);
                return(ac);
            }
            throw new NotImplementedException();
        }
Пример #4
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);
        }
Пример #5
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);
            }
        }
Пример #6
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);
            }
        }
Пример #7
0
        public IEnumerable GetProperties(object obj)
        {
            Wrapper.Action action = obj as Wrapper.Action;
            if (action != null)
            {
                foreach (ItemGroup iset in action.ClassDescriptor.ItemGroups)
                {
                    foreach (ItemDescriptor it in iset)
                    {
                        PropertyDescriptor prop = it as PropertyDescriptor;

                        if (!prop.VisibleFor(action.Wrapped) || !prop.CanWrite)
                        {
                            continue;
                        }

                        object value = prop.GetValue(action.Wrapped);

                        // If the property has its default value, we don't need to check it
                        if (value == null || (prop.HasDefault && prop.IsDefaultValue(value)))
                        {
                            continue;
                        }

                        yield return(it);
                    }
                }
            }
            else if (obj is ActionGroup)
            {
                yield return("name");                   // ActionGroup only has one property, the name
            }
            else
            {
                yield break;
            }
        }
Пример #8
0
		public object DeserializeChild (XmlElement data)
		{
			ObjectReader or = new ObjectReader (project, FileFormat.Native);
			if (data.LocalName == "action") {
				Wrapper.Action ac = new Wrapper.Action ();
				ac.Read (or, data);
				return ac;
			} else if (data.LocalName == "action-group") {
				ActionGroup ac = new ActionGroup ();
				ac.Read (or, data);
				return ac;
			}
			throw new NotImplementedException ();
		}
Пример #9
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 ();
        }