public PlayQueueSource () : base (Catalog.GetString ("Play Queue"), null) { BindToDatabase (); TypeUniqueId = DbId.ToString (); Initialize (); AfterInitialized (); Order = 20; Properties.SetString ("Icon.Name", "source-playlist"); Properties.SetString ("RemoveTracksActionLabel", Catalog.GetString ("Remove From Play Queue")); DatabaseTrackModel.ForcedSortQuery = "CorePlaylistEntries.ViewOrder ASC, CorePlaylistEntries.EntryID ASC"; DatabaseTrackModel.CanReorder = true; ServiceManager.PlayerEngine.ConnectEvent (OnPlayerEvent); ServiceManager.PlaybackController.TrackStarted += OnTrackStarted; // TODO change this Gtk.Action code so that the actions can be removed. And so this // class doesn't depend on Gtk/ThickClient. actions = new PlayQueueActions (this); Properties.SetString ("ActiveSourceUIResource", "ActiveSourceUI.xml"); Properties.SetString ("GtkActionPath", "/PlayQueueContextMenu"); // TODO listen to all primary sources, and handle transient primary sources ServiceManager.SourceManager.MusicLibrary.TracksChanged += HandleTracksChanged; ServiceManager.SourceManager.MusicLibrary.TracksDeleted += HandleTracksDeleted; ServiceManager.SourceManager.VideoLibrary.TracksChanged += HandleTracksChanged; ServiceManager.SourceManager.VideoLibrary.TracksDeleted += HandleTracksDeleted; populate_from = ServiceManager.SourceManager.Sources.FirstOrDefault ( source => source.Name == populate_from_name) as DatabaseSource; if (populate_from != null) { populate_from.Reload (); } TrackModel.Reloaded += HandleReloaded; int saved_offset = DatabaseConfigurationClient.Client.Get (CurrentOffsetSchema, CurrentOffsetSchema.Get ()); Offset = Math.Min ( saved_offset, ServiceManager.DbConnection.Query<long> (@" SELECT MAX(ViewOrder) + 1 FROM CorePlaylistEntries WHERE PlaylistID = ?", DbId)); ServiceManager.SourceManager.AddSource (this); }
public HeaderWidget CreateHeaderWidget () { var header_widget = new HeaderWidget (shuffler, populate_shuffle_mode, populate_from_name); header_widget.ModeChanged += delegate (object sender, EventArgs<RandomBy> e) { populate_shuffle_mode = e.Value.Id; PopulateModeSchema.Set (populate_shuffle_mode); UpdatePlayQueue (); OnUpdated (); }; populate_shuffle_mode = header_widget.ShuffleModeId; header_widget.SourceChanged += delegate (object sender, EventArgs<DatabaseSource> e) { populate_from = e.Value; if (populate_from == null) { populate_from_name = String.Empty; PopulateFromSchema.Set (String.Empty); return; } populate_from_name = e.Value.Name; PopulateFromSchema.Set (e.Value.Name); source_set_at = DateTime.Now; populate_from.Reload (); Refresh (); }; return header_widget; }