[tomboy] Disable synchronization menu items unless a backend is configured
- From: Benjamin Podszun <bpodszun src gnome org>
- To: svn-commits-list gnome org
- Subject: [tomboy] Disable synchronization menu items unless a backend is configured
- Date: Fri, 22 May 2009 06:46:57 -0400 (EDT)
commit 5bfe43adc8d6e76b69febdafb81d479c3a066ced
Author: Benjamin Podszun <benjamin podszun gmail com>
Date: Fri May 22 12:45:53 2009 +0200
Disable synchronization menu items unless a backend is configured
Fixes bug #473335
---
Tomboy/NoteWindow.cs | 33 +++++++++++++++++++++++++++------
Tomboy/Synchronization/SyncManager.cs | 20 ++++++++++++++++++--
2 files changed, 45 insertions(+), 8 deletions(-)
diff --git a/Tomboy/NoteWindow.cs b/Tomboy/NoteWindow.cs
index 2da95ab..35e0422 100644
--- a/Tomboy/NoteWindow.cs
+++ b/Tomboy/NoteWindow.cs
@@ -18,6 +18,7 @@ namespace Tomboy
Gtk.ToolButton link_button;
NoteTextMenu text_menu;
Gtk.Menu plugin_menu;
+ Gtk.ImageMenuItem sync_menu_item;
Gtk.TextView editor;
Gtk.ScrolledWindow editor_window;
NoteFindBar find_bar;
@@ -184,6 +185,8 @@ namespace Tomboy
protected override bool OnDeleteEvent (Gdk.Event evnt)
{
+ Preferences.SettingChanged -= Preferences_SettingChanged;
+
CloseWindowHandler (null, null);
return true;
}
@@ -507,17 +510,35 @@ namespace Tomboy
tb.Insert (new Gtk.SeparatorToolItem (), -1);
- Gtk.ImageMenuItem item =
- new Gtk.ImageMenuItem (Catalog.GetString ("Synchronize Notes"));
- item.Image = new Gtk.Image (Gtk.Stock.Convert, Gtk.IconSize.Menu);
- item.Activated += SyncItemSelected;
- item.Show ();
- PluginMenu.Add (item);
+ sync_menu_item = new Gtk.ImageMenuItem (Catalog.GetString ("Synchronize Notes"));
+ sync_menu_item.Image = new Gtk.Image (Gtk.Stock.Convert, Gtk.IconSize.Menu);
+ sync_menu_item.Activated += SyncItemSelected;
+ sync_menu_item.Show ();
+ PluginMenu.Add (sync_menu_item);
+
+ // We might want to know when various settings are altered.
+ Preferences.SettingChanged += Preferences_SettingChanged;
+
+ // Update items based on configuration.
+ UpdateMenuItems ();
tb.ShowAll ();
return tb;
}
+ void Preferences_SettingChanged (object sender, EventArgs args)
+ {
+ // Update items based on configuration.
+ UpdateMenuItems ();
+ }
+
+ void UpdateMenuItems ()
+ {
+ // Is synchronization configured and active?
+ string sync_addin_id = Preferences.Get (Preferences.SYNC_SELECTED_SERVICE_ADDIN) as string;
+ sync_menu_item.Sensitive = !string.IsNullOrEmpty (sync_addin_id);
+ }
+
void SyncItemSelected (object sender, EventArgs args)
{
Tomboy.ActionManager ["NoteSynchronizationAction"].Activate ();
diff --git a/Tomboy/Synchronization/SyncManager.cs b/Tomboy/Synchronization/SyncManager.cs
index 51c0fcf..e2d7924 100644
--- a/Tomboy/Synchronization/SyncManager.cs
+++ b/Tomboy/Synchronization/SyncManager.cs
@@ -151,7 +151,7 @@ namespace Tomboy.Sync
// is the first reference to SyncManager
///
- /// Add a "Synchronize Notes" to Tomboy's Tray Icon Menu
+ /// Add a "Synchronize Notes" to Tomboy's Main Menu
///
Gtk.ActionGroup action_group = new Gtk.ActionGroup ("Sync");
action_group.Add (new Gtk.ActionEntry [] {
@@ -162,7 +162,6 @@ namespace Tomboy.Sync
delegate {
Tomboy.ActionManager ["NoteSynchronizationAction"].Activate ();
})
-// delegate { SyncManager.OpenNoteSyncWindow (); })
});
Tomboy.ActionManager.UI.AddUiFromString (@"
@@ -191,6 +190,23 @@ namespace Tomboy.Sync
// TODO: Call something like AddinManager.Disable (addin)
}
}
+
+ Preferences.SettingChanged += Preferences_SettingChanged;
+
+ // Update sync item based on configuration.
+ UpdateSyncAction ();
+ }
+
+ static void Preferences_SettingChanged (object sender, EventArgs args)
+ {
+ // Update sync item based on configuration.
+ UpdateSyncAction ();
+ }
+
+ static void UpdateSyncAction ()
+ {
+ string sync_addin_id = Preferences.Get (Preferences.SYNC_SELECTED_SERVICE_ADDIN) as string;
+ Tomboy.ActionManager["SyncNotesAction"].Sensitive = !string.IsNullOrEmpty (sync_addin_id);
}
public static void PerformSynchronization ()
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]