banshee r3748 - in trunk/banshee: . src/Clients/Nereid/Nereid src/Core/Banshee.Core/Banshee.Configuration src/Core/Banshee.ThickClient src/Core/Banshee.ThickClient/Banshee.Collection.Gui src/Core/Banshee.ThickClient/Banshee.Gui src/Core/Banshee.ThickClient/Banshee.Sources.Gui
- From: scottp svn gnome org
- To: svn-commits-list gnome org
- Subject: banshee r3748 - in trunk/banshee: . src/Clients/Nereid/Nereid src/Core/Banshee.Core/Banshee.Configuration src/Core/Banshee.ThickClient src/Core/Banshee.ThickClient/Banshee.Collection.Gui src/Core/Banshee.ThickClient/Banshee.Gui src/Core/Banshee.ThickClient/Banshee.Sources.Gui
- Date: Thu, 10 Apr 2008 09:08:06 +0100 (BST)
Author: scottp
Date: Thu Apr 10 09:08:06 2008
New Revision: 3748
URL: http://svn.gnome.org/viewvc/banshee?rev=3748&view=rev
Log:
* src/Clients/Nereid/Nereid/PlayerInterface.cs: Use the fancy new
PersistantPanController. FANCY!
* src/Core/Banshee.ThickClient/Banshee.Collection.Gui/PersistentColumnController.cs:
Got rid of now-unnessisary volatile modifier.
* src/Core/Banshee.ThickClient/Banshee.Gui/PersistentPaneController.cs:
The PersistentPanController can be used to save/restore the
position of a Gtk.Pane automatically. Passing a Gtk.Paned and some
schema info to the static Control method will set it up and it will
always do the right thing.
* src/Core/Banshee.ThickClient/Banshee.Sources.Gui/CompositeTrackSourceContents.cs:
Use PeristentPaneController for browser panes. This fixes BGO
#522470.
* src/Core/Banshee.Core/Banshee.Configuration/SchemaEntry.cs: Since
this is a public struct, we do the neighborly thing and impliment
IEquatable. I thought I was going to use this but ended up not
doing so. Still, it's the right thing to do.
Added:
trunk/banshee/src/Core/Banshee.ThickClient/Banshee.Gui/PersistentPaneController.cs
Modified:
trunk/banshee/ChangeLog
trunk/banshee/src/Clients/Nereid/Nereid/PlayerInterface.cs
trunk/banshee/src/Core/Banshee.Core/Banshee.Configuration/SchemaEntry.cs
trunk/banshee/src/Core/Banshee.ThickClient/Banshee.Collection.Gui/PersistentColumnController.cs
trunk/banshee/src/Core/Banshee.ThickClient/Banshee.Sources.Gui/CompositeTrackSourceContents.cs
trunk/banshee/src/Core/Banshee.ThickClient/Banshee.ThickClient.mdp
trunk/banshee/src/Core/Banshee.ThickClient/Makefile.am
Modified: trunk/banshee/src/Clients/Nereid/Nereid/PlayerInterface.cs
==============================================================================
--- trunk/banshee/src/Clients/Nereid/Nereid/PlayerInterface.cs (original)
+++ trunk/banshee/src/Clients/Nereid/Nereid/PlayerInterface.cs Thu Apr 10 09:08:06 2008
@@ -77,7 +77,6 @@
{
BuildPrimaryLayout ();
ConnectEvents ();
- LoadSettings ();
ActionService.TrackActions.TrackSelector = this;
ActionService.SourceActions.SourceView = this;
@@ -172,6 +171,7 @@
VBox source_box = new VBox ();
views_pane = new HPaned ();
+ PersistentPaneController.Control (views_pane, SourceViewWidth);
view_container = new ViewContainer ();
source_view = new SourceView ();
@@ -223,15 +223,6 @@
}
#endregion
-
-#region Configuration Loading/Saving
-
- private void LoadSettings ()
- {
- views_pane.Position = SourceViewWidth.Get ();
- }
-
-#endregion
#region Events and Logic Setup
Modified: trunk/banshee/src/Core/Banshee.Core/Banshee.Configuration/SchemaEntry.cs
==============================================================================
--- trunk/banshee/src/Core/Banshee.Core/Banshee.Configuration/SchemaEntry.cs (original)
+++ trunk/banshee/src/Core/Banshee.Core/Banshee.Configuration/SchemaEntry.cs Thu Apr 10 09:08:06 2008
@@ -26,9 +26,11 @@
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
+using System;
+
namespace Banshee.Configuration
{
- public struct SchemaEntry<T>
+ public struct SchemaEntry<T> : IEquatable<SchemaEntry<T>>
{
public static SchemaEntry<T> Zero;
@@ -62,5 +64,20 @@
public readonly T DefaultValue;
public readonly string ShortDescription;
public readonly string LongDescription;
+
+ public bool Equals (SchemaEntry<T> entry)
+ {
+ return Namespace == entry.Namespace && Key == entry.Key;
+ }
+
+ public override bool Equals (object o)
+ {
+ return (o is SchemaEntry<T>) && Equals ((SchemaEntry<T>)o);
+ }
+
+ public override int GetHashCode ()
+ {
+ return Namespace.GetHashCode () ^ Key.GetHashCode ();
+ }
}
}
Modified: trunk/banshee/src/Core/Banshee.ThickClient/Banshee.Collection.Gui/PersistentColumnController.cs
==============================================================================
--- trunk/banshee/src/Core/Banshee.ThickClient/Banshee.Collection.Gui/PersistentColumnController.cs (original)
+++ trunk/banshee/src/Core/Banshee.ThickClient/Banshee.Collection.Gui/PersistentColumnController.cs Thu Apr 10 09:08:06 2008
@@ -39,7 +39,7 @@
{
private string root_namespace;
private bool loaded = false;
- private volatile bool pending_changes;
+ private bool pending_changes;
private uint timer_id = 0;
private string source_id;
Added: trunk/banshee/src/Core/Banshee.ThickClient/Banshee.Gui/PersistentPaneController.cs
==============================================================================
--- (empty file)
+++ trunk/banshee/src/Core/Banshee.ThickClient/Banshee.Gui/PersistentPaneController.cs Thu Apr 10 09:08:06 2008
@@ -0,0 +1,104 @@
+//
+// PersistentPanedController.cs
+//
+// Author:
+// Scott Peterson <lunchtimemama gmail com>
+//
+// Copyright (c) 2008 Scott Peterson
+//
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in
+// all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+// THE SOFTWARE.
+//
+
+using System;
+using System.Collections.Generic;
+using Gtk;
+
+using Banshee.Configuration;
+
+namespace Banshee.Gui
+{
+ public class PersistentPaneController
+ {
+ private static Dictionary<string, PersistentPaneController> controllers = new Dictionary<string, PersistentPaneController> ();
+
+ private string @namespace;
+ private string key;
+ private int fallback;
+ private uint timer_id = 0;
+ private bool pending_changes;
+ private Paned pane;
+
+ public static void Control (Paned pane, string name)
+ {
+ Control (pane, "interface.panes." + name, "position", pane.Position);
+ }
+
+ public static void Control (Paned pane, SchemaEntry<int> entry)
+ {
+ Control (pane, entry.Namespace, entry.Key, entry.DefaultValue);
+ }
+
+ private static void Control (Paned pane, string @namespace, string key, int defaultValue)
+ {
+ string dict_key = String.Format ("{0}.{1}", @namespace, key);
+ if (controllers.ContainsKey (dict_key)) {
+ controllers[dict_key].Paned = pane;
+ } else {
+ controllers.Add (dict_key, new PersistentPaneController (pane, @namespace, key, defaultValue));
+ }
+ }
+
+ private PersistentPaneController (Paned pane, string @namespace, string key, int fallback)
+ {
+ this namespace = @namespace;
+ this.key = key;
+ this.fallback = fallback;
+ Paned = pane;
+ }
+
+ private Paned Paned {
+ set {
+ pane = value;
+ pane.Position = ConfigurationClient.Get<int> (@namespace, key, fallback);
+ pane.SizeAllocated += delegate { Save (); };
+ }
+ }
+
+ private void Save ()
+ {
+ if (timer_id == 0) {
+ timer_id = GLib.Timeout.Add (500, OnTimeout);
+ } else {
+ pending_changes = true;
+ }
+ }
+
+ private bool OnTimeout ()
+ {
+ if (pending_changes) {
+ pending_changes = false;
+ return true;
+ } else {
+ ConfigurationClient.Set<int> (@namespace, key, pane.Position);
+ timer_id = 0;
+ return false;
+ }
+ }
+ }
+}
Modified: trunk/banshee/src/Core/Banshee.ThickClient/Banshee.Sources.Gui/CompositeTrackSourceContents.cs
==============================================================================
--- trunk/banshee/src/Core/Banshee.ThickClient/Banshee.Sources.Gui/CompositeTrackSourceContents.cs (original)
+++ trunk/banshee/src/Core/Banshee.ThickClient/Banshee.Sources.Gui/CompositeTrackSourceContents.cs Thu Apr 10 09:08:06 2008
@@ -209,6 +209,7 @@
artist_album_box.Add2 (album_scrolled_window);
artist_album_box.Position = 350;
+ PersistentPaneController.Control (artist_album_box, "browser.left.artist_album_box");
container.Add1 (artist_album_box);
container.Add2 (track_scrolled_window);
@@ -216,6 +217,7 @@
browser_container = artist_album_box;
container.Position = 275;
+ PersistentPaneController.Control (container, "browser.left");
ShowPack ();
}
@@ -236,6 +238,7 @@
browser_container = artist_album_box;
container.Position = 175;
+ PersistentPaneController.Control (container, "browser.top");
ShowPack ();
}
Modified: trunk/banshee/src/Core/Banshee.ThickClient/Banshee.ThickClient.mdp
==============================================================================
--- trunk/banshee/src/Core/Banshee.ThickClient/Banshee.ThickClient.mdp (original)
+++ trunk/banshee/src/Core/Banshee.ThickClient/Banshee.ThickClient.mdp Thu Apr 10 09:08:06 2008
@@ -95,6 +95,8 @@
<File name="Banshee.Sources.Gui/ITrackModelSourceContents.cs" subtype="Code" buildaction="Compile" />
<File name="Banshee.Gui/PlaybackShuffleActions.cs" subtype="Code" buildaction="Compile" />
<File name="Banshee.Gui.Dialogs/ExtensionManagerDialog.cs" subtype="Code" buildaction="Compile" />
+ <File name="Banshee.Gui/PersistentPaneController.cs" subtype="Code" buildaction="Compile" />
+ <File name="Banshee.Collection.Gui/ColumnCellPositiveInt.cs" subtype="Code" buildaction="Compile" />
</Contents>
<References>
<ProjectReference type="Project" localcopy="False" refto="Hyena.Gui" />
Modified: trunk/banshee/src/Core/Banshee.ThickClient/Makefile.am
==============================================================================
--- trunk/banshee/src/Core/Banshee.ThickClient/Makefile.am (original)
+++ trunk/banshee/src/Core/Banshee.ThickClient/Makefile.am Thu Apr 10 09:08:06 2008
@@ -58,6 +58,7 @@
Banshee.Gui/IconThemeUtils.cs \
Banshee.Gui/IHasSourceView.cs \
Banshee.Gui/InterfaceActionService.cs \
+ Banshee.Gui/PersistentPaneController.cs \
Banshee.Gui/PlaybackActions.cs \
Banshee.Gui/PlaybackRepeatActions.cs \
Banshee.Gui/PlaybackShuffleActions.cs \
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]