[banshee] AlbumListView: Allow subclasses to switch between album grid and list
- From: Bertrand Lorentz <blorentz src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [banshee] AlbumListView: Allow subclasses to switch between album grid and list
- Date: Sun, 20 Jan 2013 18:14:36 +0000 (UTC)
commit 8bd2b8ee29797b292b67a2842d3b9101b588a4a6
Author: Bertrand Lorentz <bertrand lorentz gmail com>
Date: Sun Jan 20 18:16:25 2013 +0100
AlbumListView: Allow subclasses to switch between album grid and list
Add SwitchToAlbumList and SwitchToAlbumGrid protected methods, so that
AlbumListView subclasses can choose whether to display the album grid
or the old album list.
The "Disable album grid" preference is not changed by these methods, and
it still determines the initial display. This means subclasses must be
careful if they don't want to follow the preference.
.../Banshee.Collection.Gui/AlbumListView.cs | 43 +++++++++++---------
1 files changed, 24 insertions(+), 19 deletions(-)
---
diff --git a/src/Core/Banshee.ThickClient/Banshee.Collection.Gui/AlbumListView.cs b/src/Core/Banshee.ThickClient/Banshee.Collection.Gui/AlbumListView.cs
index 26dfaab..3d94d7e 100644
--- a/src/Core/Banshee.ThickClient/Banshee.Collection.Gui/AlbumListView.cs
+++ b/src/Core/Banshee.ThickClient/Banshee.Collection.Gui/AlbumListView.cs
@@ -96,7 +96,11 @@ namespace Banshee.Collection.Gui
return;
}
- DisabledAlbumGrid = DisableAlbumGrid.Get ();
+ if (DisableAlbumGrid.Get ()) {
+ SwitchToAlbumList ();
+ } else {
+ SwitchToAlbumGrid ();
+ }
}
private PreferenceBase disable_album_grid;
@@ -114,7 +118,7 @@ namespace Banshee.Collection.Gui
private void InstallPreferences ()
{
music_lib = ServiceManager.SourceManager.MusicLibrary;
- disable_album_grid = music_lib.PreferencesPage["misc"].Add (DisableAlbumGridPref);
+ disable_album_grid = music_lib.PreferencesPage["misc"].FindOrAdd (DisableAlbumGridPref);
ServiceManager.SourceManager.SourceAdded -= InstallPreferences;
}
@@ -131,24 +135,25 @@ namespace Banshee.Collection.Gui
ServiceManager.SourceManager.SourceRemoved -= UninstallPreferences;
}
- private bool DisabledAlbumGrid {
- get { return DisableAlbumGrid.Get (); }
- set {
- DisableAlbumGrid.Set (value);
- if (value) {
- ViewLayout = null;
- if (classic_layout_column == null)
- classic_layout_column = new Column ("Album", renderer, 1.0);
- column_controller.Add (classic_layout_column);
- ColumnController = column_controller;
- } else {
- if (classic_layout_column != null)
- column_controller.Remove (classic_layout_column);
- ColumnController = null;
- ViewLayout = grid_layout;
- }
- album_grid_rendered = !value;
+ protected void SwitchToAlbumList ()
+ {
+ ViewLayout = null;
+ if (classic_layout_column == null) {
+ classic_layout_column = new Column ("Album", renderer, 1.0);
+ }
+ column_controller.Add (classic_layout_column);
+ ColumnController = column_controller;
+ album_grid_rendered = false;
+ }
+
+ protected void SwitchToAlbumGrid ()
+ {
+ if (classic_layout_column != null) {
+ column_controller.Remove (classic_layout_column);
}
+ ColumnController = null;
+ ViewLayout = grid_layout;
+ album_grid_rendered = true;
}
private static SchemaPreference<bool> DisableAlbumGridPref = null;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]