private void AddPlaylistButton_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                var playlist = new PlaylistSource {
                    Name = "New Playlist"
                };

                var source = GetSelectedSource();
                if (source != null)
                {
                    source.IsExpanded = true;
                    playlist.Parent   = source;
                    source.AddChild(playlist);
                }
                else
                {
                    boundSources.Add(playlist);
                }

                sourceController.Save(playlist);
            }
            catch (Exception ex)
            {
                log.Error("AddPlaylistButton_Click", ex);
            }
        }
Esempio n. 2
0
        public override void SyncPlaylists()
        {
            lock (mtp_device) {
                List <MTP.Playlist> device_playlists = new List <MTP.Playlist> (mtp_device.GetPlaylists());
                foreach (MTP.Playlist playlist in device_playlists)
                {
                    playlist.Remove();
                }
                device_playlists.Clear();

                // Add playlists from Banshee to the device
                List <Source> children = new List <Source> (Children);
                foreach (Source child in children)
                {
                    PlaylistSource from = child as PlaylistSource;
                    if (from != null && from.Count > 0)
                    {
                        MTP.Playlist playlist = new MTP.Playlist(mtp_device, from.Name);
                        foreach (uint track_id in ServiceManager.DbConnection.QueryEnumerable <uint> (String.Format(
                                                                                                          "SELECT CoreTracks.ExternalID FROM {0} WHERE {1}",
                                                                                                          from.DatabaseTrackModel.ConditionFromFragment, from.DatabaseTrackModel.Condition)))
                        {
                            playlist.AddTrack(track_id);
                        }
                        playlist.Save();
                    }
                }
            }
        }
Esempio n. 3
0
        public static int RemoveArtistOrAlbumFromPlaylist(int playlistId, int id, bool isAlbum)
        {
            if (playlistId != 1 && playlistId != 2)
            {
                return(0);
            }

            int            count  = 0;
            PlaylistSource source = playlistId == 1 ? RemotePlaylist : PlayQueuePlaylist;

            for (int i = 0; i < source.TrackModel.Count; i++)
            {
                object t = source.TrackModel.GetItem(i);

                if (t is DatabaseTrackInfo && (isAlbum && ((DatabaseTrackInfo)t).AlbumId == id ||
                                               !isAlbum && ((DatabaseTrackInfo)t).ArtistId == id))
                {
                    source.RemoveTrack(i);
                    i--;
                    count++;
                }
            }

            return(count);
        }
Esempio n. 4
0
        protected override void OnDragDataReceived(Gdk.DragContext context, int x, int y,
                                                   Gtk.SelectionData data, uint info, uint time)
        {
            try {
                if (final_drag_start_time != context.StartTime || final_drag_source == null)
                {
                    Gtk.Drag.Finish(context, false, false, time);
                    return;
                }

                Source drop_source = final_drag_source;

                if (final_drag_source == NewPlaylistSource)
                {
                    PlaylistSource playlist = new PlaylistSource(Catalog.GetString("New Playlist"),
                                                                 (new_playlist_parent as PrimarySource));
                    playlist.Save();
                    playlist.PrimarySource.AddChildSource(playlist);
                    drop_source = playlist;
                }

                if (data.Target.Name == Banshee.Gui.DragDrop.DragDropTarget.Source.Target)
                {
                    DragDropList <Source> sources = data;
                    if (sources.Count > 0)
                    {
                        drop_source.MergeSourceInput(sources[0], SourceMergeType.Source);
                    }
                }
                else if (data.Target.Name == Banshee.Gui.DragDrop.DragDropTarget.UriList.Target)
                {
                    foreach (string uri in DragDropUtilities.SplitSelectionData(data))
                    {
                        // TODO if we dropped onto a playlist, add ourselves
                        // to it after importing (or if already imported, find
                        // and add to playlist)
                        ServiceManager.Get <Banshee.Library.LibraryImportManager> ().Enqueue(uri);
                    }
                }
                else if (data.Target.Name == Hyena.Data.Gui.ListViewDragDropTarget.ModelSelection.Target)
                {
                    // If the drag source is not the track list, it's a filter list, and instead of
                    // only merging the track model's selected tracks, we should merge all the tracks
                    // currently matching the active filters.
                    bool from_filter = !(Gtk.Drag.GetSourceWidget(context) is Banshee.Collection.Gui.BaseTrackListView);
                    drop_source.MergeSourceInput(
                        ServiceManager.SourceManager.ActiveSource,
                        from_filter ? SourceMergeType.Source : SourceMergeType.ModelSelection
                        );
                }
                else
                {
                    Hyena.Log.DebugFormat("SourceView got unknown drag target type: {0}", data.Target.Name);
                }

                Gtk.Drag.Finish(context, true, false, time);
            } finally {
                HideNewPlaylistRow();
            }
        }
