~ted/ubuntu/lucid/tomboy/with-patch

« back to all changes in this revision

Viewing changes to Tomboy/Addins/FixedWidth/FixedWidthMenuItem.cs

Tags: upstream-0.7.2
Import upstream version 0.7.2

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
using System;
 
2
using Gtk;
 
3
using Mono.Unix;
 
4
 
 
5
namespace Tomboy.FixedWidth
 
6
{
 
7
        class FixedWidthMenuItem : CheckMenuItem
 
8
        {
 
9
                NoteAddin Addin;
 
10
                bool event_freeze;
 
11
 
 
12
                public FixedWidthMenuItem (NoteAddin addin) 
 
13
                        : base ("<span font_family='monospace'>" +
 
14
                                Catalog.GetString ("_Fixed Width") +
 
15
                                "</span>")
 
16
                {
 
17
                        ((Label) Child).UseUnderline = true;
 
18
                        ((Label) Child).UseMarkup = true;
 
19
 
 
20
                        Addin = addin;
 
21
                        Addin.Window.TextMenu.Shown += MenuShown;
 
22
 
 
23
                        ShowAll();
 
24
                }
 
25
 
 
26
                protected void MenuShown (object sender, EventArgs e)
 
27
                {
 
28
                        event_freeze = true;
 
29
                        Active = Addin.Buffer.IsActiveTag ("monospace");
 
30
                        event_freeze = false;
 
31
                }
 
32
 
 
33
                protected override void OnActivated ()
 
34
                {
 
35
                        if (!event_freeze)
 
36
                                Addin.Buffer.ToggleActiveTag ("monospace");
 
37
 
 
38
                        base.OnActivated();
 
39
                }
 
40
 
 
41
                protected override void OnDestroyed ()
 
42
                {
 
43
                        if (Addin.HasWindow)
 
44
                                Addin.Window.TextMenu.Shown -= MenuShown;
 
45
 
 
46
                        base.OnDestroyed();
 
47
                }
 
48
        }
 
49
}