tomboy r2268 - in trunk: . Tomboy/Addins/Backlinks Tomboy/Addins/Bugzilla Tomboy/Addins/Evolution Tomboy/Addins/ExportToHtml Tomboy/Addins/PrintNotes Tomboy/Addins/Tasque Tomboy/Notebooks
- From: sharm svn gnome org
- To: svn-commits-list gnome org
- Subject: tomboy r2268 - in trunk: . Tomboy/Addins/Backlinks Tomboy/Addins/Bugzilla Tomboy/Addins/Evolution Tomboy/Addins/ExportToHtml Tomboy/Addins/PrintNotes Tomboy/Addins/Tasque Tomboy/Notebooks
- Date: Sat, 27 Dec 2008 17:23:22 +0000 (UTC)
Author: sharm
Date: Sat Dec 27 17:23:22 2008
New Revision: 2268
URL: http://svn.gnome.org/viewvc/tomboy?rev=2268&view=rev
Log:
* tomboy/Tomboy/Notebooks/NotebookNoteAddin.cs:
* tomboy/Tomboy/Addins/Bugzilla/BugzillaLink.cs:
* tomboy/Tomboy/Addins/Tasque/TasqueNoteAddin.cs:
* tomboy/Tomboy/Addins/Backlinks/BacklinkMenuItem.cs:
* tomboy/Tomboy/Notebooks/NotebookApplicationAddin.cs:
* tomboy/Tomboy/Addins/Evolution/EvolutionNoteAddin.cs:
* tomboy/Tomboy/Addins/Backlinks/BacklinksNoteAddin.cs:
* tomboy/Tomboy/Addins/PrintNotes/PrintNotesNoteAddin.cs:
* tomboy/Tomboy/Addins/ExportToHtml/ExportToHtmlNoteAddin.cs: Memory
savings, lazy-loading; beginnings of fix for bug #565790 (reduce
Tomboy memory footprint at startup). For NoteAddins, moved a lot of
work from Initialize to OnNoteOpened. In general, moved
instantiation of some objects from static constructor to lazy-loading
static properties.
Modified:
trunk/ChangeLog
trunk/Tomboy/Addins/Backlinks/BacklinkMenuItem.cs
trunk/Tomboy/Addins/Backlinks/BacklinksNoteAddin.cs
trunk/Tomboy/Addins/Bugzilla/BugzillaLink.cs
trunk/Tomboy/Addins/Evolution/EvolutionNoteAddin.cs
trunk/Tomboy/Addins/ExportToHtml/ExportToHtmlNoteAddin.cs
trunk/Tomboy/Addins/PrintNotes/PrintNotesNoteAddin.cs
trunk/Tomboy/Addins/Tasque/TasqueNoteAddin.cs
trunk/Tomboy/Notebooks/NotebookApplicationAddin.cs
trunk/Tomboy/Notebooks/NotebookNoteAddin.cs
Modified: trunk/Tomboy/Addins/Backlinks/BacklinkMenuItem.cs
==============================================================================
--- trunk/Tomboy/Addins/Backlinks/BacklinkMenuItem.cs (original)
+++ trunk/Tomboy/Addins/Backlinks/BacklinkMenuItem.cs Sat Dec 27 17:23:22 2008
@@ -11,17 +11,21 @@
static Gdk.Pixbuf note_icon;
- static BacklinkMenuItem ()
+ static Gdk.Pixbuf NoteIcon
{
- note_icon = GuiUtils.GetIcon ("note", 16);
+ get {
+ if (note_icon == null)
+ note_icon = GuiUtils.GetIcon ("note", 16);
+ return note_icon;
+ }
}
-public BacklinkMenuItem (Note note, string title_search) :
- base (note.Title)
+ public BacklinkMenuItem (Note note, string title_search) :
+ base (note.Title)
{
this.note = note;
this.title_search = title_search;
- this.Image = new Gtk.Image (note_icon);
+ this.Image = new Gtk.Image (NoteIcon);
}
protected override void OnActivated ()
Modified: trunk/Tomboy/Addins/Backlinks/BacklinksNoteAddin.cs
==============================================================================
--- trunk/Tomboy/Addins/Backlinks/BacklinksNoteAddin.cs (original)
+++ trunk/Tomboy/Addins/Backlinks/BacklinksNoteAddin.cs Sat Dec 27 17:23:22 2008
@@ -17,7 +17,20 @@
public override void Initialize ()
{
submenu_built = false;
+ }
+
+ public override void Shutdown ()
+ {
+ // The following two lines are required to prevent the plugin
+ // from leaking references when the plugin is disabled.
+ if (menu != null)
+ menu.Hidden -= OnMenuHidden;
+ if (menu_item != null)
+ menu_item.Activated -= OnMenuItemActivated;
+ }
+ public override void OnNoteOpened ()
+ {
menu = new Gtk.Menu ();
menu.Hidden += OnMenuHidden;
menu.ShowAll ();
@@ -30,18 +43,6 @@
AddPluginMenuItem (menu_item);
}
- public override void Shutdown ()
- {
- // The following two lines are required to prevent the plugin
- // from leaking references when the plugin is disabled.
- menu.Hidden -= OnMenuHidden;
- menu_item.Activated -= OnMenuItemActivated;
- }
-
- public override void OnNoteOpened ()
- {
- }
-
void OnMenuItemActivated (object sender, EventArgs args)
{
if (submenu_built == true)
Modified: trunk/Tomboy/Addins/Bugzilla/BugzillaLink.cs
==============================================================================
--- trunk/Tomboy/Addins/Bugzilla/BugzillaLink.cs (original)
+++ trunk/Tomboy/Addins/Bugzilla/BugzillaLink.cs Sat Dec 27 17:23:22 2008
@@ -9,12 +9,16 @@
//private const string StockIconFilename = "bug.png";
private static Gdk.Pixbuf bug_icon;
- static BugzillaLink ()
+ private static Gdk.Pixbuf BugIcon
{
- bug_icon = GuiUtils.GetIcon (
- System.Reflection.Assembly.GetExecutingAssembly (),
- "bug",
- 16);
+ get {
+ if (bug_icon == null)
+ bug_icon = GuiUtils.GetIcon (
+ System.Reflection.Assembly.GetExecutingAssembly (),
+ "bug",
+ 16);
+ return bug_icon;
+ }
}
public override void Initialize (string element_name)
@@ -48,7 +52,7 @@
} catch {}
if (uri == null) {
- Image = bug_icon;
+ Image = BugIcon;
return;
}
@@ -60,7 +64,7 @@
try {
Image = new Gdk.Pixbuf (imagePath);
} catch (GLib.GException) {
- Image = bug_icon;
+ Image = BugIcon;
}
}
Modified: trunk/Tomboy/Addins/Evolution/EvolutionNoteAddin.cs
==============================================================================
--- trunk/Tomboy/Addins/Evolution/EvolutionNoteAddin.cs (original)
+++ trunk/Tomboy/Addins/Evolution/EvolutionNoteAddin.cs Sat Dec 27 17:23:22 2008
@@ -210,13 +210,17 @@
{
static Gdk.Pixbuf mail_icon = null;
- static EmailLink ()
+ static Gdk.Pixbuf MailIcon
{
- mail_icon =
- GuiUtils.GetIcon (
- System.Reflection.Assembly.GetExecutingAssembly (),
- "mail",
- 16);
+ get {
+ if (mail_icon == null)
+ mail_icon =
+ GuiUtils.GetIcon (
+ System.Reflection.Assembly.GetExecutingAssembly (),
+ "mail",
+ 16);
+ return mail_icon;
+ }
}
public EmailLink ()
@@ -232,7 +236,7 @@
Foreground = "blue";
CanActivate = true;
- Image = mail_icon;
+ Image = MailIcon;
}
public string EmailUri
Modified: trunk/Tomboy/Addins/ExportToHtml/ExportToHtmlNoteAddin.cs
==============================================================================
--- trunk/Tomboy/Addins/ExportToHtml/ExportToHtmlNoteAddin.cs (original)
+++ trunk/Tomboy/Addins/ExportToHtml/ExportToHtmlNoteAddin.cs Sat Dec 27 17:23:22 2008
@@ -19,51 +19,56 @@
Gtk.ImageMenuItem item;
- static ExportToHtmlNoteAddin ()
+ static XslTransform NoteXsl
{
- Assembly asm = Assembly.GetExecutingAssembly ();
- string asm_dir = System.IO.Path.GetDirectoryName (asm.Location);
- string stylesheet_file = Path.Combine (asm_dir, stylesheet_name);
-
- xsl = new XslTransform ();
-
- if (File.Exists (stylesheet_file)) {
- Logger.Log ("ExportToHTML: Using user-custom {0} file.",
- stylesheet_name);
- xsl.Load (stylesheet_file);
- } else {
- Stream resource = asm.GetManifestResourceStream (stylesheet_name);
- if (resource != null) {
- XmlTextReader reader = new XmlTextReader (resource);
- xsl.Load (reader, null, null);
- resource.Close ();
- } else {
- Logger.Log ("Unable to find HTML export template '{0}'.",
- stylesheet_name);
+ get {
+ if (xsl == null) {
+ Assembly asm = Assembly.GetExecutingAssembly ();
+ string asm_dir = System.IO.Path.GetDirectoryName (asm.Location);
+ string stylesheet_file = Path.Combine (asm_dir, stylesheet_name);
+
+ xsl = new XslTransform ();
+
+ if (File.Exists (stylesheet_file)) {
+ Logger.Log ("ExportToHTML: Using user-custom {0} file.",
+ stylesheet_name);
+ xsl.Load (stylesheet_file);
+ } else {
+ Stream resource = asm.GetManifestResourceStream (stylesheet_name);
+ if (resource != null) {
+ XmlTextReader reader = new XmlTextReader (resource);
+ xsl.Load (reader, null, null);
+ resource.Close ();
+ } else {
+ Logger.Log ("Unable to find HTML export template '{0}'.",
+ stylesheet_name);
+ }
+ }
}
+ return xsl;
}
}
public override void Initialize ()
{
- item =
- new Gtk.ImageMenuItem (Catalog.GetString ("Export to HTML"));
- item.Image = new Gtk.Image (Gtk.Stock.Save, Gtk.IconSize.Menu);
- item.Activated += ExportButtonClicked;
- item.Show ();
- AddPluginMenuItem (item);
}
public override void Shutdown ()
{
// Disconnect the event handlers so
// there aren't any memory leaks.
- item.Activated -= ExportButtonClicked;
+ if (item != null)
+ item.Activated -= ExportButtonClicked;
}
public override void OnNoteOpened ()
{
- // Do nothing.
+ item =
+ new Gtk.ImageMenuItem (Catalog.GetString ("Export to HTML"));
+ item.Image = new Gtk.Image (Gtk.Stock.Save, Gtk.IconSize.Menu);
+ item.Activated += ExportButtonClicked;
+ item.Show ();
+ AddPluginMenuItem (item);
}
void ExportButtonClicked (object sender, EventArgs args)
@@ -191,7 +196,7 @@
}
NoteNameResolver resolver = new NoteNameResolver (note.Manager, note);
- xsl.Transform (doc, args, writer, resolver);
+ NoteXsl.Transform (doc, args, writer, resolver);
}
}
Modified: trunk/Tomboy/Addins/PrintNotes/PrintNotesNoteAddin.cs
==============================================================================
--- trunk/Tomboy/Addins/PrintNotes/PrintNotesNoteAddin.cs (original)
+++ trunk/Tomboy/Addins/PrintNotes/PrintNotesNoteAddin.cs Sat Dec 27 17:23:22 2008
@@ -15,23 +15,23 @@
public override void Initialize ()
{
- item = new Gtk.ImageMenuItem (Catalog.GetString ("Print"));
- item.Image = new Gtk.Image (Gtk.Stock.Print, Gtk.IconSize.Menu);
- item.Activated += PrintButtonClicked;
- item.Show ();
- AddPluginMenuItem (item);
}
public override void Shutdown ()
{
// Disconnect the event handlers so
// there aren't any memory leaks.
- item.Activated -= PrintButtonClicked;
+ if (item != null)
+ item.Activated -= PrintButtonClicked;
}
public override void OnNoteOpened ()
{
- // Do nothing.
+ item = new Gtk.ImageMenuItem (Catalog.GetString ("Print"));
+ item.Image = new Gtk.Image (Gtk.Stock.Print, Gtk.IconSize.Menu);
+ item.Activated += PrintButtonClicked;
+ item.Show ();
+ AddPluginMenuItem (item);
}
[DllImport("libprintnotes")]
Modified: trunk/Tomboy/Addins/Tasque/TasqueNoteAddin.cs
==============================================================================
--- trunk/Tomboy/Addins/Tasque/TasqueNoteAddin.cs (original)
+++ trunk/Tomboy/Addins/Tasque/TasqueNoteAddin.cs Sat Dec 27 17:23:22 2008
@@ -18,12 +18,15 @@
static string TasqueNamespace = "org.gnome.Tasque";
static Gdk.Pixbuf tasqueIcon = null;
-
- static TasqueNoteAddin ()
- {
- tasqueIcon =
- GuiUtils.GetIcon (System.Reflection.Assembly.GetExecutingAssembly (),
- "tasque", 22);
+
+ static Gdk.Pixbuf TasqueIcon {
+ get {
+ if (tasqueIcon == null)
+ tasqueIcon =
+ GuiUtils.GetIcon (System.Reflection.Assembly.GetExecutingAssembly (),
+ "tasque", 22);
+ return tasqueIcon;
+ }
}
Gtk.MenuToolButton menuToolButton;
@@ -54,7 +57,7 @@
menu.Hidden += OnMenuHidden;
menu.ShowAll ();
- Gtk.Image tasqueImage = new Gtk.Image (tasqueIcon);
+ Gtk.Image tasqueImage = new Gtk.Image (TasqueIcon);
tasqueImage.Show ();
menuToolButton =
new Gtk.MenuToolButton (tasqueImage, Catalog.GetString ("Tasque"));
Modified: trunk/Tomboy/Notebooks/NotebookApplicationAddin.cs
==============================================================================
--- trunk/Tomboy/Notebooks/NotebookApplicationAddin.cs (original)
+++ trunk/Tomboy/Notebooks/NotebookApplicationAddin.cs Sat Dec 27 17:23:22 2008
@@ -12,11 +12,22 @@
static Gdk.Pixbuf notebookIcon;
static Gdk.Pixbuf newNotebookIcon;
- static NotebookApplicationAddin ()
+ static Gdk.Pixbuf NotebookIcon
{
- notebookIcon = GuiUtils.GetIcon ("notebook", 16);
- newNotebookIcon = GuiUtils.GetIcon ("notebook-new", 16);
-
+ get {
+ if (notebookIcon == null)
+ notebookIcon = GuiUtils.GetIcon ("notebook", 16);
+ return notebookIcon;
+ }
+ }
+
+ static Gdk.Pixbuf NewNotebookIcon
+ {
+ get {
+ if (newNotebookIcon == null)
+ newNotebookIcon = GuiUtils.GetIcon ("notebook-new", 16);
+ return newNotebookIcon;
+ }
}
bool initialized;
@@ -96,7 +107,7 @@
if (item != null) {
if (item is Gtk.ImageMenuItem) {
Gtk.ImageMenuItem imageItem = item as Gtk.ImageMenuItem;
- (imageItem.Image as Gtk.Image).Pixbuf = notebookIcon;
+ (imageItem.Image as Gtk.Image).Pixbuf = NotebookIcon;
}
trayNotebookMenu = new Gtk.Menu ();
item.Submenu = trayNotebookMenu;
@@ -110,7 +121,7 @@
if (imageitem != null) {
if (imageitem is Gtk.ImageMenuItem) {
Gtk.ImageMenuItem imageItem = imageitem as Gtk.ImageMenuItem;
- (imageItem.Image as Gtk.Image).Pixbuf = notebookIcon;
+ (imageItem.Image as Gtk.Image).Pixbuf = NotebookIcon;
}
mainWindowNotebookMenu = new Gtk.Menu ();
imageitem.Submenu = mainWindowNotebookMenu;
@@ -210,7 +221,7 @@
// Add in the "New Notebook..." menu item
Gtk.ImageMenuItem newNotebookMenuItem =
new Gtk.ImageMenuItem (Catalog.GetString ("New Note_book..."));
- newNotebookMenuItem.Image = new Gtk.Image (newNotebookIcon);
+ newNotebookMenuItem.Image = new Gtk.Image (NewNotebookIcon);
newNotebookMenuItem.Activated += OnNewNotebookMenuItem;
newNotebookMenuItem.ShowAll ();
menu.Append (newNotebookMenuItem);
Modified: trunk/Tomboy/Notebooks/NotebookNoteAddin.cs
==============================================================================
--- trunk/Tomboy/Notebooks/NotebookNoteAddin.cs (original)
+++ trunk/Tomboy/Notebooks/NotebookNoteAddin.cs Sat Dec 27 17:23:22 2008
@@ -13,23 +13,33 @@
static Gdk.Pixbuf notebookIcon;
static Gdk.Pixbuf newNotebookIcon;
- static NotebookNoteAddin ()
+ static Gdk.Pixbuf NotebookIcon
{
- notebookIcon = GuiUtils.GetIcon ("notebook", 22);
- newNotebookIcon = GuiUtils.GetIcon ("notebook-new", 16);
+ get {
+ if (notebookIcon == null)
+ notebookIcon = GuiUtils.GetIcon ("notebook", 22);
+ return notebookIcon;
+ }
+ }
+
+ static Gdk.Pixbuf NewNotebookIcon
+ {
+ get {
+ if (newNotebookIcon == null)
+ newNotebookIcon = GuiUtils.GetIcon ("notebook-new", 16);
+ return newNotebookIcon;
+ }
}
public override void Initialize ()
{
- menu = new Gtk.Menu ();
- menu.ShowAll ();
}
private void InitializeToolButton ()
{
toolButton =
new ToolMenuButton (Note.Window.Toolbar,
- new Gtk.Image (notebookIcon),
+ new Gtk.Image (NotebookIcon),
string.Empty, menu);
toolButton.Homogeneous = false;
Gtk.Tooltips toolbarTips = new Gtk.Tooltips ();
@@ -60,6 +70,11 @@
public override void OnNoteOpened ()
{
+ if (menu == null) {
+ menu = new Gtk.Menu ();
+ menu.ShowAll ();
+ }
+
if (toolButton == null) {
InitializeToolButton ();
@@ -139,7 +154,7 @@
// Add the "New Notebook..."
Gtk.ImageMenuItem newNotebookMenuItem =
new Gtk.ImageMenuItem (Catalog.GetString ("_New notebook..."));
- newNotebookMenuItem.Image = new Gtk.Image (newNotebookIcon);
+ newNotebookMenuItem.Image = new Gtk.Image (NewNotebookIcon);
newNotebookMenuItem.Activated += OnNewNotebookMenuItem;
newNotebookMenuItem.Show ();
menu.Append (newNotebookMenuItem);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]