banshee r4155 - in trunk/banshee: . src/Core/Banshee.ThickClient/Banshee.Collection.Gui src/Core/Banshee.ThickClient/Banshee.Gui src/Extensions/Banshee.InternetRadio src/Extensions/Banshee.InternetRadio/Banshee.InternetRadio
- From: abock svn gnome org
- To: svn-commits-list gnome org
- Subject: banshee r4155 - in trunk/banshee: . src/Core/Banshee.ThickClient/Banshee.Collection.Gui src/Core/Banshee.ThickClient/Banshee.Gui src/Extensions/Banshee.InternetRadio src/Extensions/Banshee.InternetRadio/Banshee.InternetRadio
- Date: Tue, 17 Jun 2008 02:50:54 +0000 (UTC)
Author: abock
Date: Tue Jun 17 02:50:54 2008
New Revision: 4155
URL: http://svn.gnome.org/viewvc/banshee?rev=4155&view=rev
Log:
2008-06-16 Aaron Bockover <abock gnome org>
* src/Core/Banshee.ThickClient/Banshee.Collection.Gui/DefaultColumnController.cs:
Added the column for the Comments field
* src/Core/Banshee.ThickClient/Banshee.Gui/TrackActions.cs:
Support a TrackPropertiesHandler property that is an InvokeHandle; if set
it runs the handle instead of the default track editor dialog; this allows
sources to provide their own track editor
* src/Extensions/Banshee.InternetRadio/Banshee.InternetRadio/InternetRadioSource.cs:
Support station adding, editing, playback, and a custom column controller,
making internet radio maybe 70% complete; it works, but it's still missing
polish and finishing touches, so stay tuned
* src/Extensions/Banshee.InternetRadio/Banshee.InternetRadio/RadioColumnController.cs:
Custom column controller that exposes and customizes applicable fields
for internet radio stations
* src/Extensions/Banshee.InternetRadio/Banshee.InternetRadio/StationEditor.cs:
Added rating and support loading and saving of station data
* src/Extensions/Banshee.InternetRadio/Banshee.InternetRadio/StationTrackInfo.cs:
DatabaseTrackInfo wrapper, not in use yet
Added:
trunk/banshee/src/Extensions/Banshee.InternetRadio/Banshee.InternetRadio/RadioColumnController.cs
trunk/banshee/src/Extensions/Banshee.InternetRadio/Banshee.InternetRadio/StationTrackInfo.cs
Modified:
trunk/banshee/ChangeLog
trunk/banshee/src/Core/Banshee.ThickClient/Banshee.Collection.Gui/DefaultColumnController.cs
trunk/banshee/src/Core/Banshee.ThickClient/Banshee.Gui/TrackActions.cs
trunk/banshee/src/Extensions/Banshee.InternetRadio/Banshee.InternetRadio.mdp
trunk/banshee/src/Extensions/Banshee.InternetRadio/Banshee.InternetRadio/InternetRadioSource.cs
trunk/banshee/src/Extensions/Banshee.InternetRadio/Banshee.InternetRadio/StationEditor.cs
trunk/banshee/src/Extensions/Banshee.InternetRadio/Makefile.am
Modified: trunk/banshee/src/Core/Banshee.ThickClient/Banshee.Collection.Gui/DefaultColumnController.cs
==============================================================================
--- trunk/banshee/src/Core/Banshee.ThickClient/Banshee.Collection.Gui/DefaultColumnController.cs (original)
+++ trunk/banshee/src/Core/Banshee.ThickClient/Banshee.Collection.Gui/DefaultColumnController.cs Tue Jun 17 02:50:54 2008
@@ -142,6 +142,12 @@
get { return composer_column; }
}
+ private SortableColumn comment_column = new SortableColumn (Catalog.GetString ("Comment"),
+ new ColumnCellText ("Comment", true), 0.25, "Comment", false);
+ public SortableColumn CommentColumn {
+ get { return comment_column; }
+ }
+
private SortableColumn play_count_column = new SortableColumn (Catalog.GetString ("Play Count"),
new ColumnCellText ("PlayCount", true), 0.15, "PlayCount", false);
public SortableColumn PlayCountColumn {
Modified: trunk/banshee/src/Core/Banshee.ThickClient/Banshee.Gui/TrackActions.cs
==============================================================================
--- trunk/banshee/src/Core/Banshee.ThickClient/Banshee.Gui/TrackActions.cs (original)
+++ trunk/banshee/src/Core/Banshee.ThickClient/Banshee.Gui/TrackActions.cs Tue Jun 17 02:50:54 2008
@@ -273,10 +273,16 @@
private void OnTrackProperties (object o, EventArgs args)
{
if (current_source != null) {
- TrackEditor propEdit = new TrackEditor (current_source.TrackModel.SelectedItems);
- propEdit.Saved += delegate {
- //ui.playlistView.QueueDraw();
- };
+ Source source = current_source as Source;
+ InvokeHandler handler = source != null
+ ? source.Properties.Get<InvokeHandler> ("TrackPropertiesHandler")
+ : null;
+
+ if (handler != null) {
+ handler ();
+ } else {
+ new TrackEditor (current_source.TrackModel.SelectedItems);
+ }
}
}
Modified: trunk/banshee/src/Extensions/Banshee.InternetRadio/Banshee.InternetRadio.mdp
==============================================================================
--- trunk/banshee/src/Extensions/Banshee.InternetRadio/Banshee.InternetRadio.mdp (original)
+++ trunk/banshee/src/Extensions/Banshee.InternetRadio/Banshee.InternetRadio.mdp Tue Jun 17 02:50:54 2008
@@ -1,4 +1,4 @@
-<Project name="Banshee.InternetRadio" fileversion="2.0" language="C#" clr-version="Net_2_0" UseParentDirectoryAsNamespace="True" ctype="DotNetProject">
+<Project name="Banshee.InternetRadio" fileversion="2.0" UseParentDirectoryAsNamespace="True" language="C#" clr-version="Net_2_0" ctype="DotNetProject">
<Configurations active="Debug">
<Configuration name="Debug" ctype="DotNetProjectConfiguration">
<Output directory="../../../bin" assemblyKeyFile="." assembly="Banshee.InternetRadio" />
@@ -13,12 +13,15 @@
<File name="Resources/GlobalUI.xml" subtype="Code" buildaction="EmbedAsResource" />
<File name="Banshee.InternetRadio/InternetRadioSource.cs" subtype="Code" buildaction="Compile" />
<File name="Banshee.InternetRadio/StationEditor.cs" subtype="Code" buildaction="Compile" />
+ <File name="Banshee.InternetRadio/RadioColumnController.cs" subtype="Code" buildaction="Compile" />
+ <File name="Banshee.InternetRadio/StationTrackInfo.cs" subtype="Code" buildaction="Compile" />
</Contents>
<References>
<ProjectReference type="Project" localcopy="True" refto="Banshee.Core" />
<ProjectReference type="Project" localcopy="True" refto="Banshee.Services" />
<ProjectReference type="Project" localcopy="True" refto="Banshee.ThickClient" />
<ProjectReference type="Gac" localcopy="True" refto="gtk-sharp, Version=2.10.0.0, Culture=neutral, PublicKeyToken=35e10195dab3c99f" />
+ <ProjectReference type="Project" localcopy="True" refto="Hyena" />
</References>
<MonoDevelop.Autotools.MakefileInfo IntegrationEnabled="True" RelativeMakefileName="./Makefile.am">
<BuildFilesVar Sync="True" Name="SOURCES" />
Modified: trunk/banshee/src/Extensions/Banshee.InternetRadio/Banshee.InternetRadio/InternetRadioSource.cs
==============================================================================
--- trunk/banshee/src/Extensions/Banshee.InternetRadio/Banshee.InternetRadio/InternetRadioSource.cs (original)
+++ trunk/banshee/src/Extensions/Banshee.InternetRadio/Banshee.InternetRadio/InternetRadioSource.cs Tue Jun 17 02:50:54 2008
@@ -34,6 +34,7 @@
using Banshee.Base;
using Banshee.Sources;
+using Banshee.Streaming;
using Banshee.ServiceStack;
using Banshee.Collection;
using Banshee.Collection.Database;
@@ -71,6 +72,24 @@
Properties.SetString ("ActiveSourceUIResource", "ActiveSourceUI.xml");
Properties.SetString ("GtkActionPath", "/InternetRadioContextMenu");
+
+ Properties.Set<RadioColumnController> ("TrackView.ColumnController", new RadioColumnController ());
+ Properties.SetString ("TrackPropertiesLabel", Catalog.GetString ("Edit Station"));
+ Properties.Set<InvokeHandler> ("TrackPropertiesHandler", delegate {
+ if (TrackModel.SelectedItems == null || TrackModel.SelectedItems.Count <= 0) {
+ return;
+ }
+
+ foreach (TrackInfo track in TrackModel.SelectedItems) {
+ StationTrackInfo station_track = track as StationTrackInfo;
+ if (station_track != null) {
+ EditStation (station_track);
+ return;
+ }
+ }
+ });
+
+ ServiceManager.PlayerEngine.TrackIntercept += OnPlayerEngineTrackIntercept;
}
public override void Dispose ()
@@ -87,17 +106,85 @@
uia_service.GlobalActions.Remove ("AddRadioStationAction");
ui_id = 0;
}
+
+ ServiceManager.PlayerEngine.TrackIntercept -= OnPlayerEngineTrackIntercept;
+ }
+
+ private bool OnPlayerEngineTrackIntercept (TrackInfo track)
+ {
+ DatabaseTrackInfo station = track as DatabaseTrackInfo;
+ if (station == null || station.PrimarySource != this) {
+ return false;
+ }
+
+ new RadioTrackInfo (station.Uri).Play ();
+
+ return true;
}
private void OnAddStation (object o, EventArgs args)
{
- StationEditor editor = new StationEditor ();
+ EditStation (null);
+ }
+
+ private void EditStation (StationTrackInfo track)
+ {
+ StationEditor editor = new StationEditor (track);
+ editor.Response += OnStationEditorResponse;
+ editor.Show ();
+ }
+
+ private void OnStationEditorResponse (object o, ResponseArgs args)
+ {
+ StationEditor editor = (StationEditor)o;
+ bool destroy = true;
+
try {
- editor.Run ();
+ if (args.ResponseId == ResponseType.Ok) {
+ StationTrackInfo track = editor.Track ?? new StationTrackInfo ();
+ track.PrimarySource = this;
+ track.IsLive = true;
+
+ try {
+ track.Uri = new SafeUri (editor.StreamUri);
+ } catch {
+ destroy = false;
+ editor.ErrorMessage = Catalog.GetString ("Please provide a valid station URI");
+ }
+
+ track.Comment = editor.Description;
+
+ if (!String.IsNullOrEmpty (editor.Genre)) {
+ track.Genre = editor.Genre;
+ } else {
+ destroy = false;
+ editor.ErrorMessage = Catalog.GetString ("Please provide a station genre");
+ }
+
+ if (!String.IsNullOrEmpty (editor.StationTitle)) {
+ track.TrackTitle = editor.StationTitle;
+ } else {
+ destroy = false;
+ editor.ErrorMessage = Catalog.GetString ("Please provide a station title");
+ }
+
+ track.Rating = editor.Rating;
+
+ if (destroy) {
+ track.Save ();
+ }
+ }
} finally {
- editor.Destroy ();
+ if (destroy) {
+ editor.Response -= OnStationEditorResponse;
+ editor.Destroy ();
+ }
}
}
+
+ public override bool CanDeleteTracks {
+ get { return false; }
+ }
public override bool ShowBrowser {
get { return false; }
Added: trunk/banshee/src/Extensions/Banshee.InternetRadio/Banshee.InternetRadio/RadioColumnController.cs
==============================================================================
--- (empty file)
+++ trunk/banshee/src/Extensions/Banshee.InternetRadio/Banshee.InternetRadio/RadioColumnController.cs Tue Jun 17 02:50:54 2008
@@ -0,0 +1,61 @@
+//
+// RadioColumnController.cs
+//
+// Author:
+// Aaron Bockover <abockover novell com>
+//
+// Copyright (C) 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 Mono.Unix;
+
+using Banshee.Collection.Gui;
+
+namespace Banshee.InternetRadio
+{
+ public class RadioColumnController : DefaultColumnController
+ {
+ public RadioColumnController () : base (false)
+ {
+ AddRange (
+ IndicatorColumn,
+ TitleColumn,
+ GenreColumn,
+ CommentColumn,
+ RatingColumn,
+ PlayCountColumn,
+ LastPlayedColumn,
+ LastSkippedColumn,
+ DateAddedColumn,
+ UriColumn
+ );
+
+ IndicatorColumn.Visible = true;
+ TitleColumn.Visible = true;
+ GenreColumn.Visible = true;
+ CommentColumn.Visible = true;
+ CommentColumn.Title = Catalog.GetString ("Description");
+ RatingColumn.Visible = true;
+ }
+ }
+}
Modified: trunk/banshee/src/Extensions/Banshee.InternetRadio/Banshee.InternetRadio/StationEditor.cs
==============================================================================
--- trunk/banshee/src/Extensions/Banshee.InternetRadio/Banshee.InternetRadio/StationEditor.cs (original)
+++ trunk/banshee/src/Extensions/Banshee.InternetRadio/Banshee.InternetRadio/StationEditor.cs Tue Jun 17 02:50:54 2008
@@ -30,6 +30,10 @@
using Gtk;
using Mono.Unix;
+using Banshee.ServiceStack;
+
+using Hyena.Widgets;
+
namespace Banshee.InternetRadio
{
public class StationEditor : Gtk.Dialog
@@ -38,11 +42,13 @@
private Entry name_entry;
private Entry description_entry;
private Entry stream_entry;
- private ComboBoxEntry group_entry;
+ private ComboBoxEntry genre_entry;
+ private RatingEntry rating_entry;
private Alignment error_container;
private Label error;
+ private StationTrackInfo track;
- public StationEditor () : base()
+ public StationEditor (StationTrackInfo track) : base()
{
AccelGroup accel_group = new AccelGroup ();
AddAccelGroup (accel_group);
@@ -51,7 +57,9 @@
SkipTaskbarHint = true;
Modal = true;
- string title = null /*station*/ == null
+ this.track = track;
+
+ string title = track == null
? Catalog.GetString ("Add new radio station")
: Catalog.GetString ("Edit radio station");
@@ -82,7 +90,7 @@
header.Show ();
Label message = new Label ();
- message.Text = Catalog.GetString ("Enter the Group, Title and URL of the radio station you wish to add. A description is optional.");
+ message.Text = Catalog.GetString ("Enter the Genre, Title and URL of the radio station you wish to add. A description is optional.");
message.Xalign = 0.0f;
message.Wrap = true;
message.Show ();
@@ -91,21 +99,26 @@
table.RowSpacing = 6;
table.ColumnSpacing = 6;
- Label label = new Label (Catalog.GetString ("Station Group:"));
+ Label label = new Label (Catalog.GetString ("Station Genre:"));
label.Xalign = 0.0f;
- group_entry = ComboBoxEntry.NewText ();
+ genre_entry = ComboBoxEntry.NewText ();
- /*foreach(string group_name in station_model.StationGroupNames) {
- group_entry.AppendText(group_name);
- }*/
-
- /*if (group != null) {
- group_entry.Entry.Text = group;
- }*/
+ System.Data.IDataReader reader = ServiceManager.DbConnection.Query (
+ "SELECT DISTINCT Genre FROM CoreTracks ORDER BY Genre");
+ while (reader != null && reader.Read ()) {
+ string genre = reader[0] as string;
+ if (!String.IsNullOrEmpty (genre)) {
+ genre_entry.AppendText (genre);
+ }
+ }
+
+ if (track != null && !String.IsNullOrEmpty (track.Genre)) {
+ genre_entry.Entry.Text = track.Genre;
+ }
table.Attach (label, 0, 1, 0, 1, AttachOptions.Fill, AttachOptions.Fill | AttachOptions.Expand, 0, 0);
- table.Attach (group_entry, 1, 2, 0, 1, AttachOptions.Fill | AttachOptions.Expand, AttachOptions.Shrink, 0, 0);
+ table.Attach (genre_entry, 1, 2, 0, 1, AttachOptions.Fill | AttachOptions.Expand, AttachOptions.Shrink, 0, 0);
label = new Label (Catalog.GetString ("Station Title:"));
label.Xalign = 0.0f;
@@ -131,6 +144,16 @@
table.Attach (label, 0, 1, 3, 4, AttachOptions.Fill, AttachOptions.Fill | AttachOptions.Expand, 0, 0);
table.Attach (description_entry, 1, 2, 3, 4, AttachOptions.Expand | AttachOptions.Fill, AttachOptions.Shrink, 0, 0);
+ label = new Label (Catalog.GetString ("Rating:"));
+ label.Xalign = 0.0f;
+
+ rating_entry = new RatingEntry ();
+
+ table.Attach (label, 0, 1, 4, 5, AttachOptions.Fill, AttachOptions.Fill | AttachOptions.Expand, 0, 0);
+ HBox rating_box = new HBox ();
+ rating_box.PackStart (rating_entry, false, false, 0);
+ table.Attach (rating_box, 1, 2, 4, 5, AttachOptions.Expand | AttachOptions.Fill, AttachOptions.Shrink, 0, 0);
+
table.ShowAll ();
main_box.PackStart (header, false, false, 0);
@@ -165,19 +188,21 @@
name_entry.HasFocus = true;
- /*if (station != null) {
- if (station.Title != null) {
- name_entry.Text = station.Title;
+ if (track != null) {
+ if (!String.IsNullOrEmpty (track.TrackTitle)) {
+ name_entry.Text = track.TrackTitle;
}
- if (station.LocationCount > 0) {
- stream_entry.Text = station.GetLocationAt (0).AbsoluteUri;
+ if (!String.IsNullOrEmpty (track.Uri.AbsoluteUri)) {
+ stream_entry.Text = track.Uri.AbsoluteUri;
}
- if (station.Annotation != null) {
- description_entry.Text = station.Annotation;
+ if (!String.IsNullOrEmpty (track.Comment)) {
+ description_entry.Text = track.Comment;
}
- }*/
+
+ rating_entry.Value = track.Rating;
+ }
error_container = new Alignment (0.0f, 0.0f, 1.0f, 1.0f);
error_container.TopPadding = 6;
@@ -201,7 +226,7 @@
table.Attach (error_container, 0, 2, 4, 5, AttachOptions.Expand | AttachOptions.Fill, AttachOptions.Shrink, 0, 0);
- group_entry.Entry.Changed += OnFieldsChanged;
+ genre_entry.Entry.Changed += OnFieldsChanged;
name_entry.Changed += OnFieldsChanged;
stream_entry.Changed += OnFieldsChanged;
@@ -210,7 +235,7 @@
private void OnFieldsChanged (object o, EventArgs args)
{
- save_button.Sensitive = group_entry.Entry.Text.Trim ().Length > 0 &&
+ save_button.Sensitive = genre_entry.Entry.Text.Trim ().Length > 0 &&
name_entry.Text.Trim ().Length > 0 && stream_entry.Text.Trim ().Length > 0;
}
@@ -220,8 +245,12 @@
stream_entry.SelectRegion (0, stream_entry.Text.Length);
}
- public new string Group {
- get { return group_entry.Entry.Text.Trim (); }
+ public StationTrackInfo Track {
+ get { return track; }
+ }
+
+ public string Genre {
+ get { return genre_entry.Entry.Text.Trim (); }
}
public string StationTitle {
@@ -236,6 +265,10 @@
get { return description_entry.Text.Trim (); }
}
+ public int Rating {
+ get { return rating_entry.Value; }
+ }
+
public string ErrorMessage {
set {
if (value == null) {
Added: trunk/banshee/src/Extensions/Banshee.InternetRadio/Banshee.InternetRadio/StationTrackInfo.cs
==============================================================================
--- (empty file)
+++ trunk/banshee/src/Extensions/Banshee.InternetRadio/Banshee.InternetRadio/StationTrackInfo.cs Tue Jun 17 02:50:54 2008
@@ -0,0 +1,53 @@
+//
+// StationTrackInfo.cs
+//
+// Author:
+// Aaron Bockover <abockover novell com>
+//
+// Copyright (C) 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 Banshee.Streaming;
+using Banshee.Collection;
+using Banshee.Collection.Database;
+
+namespace Banshee.InternetRadio
+{
+ public class StationTrackInfo : DatabaseTrackInfo
+ {
+ private RadioTrackInfo radio_track;
+
+ public override bool TrackEqual (TrackInfo track)
+ {
+ StationTrackInfo station = track as StationTrackInfo;
+ return station != null && station.radio_track == radio_track;
+ }
+
+ public void Play ()
+ {
+ radio_track = new RadioTrackInfo (Uri);
+ radio_track.Play ();
+ }
+ }
+}
Modified: trunk/banshee/src/Extensions/Banshee.InternetRadio/Makefile.am
==============================================================================
--- trunk/banshee/src/Extensions/Banshee.InternetRadio/Makefile.am (original)
+++ trunk/banshee/src/Extensions/Banshee.InternetRadio/Makefile.am Tue Jun 17 02:50:54 2008
@@ -5,7 +5,9 @@
SOURCES = \
Banshee.InternetRadio/InternetRadioSource.cs \
- Banshee.InternetRadio/StationEditor.cs
+ Banshee.InternetRadio/RadioColumnController.cs \
+ Banshee.InternetRadio/StationEditor.cs \
+ Banshee.InternetRadio/StationTrackInfo.cs
RESOURCES = \
Banshee.InternetRadio.addin.xml \
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]