banshee r3913 - in trunk/banshee: . libbanshee src/Core/Banshee.Services src/Core/Banshee.ThickClient src/Core/Banshee.ThickClient/Banshee.Sources.Gui src/Extensions/Banshee.MiniMode src/Extensions/Banshee.MiniMode/Banshee.MiniMode
- From: abock svn gnome org
- To: svn-commits-list gnome org
- Subject: banshee r3913 - in trunk/banshee: . libbanshee src/Core/Banshee.Services src/Core/Banshee.ThickClient src/Core/Banshee.ThickClient/Banshee.Sources.Gui src/Extensions/Banshee.MiniMode src/Extensions/Banshee.MiniMode/Banshee.MiniMode
- Date: Fri, 9 May 2008 22:44:21 +0100 (BST)
Author: abock
Date: Fri May 9 21:44:20 2008
New Revision: 3913
URL: http://svn.gnome.org/viewvc/banshee?rev=3913&view=rev
Log:
2008-05-09 Aaron Bockover <abock gnome org>
* src/Core/Banshee.ThickClient/Banshee.Sources.Gui/SourceComboBox.cs:
Moved from MiniMode; use the new SourceModel and use the SourceRowRenderer
* src/Core/Banshee.ThickClient/Banshee.Sources.Gui/SourceModel.cs: Pulled
out model specific code from SourceView into a new TreeModel subclass
that SourceView and SourceComboBox can use
* src/Core/Banshee.ThickClient/Banshee.Sources.Gui/SourceRowRenderer.cs:
Implemented proper CellRendererState -> StateType mapping so the renderer
works properly inside other widgets (i.e. GtkComboBox); add some default
sizing for non TreeView widgets
* src/Core/Banshee.ThickClient/Banshee.Sources.Gui/SourceView.cs:
* src/Core/Banshee.ThickClient/Banshee.Sources.Gui/SourceView_DragAndDrop.cs:
Fixed up to use the new SourceModel
* src/Extensions/Banshee.MiniMode/Banshee.MiniMode/MiniModeWindow.cs:
Fixed up to use the new SourceComboBox
Added:
trunk/banshee/src/Core/Banshee.ThickClient/Banshee.Sources.Gui/SourceComboBox.cs
- copied, changed from r3903, /trunk/banshee/src/Extensions/Banshee.MiniMode/Banshee.MiniMode/SourceComboBox.cs
trunk/banshee/src/Core/Banshee.ThickClient/Banshee.Sources.Gui/SourceModel.cs
Removed:
trunk/banshee/src/Extensions/Banshee.MiniMode/Banshee.MiniMode/SourceComboBox.cs
Modified:
trunk/banshee/ChangeLog
trunk/banshee/libbanshee/libbanshee.mdp
trunk/banshee/src/Core/Banshee.Services/Banshee.Services.mdp
trunk/banshee/src/Core/Banshee.ThickClient/Banshee.Sources.Gui/SourceRowRenderer.cs
trunk/banshee/src/Core/Banshee.ThickClient/Banshee.Sources.Gui/SourceView.cs
trunk/banshee/src/Core/Banshee.ThickClient/Banshee.Sources.Gui/SourceView_DragAndDrop.cs
trunk/banshee/src/Core/Banshee.ThickClient/Banshee.ThickClient.mdp
trunk/banshee/src/Core/Banshee.ThickClient/Makefile.am
trunk/banshee/src/Extensions/Banshee.MiniMode/Banshee.MiniMode.mdp
trunk/banshee/src/Extensions/Banshee.MiniMode/Banshee.MiniMode/MiniModeWindow.cs
trunk/banshee/src/Extensions/Banshee.MiniMode/Makefile.am
Modified: trunk/banshee/libbanshee/libbanshee.mdp
==============================================================================
--- trunk/banshee/libbanshee/libbanshee.mdp (original)
+++ trunk/banshee/libbanshee/libbanshee.mdp Fri May 9 21:44:20 2008
@@ -1,5 +1,5 @@
<Project name="libbanshee" fileversion="2.0" language="C" ctype="CProject">
- <Configurations>
+ <Configurations active="Debug">
<Configuration name="Debug" ctype="CProjectConfiguration">
<Output directory="../bin" output="libbanshee" />
<Build debugmode="True" target="SharedLibrary" />
Modified: trunk/banshee/src/Core/Banshee.Services/Banshee.Services.mdp
==============================================================================
--- trunk/banshee/src/Core/Banshee.Services/Banshee.Services.mdp (original)
+++ trunk/banshee/src/Core/Banshee.Services/Banshee.Services.mdp Fri May 9 21:44:20 2008
@@ -166,6 +166,7 @@
<File name="Banshee.Collection.Database/IDatabaseTrackModelProvider.cs" subtype="Code" buildaction="Compile" />
<File name="Banshee.ServiceStack/IDelayedInitializeService.cs" subtype="Code" buildaction="Compile" />
<File name="Banshee.Sources/DurationStatusFormatters.cs" subtype="Code" buildaction="Compile" />
+ <File name="Banshee.SmartPlaylist/SmartPlaylistDefinition.cs" subtype="Code" buildaction="Compile" />
</Contents>
<References>
<ProjectReference type="Gac" localcopy="True" refto="System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
Copied: trunk/banshee/src/Core/Banshee.ThickClient/Banshee.Sources.Gui/SourceComboBox.cs (from r3903, /trunk/banshee/src/Extensions/Banshee.MiniMode/Banshee.MiniMode/SourceComboBox.cs)
==============================================================================
--- /trunk/banshee/src/Extensions/Banshee.MiniMode/Banshee.MiniMode/SourceComboBox.cs (original)
+++ trunk/banshee/src/Core/Banshee.ThickClient/Banshee.Sources.Gui/SourceComboBox.cs Fri May 9 21:44:20 2008
@@ -1,95 +1,93 @@
-/***************************************************************************
- * SourceComboBox.cs
- *
- * Copyright (C) 2006 Novell, Inc.
- * Written by Aaron Bockover <aaron abock org>
- * Felipe Almeida Lessa
- ****************************************************************************/
+// SourceComboBox.cs
+//
+// Authors:
+// Aaron Bockover <abockover novell com>
+// Felipe Almeida Lessa
+//
+// Copyright (C) 2005-2008 Novell, Inc.
+//
+// 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.
+//
-/* THIS FILE IS LICENSED UNDER THE MIT LICENSE AS OUTLINED IMMEDIATELY BELOW:
- *
- * 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 Gtk;
using Banshee.ServiceStack;
using Banshee.Sources;
-namespace Banshee.MiniMode
+namespace Banshee.Sources.Gui
{
- public class SourceComboBox : Gtk.ComboBox
+ public class SourceComboBox : ComboBox
{
- public SourceComboBox()
+ private SourceModel store;
+
+ public SourceComboBox ()
{
- Clear();
-
- CellRendererPixbuf image = new CellRendererPixbuf();
- PackStart(image, false);
- AddAttribute(image, "pixbuf", 0);
-
- CellRendererText text = new CellRendererText();
- PackStart(text, true);
- AddAttribute(text, "text", 1);
+ SourceRowRenderer renderer = new SourceRowRenderer ();
+ PackStart (renderer, true);
+ SetCellDataFunc (renderer, new CellLayoutDataFunc (SourceCellDataFunc));
- Model = new SourceModel();
+ store = new SourceModel ();
+ Model = store;
ServiceManager.SourceManager.ActiveSourceChanged += delegate {
- UpdateActiveSource();
+ UpdateActiveSource ();
};
ServiceManager.SourceManager.SourceUpdated += delegate {
- QueueDraw();
+ QueueDraw ();
};
+
+ store.Refresh ();
}
- public void UpdateActiveSource()
+ private void SourceCellDataFunc (CellLayout layout, CellRenderer cell, TreeModel tree_model, TreeIter iter)
{
- lock(this) {
- TreeIter iter = Model.FindSource(ServiceManager.SourceManager.ActiveSource);
- if(!iter.Equals(TreeIter.Zero)) {
- SetActiveIter(iter);
+ SourceRowRenderer.CellDataHandler (cell, tree_model, iter);
+ }
+
+ public void UpdateActiveSource ()
+ {
+ lock (this) {
+ TreeIter iter = store.FindSource (ServiceManager.SourceManager.ActiveSource);
+ if (!iter.Equals (TreeIter.Zero)) {
+ SetActiveIter (iter);
}
}
}
- protected override void OnChanged()
+ protected override void OnChanged ()
{
- lock(this) {
+ lock (this) {
TreeIter iter;
- if(GetActiveIter(out iter)) {
- Source new_source = Model.GetValue(iter, 2) as Source;
- if(new_source != null && ServiceManager.SourceManager.ActiveSource != new_source) {
- ServiceManager.SourceManager.SetActiveSource(new_source);
- if(new_source is ITrackModelSource) {
+ if (GetActiveIter (out iter)) {
+ Source new_source = store.GetValue(iter, 0) as Source;
+ if (new_source != null && ServiceManager.SourceManager.ActiveSource != new_source) {
+ ServiceManager.SourceManager.SetActiveSource (new_source);
+ if (new_source is ITrackModelSource) {
ServiceManager.PlaybackController.NextSource = (ITrackModelSource)new_source;
}
}
}
}
}
-
- public new SourceModel Model {
- get { return base.Model as SourceModel; }
- set { base.Model = value; }
- }
}
}
Added: trunk/banshee/src/Core/Banshee.ThickClient/Banshee.Sources.Gui/SourceModel.cs
==============================================================================
--- (empty file)
+++ trunk/banshee/src/Core/Banshee.ThickClient/Banshee.Sources.Gui/SourceModel.cs Fri May 9 21:44:20 2008
@@ -0,0 +1,271 @@
+//
+// SourceModel.cs
+//
+// Author:
+// Aaron Bockover <abockover novell com>
+//
+// Copyright (C) 2005-2008 Novell, Inc.
+//
+// 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.Sources;
+using Banshee.ServiceStack;
+
+namespace Banshee.Sources.Gui
+{
+ public delegate void SourceRowEventHandler (object o, SourceRowEventArgs args);
+
+ public sealed class SourceRowEventArgs : EventArgs
+ {
+ public SourceRowEventArgs (Source source, TreeIter iter, TreeIter parentIter)
+ {
+ this.source = source;
+ this.iter = iter;
+ this.parent_iter = parentIter;
+ }
+
+ private Source source;
+ public Source Source {
+ get { return source; }
+ }
+
+ private TreeIter iter;
+ public TreeIter Iter {
+ get { return iter; }
+ }
+
+ private TreeIter parent_iter;
+ public TreeIter ParentIter {
+ get { return parent_iter; }
+ }
+ }
+
+ public class SourceModel : TreeStore
+ {
+ public event SourceRowEventHandler SourceRowInserted;
+ public event SourceRowEventHandler SourceRowRemoved;
+
+ public SourceModel () : base (typeof (Source), typeof (int), typeof (bool))
+ {
+ SetSortColumnId (1, SortType.Ascending);
+ ChangeSortColumn ();
+
+ ServiceManager.SourceManager.SourceAdded += OnSourceAdded;
+ ServiceManager.SourceManager.SourceRemoved += OnSourceRemoved;
+ }
+
+ public override void Dispose ()
+ {
+ ServiceManager.SourceManager.SourceAdded -= OnSourceAdded;
+ ServiceManager.SourceManager.SourceRemoved -= OnSourceRemoved;
+ base.Dispose ();
+ }
+
+ private void OnSourceAdded (SourceAddedArgs args)
+ {
+ AddSource (args.Source);
+ }
+
+ private void OnSourceRemoved (SourceEventArgs args)
+ {
+ RemoveSource (args.Source);
+ }
+
+ protected virtual void OnSourceRowInserted (Source source, TreeIter iter, TreeIter parentIter)
+ {
+ SourceRowEventHandler handler = SourceRowInserted;
+ if (handler != null) {
+ handler (this, new SourceRowEventArgs (source, iter, parentIter));
+ }
+ }
+
+ protected virtual void OnSourceRowRemoved (Source source, TreeIter iter)
+ {
+ SourceRowEventHandler handler = SourceRowRemoved;
+ if (handler != null) {
+ handler (this, new SourceRowEventArgs (source, iter, TreeIter.Zero));
+ }
+ }
+
+#region Source <-> Iter Methods
+
+ public Source GetSource (TreeIter iter)
+ {
+ return GetValue (iter, 0) as Source;
+ }
+
+ public Source GetSource (TreePath path)
+ {
+ TreeIter iter;
+
+ if (GetIter (out iter, path)) {
+ return GetSource (iter);
+ }
+
+ return null;
+ }
+
+ public TreeIter FindSource (Source source)
+ {
+ foreach (TreeIter iter in FindInModel (0, source)) {
+ return iter;
+ }
+
+ return TreeIter.Zero;
+ }
+
+ public IEnumerable<TreeIter> FindInModel (int column, object match)
+ {
+ TreeIter iter = TreeIter.Zero;
+ GetIterFirst (out iter);
+ return FindInModel (column, match, iter);
+ }
+
+ public IEnumerable<TreeIter> FindInModel (int column, object match, TreeIter iter)
+ {
+ if (!IterIsValid (iter)) {
+ yield break;
+ }
+
+ do {
+ object result = GetValue (iter, column);
+ Type result_type = result != null ? result.GetType () : null;
+ if (result_type != null && ((result_type.IsValueType && result.Equals (match)) || result == match)) {
+ yield return iter;
+ }
+
+ if (IterHasChild (iter)) {
+ TreeIter citer = TreeIter.Zero;
+ IterChildren (out citer, iter);
+ foreach (TreeIter yiter in FindInModel (column, match, citer)) {
+ if (!yiter.Equals (TreeIter.Zero)) {
+ yield return yiter;
+ }
+ }
+ }
+ } while (IterNext (ref iter));
+ }
+
+ /*private void AddRowSeparator (int order)
+ {
+ TreeIter iter = InsertNode (order);
+
+ SetValue (iter, 0, null);
+ SetValue (iter, 1, order);
+ SetValue (iter, 2, true);
+ }
+
+ private void ClearRowSeparators ()
+ {
+ Queue<TreeIter> to_remove = new Queue<TreeIter> ();
+ foreach (TreeIter iter in FindInModel (2, true)) {
+ to_remove.Enqueue (iter);
+ }
+
+ while (to_remove.Count > 0) {
+ TreeIter iter = to_remove.Dequeue ();
+ Remove (ref iter);
+ }
+ }*/
+
+#endregion
+
+
+#region Add/Remove Sources / SourceManager interaction
+
+ public void AddSource (Source source)
+ {
+ AddSource (source, TreeIter.Zero);
+ }
+
+ public void AddSource (Source source, TreeIter parent)
+ {
+ // Don't add duplicates
+ if (!FindSource (source).Equals (TreeIter.Zero)) {
+ return;
+ }
+
+ // Don't add a child source before its parent
+ if (parent.Equals (TreeIter.Zero) && source.Parent != null) {
+ return;
+ }
+
+ int position = source.Order;
+
+ TreeIter iter = parent.Equals (TreeIter.Zero)
+ ? InsertNode (position)
+ : InsertNode (parent, position);
+
+ SetValue (iter, 0, source);
+ SetValue (iter, 1, source.Order);
+ SetValue (iter, 2, false);
+
+ lock (source.Children) {
+ foreach (Source child in source.Children) {
+ AddSource (child, iter);
+ }
+ }
+
+ source.ChildSourceAdded += OnSourceChildSourceAdded;
+ source.ChildSourceRemoved += OnSourceChildSourceRemoved;
+
+ OnSourceRowInserted (source, iter, parent);
+ }
+
+ public void RemoveSource (Source source)
+ {
+ TreeIter iter = FindSource (source);
+ if (!iter.Equals (TreeIter.Zero)) {
+ Remove (ref iter);
+ }
+
+ source.ChildSourceAdded -= OnSourceChildSourceAdded;
+ source.ChildSourceRemoved -= OnSourceChildSourceRemoved;
+
+ OnSourceRowRemoved (source, iter);
+ }
+
+ public void Refresh ()
+ {
+ Clear ();
+ foreach (Source source in ServiceManager.SourceManager.Sources) {
+ AddSource (source);
+ }
+ }
+
+ private void OnSourceChildSourceAdded (SourceEventArgs args)
+ {
+ AddSource (args.Source, FindSource (args.Source.Parent));
+ }
+
+ private void OnSourceChildSourceRemoved (SourceEventArgs args)
+ {
+ RemoveSource (args.Source);
+ }
+
+#endregion
+
+ }
+}
Modified: trunk/banshee/src/Core/Banshee.ThickClient/Banshee.Sources.Gui/SourceRowRenderer.cs
==============================================================================
--- trunk/banshee/src/Core/Banshee.ThickClient/Banshee.Sources.Gui/SourceRowRenderer.cs (original)
+++ trunk/banshee/src/Core/Banshee.ThickClient/Banshee.Sources.Gui/SourceRowRenderer.cs Fri May 9 21:44:20 2008
@@ -39,21 +39,68 @@
namespace Banshee.Sources.Gui
{
- internal class SourceRowRenderer : CellRendererText
+ public class SourceRowRenderer : CellRendererText
{
- public Source source;
- public SourceView view;
- public TreePath path;
+ public static void CellDataHandler (CellRenderer cell, TreeModel model, TreeIter iter)
+ {
+ SourceRowRenderer renderer = cell as SourceRowRenderer;
+ Source source = model.GetValue (iter, 0) as Source;
+
+ if (renderer == null) {
+ return;
+ }
+
+ renderer.Source = source;
+ renderer.Path = model.GetPath (iter);
+
+ if (source == null) {
+ return;
+ }
+
+ renderer.Sensitive = source.CanActivate;
+ }
+
+ private Source source;
+ public Source Source {
+ get { return source; }
+ set { source = value; }
+ }
+
+ private SourceView view;
+ public SourceView View {
+ get { return view; }
+ set { view = value; }
+ }
+
+ private TreePath path;
+ public TreePath Path {
+ get { return path; }
+ set { path = value; }
+ }
+
+ private int padding;
+ public int Padding {
+ get { return padding; }
+ set { padding = value; }
+ }
public SourceRowRenderer ()
{
}
- private StateType RendererStateToWidgetState (CellRendererState flags)
+ private StateType RendererStateToWidgetState (Widget widget, CellRendererState flags)
{
- return (CellRendererState.Selected & flags).Equals (CellRendererState.Selected)
- ? StateType.Selected
- : StateType.Normal;
+ if (!Sensitive) {
+ return StateType.Insensitive;
+ } else if ((flags & CellRendererState.Selected) == CellRendererState.Selected) {
+ return widget.HasFocus ? StateType.Selected : StateType.Active;
+ } else if ((flags & CellRendererState.Prelit) == CellRendererState.Prelit) {
+ return StateType.Prelight;
+ } else if (widget.State == StateType.Insensitive) {
+ return StateType.Insensitive;
+ } else {
+ return StateType.Normal;
+ }
}
public override void GetSize (Widget widget, ref Gdk.Rectangle cell_area,
@@ -65,8 +112,14 @@
x_offset = 0;
y_offset = 0;
- width = text_w;
- height = (int)Math.Max (22, text_h) + 5;
+
+ if (!(widget is TreeView)) {
+ width = 200;
+ } else {
+ width = 0;
+ }
+
+ height = (int)Math.Max (22, text_h) + Padding;
}
protected override void Render (Gdk.Drawable drawable, Widget widget, Gdk.Rectangle background_area,
@@ -76,36 +129,10 @@
return;
}
- bool path_selected = view.Selection.PathIsSelected (path);
- StateType state = RendererStateToWidgetState (flags);
+ bool path_selected = view != null && view.Selection.PathIsSelected (path);
+ StateType state = RendererStateToWidgetState (widget, flags);
- if (path_selected && view.Cr != null) {
- Gdk.Rectangle rect = background_area;
- rect.X -= 2;
- rect.Width += 4;
-
- // clear the standard GTK selection and focus
- drawable.DrawRectangle (widget.Style.BaseGC (StateType.Normal), true, rect);
-
- // draw the hot cairo selection
- if (!view.EditingRow) {
- view.Theme.DrawRowSelection (view.Cr, background_area.X + 1, background_area.Y + 1,
- background_area.Width - 2, background_area.Height - 2);
- }
- } else if (path != null && path.Equals (view.HighlightedPath) && view.Cr != null) {
- view.Theme.DrawRowSelection (view.Cr, background_area.X + 1, background_area.Y + 1,
- background_area.Width - 2, background_area.Height - 2, false);
- } else if (view.NotifyStage.ActorCount > 0 && view.Cr != null) {
- TreeIter iter;
- if (view.Model.GetIter (out iter, path) && view.NotifyStage.Contains (iter)) {
- Actor<TreeIter> actor = view.NotifyStage[iter];
- Cairo.Color color = view.Theme.Colors.GetWidgetColor (GtkColorClass.Background, StateType.Active);
- color.A = Math.Sin (actor.Percent * Math.PI);
-
- view.Theme.DrawRowSelection (view.Cr, background_area.X + 1, background_area.Y + 1,
- background_area.Width - 2, background_area.Height - 2, true, true, color);
- }
- }
+ RenderSelection (widget, drawable, background_area, path_selected, state);
int title_layout_width = 0, title_layout_height = 0;
int count_layout_width = 0, count_layout_height = 0;
@@ -120,7 +147,7 @@
? Pango.Weight.Bold
: Pango.Weight.Normal;
- if (source == view.NewPlaylistSource) {
+ if (view != null && source == view.NewPlaylistSource) {
fd.Style = Pango.Style.Italic;
hide_counts = true;
}
@@ -177,6 +204,42 @@
count_layout);
}
+ private void RenderSelection (Gtk.Widget widget, Gdk.Drawable drawable, Gdk.Rectangle background_area,
+ bool path_selected, StateType state)
+ {
+ if (view == null) {
+ return;
+ }
+
+ if (path_selected && view.Cr != null) {
+ Gdk.Rectangle rect = background_area;
+ rect.X -= 2;
+ rect.Width += 4;
+
+ // clear the standard GTK selection and focus
+ drawable.DrawRectangle (widget.Style.BaseGC (StateType.Normal), true, rect);
+
+ // draw the hot cairo selection
+ if (!view.EditingRow) {
+ view.Theme.DrawRowSelection (view.Cr, background_area.X + 1, background_area.Y + 1,
+ background_area.Width - 2, background_area.Height - 2);
+ }
+ } else if (path != null && path.Equals (view.HighlightedPath) && view.Cr != null) {
+ view.Theme.DrawRowSelection (view.Cr, background_area.X + 1, background_area.Y + 1,
+ background_area.Width - 2, background_area.Height - 2, false);
+ } else if (view.NotifyStage.ActorCount > 0 && view.Cr != null) {
+ TreeIter iter;
+ if (view.Model.GetIter (out iter, path) && view.NotifyStage.Contains (iter)) {
+ Actor<TreeIter> actor = view.NotifyStage[iter];
+ Cairo.Color color = view.Theme.Colors.GetWidgetColor (GtkColorClass.Background, StateType.Active);
+ color.A = Math.Sin (actor.Percent * Math.PI);
+
+ view.Theme.DrawRowSelection (view.Cr, background_area.X + 1, background_area.Y + 1,
+ background_area.Width - 2, background_area.Height - 2, true, true, color);
+ }
+ }
+ }
+
private int Middle (Gdk.Rectangle area, int height)
{
return area.Y + (int)Math.Round ((double)(area.Height - height) / 2.0) + 1;
Modified: trunk/banshee/src/Core/Banshee.ThickClient/Banshee.Sources.Gui/SourceView.cs
==============================================================================
--- trunk/banshee/src/Core/Banshee.ThickClient/Banshee.Sources.Gui/SourceView.cs (original)
+++ trunk/banshee/src/Core/Banshee.ThickClient/Banshee.Sources.Gui/SourceView.cs Fri May 9 21:44:20 2008
@@ -56,18 +56,24 @@
private Stage<TreeIter> notify_stage = new Stage<TreeIter> (2000);
- private TreeStore store;
private TreeViewColumn focus_column;
private TreePath highlight_path;
+ private SourceModel store;
private int current_timeout = -1;
private bool editing_row = false;
public SourceView ()
{
BuildColumns ();
- BuildModel ();
+
+ store = new SourceModel ();
+ store.SourceRowInserted += OnSourceRowInserted;
+ store.SourceRowRemoved += OnSourceRowRemoved;
+ store.RowChanged += OnRowChanged;
+ Model = store;
+
ConfigureDragAndDrop ();
- RefreshList ();
+ store.Refresh ();
ConnectEvents ();
RowSeparatorFunc = RowSeparatorHandler;
@@ -85,6 +91,7 @@
focus_column = new TreeViewColumn ();
renderer = new SourceRowRenderer ();
+ renderer.Padding = 5;
focus_column.PackStart (renderer, true);
focus_column.SetCellDataFunc (renderer, new TreeCellDataFunc (SourceCellDataFunc));
AppendColumn (focus_column);
@@ -92,24 +99,8 @@
HeadersVisible = false;
}
- private void BuildModel ()
- {
- store = new TreeStore (typeof (Source), typeof (int), typeof (bool));
- store.SetSortColumnId (1, SortType.Ascending);
- store.ChangeSortColumn ();
- Model = store;
- }
-
private void ConnectEvents ()
{
- ServiceManager.SourceManager.SourceAdded += delegate (SourceAddedArgs args) {
- AddSource (args.Source);
- };
-
- ServiceManager.SourceManager.SourceRemoved += delegate (SourceEventArgs args) {
- RemoveSource (args.Source);
- };
-
ServiceManager.SourceManager.ActiveSourceChanged += delegate (SourceEventArgs args) {
ResetSelection ();
};
@@ -117,7 +108,7 @@
ServiceManager.SourceManager.SourceUpdated += delegate (SourceEventArgs args) {
Banshee.Base.ThreadAssist.ProxyToMain (delegate {
lock (args.Source) {
- TreeIter iter = FindSource (args.Source);
+ TreeIter iter = store.FindSource (args.Source);
if (!TreeIter.Zero.Equals (iter)) {
store.SetValue (iter, 1, args.Source.Order);
QueueDraw ();
@@ -167,12 +158,12 @@
return base.OnButtonPressEvent (press);
}
- Source source = GetSource (path);
+ Source source = store.GetSource (path);
// From F-Spot's SaneTreeView class
- int expander_size = (int) StyleGetProperty ("expander-size");
- int horizontal_separator = (int) StyleGetProperty ("horizontal-separator");
- bool on_expander = (press.X <= (horizontal_separator * 2 + path.Depth * expander_size));
+ int expander_size = (int)StyleGetProperty ("expander-size");
+ int horizontal_separator = (int)StyleGetProperty ("horizontal-separator");
+ bool on_expander = press.X <= horizontal_separator * 2 + path.Depth * expander_size;
if (on_expander) {
bool ret = base.OnButtonPressEvent (press);
@@ -242,13 +233,13 @@
protected override void OnRowExpanded (TreeIter iter, TreePath path)
{
base.OnRowExpanded (iter, path);
- GetSource (iter).Expanded = true;
+ store.GetSource (iter).Expanded = true;
}
protected override void OnRowCollapsed (TreeIter iter, TreePath path)
{
base.OnRowCollapsed (iter, path);
- GetSource (iter).Expanded = false;
+ store.GetSource (iter).Expanded = false;
}
protected override void OnCursorChanged ()
@@ -288,181 +279,44 @@
#endregion
-#region Source <-> Iter Methods
-
- public Source GetSource (TreeIter iter)
- {
- return store.GetValue (iter, 0) as Source;
- }
-
- public Source GetSource (TreePath path)
- {
- TreeIter iter;
-
- if (store.GetIter (out iter, path)) {
- return GetSource (iter);
- }
-
- return null;
- }
-
- private TreeIter FindSource (Source source)
- {
- foreach (TreeIter iter in FindInModel (0, source)) {
- return iter;
- }
-
- return TreeIter.Zero;
- }
-
- private IEnumerable<TreeIter> FindInModel (int column, object match)
- {
- TreeIter iter = TreeIter.Zero;
- store.GetIterFirst (out iter);
- return FindInModel (column, match, iter);
- }
-
- private IEnumerable<TreeIter> FindInModel (int column, object match, TreeIter iter)
- {
- if (!store.IterIsValid (iter)) {
- yield break;
- }
-
- do {
- object result = store.GetValue (iter, column);
- Type result_type = result != null ? result.GetType () : null;
- if (result_type != null && ((result_type.IsValueType && result.Equals (match)) || result == match)) {
- yield return iter;
- }
-
- if (store.IterHasChild (iter)) {
- TreeIter citer = TreeIter.Zero;
- store.IterChildren (out citer, iter);
- foreach (TreeIter yiter in FindInModel (column, match, citer)) {
- if (!yiter.Equals (TreeIter.Zero)) {
- yield return yiter;
- }
- }
- }
- } while (store.IterNext (ref iter));
- }
-
- /*private void AddRowSeparator (int order)
- {
- TreeIter iter = store.InsertNode (order);
-
- store.SetValue (iter, 0, null);
- store.SetValue (iter, 1, order);
- store.SetValue (iter, 2, true);
- }
-
- private void ClearRowSeparators ()
- {
- Queue<TreeIter> to_remove = new Queue<TreeIter> ();
- foreach (TreeIter iter in FindInModel (2, true)) {
- to_remove.Enqueue (iter);
- }
-
- while (to_remove.Count > 0) {
- TreeIter iter = to_remove.Dequeue ();
- store.Remove (ref iter);
- }
- }*/
-
-#endregion
-
#region Add/Remove Sources / SourceManager interaction
- private void AddSource (Source source)
+ private void OnSourceRowInserted (object o, SourceRowEventArgs args)
{
- AddSource (source, TreeIter.Zero);
- }
-
- private void AddSource (Source source, TreeIter parent)
- {
- // Don't add duplicates
- if (!FindSource (source).Equals (TreeIter.Zero)) {
- return;
- }
-
- // Don't add a child source before its parent
- if (parent.Equals (TreeIter.Zero) && source.Parent != null) {
- return;
- }
-
- int position = source.Order;
+ args.Source.UserNotifyUpdated += OnSourceUserNotifyUpdated;
- TreeIter iter = parent.Equals (TreeIter.Zero)
- ? store.InsertNode (position)
- : store.InsertNode (parent, position);
-
- store.SetValue (iter, 0, source);
- store.SetValue (iter, 1, source.Order);
- store.SetValue (iter, 2, false);
-
- lock (source.Children) {
- foreach (Source child in source.Children) {
- AddSource (child, iter);
- }
- }
-
- source.ChildSourceAdded += OnSourceChildSourceAdded;
- source.ChildSourceRemoved += OnSourceChildSourceRemoved;
- source.UserNotifyUpdated += OnSourceUserNotifyUpdated;
-
- if (source.Parent != null && source.Parent.AutoExpand == true) {
- Expand (parent);
+ if (args.Source.Parent != null && args.Source.Parent.AutoExpand == true) {
+ Expand (args.ParentIter);
}
- if (source.Expanded || source.AutoExpand == true) {
- Expand (iter);
+ if (args.Source.Expanded || args.Source.AutoExpand == true) {
+ Expand (args.Iter);
}
UpdateView ();
}
-
- private void RemoveSource (Source source)
+
+ private void OnSourceRowRemoved (object o, SourceRowEventArgs args)
{
- TreeIter iter = FindSource (source);
- if (!iter.Equals (TreeIter.Zero)) {
- store.Remove (ref iter);
- }
-
- source.ChildSourceAdded -= OnSourceChildSourceAdded;
- source.ChildSourceRemoved -= OnSourceChildSourceRemoved;
- source.UserNotifyUpdated -= OnSourceUserNotifyUpdated;
-
+ args.Source.UserNotifyUpdated -= OnSourceUserNotifyUpdated;
UpdateView ();
}
-
- private void Expand (TreeIter iter)
- {
- TreePath path = store.GetPath (iter);
- ExpandRow (path, true);
- }
- private void RefreshList ()
+ private void OnRowChanged (object o, RowChangedArgs args)
{
- store.Clear ();
- foreach (Source source in ServiceManager.SourceManager.Sources) {
- AddSource (source);
- }
+ QueueDraw ();
}
-
- private void OnSourceChildSourceAdded (SourceEventArgs args)
+
+ private void Expand (TreeIter iter)
{
- AddSource (args.Source, FindSource (args.Source.Parent));
+ TreePath path = store.GetPath (iter);
+ ExpandRow (path, true);
}
- private void OnSourceChildSourceRemoved (SourceEventArgs args)
- {
- RemoveSource (args.Source);
- }
-
private void OnSourceUserNotifyUpdated (object o, EventArgs args)
{
Banshee.Base.ThreadAssist.ProxyToMain (delegate {
- TreeIter iter = FindSource ((Source)o);
+ TreeIter iter = store.FindSource ((Source)o);
if (iter.Equals (TreeIter.Zero)) {
return;
}
@@ -507,7 +361,7 @@
public void BeginRenameSource (Source source)
{
- TreeIter iter = FindSource (source);
+ TreeIter iter = store.FindSource (source);
if (iter.Equals (TreeIter.Zero)) {
return;
}
@@ -520,21 +374,12 @@
private void SourceCellDataFunc (TreeViewColumn tree_column, CellRenderer cell,
TreeModel tree_model, TreeIter iter)
{
- SourceRowRenderer renderer = (SourceRowRenderer)cell;
- renderer.view = this;
- renderer.source = (Source)store.GetValue (iter, 0);
- renderer.path = store.GetPath (iter);
-
- if (renderer.source == null) {
- return;
- }
-
- renderer.Sensitive = renderer.source.CanActivate;
+ SourceRowRenderer.CellDataHandler (cell, tree_model, iter);
}
private void ResetSelection ()
{
- TreeIter iter = FindSource (ServiceManager.SourceManager.ActiveSource);
+ TreeIter iter = store.FindSource (ServiceManager.SourceManager.ActiveSource);
if (!iter.Equals (TreeIter.Zero)){
Selection.SelectIter (iter);
@@ -600,7 +445,8 @@
internal Source NewPlaylistSource {
get {
return new_playlist_source ??
- new_playlist_source = new PlaylistSource (Catalog.GetString ("New Playlist"), ServiceManager.SourceManager.MusicLibrary.DbId);
+ new_playlist_source = new PlaylistSource (Catalog.GetString ("New Playlist"),
+ ServiceManager.SourceManager.MusicLibrary.DbId);
}
}
Modified: trunk/banshee/src/Core/Banshee.ThickClient/Banshee.Sources.Gui/SourceView_DragAndDrop.cs
==============================================================================
--- trunk/banshee/src/Core/Banshee.ThickClient/Banshee.Sources.Gui/SourceView_DragAndDrop.cs (original)
+++ trunk/banshee/src/Core/Banshee.ThickClient/Banshee.Sources.Gui/SourceView_DragAndDrop.cs Fri May 9 21:44:20 2008
@@ -81,7 +81,7 @@
return false;
}
- Source drop_source = GetSource (path);
+ Source drop_source = store.GetSource (path);
Source parent_source = drop_source as LibrarySource ?? drop_source.Parent as LibrarySource;
// Scroll if within 20 pixels of the top or bottom
@@ -120,7 +120,7 @@
HideNewPlaylistRow ();
}
- TreeIter parent_iter = FindSource (parent);
+ TreeIter parent_iter = store.FindSource (parent);
new_playlist_iter = store.AppendNode (parent_iter);
store.SetValue (new_playlist_iter, 0, NewPlaylistSource);
@@ -143,7 +143,7 @@
}
if (!parent_was_expanded) {
- TreeIter iter = FindSource (new_playlist_parent);
+ TreeIter iter = store.FindSource (new_playlist_parent);
TreePath path = store.GetPath (iter);
CollapseRow (path);
}
@@ -164,7 +164,7 @@
path = store.GetPath (new_playlist_iter);
}
- final_drag_source = GetSource (path);
+ final_drag_source = store.GetSource (path);
final_drag_start_time = context.StartTime;
HideNewPlaylistRow ();
@@ -189,7 +189,8 @@
Source drop_source = final_drag_source;
if (final_drag_source == NewPlaylistSource) {
- PlaylistSource playlist = new PlaylistSource ("New Playlist", (new_playlist_parent as PrimarySource).DbId);
+ PlaylistSource playlist = new PlaylistSource ("New Playlist",
+ (new_playlist_parent as PrimarySource).DbId);
playlist.Save ();
playlist.PrimarySource.AddChildSource (playlist);
drop_source = playlist;
@@ -201,7 +202,8 @@
drop_source.MergeSourceInput (sources[0], SourceMergeType.Source);
}
} else {
- drop_source.MergeSourceInput (ServiceManager.SourceManager.ActiveSource, SourceMergeType.ModelSelection);
+ drop_source.MergeSourceInput (ServiceManager.SourceManager.ActiveSource,
+ SourceMergeType.ModelSelection);
}
Gtk.Drag.Finish (context, true, false, time);
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 Fri May 9 21:44:20 2008
@@ -106,6 +106,9 @@
<File name="Banshee.Addins.Gui/AddinDetailsDialog.cs" subtype="Code" buildaction="Compile" />
<File name="Banshee.Addins.Gui/AddinTile.cs" subtype="Code" buildaction="Compile" />
<File name="Banshee.Addins.Gui/AddinView.cs" subtype="Code" buildaction="Compile" />
+ <File name="Resources/jcastro.png" subtype="Code" buildaction="EmbedAsResource" />
+ <File name="Banshee.Sources.Gui/SourceModel.cs" subtype="Code" buildaction="Compile" />
+ <File name="Banshee.Sources.Gui/SourceComboBox.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 Fri May 9 21:44:20 2008
@@ -93,7 +93,9 @@
Banshee.Sources.Gui/ISourceContents.cs \
Banshee.Sources.Gui/ITrackModelSourceContents.cs \
Banshee.Sources.Gui/ObjectListSourceContents.cs \
+ Banshee.Sources.Gui/SourceComboBox.cs \
Banshee.Sources.Gui/SourceIconResolver.cs \
+ Banshee.Sources.Gui/SourceModel.cs \
Banshee.Sources.Gui/SourceRowRenderer.cs \
Banshee.Sources.Gui/SourceView.cs \
Banshee.Sources.Gui/SourceView_DragAndDrop.cs
Modified: trunk/banshee/src/Extensions/Banshee.MiniMode/Banshee.MiniMode.mdp
==============================================================================
--- trunk/banshee/src/Extensions/Banshee.MiniMode/Banshee.MiniMode.mdp (original)
+++ trunk/banshee/src/Extensions/Banshee.MiniMode/Banshee.MiniMode.mdp Fri May 9 21:44:20 2008
@@ -11,7 +11,6 @@
<File name="Banshee.MiniMode.addin.xml" subtype="Code" buildaction="EmbedAsResource" />
<File name="Banshee.MiniMode/MiniModeService.cs" subtype="Code" buildaction="Compile" />
<File name="Banshee.MiniMode/MiniModeWindow.cs" subtype="Code" buildaction="Compile" />
- <File name="Banshee.MiniMode/SourceComboBox.cs" subtype="Code" buildaction="Compile" />
<File name="Banshee.MiniMode/SourceModel.cs" subtype="Code" buildaction="Compile" />
<File name="Resources/minimode.glade" subtype="Code" buildaction="EmbedAsResource" />
</Contents>
Modified: trunk/banshee/src/Extensions/Banshee.MiniMode/Banshee.MiniMode/MiniModeWindow.cs
==============================================================================
--- trunk/banshee/src/Extensions/Banshee.MiniMode/Banshee.MiniMode/MiniModeWindow.cs (original)
+++ trunk/banshee/src/Extensions/Banshee.MiniMode/Banshee.MiniMode/MiniModeWindow.cs Fri May 9 21:44:20 2008
@@ -39,6 +39,7 @@
using Banshee.Collection.Gui;
using Banshee.Gui;
using Banshee.Gui.Widgets;
+using Banshee.Sources.Gui;
using Banshee.MediaEngine;
using Banshee.ServiceStack;
using Banshee.Widgets;
@@ -72,7 +73,7 @@
public MiniMode() : base(Catalog.GetString("Banshee Music Player"))
{
elements_service = ServiceManager.Get<GtkElementsService>();
- interface_action_service = ServiceManager.Get<InterfaceActionService>("InterfaceActionService");
+ interface_action_service = ServiceManager.Get<InterfaceActionService>();
default_main_window = elements_service.PrimaryWindow;
@@ -117,7 +118,7 @@
// Source combobox
source_combo_box = new SourceComboBox();
SourceBox.PackStart(source_combo_box, true, true, 0);
- source_combo_box.ShowAll();
+ source_combo_box.Show();
// Track info
track_info_display = new TrackInfoDisplay ();
Modified: trunk/banshee/src/Extensions/Banshee.MiniMode/Makefile.am
==============================================================================
--- trunk/banshee/src/Extensions/Banshee.MiniMode/Makefile.am (original)
+++ trunk/banshee/src/Extensions/Banshee.MiniMode/Makefile.am Fri May 9 21:44:20 2008
@@ -6,7 +6,6 @@
SOURCES = \
Banshee.MiniMode/MiniModeService.cs \
Banshee.MiniMode/MiniModeWindow.cs \
- Banshee.MiniMode/SourceComboBox.cs \
Banshee.MiniMode/SourceModel.cs
RESOURCES = \
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]