~ubuntu-branches/ubuntu/trusty/monodevelop/trusty-proposed

« back to all changes in this revision

Viewing changes to external/mono-addins/Samples/TextEditor/TextEditorLib/ExtensionNodes/MenuItemNode.cs

  • Committer: Package Import Robot
  • Author(s): Jo Shields
  • Date: 2013-05-12 09:46:03 UTC
  • mto: This revision was merged to the branch mainline in revision 29.
  • Revision ID: package-import@ubuntu.com-20130512094603-mad323bzcxvmcam0
Tags: upstream-4.0.5+dfsg
ImportĀ upstreamĀ versionĀ 4.0.5+dfsg

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
 
 
2
using System;
 
3
using Mono.Addins;
 
4
 
 
5
namespace TextEditor
 
6
{
 
7
        [ExtensionNode ("MenuItem")]
 
8
        public class MenuItemNode: MenuNode
 
9
        {
 
10
                [NodeAttribute]
 
11
                string label;
 
12
                
 
13
                [NodeAttribute]
 
14
                string icon;
 
15
                
 
16
                [NodeAttribute]
 
17
                string commandType;
 
18
                
 
19
                static Gtk.AccelGroup accelGroup = new Gtk.AccelGroup ();
 
20
                
 
21
                public override Gtk.MenuItem GetMenuItem ()
 
22
                {
 
23
                        Gtk.MenuItem item;
 
24
                        if (icon != null)
 
25
                                item = new Gtk.ImageMenuItem (icon, accelGroup);
 
26
                        else
 
27
                                item = new Gtk.MenuItem (label);
 
28
                        item.Activated += OnClicked;
 
29
                        return item;
 
30
                }
 
31
                
 
32
                void OnClicked (object s, EventArgs a)
 
33
                {
 
34
                        ICommand command = (ICommand) Addin.CreateInstance (commandType);
 
35
                        command.Run ();
 
36
                }
 
37
        }
 
38
}