Esempio n. 5
0
        private void HandleSourceAdded(SourceEventArgs args)
        {
            PlaylistSource playlist = args.Source as PlaylistSource;

            if (playlist == null)
            {
                return;
            }

            IDataReader reader = Globals.Library.Db.Query(String.Format(
                                                              "SELECT Condition, OrderBy, LimitNumber FROM SmartPlaylists WHERE PlaylistID = {0}",
                                                              playlist.Id
                                                              ));

            if (!reader.Read())
            {
                return;
            }

            string condition    = reader[0] as string;
            string order_by     = reader[1] as string;
            string limit_number = reader[2] as string;

            reader.Dispose();

            //Console.WriteLine ("Adding smart playlist {0}, id {1}", playlist.Name, playlist.Id);
            playlists.Add(playlist, new SmartPlaylist(playlist, condition, order_by, limit_number));
        }
Esempio n. 6
0
        /// <summary>
        /// 화면에 데이터를 로딩한다.
        /// </summary>
        async void LoadFiles()
        {
            Stopwatch st = null;

            if (Debugger.IsAttached)
            {
                st = new Stopwatch();
                st.Start();
            }

            await ThreadPool.RunAsync(async handler =>
            {
                //완료 기표
                loadingModel = LoadingMode.None;
                //재생목록 DB쿼리 (1 ~ 100개, 자막도 로드)
                var miList = new List <MediaInfo>();
                fileDAO.LoadPlayList(miList, 100, 0, true);
                //화면에 반영
                foreach (var mi in miList)
                {
                    await DispatcherHelper.RunAsync(() => { PlaylistSource.Add(mi); });
                }

                await DispatcherHelper.RunAsync(() =>
                {
                    CheckListButtonEnable = miList.Count > 0;
                    ReorderButtonEnable   = miList.Count > 1;
                });
            });

            if (Debugger.IsAttached)
            {
                System.Diagnostics.Debug.WriteLine("재생목록 로드 : " + st.Elapsed);
            }
        }
        private void ProcessRegularPlaylist(string name, XmlReader xml_reader)
        {
            var playlist_source = new PlaylistSource(name, ServiceManager.SourceManager.MusicLibrary);

            playlist_source.Save();
            ServiceManager.SourceManager.MusicLibrary.AddChildSource(playlist_source);

            // Get the songs in the playlists
            if (xml_reader != null)
            {
                while (xml_reader.ReadToFollowing("integer") && !CheckForCanceled())
                {
                    xml_reader.Read();
                    int itunes_id = Int32.Parse(xml_reader.ReadContentAsString());
                    int track_id;
                    if (data.track_ids.TryGetValue(itunes_id, out track_id))
                    {
                        try {
                            ServiceManager.DbConnection.Execute(
                                "INSERT INTO CorePlaylistEntries (PlaylistID, TrackID) VALUES (?, ?)",
                                playlist_source.DbId, track_id);
                        } catch {
                        }
                    }
                }
                playlist_source.Reload();
                playlist_source.NotifyUser();
            }
        }
        protected override bool OnDragDrop(Gdk.DragContext context, int x, int y, uint time_)
        {
            y = TranslateToListY(y);
            if (Gtk.Drag.GetSourceWidget(context) == this)
            {
                PlaylistSource playlist = ServiceManager.SourceManager.ActiveSource as PlaylistSource;
                if (playlist != null)
                {
                    //Gtk.Drag.
                    int row = GetRowAtY(y);
                    if (row != GetRowAtY(y + RowHeight / 2))
                    {
                        row += 1;
                    }

                    if (playlist.TrackModel.Selection.Contains(row))
                    {
                        // can't drop within the selection
                        return(false);
                    }

                    playlist.ReorderSelectedTracks(row);
                    return(true);
                }
            }

            return(false);
        }
