banshee r4485 - in trunk/banshee: . src/Core/Banshee.ThickClient/Banshee.Gui src/Dap/Banshee.Dap src/Dap/Banshee.Dap/Banshee.Dap src/Dap/Banshee.Dap/Banshee.Dap.Gui src/Dap/Banshee.Dap/Resources
- From: gburt svn gnome org
- To: svn-commits-list gnome org
- Subject: banshee r4485 - in trunk/banshee: . src/Core/Banshee.ThickClient/Banshee.Gui src/Dap/Banshee.Dap src/Dap/Banshee.Dap/Banshee.Dap src/Dap/Banshee.Dap/Banshee.Dap.Gui src/Dap/Banshee.Dap/Resources
- Date: Mon, 8 Sep 2008 02:47:48 +0000 (UTC)
Author: gburt
Date: Mon Sep 8 02:47:48 2008
New Revision: 4485
URL: http://svn.gnome.org/viewvc/banshee?rev=4485&view=rev
Log:
2008-09-07 Gabriel Burt <gabriel burt gmail com>
* src/Dap/Banshee.Dap/Banshee.Dap/DapSource.cs: Create GUI objects on the
GUI thread.
* src/Dap/Banshee.Dap/Makefile.am:
* src/Dap/Banshee.Dap/Resources/ActiveSourceUI.xml:
* src/Dap/Banshee.Dap/Resources/GlobalUI.xml: Move the Sync context menu
item to GlobalUI.
* src/Dap/Banshee.Dap/Banshee.Dap.Gui/DapContent.cs:
* src/Dap/Banshee.Dap/Banshee.Dap.Gui/DapActions.cs: Make the DapActions
static and work for multiple DapSources, including updating properly when
right-clicked on even if not the ActiveSource.
* src/Core/Banshee.ThickClient/Banshee.Gui/SourceActions.cs: Add an event
for when we update the actions, so that other action groups or code that
needs to update them for right-click context menus can easily do that.
Added:
trunk/banshee/src/Dap/Banshee.Dap/Resources/GlobalUI.xml
Modified:
trunk/banshee/ChangeLog
trunk/banshee/src/Core/Banshee.ThickClient/Banshee.Gui/SourceActions.cs
trunk/banshee/src/Dap/Banshee.Dap/Banshee.Dap.Gui/DapActions.cs
trunk/banshee/src/Dap/Banshee.Dap/Banshee.Dap.Gui/DapContent.cs
trunk/banshee/src/Dap/Banshee.Dap/Banshee.Dap/DapSource.cs
trunk/banshee/src/Dap/Banshee.Dap/Makefile.am
trunk/banshee/src/Dap/Banshee.Dap/Resources/ActiveSourceUI.xml
Modified: trunk/banshee/src/Core/Banshee.ThickClient/Banshee.Gui/SourceActions.cs
==============================================================================
--- trunk/banshee/src/Core/Banshee.ThickClient/Banshee.Gui/SourceActions.cs (original)
+++ trunk/banshee/src/Core/Banshee.ThickClient/Banshee.Gui/SourceActions.cs Mon Sep 8 02:47:48 2008
@@ -56,6 +56,8 @@
set { source_view = value; }
}
+ public event Action<Source> Updated;
+
public Source ActionSource {
get { return ((SourceView == null) ? null : SourceView.HighlightedSource) ?? ActiveSource; }
}
@@ -376,6 +378,11 @@
if (source != null) {
UpdateAction ("SortChildrenAction", source.Children.Count > 1, true, null);
}
+
+ Action<Source> handler = Updated;
+ if (handler != null) {
+ handler (source);
+ }
}
private static bool ConfirmUnmap (IUnmapableSource source)
Modified: trunk/banshee/src/Dap/Banshee.Dap/Banshee.Dap.Gui/DapActions.cs
==============================================================================
--- trunk/banshee/src/Dap/Banshee.Dap/Banshee.Dap.Gui/DapActions.cs (original)
+++ trunk/banshee/src/Dap/Banshee.Dap/Banshee.Dap.Gui/DapActions.cs Mon Sep 8 02:47:48 2008
@@ -32,36 +32,70 @@
using Banshee.Dap;
using Banshee.Gui;
+using Banshee.ServiceStack;
namespace Banshee.Dap.Gui
{
public class DapActions : BansheeActionGroup
{
- private DapSource dap;
- public DapActions (DapSource dap) : base ("dap")
+ private DapSource previous_dap = null;
+ private DapSource Dap {
+ get { return Actions.SourceActions.ActionSource as DapSource; }
+ }
+
+ public DapActions () : base ("dap")
{
- this.dap = dap;
AddImportant (
new ActionEntry ("SyncDapAction", null,
Catalog.GetString ("Synchronize"), null,
- String.Format (Catalog.GetString ("Synchronize {0}"), dap.Name), OnSyncDap)
+ String.Empty, OnSyncDap)
);
+
+ AddUiFromFile ("GlobalUI.xml");
this["SyncDapAction"].IconName = Stock.Refresh;
- UpdateActions ();
- dap.Sync.Updated += delegate { Banshee.Base.ThreadAssist.ProxyToMain (UpdateActions); };
+ ServiceManager.SourceManager.ActiveSourceChanged += OnActiveSourceChanged;
+ Actions.SourceActions.Updated += delegate { UpdateActions (); };
+ OnActiveSourceChanged (null);
+
+ Register ();
+ }
+
+ private void OnActiveSourceChanged (EventArgs args)
+ {
+ if (previous_dap != null) {
+ previous_dap.Sync.Updated -= OnSyncUpdated;
+ }
+
+ previous_dap = ActiveSource as DapSource;
+
+ if (previous_dap != null) {
+ previous_dap.Sync.Updated += OnSyncUpdated;
+ }
+ }
+
+ private void OnSyncUpdated (DapSync sync)
+ {
+ Banshee.Base.ThreadAssist.ProxyToMain (UpdateActions);
}
private void UpdateActions ()
{
- UpdateAction ("SyncDapAction", dap.Sync.Enabled && !dap.Sync.AutoSync);
+ DapSource dap = Dap;
+ if (dap != null) {
+ UpdateAction ("SyncDapAction", dap.Sync.Enabled && !dap.Sync.AutoSync);
+ this["SyncDapAction"].Label = String.Format (Catalog.GetString ("Synchronize {0}"), dap.Name);
+ }
}
private void OnSyncDap (object o, EventArgs args)
{
- Banshee.Base.ThreadAssist.SpawnFromMain (delegate {
- dap.Sync.Sync ();
- });
+ DapSource dap = Dap;
+ if (dap != null) {
+ Banshee.Base.ThreadAssist.SpawnFromMain (delegate {
+ dap.Sync.Sync ();
+ });
+ }
}
}
}
Modified: trunk/banshee/src/Dap/Banshee.Dap/Banshee.Dap.Gui/DapContent.cs
==============================================================================
--- trunk/banshee/src/Dap/Banshee.Dap/Banshee.Dap.Gui/DapContent.cs (original)
+++ trunk/banshee/src/Dap/Banshee.Dap/Banshee.Dap.Gui/DapContent.cs Mon Sep 8 02:47:48 2008
@@ -42,7 +42,6 @@
public class DapContent : DapPropertiesDisplay
{
private DapSource dap;
- private DapActions actions;
private VBox vbox;
private WrapLabel dap_stats;
@@ -88,8 +87,11 @@
private void BuildActions ()
{
- actions = new DapActions (dap);
- dap.Properties.Set<Banshee.Gui.BansheeActionGroup> ("ActiveSourceActions", actions);
+ if (actions == null) {
+ actions = new DapActions ();
+ }
}
+
+ private static Banshee.Gui.BansheeActionGroup actions;
}
}
Modified: trunk/banshee/src/Dap/Banshee.Dap/Banshee.Dap/DapSource.cs
==============================================================================
--- trunk/banshee/src/Dap/Banshee.Dap/Banshee.Dap/DapSource.cs (original)
+++ trunk/banshee/src/Dap/Banshee.Dap/Banshee.Dap/DapSource.cs Mon Sep 8 02:47:48 2008
@@ -188,7 +188,10 @@
AddChildSource (podcast_group_source = new PodcastGroupSource (this));
BuildPreferences ();
- Properties.Set<Banshee.Sources.Gui.ISourceContents> ("Nereid.SourceContents", new DapContent (this));
+
+ ThreadAssist.ProxyToMain (delegate {
+ Properties.Set<Banshee.Sources.Gui.ISourceContents> ("Nereid.SourceContents", new DapContent (this));
+ });
}
private void BuildPreferences ()
Modified: trunk/banshee/src/Dap/Banshee.Dap/Makefile.am
==============================================================================
--- trunk/banshee/src/Dap/Banshee.Dap/Makefile.am (original)
+++ trunk/banshee/src/Dap/Banshee.Dap/Makefile.am Mon Sep 8 02:47:48 2008
@@ -22,7 +22,8 @@
RESOURCES = \
Banshee.Dap.addin.xml \
- Resources/ActiveSourceUI.xml
+ Resources/ActiveSourceUI.xml \
+ Resources/GlobalUI.xml
include $(top_srcdir)/build/build.mk
Modified: trunk/banshee/src/Dap/Banshee.Dap/Resources/ActiveSourceUI.xml
==============================================================================
--- trunk/banshee/src/Dap/Banshee.Dap/Resources/ActiveSourceUI.xml (original)
+++ trunk/banshee/src/Dap/Banshee.Dap/Resources/ActiveSourceUI.xml Mon Sep 8 02:47:48 2008
@@ -5,10 +5,4 @@
<toolitem action="SyncDapAction"/>
</placeholder>
</toolbar>
-
- <popup name="RemovableSourceContextMenu" action="RemovableSourceContextMenuAction">
- <placeholder name="AboveImportSource">
- <menuitem action="SyncDapAction"/>
- </placeholder>
- </popup>
</ui>
Added: trunk/banshee/src/Dap/Banshee.Dap/Resources/GlobalUI.xml
==============================================================================
--- (empty file)
+++ trunk/banshee/src/Dap/Banshee.Dap/Resources/GlobalUI.xml Mon Sep 8 02:47:48 2008
@@ -0,0 +1,7 @@
+<ui>
+ <popup name="RemovableSourceContextMenu" action="RemovableSourceContextMenuAction">
+ <placeholder name="AboveImportSource">
+ <menuitem action="SyncDapAction"/>
+ </placeholder>
+ </popup>
+</ui>
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]