3
using System.Collections.Generic;
8
/// A NoteAddin extends the functionality of a note and a NoteWindow.
9
/// If you wish to extend Tomboy in a more broad sense, perhaps you
10
/// should create an ApplicationAddin.
12
public abstract class NoteAddin : AbstractAddin
16
List<Gtk.MenuItem> tools_menu_items;
17
List<Gtk.MenuItem> text_menu_items;
19
public void Initialize (Note note)
22
this.note.Opened += OnNoteOpenedEvent;
30
protected override void Dispose (bool disposing)
33
if (tools_menu_items != null) {
34
foreach (Gtk.Widget item in tools_menu_items)
38
if (text_menu_items != null) {
39
foreach (Gtk.Widget item in text_menu_items)
46
note.Opened -= OnNoteOpenedEvent;
50
/// Called when the NoteAddin is attached to a Note
52
public abstract void Initialize ();
55
/// Called when a note is deleted and also when
56
/// the addin is disabled.
58
public abstract void Shutdown ();
61
/// Called when the note is opened.
63
public abstract void OnNoteOpened ();
72
get { return note.HasBuffer; }
75
public NoteBuffer Buffer
79
if (IsDisposing && !HasBuffer)
80
throw new InvalidOperationException ("Plugin is disposing already");
88
get { return note.HasWindow; }
91
public NoteWindow Window
95
if (IsDisposing && !HasWindow)
96
throw new InvalidOperationException ("Plugin is disposing already");
102
public NoteManager Manager
104
get { return note.Manager; }
107
void OnNoteOpenedEvent (object sender, EventArgs args)
111
if (tools_menu_items != null) {
112
foreach (Gtk.Widget item in tools_menu_items) {
113
if (item.Parent == null ||
114
item.Parent != Window.PluginMenu)
115
Window.PluginMenu.Add (item);
119
if (text_menu_items != null) {
120
foreach (Gtk.Widget item in text_menu_items) {
121
if (item.Parent == null ||
122
item.Parent != Window.TextMenu) {
123
Window.TextMenu.Add (item);
124
Window.TextMenu.ReorderChild (item, 7);
130
public void AddPluginMenuItem (Gtk.MenuItem item)
133
throw new InvalidOperationException ("Plugin is disposing already");
135
if (tools_menu_items == null)
136
tools_menu_items = new List<Gtk.MenuItem> ();
138
tools_menu_items.Add (item);
141
Window.PluginMenu.Add (item);
144
public void AddTextMenuItem (Gtk.MenuItem item)
147
throw new InvalidOperationException ("Plugin is disposing already");
149
if (text_menu_items == null)
150
text_menu_items = new List<Gtk.MenuItem> ();
152
text_menu_items.Add (item);
155
Window.TextMenu.Add (item);
156
Window.TextMenu.ReorderChild (item, 7);