[banshee] [TrackEditor] Launch in readonly mode when saving metadata doesn't work
- From: Andrés Aragoneses <aaragoneses src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [banshee] [TrackEditor] Launch in readonly mode when saving metadata doesn't work
- Date: Mon, 24 May 2010 06:54:03 +0000 (UTC)
commit 454df5ee268aa6b5b9c9b76a0c6b9df67bb625a2
Author: Andrés G. Aragoneses <knocte gmail com>
Date: Mon May 24 08:39:42 2010 +0200
[TrackEditor] Launch in readonly mode when saving metadata doesn't work
As SaveTrackMetadataJob is currently a bit limited, we will now assume
by default that track's metadata cannot be edited, so the TrackEditor
will be launched as read-only mode in these cases. (BGO#611923)
.../Banshee.Library/LibrarySource.cs | 4 +
.../Banshee.Playlist/AbstractPlaylistSource.cs | 4 +
.../Banshee.Sources/DatabaseSource.cs | 4 -
.../Banshee.Gui.TrackEditor/AlbumArtistEntry.cs | 6 ++
.../Banshee.Gui.TrackEditor/FieldPage.cs | 7 ++-
.../Banshee.Gui.TrackEditor/GenreEntry.cs | 5 ++
.../Banshee.Gui.TrackEditor/IEditorField.cs | 2 +
.../Banshee.Gui.TrackEditor/LicenseEntry.cs | 5 ++
.../Banshee.Gui.TrackEditor/PageNavigationEntry.cs | 5 ++
.../Banshee.Gui.TrackEditor/PageType.cs | 1 +
.../Banshee.Gui.TrackEditor/RangeEntry.cs | 14 +++-
.../Banshee.Gui.TrackEditor/RatingEntry.cs | 5 ++
.../Banshee.Gui.TrackEditor/SortingPage.cs | 4 +
.../Banshee.Gui.TrackEditor/SpinButtonEntry.cs | 16 +++++
.../Banshee.Gui.TrackEditor/TextEntry.cs | 5 ++
.../Banshee.Gui.TrackEditor/TextViewEntry.cs | 5 ++
.../Banshee.Gui.TrackEditor/TrackEditorDialog.cs | 61 ++++++++++++++++---
.../Banshee.Gui/TrackActions.cs | 16 ++---
src/Extensions/Banshee.Bpm/Banshee.Bpm/BpmEntry.cs | 5 ++
19 files changed, 146 insertions(+), 28 deletions(-)
---
diff --git a/src/Core/Banshee.Services/Banshee.Library/LibrarySource.cs b/src/Core/Banshee.Services/Banshee.Library/LibrarySource.cs
index 50e9a28..4f573c0 100644
--- a/src/Core/Banshee.Services/Banshee.Library/LibrarySource.cs
+++ b/src/Core/Banshee.Services/Banshee.Library/LibrarySource.cs
@@ -93,6 +93,10 @@ namespace Banshee.Library
get { return UniqueId; }
}
+ public override bool HasEditableTrackProperties {
+ get { return true; }
+ }
+
public override string BaseDirectory {
get {
string dir = base_dir_schema.Get ();
diff --git a/src/Core/Banshee.Services/Banshee.Playlist/AbstractPlaylistSource.cs b/src/Core/Banshee.Services/Banshee.Playlist/AbstractPlaylistSource.cs
index 47b3e86..5ed6749 100644
--- a/src/Core/Banshee.Services/Banshee.Playlist/AbstractPlaylistSource.cs
+++ b/src/Core/Banshee.Services/Banshee.Playlist/AbstractPlaylistSource.cs
@@ -103,6 +103,10 @@ namespace Banshee.Playlist
set { primary_source_id = value.DbId; }
}
+ public override bool HasEditableTrackProperties {
+ get { return PrimarySource == null || PrimarySource.HasEditableTrackProperties; }
+ }
+
private HyenaSqliteCommand count_updated_command;
protected HyenaSqliteCommand CountUpdatedCommand {
get {
diff --git a/src/Core/Banshee.Services/Banshee.Sources/DatabaseSource.cs b/src/Core/Banshee.Services/Banshee.Sources/DatabaseSource.cs
index 6227f11..08ea6aa 100644
--- a/src/Core/Banshee.Services/Banshee.Sources/DatabaseSource.cs
+++ b/src/Core/Banshee.Services/Banshee.Sources/DatabaseSource.cs
@@ -308,10 +308,6 @@ namespace Banshee.Sources
get { return true; }
}
- public override bool HasEditableTrackProperties {
- get { return true; }
- }
-
#endregion
#region Filters (aka Browsers)
diff --git a/src/Core/Banshee.ThickClient/Banshee.Gui.TrackEditor/AlbumArtistEntry.cs b/src/Core/Banshee.ThickClient/Banshee.Gui.TrackEditor/AlbumArtistEntry.cs
index f96ccb7..988c14a 100644
--- a/src/Core/Banshee.ThickClient/Banshee.Gui.TrackEditor/AlbumArtistEntry.cs
+++ b/src/Core/Banshee.ThickClient/Banshee.Gui.TrackEditor/AlbumArtistEntry.cs
@@ -84,6 +84,12 @@ namespace Banshee.Gui.TrackEditor
set { entry.Text = value ?? String.Empty; }
}
+ public void SetAsReadOnly ()
+ {
+ entry.IsEditable = false;
+ enable_compilation.Sensitive = false;
+ }
+
private void OnChanged (object o, EventArgs args)
{
UpdateSensitivities ();
diff --git a/src/Core/Banshee.ThickClient/Banshee.Gui.TrackEditor/FieldPage.cs b/src/Core/Banshee.ThickClient/Banshee.Gui.TrackEditor/FieldPage.cs
index 37a172f..32bf23e 100644
--- a/src/Core/Banshee.ThickClient/Banshee.Gui.TrackEditor/FieldPage.cs
+++ b/src/Core/Banshee.ThickClient/Banshee.Gui.TrackEditor/FieldPage.cs
@@ -134,6 +134,12 @@ namespace Banshee.Gui.TrackEditor
public FieldSlot AddField (Box parent, Widget label, Widget field, string syncTooltip, FieldLabelClosure labelClosure,
FieldValueClosure readClosure, FieldValueClosure writeClosure, FieldValueClosure syncClosure, FieldOptions options)
{
+ var editor_field = field as IEditorField;
+
+ if (editor_field != null && dialog.Mode == EditorMode.View) {
+ editor_field.SetAsReadOnly ();
+ }
+
FieldSlot slot = new FieldSlot ();
slot.Parent = parent;
@@ -168,7 +174,6 @@ namespace Banshee.Gui.TrackEditor
AttachOptions.Expand | AttachOptions.Fill,
AttachOptions.Fill, 0, 0);
- IEditorField editor_field = field as IEditorField;
if (editor_field != null) {
editor_field.Changed += delegate {
if (CurrentTrack != null) {
diff --git a/src/Core/Banshee.ThickClient/Banshee.Gui.TrackEditor/GenreEntry.cs b/src/Core/Banshee.ThickClient/Banshee.Gui.TrackEditor/GenreEntry.cs
index 1dbfb91..ff086f6 100644
--- a/src/Core/Banshee.ThickClient/Banshee.Gui.TrackEditor/GenreEntry.cs
+++ b/src/Core/Banshee.ThickClient/Banshee.Gui.TrackEditor/GenreEntry.cs
@@ -78,5 +78,10 @@ namespace Banshee.Gui.TrackEditor
get { return Entry.Text; }
set { Entry.Text = value ?? String.Empty; }
}
+
+ public void SetAsReadOnly ()
+ {
+ Sensitive = false;
+ }
}
}
diff --git a/src/Core/Banshee.ThickClient/Banshee.Gui.TrackEditor/IEditorField.cs b/src/Core/Banshee.ThickClient/Banshee.Gui.TrackEditor/IEditorField.cs
index 5f0ade2..552f12f 100644
--- a/src/Core/Banshee.ThickClient/Banshee.Gui.TrackEditor/IEditorField.cs
+++ b/src/Core/Banshee.ThickClient/Banshee.Gui.TrackEditor/IEditorField.cs
@@ -33,5 +33,7 @@ namespace Banshee.Gui.TrackEditor
public interface IEditorField
{
event EventHandler Changed;
+
+ void SetAsReadOnly ();
}
}
diff --git a/src/Core/Banshee.ThickClient/Banshee.Gui.TrackEditor/LicenseEntry.cs b/src/Core/Banshee.ThickClient/Banshee.Gui.TrackEditor/LicenseEntry.cs
index 3efae68..29149aa 100644
--- a/src/Core/Banshee.ThickClient/Banshee.Gui.TrackEditor/LicenseEntry.cs
+++ b/src/Core/Banshee.ThickClient/Banshee.Gui.TrackEditor/LicenseEntry.cs
@@ -79,5 +79,10 @@ namespace Banshee.Gui.TrackEditor
get { return Entry.Text; }
set { Entry.Text = value ?? String.Empty; }
}
+
+ public void SetAsReadOnly ()
+ {
+ Sensitive = false;
+ }
}
}
diff --git a/src/Core/Banshee.ThickClient/Banshee.Gui.TrackEditor/PageNavigationEntry.cs b/src/Core/Banshee.ThickClient/Banshee.Gui.TrackEditor/PageNavigationEntry.cs
index a0d5100..6d80d78 100644
--- a/src/Core/Banshee.ThickClient/Banshee.Gui.TrackEditor/PageNavigationEntry.cs
+++ b/src/Core/Banshee.ThickClient/Banshee.Gui.TrackEditor/PageNavigationEntry.cs
@@ -117,5 +117,10 @@ namespace Banshee.Gui.TrackEditor
get { return entry.Text; }
set { entry.Text = value; }
}
+
+ public void SetAsReadOnly ()
+ {
+ entry.IsEditable = false;
+ }
}
}
diff --git a/src/Core/Banshee.ThickClient/Banshee.Gui.TrackEditor/PageType.cs b/src/Core/Banshee.ThickClient/Banshee.Gui.TrackEditor/PageType.cs
index e2cfed9..7f61c7c 100644
--- a/src/Core/Banshee.ThickClient/Banshee.Gui.TrackEditor/PageType.cs
+++ b/src/Core/Banshee.ThickClient/Banshee.Gui.TrackEditor/PageType.cs
@@ -33,6 +33,7 @@ namespace Banshee.Gui.TrackEditor
public enum PageType
{
Edit,
+ EditOnly,
View,
ViewOnly
}
diff --git a/src/Core/Banshee.ThickClient/Banshee.Gui.TrackEditor/RangeEntry.cs b/src/Core/Banshee.ThickClient/Banshee.Gui.TrackEditor/RangeEntry.cs
index c2e5071..e2aed7a 100644
--- a/src/Core/Banshee.ThickClient/Banshee.Gui.TrackEditor/RangeEntry.cs
+++ b/src/Core/Banshee.ThickClient/Banshee.Gui.TrackEditor/RangeEntry.cs
@@ -38,13 +38,13 @@ namespace Banshee.Gui.TrackEditor
public event EventHandler Changed;
- private SpinButton from_entry;
- public SpinButton From {
+ private SpinButtonEntry from_entry;
+ public SpinButtonEntry From {
get { return from_entry; }
}
- private SpinButton to_entry;
- public SpinButton To {
+ private SpinButtonEntry to_entry;
+ public SpinButtonEntry To {
get { return to_entry; }
}
@@ -76,6 +76,12 @@ namespace Banshee.Gui.TrackEditor
to_entry.ValueChanged += OnChanged;
}
+ public void SetAsReadOnly ()
+ {
+ from_entry.IsEditable = false;
+ to_entry.IsEditable = false;
+ }
+
protected override bool OnMnemonicActivated (bool group_cycling) {
return from_entry.MnemonicActivate(group_cycling);
}
diff --git a/src/Core/Banshee.ThickClient/Banshee.Gui.TrackEditor/RatingEntry.cs b/src/Core/Banshee.ThickClient/Banshee.Gui.TrackEditor/RatingEntry.cs
index 033008f..144738f 100644
--- a/src/Core/Banshee.ThickClient/Banshee.Gui.TrackEditor/RatingEntry.cs
+++ b/src/Core/Banshee.ThickClient/Banshee.Gui.TrackEditor/RatingEntry.cs
@@ -37,5 +37,10 @@ namespace Banshee.Gui.TrackEditor
{
AlwaysShowEmptyStars = true;
}
+
+ public void SetAsReadOnly ()
+ {
+ Sensitive = false;
+ }
}
}
diff --git a/src/Core/Banshee.ThickClient/Banshee.Gui.TrackEditor/SortingPage.cs b/src/Core/Banshee.ThickClient/Banshee.Gui.TrackEditor/SortingPage.cs
index 243e3d8..c3504c0 100644
--- a/src/Core/Banshee.ThickClient/Banshee.Gui.TrackEditor/SortingPage.cs
+++ b/src/Core/Banshee.ThickClient/Banshee.Gui.TrackEditor/SortingPage.cs
@@ -42,6 +42,10 @@ namespace Banshee.Gui.TrackEditor
get { return Catalog.GetString ("Sorting"); }
}
+ public override PageType PageType {
+ get { return PageType.EditOnly; }
+ }
+
protected override void AddFields ()
{
AddField (this, new TextEntry (),
diff --git a/src/Core/Banshee.ThickClient/Banshee.Gui.TrackEditor/SpinButtonEntry.cs b/src/Core/Banshee.ThickClient/Banshee.Gui.TrackEditor/SpinButtonEntry.cs
index 4b3a7ae..4018817 100644
--- a/src/Core/Banshee.ThickClient/Banshee.Gui.TrackEditor/SpinButtonEntry.cs
+++ b/src/Core/Banshee.ThickClient/Banshee.Gui.TrackEditor/SpinButtonEntry.cs
@@ -42,6 +42,22 @@ namespace Banshee.Gui.TrackEditor
{
}
+ public void SetAsReadOnly ()
+ {
+ IsEditable = false;
+ }
+
+ //FIXME: workaround for BGO#611825, remove it when it's fixed:
+ public new double Value {
+ set {
+ base.Value = value;
+ if (!IsEditable) {
+ Adjustment = new Adjustment (value, value, value, 0, 0, 0);
+ }
+ }
+ get { return base.Value; }
+ }
+
// Make sure the value is updated every time the text is changed, not just when the focus leaves
// this SpinButton, since that may be too late
protected override void OnChanged ()
diff --git a/src/Core/Banshee.ThickClient/Banshee.Gui.TrackEditor/TextEntry.cs b/src/Core/Banshee.ThickClient/Banshee.Gui.TrackEditor/TextEntry.cs
index ce60f28..253b81b 100644
--- a/src/Core/Banshee.ThickClient/Banshee.Gui.TrackEditor/TextEntry.cs
+++ b/src/Core/Banshee.ThickClient/Banshee.Gui.TrackEditor/TextEntry.cs
@@ -78,5 +78,10 @@ namespace Banshee.Gui.TrackEditor
get { return base.Text; }
set { base.Text = value ?? String.Empty; }
}
+
+ public void SetAsReadOnly ()
+ {
+ IsEditable = false;
+ }
}
}
diff --git a/src/Core/Banshee.ThickClient/Banshee.Gui.TrackEditor/TextViewEntry.cs b/src/Core/Banshee.ThickClient/Banshee.Gui.TrackEditor/TextViewEntry.cs
index 4ec2f86..7e95f37 100644
--- a/src/Core/Banshee.ThickClient/Banshee.Gui.TrackEditor/TextViewEntry.cs
+++ b/src/Core/Banshee.ThickClient/Banshee.Gui.TrackEditor/TextViewEntry.cs
@@ -82,6 +82,11 @@ namespace Banshee.Gui.TrackEditor
undo_adapter.ConnectUndo (entry, track);
}
+ public void SetAsReadOnly ()
+ {
+ entry.IsEditable = false;
+ }
+
protected override bool OnMnemonicActivated (bool group_cycling) {
return entry.MnemonicActivate(group_cycling);
}
diff --git a/src/Core/Banshee.ThickClient/Banshee.Gui.TrackEditor/TrackEditorDialog.cs b/src/Core/Banshee.ThickClient/Banshee.Gui.TrackEditor/TrackEditorDialog.cs
index 9c371db..1954638 100644
--- a/src/Core/Banshee.ThickClient/Banshee.Gui.TrackEditor/TrackEditorDialog.cs
+++ b/src/Core/Banshee.ThickClient/Banshee.Gui.TrackEditor/TrackEditorDialog.cs
@@ -76,27 +76,43 @@ namespace Banshee.Gui.TrackEditor
private PulsingButton sync_all_button;
private EditorMode mode;
+ internal EditorMode Mode {
+ get { return mode; }
+ }
+
+ private bool readonly_tabs = false;
private List<ITrackEditorPage> pages = new List<ITrackEditorPage> ();
public event EventHandler Navigated;
- private TrackEditorDialog (TrackListModel model, EditorMode mode) : base (
+ private TrackEditorDialog (TrackListModel model, EditorMode mode)
+ : this (model, mode, false)
+ {
+ }
+
+ private TrackEditorDialog (TrackListModel model, EditorMode mode, bool readonlyTabs) : base (
mode == EditorMode.Edit ? Catalog.GetString ("Track Editor") : Catalog.GetString ("Track Properties"))
{
+ readonly_tabs = readonlyTabs;
this.mode = mode;
LoadTrackModel (model);
- if (mode == EditorMode.Edit) {
+ if (mode == EditorMode.Edit || readonly_tabs) {
WidthRequest = 525;
- AddStockButton (Stock.Cancel, ResponseType.Cancel);
- AddStockButton (Stock.Save, ResponseType.Ok);
+ if (mode == EditorMode.Edit) {
+ AddStockButton (Stock.Cancel, ResponseType.Cancel);
+ AddStockButton (Stock.Save, ResponseType.Ok);
+ }
} else {
- AddStockButton (Stock.Close, ResponseType.Close, true);
SetSizeRequest (400, 500);
}
+ if (mode == EditorMode.View) {
+ AddStockButton (Stock.Close, ResponseType.Close, true);
+ }
+
tooltip_host = TooltipSetter.CreateHost ();
AddNavigationButtons ();
@@ -196,11 +212,24 @@ namespace Banshee.Gui.TrackEditor
notebook = new Notebook ();
notebook.Show ();
+ Gtk.Widget page_to_focus = null;
foreach (TypeExtensionNode node in AddinManager.GetExtensionNodes ("/Banshee/Gui/TrackEditor/NotebookPage")) {
try {
ITrackEditorPage page = (ITrackEditorPage)node.CreateInstance ();
- if ((mode == EditorMode.Edit && (page.PageType == PageType.Edit || page.PageType == PageType.View)) ||
- (mode == EditorMode.View && (page.PageType == PageType.View || page.PageType == PageType.ViewOnly))) {
+ bool show = false;
+ if (mode == EditorMode.Edit && (page.PageType != PageType.ViewOnly)) {
+ show = true;
+ } else if (mode == EditorMode.View) {
+ if (readonly_tabs) {
+ show = page.PageType != PageType.EditOnly;
+ } else {
+ show = page.PageType == PageType.View || page.PageType == PageType.ViewOnly;
+ }
+ }
+ if (show) {
+ if (page is StatisticsPage && mode == EditorMode.View) {
+ page_to_focus = (StatisticsPage)page;
+ }
pages.Add (page);
page.Initialize (this);
page.Widget.Show ();
@@ -223,6 +252,9 @@ namespace Banshee.Gui.TrackEditor
}
main_vbox.PackStart (notebook, true, true, 0);
+ if (page_to_focus != null) {
+ notebook.CurrentPage = notebook.PageNum (page_to_focus);
+ }
}
private void BuildFooter ()
@@ -599,14 +631,23 @@ namespace Banshee.Gui.TrackEditor
Run (model, EditorMode.Edit);
}
- public static void RunView (TrackListModel model)
+ public static void RunView (TrackListModel model, bool readonlyTabs)
{
- Run (model, EditorMode.View);
+ Run (model, EditorMode.View, readonlyTabs);
}
public static void Run (TrackListModel model, EditorMode mode)
{
- TrackEditorDialog track_editor = new TrackEditorDialog (model, mode);
+ Run (new TrackEditorDialog (model, mode));
+ }
+
+ private static void Run (TrackListModel model, EditorMode mode, bool readonlyTabs)
+ {
+ Run (new TrackEditorDialog (model, mode, readonlyTabs));
+ }
+
+ private static void Run (TrackEditorDialog track_editor)
+ {
track_editor.Response += delegate (object o, ResponseArgs args) {
if (args.ResponseId == ResponseType.Ok) {
track_editor.Save ();
diff --git a/src/Core/Banshee.ThickClient/Banshee.Gui/TrackActions.cs b/src/Core/Banshee.ThickClient/Banshee.Gui/TrackActions.cs
index f4a2884..368f6a4 100644
--- a/src/Core/Banshee.ThickClient/Banshee.Gui/TrackActions.cs
+++ b/src/Core/Banshee.ThickClient/Banshee.Gui/TrackActions.cs
@@ -42,6 +42,7 @@ using Banshee.Collection;
using Banshee.Collection.Database;
using Banshee.ServiceStack;
using Banshee.Widgets;
+using Banshee.Gui;
using Banshee.Gui.Dialogs;
using Banshee.Gui.Widgets;
@@ -241,7 +242,7 @@ namespace Banshee.Gui
UpdateAction ("TrackPropertiesAction", source.HasViewableTrackProperties, has_selection, source);
UpdateAction ("TrackEditorAction", source.HasEditableTrackProperties, has_selection, source);
- UpdateAction ("RateTracksAction", in_database, has_selection, null);
+ UpdateAction ("RateTracksAction", source.HasEditableTrackProperties, has_selection, null);
UpdateAction ("AddToPlaylistAction", in_database && primary_source != null &&
primary_source.SupportsPlaylists && !primary_source.PlaylistsReadOnly, has_selection, null);
@@ -311,14 +312,17 @@ namespace Banshee.Gui
private void OnTrackProperties (object o, EventArgs args)
{
if (current_source != null && !RunSourceOverrideHandler ("TrackPropertiesActionHandler")) {
- Banshee.Gui.TrackEditor.TrackEditorDialog.RunView (current_source.TrackModel);
+ var s = current_source as Source;
+ var readonly_tabs = s != null && !s.HasEditableTrackProperties;
+ TrackEditor.TrackEditorDialog.RunView (current_source.TrackModel,
+ readonly_tabs);
}
}
private void OnTrackEditor (object o, EventArgs args)
{
if (current_source != null && !RunSourceOverrideHandler ("TrackEditorActionHandler")) {
- Banshee.Gui.TrackEditor.TrackEditorDialog.RunEdit (current_source.TrackModel);
+ TrackEditor.TrackEditorDialog.RunEdit (current_source.TrackModel);
}
}
@@ -540,11 +544,5 @@ namespace Banshee.Gui
}
return ret;
}
-
- // Reserve strings in preparation for the 1.5.5 string freeze (BGO#611923)
- public void ReservedStrings ()
- {
- Catalog.GetString ("View Track Information");
- }
}
}
diff --git a/src/Extensions/Banshee.Bpm/Banshee.Bpm/BpmEntry.cs b/src/Extensions/Banshee.Bpm/Banshee.Bpm/BpmEntry.cs
index 4260d22..2d7797e 100644
--- a/src/Extensions/Banshee.Bpm/Banshee.Bpm/BpmEntry.cs
+++ b/src/Extensions/Banshee.Bpm/Banshee.Bpm/BpmEntry.cs
@@ -71,6 +71,11 @@ namespace Banshee.Bpm
};
}
+ public void SetAsReadOnly ()
+ {
+ Sensitive = false;
+ }
+
private void BuildWidgets ()
{
Spacing = 6;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]