[tomboy/better-templates: 2/3] Make NotebookNoteAddin handle button sensitivity when untemplating
- From: Sanford Armstrong <sharm src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [tomboy/better-templates: 2/3] Make NotebookNoteAddin handle button sensitivity when untemplating
- Date: Sun, 25 Jul 2010 16:59:42 +0000 (UTC)
commit b226a069e097961411403c0be309d8a1d5928493
Author: Sandy Armstrong <sanfordarmstrong gmail com>
Date: Sun Jul 25 09:39:50 2010 -0700
Make NotebookNoteAddin handle button sensitivity when untemplating
Tomboy/Notebooks/NotebookNoteAddin.cs | 41 +++++++++++++++++++++++++--------
1 files changed, 31 insertions(+), 10 deletions(-)
---
diff --git a/Tomboy/Notebooks/NotebookNoteAddin.cs b/Tomboy/Notebooks/NotebookNoteAddin.cs
index 201db5a..b066e54 100644
--- a/Tomboy/Notebooks/NotebookNoteAddin.cs
+++ b/Tomboy/Notebooks/NotebookNoteAddin.cs
@@ -11,6 +11,16 @@ namespace Tomboy.Notebooks
Gtk.Menu menu;
static Gdk.Pixbuf notebookIcon;
static Gdk.Pixbuf newNotebookIcon;
+ static Tag templateTag;
+
+ static Tag TemplateTag
+ {
+ get {
+ if (templateTag == null)
+ templateTag = TagManager.GetOrCreateSystemTag (TagManager.TemplateNoteSystemTag);
+ return templateTag;
+ }
+ }
static Gdk.Pixbuf NotebookIcon
{
@@ -53,6 +63,18 @@ namespace Tomboy.Notebooks
NotebookManager.NoteAddedToNotebook += OnNoteAddedToNotebook;
NotebookManager.NoteRemovedFromNotebook += OnNoteRemovedFromNotebook;
+
+
+ Note.TagAdded += delegate (Note taggedNote, Tag tag) {
+ if (taggedNote == Note && tag == TemplateTag)
+ UpdateButtonSensitivity (true);
+ };
+
+ // TODO: Make sure this is handled in NotebookNoteAddin, too
+ Note.TagRemoved += delegate (Note taggedNote, string tag) {
+ if (taggedNote == Note && tag == TemplateTag.NormalizedName)
+ UpdateButtonSensitivity (false);
+ };
}
public override void Shutdown ()
@@ -77,18 +99,17 @@ namespace Tomboy.Notebooks
if (toolButton == null) {
InitializeToolButton ();
-
- // Disable the notebook button if this note is a template note
- Tag templateTag = TagManager.GetOrCreateSystemTag (TagManager.TemplateNoteSystemTag);
- if (Note.ContainsTag (templateTag) == true) {
- toolButton.Sensitive = false;
-
- // Also prevent notebook templates from being deleted
- if (NotebookManager.GetNotebookFromNote (Note) != null)
- Note.Window.DeleteButton.Sensitive = false;
- }
+ UpdateButtonSensitivity (Note.ContainsTag (TemplateTag));
}
}
+
+ private void UpdateButtonSensitivity (bool isTemplate)
+ {
+ if (toolButton != null)
+ toolButton.Sensitive = !isTemplate;
+ if (Note.HasWindow)
+ Note.Window.DeleteButton.Sensitive = !isTemplate || NotebookManager.GetNotebookFromNote (Note) == null;
+ }
void OnMenuShown (object sender, EventArgs args)
{
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]