[banshee] Dap: refactoring to split method
- From: AndrÃs Aragoneses <aaragoneses src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [banshee] Dap: refactoring to split method
- Date: Thu, 3 Nov 2011 00:21:55 +0000 (UTC)
commit f0af36f4e5ef39e7aa7439bb4ac2eb13ae547b1f
Author: AndrÃs G. Aragoneses <knocte gmail com>
Date: Wed Nov 2 23:24:45 2011 +0000
Dap: refactoring to split method
Extract a method in the DapSync class so the
original is not so large. This also moves the
GUI bits from the namespace Banshee.Dap to
Banshee.Dap.Gui.
There is no change of behaviour in this commit.
src/Dap/Banshee.Dap/Banshee.Dap.Gui/DapActions.cs | 33 +++++++++++++++++++
src/Dap/Banshee.Dap/Banshee.Dap/DapSync.cs | 35 ++-------------------
2 files changed, 36 insertions(+), 32 deletions(-)
---
diff --git a/src/Dap/Banshee.Dap/Banshee.Dap.Gui/DapActions.cs b/src/Dap/Banshee.Dap/Banshee.Dap.Gui/DapActions.cs
index 8d05fd4..91112ac 100644
--- a/src/Dap/Banshee.Dap/Banshee.Dap.Gui/DapActions.cs
+++ b/src/Dap/Banshee.Dap/Banshee.Dap.Gui/DapActions.cs
@@ -31,6 +31,7 @@ using Mono.Unix;
using Gtk;
using Hyena;
+using Hyena.Widgets;
using Banshee.Dap;
using Banshee.Gui;
@@ -96,5 +97,37 @@ namespace Banshee.Dap.Gui
dap.Sync.Sync ();
}
}
+
+ internal static bool ConfirmUserAction (int tracks_to_remove)
+ {
+ string header = String.Format (
+ Catalog.GetPluralString (
+ // singular form unused b/c we know it's > 1, but we still need GetPlural
+ "The sync operation will remove one track from your device.",
+ "The sync operation will remove {0} tracks from your device.",
+ tracks_to_remove),
+ tracks_to_remove);
+ string message = Catalog.GetString ("Are you sure you want to continue?");
+
+ var md = new HigMessageDialog (
+ ServiceManager.Get<GtkElementsService> ().PrimaryWindow,
+ DialogFlags.DestroyWithParent, MessageType.Warning,
+ ButtonsType.None, header, message
+ );
+ md.AddButton ("gtk-cancel", ResponseType.No, true);
+ md.AddButton (Catalog.GetString ("Remove tracks"), ResponseType.Yes, false);
+
+ bool remove_tracks = false;
+ ThreadAssist.BlockingProxyToMain (() => {
+ try {
+ if (md.Run () == (int) ResponseType.Yes) {
+ remove_tracks = true;
+ }
+ } finally {
+ md.Destroy ();
+ }
+ });
+ return remove_tracks;
+ }
}
}
diff --git a/src/Dap/Banshee.Dap/Banshee.Dap/DapSync.cs b/src/Dap/Banshee.Dap/Banshee.Dap/DapSync.cs
index fc4e273..ceeb233 100644
--- a/src/Dap/Banshee.Dap/Banshee.Dap/DapSync.cs
+++ b/src/Dap/Banshee.Dap/Banshee.Dap/DapSync.cs
@@ -45,9 +45,7 @@ using Banshee.SmartPlaylist;
using Banshee.Query;
using Banshee.Preferences;
-using Banshee.Gui;
-using Hyena.Widgets;
-using Gtk;
+using Banshee.Dap.Gui;
namespace Banshee.Dap
{
@@ -359,37 +357,10 @@ namespace Banshee.Dap
library_sync.Sync ();
} catch (DapLibrarySync.PossibleUserErrorException e) {
- string header = String.Format (
- Catalog.GetPluralString (
- // singular form unused b/c we know it's > 1, but we still need GetPlural
- "The sync operation will remove one track from your device.",
- "The sync operation will remove {0} tracks from your device.",
- e.TracksToRemove),
- e.TracksToRemove);
- string message = Catalog.GetString ("Are you sure you want to continue?");
-
- HigMessageDialog md = new HigMessageDialog (
- ServiceManager.Get<GtkElementsService> ().PrimaryWindow,
- DialogFlags.DestroyWithParent, MessageType.Warning,
- ButtonsType.None, header, message
- );
- md.AddButton ("gtk-cancel", ResponseType.No, true);
- md.AddButton (Catalog.GetString ("Remove tracks"), ResponseType.Yes, false);
-
- bool remove_tracks = false;
- ThreadAssist.BlockingProxyToMain (() => {
- try {
- if (md.Run () == (int) ResponseType.Yes) {
- remove_tracks = true;
- }
- } finally {
- md.Destroy ();
- }
- });
-
- if (remove_tracks) {
+ if (DapActions.ConfirmUserAction (e.TracksToRemove)) {
library_sync.Sync (true);
}
+
}
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]