6 public class TracLink
: DynamicNoteTag
8 private const string UriAttributeName
= "uri";
9 private const string StockIconFilename
= "stock_bug.png";
11 public override void Initialize (string element_name
)
13 base.Initialize (element_name
);
15 Underline
= Pango
.Underline
.Single
;
19 CanSpellCheck
= false;
26 return (string) Attributes
[UriAttributeName
];
29 Attributes
[UriAttributeName
] = value;
34 private void SetImage()
36 System
.Uri uri
= null;
38 uri
= new System
.Uri(BugUrl
);
42 Image
= new Gdk
.Pixbuf(null, StockIconFilename
);
46 string host
= uri
.Host
;
47 // TODO: Get this in a safer way
48 string imageDir
= "~/.tomboy/TracIcons/";
49 string imagePath
= imageDir
.Replace ("~", Environment
.GetEnvironmentVariable ("HOME")) + host
+ ".png";
52 Image
= new Gdk
.Pixbuf (imagePath
);
53 } catch (GLib
.GException
) {
54 Image
= new Gdk
.Pixbuf(null, StockIconFilename
);
58 protected override bool OnActivate (NoteEditor editor
, Gtk
.TextIter start
, Gtk
.TextIter end
)
60 if (BugUrl
!= string.Empty
) {
61 Logger
.Log ("Opening url '{0}'...", BugUrl
);
62 Gnome
.Url
.Show (BugUrl
);
67 protected override void OnAttributeRead (string attributeName
)
69 base.OnAttributeRead (attributeName
);
71 if (attributeName
== UriAttributeName
)