public override bool SetSource(ISource source) { ITrackModelSource track_source = source as ITrackModelSource; IFilterableSource filterable_source = source as IFilterableSource; if (track_source == null) { return(false); } this.source = source; SetModel(track_view, track_source.TrackModel); if (filterable_source != null && filterable_source.CurrentFilters != null) { foreach (IListModel model in filterable_source.CurrentFilters) { if (model is IListModel <ArtistInfo> ) { SetModel(artist_view, (model as IListModel <ArtistInfo>)); } else if (model is IListModel <AlbumInfo> ) { SetModel(album_view, (model as IListModel <AlbumInfo>)); } } } return(true); }
private void OnJumpToPlayingTrack(object o, EventArgs args) { ITrackModelSource track_src = ServiceManager.PlaybackController.Source; Source src = track_src as Source; if (track_src != null && src != null) { int i = track_src.TrackModel.IndexOf(ServiceManager.PlaybackController.CurrentTrack); if (i != -1) { // TODO clear the search/filters if there are any, since they might be hiding the currently playing item? // and/or switch to the track's primary source? what if it's been removed from the library all together? IListView <TrackInfo> track_list = src.Properties.Get <IListView <TrackInfo> > ("Track.IListView"); if (track_list != null) { ServiceManager.SourceManager.SetActiveSource(src); track_src.TrackModel.Selection.Clear(false); track_src.TrackModel.Selection.Select(i); track_src.TrackModel.Selection.FocusedIndex = i; track_list.CenterOn(i); track_list.GrabFocus(); } } } }
private static bool ConfirmRemove(ITrackModelSource source, bool delete, int selCount) { if (!source.ConfirmRemoveTracks) { return(true); } bool ret = false; string header = null; string message = null; string button_label = null; if (delete) { header = String.Format( Catalog.GetPluralString( "Are you sure you want to permanently delete this item?", "Are you sure you want to permanently delete the selected {0} items?", selCount ), selCount ); message = Catalog.GetString("If you delete the selection, it will be permanently lost."); button_label = "gtk-delete"; } else { header = String.Format(Catalog.GetString("Remove selection from {0}?"), source.Name); message = String.Format( Catalog.GetPluralString( "Are you sure you want to remove the selected item from your {1}?", "Are you sure you want to remove the selected {0} items from your {1}?", selCount ), selCount, source.GenericName ); button_label = "gtk-remove"; } HigMessageDialog md = new HigMessageDialog( ServiceManager.Get <GtkElementsService> ().PrimaryWindow, DialogFlags.DestroyWithParent, delete ? MessageType.Warning : MessageType.Question, ButtonsType.None, header, message ); // Delete from Disk defaults to Cancel and the others to OK/Confirm. md.AddButton("gtk-cancel", ResponseType.No, delete); md.AddButton(button_label, ResponseType.Yes, !delete); try { if (md.Run() == (int)ResponseType.Yes) { ret = true; } } finally { md.Destroy(); } return(ret); }
public override bool SetSource(ISource source) { ITrackModelSource track_source = source as ITrackModelSource; IFilterableSource filterable_source = source as IFilterableSource; if (track_source == null) { return(false); } base.SetSource(source); SetModel(track_view, track_source.TrackModel); bool genre_view_model_set = false; if (filterable_source != null && filterable_source.CurrentFilters != null) { foreach (IListModel model in filterable_source.CurrentFilters) { if (model is IListModel <ArtistInfo> && model is DatabaseArtistListModel) { SetModel(artist_view, (model as IListModel <ArtistInfo>)); } else if (model is IListModel <ArtistInfo> && model is DatabaseAlbumArtistListModel) { SetModel(albumartist_view, (model as IListModel <ArtistInfo>)); } else if (model is IListModel <AlbumInfo> ) { SetModel(album_view, (model as IListModel <AlbumInfo>)); } else if (model is IListModel <QueryFilterInfo <string> > && !genre_view_model_set) { SetModel(genre_view, (model as IListModel <QueryFilterInfo <string> >)); genre_view_model_set = true; } else if (model is DatabaseYearListModel) { SetModel(year_view, model as IListModel <YearInfo>); } else { Hyena.Log.DebugFormat("CompositeTrackSourceContents got non-album/artist filter model: {0}", model); } } } ClearFilterSelections(); track_view.HeaderVisible = true; return(true); }
private void UpdateActions() { Source source = ServiceManager.SourceManager.ActiveSource; bool in_database = source is DatabaseSource; PrimarySource primary_source = (source as PrimarySource) ?? (source.Parent as PrimarySource); Hyena.Collections.Selection selection = (source is ITrackModelSource) ? (source as ITrackModelSource).TrackModel.Selection : null; if (selection != null) { Sensitive = Visible = true; bool has_selection = selection.Count > 0; foreach (string action in require_selection_actions) { this[action].Sensitive = has_selection; } bool has_single_selection = selection.Count == 1; this["SelectAllAction"].Sensitive = !selection.AllSelected; if (source != null) { ITrackModelSource track_source = source as ITrackModelSource; bool is_track_source = track_source != null; UpdateActions(is_track_source && source.CanSearch, has_single_selection, "SearchMenuAction", "SearchForSameArtistAction", "SearchForSameAlbumAction" ); UpdateAction("RemoveTracksAction", is_track_source && track_source.CanRemoveTracks, has_selection, source); UpdateAction("DeleteTracksFromDriveAction", is_track_source && track_source.CanDeleteTracks, has_selection, source); UpdateAction("RemoveTracksFromLibraryAction", source.Parent is LibrarySource, has_selection, null); UpdateAction("TrackPropertiesAction", source.HasViewableTrackProperties, has_selection, source); UpdateAction("TrackEditorAction", source.HasEditableTrackProperties, has_selection, source); UpdateAction("RateTracksAction", in_database, has_selection, null); UpdateAction("AddToPlaylistAction", in_database && primary_source != null && primary_source.SupportsPlaylists && !primary_source.PlaylistsReadOnly, has_selection, null); if (primary_source != null && !(primary_source is LibrarySource)) { this["DeleteTracksFromDriveAction"].Label = String.Format( Catalog.GetString("_Delete From \"{0}\""), primary_source.StorageName); } } } else { Sensitive = Visible = false; } }
private void OnDeleteSelectedTracksFromDrive(object o, EventArgs args) { ITrackModelSource source = ActiveSource as ITrackModelSource; if (!ConfirmRemove(source, true, Selection.Count)) { return; } if (source != null && source.CanDeleteTracks) { source.DeleteTracks(Selection); } }
private void OnRemoveTracks(object o, EventArgs args) { ITrackModelSource source = ActiveSource as ITrackModelSource; if (!ConfirmRemove(source, false, Selection.Count)) { return; } if (source != null && source.CanRemoveTracks) { source.RemoveTracks(Selection); } }
/// <summary> /// Adds the currently selected item(s) of the active source to the internet radio source /// as new stations. Any session data (as in live365 with activated user login) will previously /// be cleared. /// </summary> /// <param name="o"> /// A <see cref="System.Object"/> -- not used /// </param> /// <param name="e"> /// A <see cref="EventArgs"/> -- not used /// </param> protected void OnAddToInternetRadio(object o, EventArgs e) { PrimarySource internet_radio_source = GetInternetRadioSource(); PrimarySource current_source = ServiceManager.SourceManager.ActiveSource as PrimarySource; if (current_source == null) { Log.Debug("[LiveRadioSource]<OnAddToInternetRadio> ActiveSource not Primary"); return; } if (internet_radio_source == null) { Log.Debug("[LiveRadioSource]<OnAddToInternetRadio> Internet Radio not found"); return; } ITrackModelSource active_track_model_source = (ITrackModelSource)current_source; if (active_track_model_source.TrackModel.SelectedItems == null || active_track_model_source.TrackModel.SelectedItems.Count <= 0) { return; } ILiveRadioPlugin current_plugin = null; foreach (ILiveRadioPlugin plugin in plugins) { if (plugin.PluginSource != null && plugin.PluginSource.Equals(current_source)) { current_plugin = plugin; } } foreach (TrackInfo track in active_track_model_source.TrackModel.SelectedItems) { DatabaseTrackInfo station_track = new DatabaseTrackInfo(track as DatabaseTrackInfo); if (station_track != null) { station_track.PrimarySource = internet_radio_source; if (current_plugin != null) { station_track.Uri = current_plugin.CleanUpUrl(station_track.Uri); } station_track.Save(); } } }
private void OnPlayerEnginePlayWhenIdleRequest(object o, EventArgs args) { ITrackModelSource next_source = NextSource; if (next_source != null && next_source.TrackModel.Selection.Count > 0) { Source = NextSource; CancelErrorTransition(); CurrentTrack = next_source.TrackModel[next_source.TrackModel.Selection.FirstIndex]; QueuePlayTrack(); } else { Next(); } }
private void OnRemoveTracks(object o, EventArgs args) { ITrackModelSource source = ActiveSource as ITrackModelSource; if (!ConfirmRemove(source, false, source.TrackModel.Selection.Count)) { return; } if (source != null && source.CanRemoveTracks) { ThreadAssist.SpawnFromMain(delegate { source.RemoveSelectedTracks(); }); } }
protected override void OnDragDataGet(Gdk.DragContext context, SelectionData selection_data, uint info, uint time) { if (info == Banshee.Gui.DragDrop.DragDropTarget.UriList.Info) { ITrackModelSource track_source = ServiceManager.SourceManager.ActiveSource as ITrackModelSource; if (track_source != null) { System.Text.StringBuilder sb = new System.Text.StringBuilder(); foreach (TrackInfo track in track_source.TrackModel.SelectedItems) { sb.Append(track.Uri); sb.Append("\r\n"); } byte [] data = System.Text.Encoding.UTF8.GetBytes(sb.ToString()); selection_data.Set(context.Targets[0], 8, data, data.Length); } } }
private void HandleActiveSourceChanged(SourceEventArgs args) { if (current_source != null && current_source.TrackModel != null) { current_source.TrackModel.Selection.Changed -= HandleSelectionChanged; current_source = null; } ITrackModelSource new_source = ActiveSource as ITrackModelSource; if (new_source != null) { new_source.TrackModel.Selection.Changed += HandleSelectionChanged; current_source = new_source; } Banshee.Base.ThreadAssist.ProxyToMain(UpdateActions); }
public override void Save(Stream stream, ITrackModelSource source) { using (StreamWriter writer = new StreamWriter(stream)) { writer.WriteLine("#EXTM3U"); TrackInfo track; for (int i = 0; i < source.TrackModel.Count; i++) { track = source.TrackModel[i]; int duration = (int)Math.Round(track.Duration.TotalSeconds); if (duration <= 0) { duration = -1; } writer.WriteLine("#EXTINF:{0},{1} - {2}", duration, track.DisplayArtistName, track.DisplayTrackTitle); writer.WriteLine(ExportUri(track.Uri)); } } }
private void OnRemoveTracksFromLibrary(object o, EventArgs args) { ITrackModelSource source = ActiveSource as ITrackModelSource; if (source != null) { LibrarySource library = source.Parent as LibrarySource; if (library != null) { if (!ConfirmRemove(library, false, Selection.Count)) { return; } ThreadAssist.SpawnFromMain(delegate { library.RemoveTracks(source.TrackModel as DatabaseTrackListModel, Selection); }); } } }
public override void Save (Stream stream, ITrackModelSource source) { Xspf.Playlist playlist = new Xspf.Playlist (); playlist.Title = source.Name; playlist.Date = DateTime.Now; for (int ii = 0; ii < source.TrackModel.Count; ii++) { TrackInfo track = source.TrackModel[ii]; Xspf.Track xtrack = new Xspf.Track (); xtrack.AddLocation (new Uri (ExportUri (track.Uri), UriKind.RelativeOrAbsolute)); xtrack.Title = track.TrackTitle; xtrack.Creator = track.ArtistName; xtrack.Album = track.AlbumTitle; if (track.TrackNumber >= 0) { xtrack.TrackNumber = (uint)track.TrackNumber; } xtrack.Duration = track.Duration; playlist.AddTrack (xtrack); } playlist.Save (stream); }
public BaseTrackListView() : base() { RulesHint = true; RowOpaquePropertyName = "Enabled"; RowBoldPropertyName = "IsPlaying"; ServiceManager.PlayerEngine.ConnectEvent( OnPlayerEvent, PlayerEvent.StartOfStream | PlayerEvent.StateChange); ForceDragSourceSet = true; IsEverReorderable = true; RowActivated += delegate(object o, RowActivatedArgs <TrackInfo> args) { ITrackModelSource source = ServiceManager.SourceManager.ActiveSource as ITrackModelSource; if (source != null && source.TrackModel == Model) { ServiceManager.PlaybackController.Source = source; ServiceManager.PlayerEngine.OpenPlay(args.RowValue); } }; }
public override void Save(Stream stream, ITrackModelSource source) { using (StreamWriter writer = new StreamWriter(stream)) { int count = 0; writer.WriteLine("[playlist]"); TrackInfo track; for (int i = 0; i < source.TrackModel.Count; i++) { track = source.TrackModel[i]; count++; writer.WriteLine("File{0}={1}", count, ExportUri(track.Uri)); writer.WriteLine("Title{0}={1} - {2}", count, track.DisplayArtistName, track.DisplayTrackTitle); writer.WriteLine("Length{0}={1}", count, (int)Math.Round(track.Duration.TotalSeconds)); } writer.WriteLine("NumberOfEntries={0}", count); writer.WriteLine("Version=2"); } }
public override void Save(Stream stream, ITrackModelSource source) { Xspf.Playlist playlist = new Xspf.Playlist(); playlist.Title = source.Name; playlist.Date = DateTime.Now; for (int ii = 0; ii < source.TrackModel.Count; ii++) { TrackInfo track = source.TrackModel[ii]; Xspf.Track xtrack = new Xspf.Track(); xtrack.AddLocation(new Uri(ExportUri(track.Uri), UriKind.RelativeOrAbsolute)); xtrack.Title = track.TrackTitle; xtrack.Creator = track.ArtistName; xtrack.Album = track.AlbumTitle; if (track.TrackNumber >= 0) { xtrack.TrackNumber = (uint)track.TrackNumber; } xtrack.Duration = track.Duration; playlist.AddTrack(xtrack); } playlist.Save(stream); }
public PlaybackControllerService() { InstantiateStacks(); player_engine = ServiceManager.PlayerEngine; player_engine.PlayWhenIdleRequest += OnPlayerEnginePlayWhenIdleRequest; player_engine.ConnectEvent(OnPlayerEvent, PlayerEvent.EndOfStream | PlayerEvent.StartOfStream | PlayerEvent.StateChange | PlayerEvent.Error, true); ServiceManager.SourceManager.ActiveSourceChanged += delegate { ITrackModelSource active_source = ServiceManager.SourceManager.ActiveSource as ITrackModelSource; if (active_source != null && source_auto_set_at == source_set_at && !player_engine.IsPlaying()) { Source = active_source; source_auto_set_at = source_set_at; } }; }
private void HandleActiveSourceChanged(SourceEventArgs args) { FilterFocused = false; if (current_source != null && current_source.TrackModel != null) { current_source.TrackModel.Reloaded -= OnReloaded; current_source.TrackModel.Selection.Changed -= HandleSelectionChanged; current_source = null; } ITrackModelSource new_source = ActiveSource as ITrackModelSource; if (new_source != null) { new_source.TrackModel.Selection.Changed += HandleSelectionChanged; new_source.TrackModel.Reloaded += OnReloaded; current_source = new_source; Selection = new_source.TrackModel.Selection; } ThreadAssist.ProxyToMain(UpdateActions); }
public override bool SetSource(ISource source) { ITrackModelSource track_source = source as ITrackModelSource; IFilterableSource filterable_source = source as IFilterableSource; if (track_source == null) { return(false); } this.source = source; SetModel(track_view, track_source.TrackModel); if (filterable_source != null && filterable_source.CurrentFilters != null) { foreach (IListModel model in filterable_source.CurrentFilters) { if (model is IListModel <ArtistInfo> ) { SetModel(artist_view, (model as IListModel <ArtistInfo>)); } else if (model is IListModel <AlbumInfo> ) { SetModel(album_view, (model as IListModel <AlbumInfo>)); } // else if (model is IListModel<QueryFilterInfo<string>>) // SetModel (genre_view, (model as IListModel<QueryFilterInfo<string>>)); // else // Hyena.Log.DebugFormat ("CompositeTrackSourceContents got non-album/artist filter model: {0}", model); } } track_view.HeaderVisible = true; return(true); }
public abstract void Save(Stream stream, ITrackModelSource source);
public InternetRadioSource() : base(Catalog.GetString("Radio"), Catalog.GetString("Radio"), "internet-radio", 220) { Properties.SetString("Icon.Name", "radio"); TypeUniqueId = "internet-radio"; IsLocal = false; AfterInitialized(); InterfaceActionService uia_service = ServiceManager.Get <InterfaceActionService> (); uia_service.GlobalActions.AddImportant( new ActionEntry("AddRadioStationAction", Stock.Add, Catalog.GetString("Add Station"), null, Catalog.GetString("Add a new Internet Radio station or playlist"), OnAddStation) ); ui_id = uia_service.UIManager.AddUiFromResource("GlobalUI.xml"); Properties.SetString("ActiveSourceUIResource", "ActiveSourceUI.xml"); Properties.Set <bool> ("ActiveSourceUIResourcePropagate", true); Properties.Set <System.Reflection.Assembly> ("ActiveSourceUIResource.Assembly", typeof(InternetRadioSource).Assembly); Properties.SetString("GtkActionPath", "/InternetRadioContextMenu"); source_contents = new InternetRadioSourceContents(); Properties.Set <bool> ("Nereid.SourceContentsPropagate", true); Properties.Set <ISourceContents> ("Nereid.SourceContents", source_contents); Properties.SetString("TrackEditorActionLabel", Catalog.GetString("Edit Station")); Properties.Set <InvokeHandler> ("TrackEditorActionHandler", delegate { ITrackModelSource active_track_model_source = (ITrackModelSource)ServiceManager.SourceManager.ActiveSource; if (active_track_model_source.TrackModel.SelectedItems == null || active_track_model_source.TrackModel.SelectedItems.Count <= 0) { return; } foreach (TrackInfo track in active_track_model_source.TrackModel.SelectedItems) { DatabaseTrackInfo station_track = track as DatabaseTrackInfo; if (station_track != null) { EditStation(station_track); return; } } }); Properties.SetString("TrackView.ColumnControllerXml", String.Format(@" <column-controller> <!--<column modify-default=""IndicatorColumn""> <renderer type=""Banshee.Podcasting.Gui.ColumnCellPodcastStatusIndicator"" /> </column>--> <add-default column=""IndicatorColumn"" /> <add-default column=""GenreColumn"" /> <column modify-default=""GenreColumn""> <visible>false</visible> </column> <add-default column=""TitleColumn"" /> <column modify-default=""TitleColumn""> <title>{0}</title> <long-title>{0}</long-title> </column> <add-default column=""ArtistColumn"" /> <column modify-default=""ArtistColumn""> <title>{1}</title> <long-title>{1}</long-title> </column> <add-default column=""CommentColumn"" /> <column modify-default=""CommentColumn""> <title>{2}</title> <long-title>{2}</long-title> </column> <add-default column=""RatingColumn"" /> <add-default column=""PlayCountColumn"" /> <add-default column=""LastPlayedColumn"" /> <add-default column=""LastSkippedColumn"" /> <add-default column=""DateAddedColumn"" /> <add-default column=""UriColumn"" /> <sort-column direction=""asc"">genre</sort-column> </column-controller>", Catalog.GetString("Station"), Catalog.GetString("Creator"), Catalog.GetString("Description") )); ServiceManager.PlayerEngine.TrackIntercept += OnPlayerEngineTrackIntercept; //ServiceManager.PlayerEngine.ConnectEvent (OnTrackInfoUpdated, Banshee.MediaEngine.PlayerEvent.TrackInfoUpdated); TrackEqualHandler = delegate(DatabaseTrackInfo a, TrackInfo b) { RadioTrackInfo radio_track = b as RadioTrackInfo; return(radio_track != null && DatabaseTrackInfo.TrackEqual( radio_track.ParentTrack as DatabaseTrackInfo, a)); }; if (new XspfMigrator(this).Migrate()) { Reload(); } }
public override void Save(Stream stream, ITrackModelSource source) { using(StreamWriter writer = new StreamWriter(stream)) { writer.WriteLine("#EXTM3U"); TrackInfo track; for (int i = 0; i < source.TrackModel.Count; i++) { track = source.TrackModel[i]; int duration = (int)Math.Round(track.Duration.TotalSeconds); if(duration <= 0) { duration = -1; } writer.WriteLine("#EXTINF:{0},{1} - {2}", duration, track.DisplayArtistName, track.DisplayTrackTitle); string trackpath = ExportUri (track.Uri); if (FolderSeparator == Folder.DosSeparator) { trackpath = trackpath.Replace (Folder.UnixSeparator, Folder.DosSeparator); } writer.WriteLine( trackpath ); } } }
private void HandleActiveSourceChanged(SourceEventArgs args) { FilterFocused = false; if (current_source != null && current_source.TrackModel != null) { current_source.TrackModel.Reloaded -= OnReloaded; current_source.TrackModel.Selection.Changed -= HandleSelectionChanged; current_source = null; } ITrackModelSource new_source = ActiveSource as ITrackModelSource; if (new_source != null) { new_source.TrackModel.Selection.Changed += HandleSelectionChanged; new_source.TrackModel.Reloaded += OnReloaded; current_source = new_source; Selection = new_source.TrackModel.Selection; } ThreadAssist.ProxyToMain (UpdateActions); }
private void SetAsPlaybackSourceUnlessPlaying() { if (current_track != null && ServiceManager.PlaybackController.Source != this) { bool set_source = !ServiceManager.PlayerEngine.IsPlaying (); if (!set_source) { long view_order = ServiceManager.DbConnection.Query<long> (@" SELECT ViewOrder FROM CorePlaylistEntries WHERE PlaylistID = ? AND EntryID = ?", DbId, Convert.ToInt64 (current_track.CacheEntryId)); long nongenerated = ServiceManager.DbConnection.Query<long> (@" SELECT COUNT(*) FROM CorePlaylistEntries WHERE PlaylistID = ? AND ViewOrder >= ? AND Generated = 0", DbId, view_order); set_source = nongenerated > 0; } if (set_source) { PriorSource = ServiceManager.PlaybackController.Source; ServiceManager.PlaybackController.NextSource = this; } } }
private static bool ConfirmRemove(ITrackModelSource source, bool delete, int selCount) { if (!source.ConfirmRemoveTracks) { return true; } bool ret = false; string header = null; string message = null; string button_label = null; if (delete) { header = String.Format ( Catalog.GetPluralString ( "Are you sure you want to permanently delete this item?", "Are you sure you want to permanently delete the selected {0} items?", selCount ), selCount ); message = Catalog.GetString ("If you delete the selection, it will be permanently lost."); button_label = "gtk-delete"; } else { header = String.Format (Catalog.GetString ("Remove selection from {0}?"), source.Name); message = String.Format ( Catalog.GetPluralString ( "Are you sure you want to remove the selected item from your {1}?", "Are you sure you want to remove the selected {0} items from your {1}?", selCount ), selCount, source.GenericName ); button_label = "gtk-remove"; } HigMessageDialog md = new HigMessageDialog ( ServiceManager.Get<GtkElementsService> ().PrimaryWindow, DialogFlags.DestroyWithParent, delete ? MessageType.Warning : MessageType.Question, ButtonsType.None, header, message ); // Delete from Disk defaults to Cancel and the others to OK/Confirm. md.AddButton ("gtk-cancel", ResponseType.No, delete); md.AddButton (button_label, ResponseType.Yes, !delete); try { if (md.Run () == (int) ResponseType.Yes) { ret = true; } } finally { md.Destroy (); } return ret; }
public override void Save(Stream stream, ITrackModelSource source) { throw new NotImplementedException(); }
public override void Save(Stream stream, ITrackModelSource source) { using(StreamWriter writer = new StreamWriter(stream)) { int count = 0; writer.WriteLine("[playlist]"); TrackInfo track; for (int i = 0; i < source.TrackModel.Count; i++) { track = source.TrackModel[i]; count++; writer.WriteLine("File{0}={1}", count, ExportUri(track.Uri)); writer.WriteLine("Title{0}={1} - {2}", count, track.DisplayArtistName, track.DisplayTrackTitle); writer.WriteLine("Length{0}={1}", count, (int)Math.Round(track.Duration.TotalSeconds)); } writer.WriteLine("NumberOfEntries={0}", count); writer.WriteLine("Version=2"); } }
public abstract void Save(Stream stream, ITrackModelSource source);
public override void Save(Stream stream, ITrackModelSource source) { throw new NotImplementedException(); }