Esempio n. 9
0
        public override void SyncPlaylists()
        {
            if (!CanSyncPlaylists)
            {
                return;
            }

            foreach (string file_name in PlaylistFiles)
            {
                try {
                    Banshee.IO.File.Delete(new SafeUri(file_name));
                } catch (Exception e) {
                    Log.Error(e);
                }
            }

            // Add playlists from Banshee to the device
            PlaylistFormatBase playlist_format = null;
            List <Source>      children        = new List <Source> (Children);

            foreach (Source child in children)
            {
                PlaylistSource from         = child as PlaylistSource;
                string         escaped_name = StringUtil.EscapeFilename(child.Name);
                if (from != null && !String.IsNullOrEmpty(escaped_name))
                {
                    from.Reload();
                    if (playlist_format == null)
                    {
                        playlist_format = Activator.CreateInstance(PlaylistTypes[0].Type) as PlaylistFormatBase;
                        playlist_format.FolderSeparator = MediaCapabilities.FolderSeparator;
                    }

                    SafeUri playlist_path = new SafeUri(System.IO.Path.Combine(
                                                            PlaylistsWritePath, String.Format("{0}.{1}", escaped_name, PlaylistTypes[0].FileExtension)));

                    System.IO.Stream stream = null;
                    try {
                        stream = Banshee.IO.File.OpenWrite(playlist_path, true);

                        if (ms_device.RootPath == null)
                        {
                            playlist_format.BaseUri = new Uri(PlaylistsWritePath);
                        }
                        else
                        {
                            playlist_format.RootPath = ms_device.RootPath;
                            playlist_format.BaseUri  = new Uri(BaseDirectory);
                        }

                        playlist_format.Save(stream, from);
                    } catch (Exception e) {
                        Log.Error(e);
                    } finally {
                        stream.Close();
                    }
                }
            }
        }
Esempio n. 10
0
 /// <summary>
 /// 화면의 데이터를 다시 저장한다.
 /// </summary>
 async void SaveFiles()
 {
     await ThreadPool.RunAsync(handler =>
     {
         //재생목록 DB에 파일 추가
         fileDAO.InsertPlayList(PlaylistSource.Reverse());
     });
 }
        public SmartPlaylist(PlaylistSource source, string condition, string order_by, string limit_number)
        {
            Source      = source;
            Condition   = condition;
            OrderBy     = order_by;
            LimitNumber = limit_number;

            RefreshMembers();
        }
Esempio n. 12
0
        private void OnNewPlaylist(object o, EventArgs args)
        {
            PlaylistSource playlist = new PlaylistSource(Catalog.GetString("New Playlist"), ActivePrimarySource);

            playlist.Save();
            playlist.PrimarySource.AddChildSource(playlist);
            playlist.NotifyUser();
            SourceView.BeginRenameSource(playlist);
        }
Esempio n. 13
0
        private void OnAddToNewPlaylist(object o, EventArgs args)
        {
            // TODO generate name based on the track selection, or begin editing it
            PlaylistSource playlist = new PlaylistSource(Catalog.GetString("New Playlist"), ActivePrimarySource);

            playlist.Save();
            playlist.PrimarySource.AddChildSource(playlist);
            AddToPlaylist(playlist);
        }
        public SmartPlaylist(PlaylistSource source, string condition, string order_by, string limit_number)
        {
            Source = source;
            Condition = condition;
            OrderBy = order_by;
            LimitNumber = limit_number;

            RefreshMembers();
        }
