~ubuntu-branches/ubuntu/karmic/mono-addins/karmic

« back to all changes in this revision

Viewing changes to Samples/TextEditorLib/ExtensionNodes/MenuItemNode.cs

  • Committer: Bazaar Package Importer
  • Author(s): Mirco Bauer
  • Date: 2007-07-14 12:07:48 UTC
  • Revision ID: james.westby@ubuntu.com-20070714120748-2elczfsjlrdsrpms
Tags: upstream-0.2
ImportĀ upstreamĀ versionĀ 0.2

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
}