Esempio n. 15
0
        private void PrimarySourceInitialize()
        {
            // Scope the tracks to this primary source
            DatabaseTrackModel.AddCondition(String.Format("CoreTracks.PrimarySourceID = {0}", DbId));

            primary_sources[DbId] = this;

            // If there was a crash, tracks can be left behind, for example in DaapSource.
            // Temporary playlists are cleaned up by the PlaylistSource.LoadAll call below
            if (IsTemporary && SavedCount > 0)
            {
                PurgeTracks();
            }

            // Load our playlists and smart playlists
            foreach (PlaylistSource pl in PlaylistSource.LoadAll(this))
            {
                AddChildSource(pl);
            }

            int sp_count = 0;

            foreach (SmartPlaylistSource pl in SmartPlaylistSource.LoadAll(this))
            {
                AddChildSource(pl);
                sp_count++;
            }

            // Create default smart playlists if we haven't done it ever before, and if the
            // user has zero smart playlists.
            if (!HaveCreatedSmartPlaylists)
            {
                if (sp_count == 0)
                {
                    foreach (SmartPlaylistDefinition def in DefaultSmartPlaylists)
                    {
                        SmartPlaylistSource pl = def.ToSmartPlaylistSource(this);
                        pl.Save();
                        AddChildSource(pl);
                        pl.RefreshAndReload();
                        sp_count++;
                    }
                }

                // Only save it if we already had some smart playlists, or we actually created some (eg not
                // if we didn't have any and the list of default ones is empty atm).
                if (sp_count > 0)
                {
                    HaveCreatedSmartPlaylists = true;
                }
            }

            expanded_schema = new SchemaEntry <bool> (
                String.Format("sources.{0}", ParentConfigurationId), "expanded", true, "Is source expanded", "Is source expanded"
                );
        }
Esempio n. 16
0
        private void LoadFromDevice(bool refresh)
        {
            // bool previous_database_supported = database_supported;

            if (refresh)
            {
                ipod_device.TrackDatabase.Reload();
            }

            tracks_map.Clear();

            if (database_supported || (ipod_device.HasTrackDatabase &&
                                       ipod_device.ModelInfo.DeviceClass == "shuffle"))
            {
                foreach (Track ipod_track in ipod_device.TrackDatabase.Tracks)
                {
                    try {
                        IpodTrackInfo track = new IpodTrackInfo(ipod_track);
                        track.PrimarySource = this;
                        track.Save(false);
                        tracks_map.Add(track.TrackId, track);
                    } catch (Exception e) {
                        Log.Exception(e);
                    }
                }

                Hyena.Data.Sqlite.HyenaSqliteCommand insert_cmd = new Hyena.Data.Sqlite.HyenaSqliteCommand(
                    @"INSERT INTO CorePlaylistEntries (PlaylistID, TrackID)
                        SELECT ?, TrackID FROM CoreTracks WHERE PrimarySourceID = ? AND ExternalID = ?");
                foreach (IPod.Playlist playlist in ipod_device.TrackDatabase.Playlists)
                {
                    if (playlist.IsOnTheGo)   // || playlist.IsPodcast) {
                    {
                        continue;
                    }
                    PlaylistSource pl_src = new PlaylistSource(playlist.Name, this);
                    pl_src.Save();
                    // We use the IPod.Track.Id here b/c we just shoved it into ExternalID above when we loaded
                    // the tracks, however when we sync, the Track.Id values may/will change.
                    foreach (IPod.Track track in playlist.Tracks)
                    {
                        ServiceManager.DbConnection.Execute(insert_cmd, pl_src.DbId, this.DbId, track.Id);
                    }
                    pl_src.UpdateCounts();
                    AddChildSource(pl_src);
                }
            }

            /*else {
             *  BuildDatabaseUnsupportedWidget ();
             * }*/

            /*if(previous_database_supported != database_supported) {
             *  OnPropertiesChanged();
             * }*/
        }
Esempio n. 17
0
 private void AddToPlaylist(PlaylistSource playlist)
 {
     if (!FilterFocused)
     {
         playlist.AddSelectedTracks(ActiveSource);
     }
     else
     {
         playlist.AddAllTracks(ActiveSource);
     }
 }
Esempio n. 18
0
        private void OnAddToNewPlaylist(object o, EventArgs args)
        {
            // TODO generate name based on the track selection, or begin editing it
            PlaylistSource playlist = new PlaylistSource("New Playlist", ActivePrimarySource);

            playlist.Save();
            playlist.PrimarySource.AddChildSource(playlist);
            ThreadAssist.SpawnFromMain(delegate {
                playlist.AddSelectedTracks(ActiveSource);
            });
        }
Esempio n. 19
0
        /// <summary>
        /// This will be called if a resource is removed (so we can react on remote playlist deletion).
        /// </summary>
        /// <param name="s">
        /// Removed resource.
        /// </param>
        public static void HandleRemovedSource(Source s)
        {
            if (s == _remotePlaylist)
            {
                try {
                    DatabaseConfigurationClient.Client.Set <int>("banshee_remote", "remote_playlist_id", -1);
                } catch {
                    // you never know...
                }

                _remotePlaylist = null;
            }
        }
Esempio n. 20
0
        internal void Sync()
        {
            if (Enabled)
            {
                Banshee.Base.ThreadAssist.AssertNotInMainThread();

                CalculateSync();

                sync.Dap.DeleteAllTracks(to_remove);
                sync.Dap.AddAllTracks(to_add);

                if (library.SupportsPlaylists && sync.Dap.SupportsPlaylists)
                {
                    // Now create the playlists, taking snapshots of smart playlists and saving them
                    // as normal playlists
                    IList <AbstractPlaylistSource> playlists = GetSyncPlaylists();
                    foreach (AbstractPlaylistSource from in playlists)
                    {
                        if (from.Count == 0)
                        {
                            continue;
                        }
                        PlaylistSource to = new PlaylistSource(from.Name, sync.Dap);
                        to.Save();

                        ServiceManager.DbConnection.Execute(
                            String.Format(
                                @"INSERT INTO CorePlaylistEntries (PlaylistID, TrackID)
                                    SELECT ?, TrackID FROM CoreTracks WHERE PrimarySourceID = ? AND MetadataHash IN
                                        (SELECT MetadataHash FROM {0} WHERE {1})",
                                from.DatabaseTrackModel.ConditionFromFragment, from.DatabaseTrackModel.Condition),
                            to.DbId, sync.Dap.DbId
                            );
                        to.UpdateCounts();

                        if (to.Count == 0)
                        {
                            // If it's empty, don't leave it on the device
                            to.Unmap();
                        }
                        else
                        {
                            sync.Dap.AddChildSource(to);
                        }
                    }
                }

                CalculateSync();
                sync.OnUpdated();
            }
        }
Esempio n. 21
0
        protected virtual void PurgeSelfIfTemporary()
        {
            if (!IsTemporary)
            {
                return;
            }

            PlaylistSource.ClearTemporary(this);
            PurgeTracks();

            ServiceManager.DbConnection.Execute(new HyenaSqliteCommand(@"
                DELETE FROM CorePrimarySources WHERE PrimarySourceId = ?"),
                                                DbId);
        }
Esempio n. 22
0
        private void OnRemovePlayList(MediaInfo mediaInfo)
        {
            for (int i = PlaylistSource.Count - 1; i >= 0; i--)
            {
                if (mediaInfo.Path == PlaylistSource[i].Path)
                {
                    PlaylistSource.RemoveAt(i);
                    fileDAO.DeletePlayList(new MediaInfo[] { mediaInfo });
                    break;
                }
            }

            CheckPlaylistCount();
        }
        // Commented out for now - this method doesn't handle actually subscribing to the feeds
        // (the most important task in migrating podcasts), and it looks like it imports podcast files
        // into the Music Library.

        /*private void ImportPodcasts(LibraryImportManager manager, XmlNodeList podcasts)
         * {
         *  foreach (XmlElement entry in podcasts) {
         *      if (CheckForCanceled ()) {
         *          break;
         *      }
         *
         *      processed++;
         *
         *      string title = String.Empty, feed = String.Empty;
         *      SafeUri uri = null;
         *
         *      foreach (XmlElement child in entry.ChildNodes) {
         *          if (child == null || child.InnerText == null || child.InnerText == String.Empty) {
         *              continue;
         *          }
         *
         *          try {
         *              switch (child.Name) {
         *                  case "title":
         *                      title = child.InnerText;
         *                      break;
         *                  case "album":
         *                      feed = child.InnerText;
         *                      break;
         *                  case "mountpoint":
         *                      uri = new SafeUri (child.InnerText);
         *                      break;
         *              }
         *          } catch (Exception) {
         *              // parsing InnerText failed
         *          }
         *      }
         *
         *      if (uri == null) {
         *          continue;
         *      }
         *
         *      UpdateUserJob (processed, count, "", title);
         *
         *      try {
         *          DatabaseTrackInfo track = manager.ImportTrack (uri);
         *
         *          if (track == null) {
         *              LogError (SafeUri.UriToFilename (uri), Catalog.GetString ("Unable to import podcast."));
         *              continue;
         *          }
         *
         *          track.TrackTitle = title;
         *          track.AlbumTitle = feed;
         *          track.Genre = "Podcast";
         *
         *          track.Save (false);
         *      } catch (Exception e) {
         *          LogError (SafeUri.UriToFilename (uri), e);
         *      }
         *  }
         * }*/

        private void ImportStaticPlaylists(XmlNodeList playlists)
        {
            foreach (XmlElement list in playlists)
            {
                if (CheckForCanceled())
                {
                    break;
                }

                processed++;

                try {
                    string title = String.Empty;
                    if (list.HasAttribute("name"))
                    {
                        title = list.GetAttribute("name");
                    }

                    UpdateUserJob(processed, count, "", title);

                    PlaylistSource playlist = new PlaylistSource(title, ServiceManager.SourceManager.MusicLibrary);
                    playlist.Save();
                    ServiceManager.SourceManager.MusicLibrary.AddChildSource(playlist);


                    HyenaSqliteCommand insert_command = new HyenaSqliteCommand(String.Format(
                                                                                   @"INSERT INTO CorePlaylistEntries (PlaylistID, TrackID) VALUES ({0}, ?)", playlist.DbId));

                    foreach (XmlElement entry in list.ChildNodes)
                    {
                        if (entry.Name != "location")
                        {
                            continue;
                        }

                        int track_id = ServiceManager.SourceManager.MusicLibrary.GetTrackIdForUri(entry.InnerText);
                        if (track_id > 0)
                        {
                            ServiceManager.DbConnection.Execute(insert_command, track_id);
                        }
                    }

                    playlist.Reload();
                    playlist.NotifyUser();
                } catch (Exception e) {
                    LogError("", e);
                }
            }
        }
Esempio n. 24
0
        private void OnImportFinished(object o, EventArgs args)
        {
            importer.Finished -= OnImportFinished;

            if (CanSyncPlaylists)
            {
                var insert_cmd = new Hyena.Data.Sqlite.HyenaSqliteCommand(
                    "INSERT INTO CorePlaylistEntries (PlaylistID, TrackID) VALUES (?, ?)");
                foreach (string playlist_path in PlaylistFiles)
                {
                    // playlist_path has a file:// prefix, and GetDirectoryName messes it up,
                    // so we need to convert it to a regular path
                    string base_folder = ms_device.RootPath != null ? BaseDirectory :
                                         System.IO.Path.GetDirectoryName(SafeUri.UriToFilename(playlist_path));

                    IPlaylistFormat loaded_playlist = PlaylistFileUtil.Load(playlist_path,
                                                                            new Uri(base_folder),
                                                                            ms_device.RootPath);
                    if (loaded_playlist == null)
                    {
                        continue;
                    }

                    string         name     = System.IO.Path.GetFileNameWithoutExtension(SafeUri.UriToFilename(playlist_path));
                    PlaylistSource playlist = new PlaylistSource(name, this);
                    playlist.Save();
                    //Hyena.Data.Sqlite.HyenaSqliteCommand.LogAll = true;
                    foreach (PlaylistElement element in loaded_playlist.Elements)
                    {
                        string track_path = element.Uri.LocalPath;
                        long   track_id   = DatabaseTrackInfo.GetTrackIdForUri(new SafeUri(track_path), DbId);
                        if (track_id == 0)
                        {
                            Log.DebugFormat("Failed to find track {0} in DAP library to load it into playlist {1}", track_path, playlist_path);
                        }
                        else
                        {
                            ServiceManager.DbConnection.Execute(insert_cmd, playlist.DbId, track_id);
                        }
                    }
                    //Hyena.Data.Sqlite.HyenaSqliteCommand.LogAll = false;
                    playlist.UpdateCounts();
                    AddChildSource(playlist);
                }
            }

            import_reset_event.Set();
        }
Esempio n. 25
0
        // Called when the Add to Playlist action is highlighted.
        // Generates the menu of playlists to which you can add the selected tracks.
        private void OnAddToPlaylistMenu(object o, EventArgs args)
        {
            Source active_source = ServiceManager.SourceManager.ActiveSource;

            List <Source> children;

            lock (ActivePrimarySource.Children) {
                children = new List <Source> (ActivePrimarySource.Children);
            }

            // TODO find just the menu that was activated instead of modifying all proxies
            foreach (Widget proxy_widget in (o as Gtk.Action).Proxies)
            {
                MenuItem menu = proxy_widget as MenuItem;
                if (menu == null)
                {
                    continue;
                }

                Menu submenu = new Menu();
                menu.Submenu = submenu;

                submenu.Append(this ["AddToNewPlaylistAction"].CreateMenuItem());
                bool separator_added = false;

                foreach (Source child in children)
                {
                    PlaylistSource playlist = child as PlaylistSource;
                    if (playlist != null)
                    {
                        if (!separator_added)
                        {
                            submenu.Append(new SeparatorMenuItem());
                            separator_added = true;
                        }

                        PlaylistMenuItem item = new PlaylistMenuItem(playlist);
                        item.Image      = new Gtk.Image("playlist-source", IconSize.Menu);
                        item.Activated += OnAddToExistingPlaylist;
                        item.Sensitive  = playlist != active_source;
                        submenu.Append(item);
                    }
                }

                submenu.ShowAll();
            }
        }
Esempio n. 26
0
        private void HandleSourceRemoved(SourceEventArgs args)
        {
            PlaylistSource source = args.Source as PlaylistSource;

            if (source == null)
            {
                return;
            }

            playlists.Remove(source);

            // Delete it from the database
            Globals.Library.Db.Execute(String.Format(
                                           "DELETE FROM SmartPlaylists WHERE PlaylistId = {0}",
                                           source.Id
                                           ));
        }
        public SmartPlaylist(string name, string condition, string order_by, string limit_number)
        {
            Source = new PlaylistSource ();

            Name = name;
            Condition = condition;
            OrderBy = order_by;
            LimitNumber = limit_number;

            Globals.Library.Db.Execute(String.Format(
                @"INSERT INTO SmartPlaylists (PlaylistID, Condition, OrderBy, LimitNumber)
                VALUES ({0}, '{1}', '{2}', '{3}')",
                Source.Id,
                Sql.Statement.EscapeQuotes(Condition),
                Sql.Statement.EscapeQuotes(OrderBy),
                LimitNumber
            ));
        }
Esempio n. 28
0
        /// <summary>
        /// 파일 재생을 요청하고, 단건에 대해 재생목록에 추가한다.
        /// </summary>
        /// <param name="fileInfo"></param>
        void PlayItem(MediaInfo fileInfo)
        {
            //리오더 모드가 아닐때만 처리
            if (ReorderMode == ListViewReorderMode.Disabled &&
                string.IsNullOrEmpty(fileInfo.OccuredError))
            {
                //UI에 로딩된 파일이면 업데이트를 위해 데이터 취득
                var mi = PlaylistSource.FirstOrDefault(x => x.Path == fileInfo.Path);
                //화면에 로딩되지 않은 상태이면 DB에서 로딩
                if (mi == null)
                {
                    mi = fileDAO.GetPlayList(fileInfo.Path);
                }

                //재생 처리
                MessengerInstance.Send <Message>(new Message("Play", mi), CCPlayerViewModel.NAME);
            }
        }
        public SmartPlaylist(string name, string condition, string order_by, string limit_number)
        {
            Source = new PlaylistSource();

            Name        = name;
            Condition   = condition;
            OrderBy     = order_by;
            LimitNumber = limit_number;

            Globals.Library.Db.Execute(String.Format(
                                           @"INSERT INTO SmartPlaylists (PlaylistID, Condition, OrderBy, LimitNumber)
                VALUES ({0}, '{1}', '{2}', '{3}')",
                                           Source.Id,
                                           Sql.Statement.EscapeQuotes(Condition),
                                           Sql.Statement.EscapeQuotes(OrderBy),
                                           LimitNumber
                                           ));
        }
Esempio n. 30
0
 private void AddToPlaylist(PlaylistSource playlist)
 {
     if (!FilterFocused)
     {
         var track = ServiceManager.PlayerEngine.CurrentTrack as DatabaseTrackInfo;
         if (chosen_from_playing_track_submenu && track != null)
         {
             playlist.AddTrack(track);
         }
         else
         {
             playlist.AddSelectedTracks(ActiveSource);
         }
     }
     else
     {
         playlist.AddAllTracks(ActiveSource);
     }
 }
        public BaseDialog(PlaylistSource queue, string title, string addType) : base(title)
        {
            this.queue   = queue;
            VBox.Spacing = 6;

            HBox filter_box = new HBox();

            filter_box.Spacing = 6;

            Label search_label = new Label("_Search:");

            filter_box.PackStart(search_label, false, false, 0);

            search_entry = new MuinsheeSearchEntry();
            search_entry.Show();
            search_entry.Changed += OnFilterChanged;
            search_entry.Ready    = true;
            OnFilterChanged(null, null);
            filter_box.PackStart(search_entry, true, true, 0);

            VBox.PackStart(filter_box, false, false, 0);

            Hyena.Widgets.ScrolledWindow sw = new Hyena.Widgets.ScrolledWindow();
            sw.Add(GetItemWidget());
            VBox.PackStart(sw, true, true, 0);

            AddDefaultCloseButton();

            Button queue_button = new ImageButton(Catalog.GetString("En_queue"), "gtk-add");

            AddActionWidget(queue_button, Gtk.ResponseType.Apply);

            Button play_button = new ImageButton(Catalog.GetString("_Play"), "media-playback-start");

            AddButton(play_button, Gtk.ResponseType.Ok, true);

            window_controller = new PersistentWindowController(this, String.Format("muinshee.{0}", addType), 500, 475, WindowPersistOptions.Size);
            window_controller.Restore();
            ShowAll();

            Response += OnResponse;
        }
Esempio n. 32
0
        private void OnImportFinished(object o, EventArgs args)
        {
            importer.Finished -= OnImportFinished;

            if (CanSyncPlaylists)
            {
                var insert_cmd = new Hyena.Data.Sqlite.HyenaSqliteCommand(
                    "INSERT INTO CorePlaylistEntries (PlaylistID, TrackID) VALUES (?, ?)");
                int [] psources = new int [] { DbId };
                foreach (string playlist_path in PlaylistFiles)
                {
                    IPlaylistFormat loaded_playlist = PlaylistFileUtil.Load(playlist_path, new Uri(PlaylistsPath));
                    if (loaded_playlist == null)
                    {
                        continue;
                    }

                    PlaylistSource playlist = new PlaylistSource(System.IO.Path.GetFileNameWithoutExtension(playlist_path), this);
                    playlist.Save();
                    //Hyena.Data.Sqlite.HyenaSqliteCommand.LogAll = true;
                    foreach (Dictionary <string, object> element in loaded_playlist.Elements)
                    {
                        string track_path = (element["uri"] as Uri).LocalPath;
                        int    track_id   = DatabaseTrackInfo.GetTrackIdForUri(new SafeUri(track_path), psources);
                        if (track_id == 0)
                        {
                            Log.DebugFormat("Failed to find track {0} in DAP library to load it into playlist {1}", track_path, playlist_path);
                        }
                        else
                        {
                            ServiceManager.DbConnection.Execute(insert_cmd, playlist.DbId, track_id);
                        }
                    }
                    //Hyena.Data.Sqlite.HyenaSqliteCommand.LogAll = false;
                    playlist.UpdateCounts();
                    AddChildSource(playlist);
                }
            }

            import_reset_event.Set();
        }