コード例 #1
0
        protected override void PluginInitialize()
        {
            // Check that our SmartPlaylists table exists in the database, otherwise make it
            if (!Globals.Library.Db.TableExists("SmartPlaylists"))
            {
                Globals.Library.Db.Execute(@"
                    CREATE TABLE SmartPlaylists (
                        PlaylistID INTEGER PRIMARY KEY,
                        Condition TEXT,
                        OrderBy TEXT,
                        LimitNumber TEXT)
                ");
            }

            // Listen for deleted playlists and new/changed songs
            SourceManager.SourceAdded    += HandleSourceAdded;
            SourceManager.SourceRemoved  += HandleSourceRemoved;
            Globals.Library.Reloaded     += HandleLibraryReloaded;
            Globals.Library.TrackAdded   += HandleTrackAdded;
            Globals.Library.TrackRemoved += HandleTrackRemoved;


            // Add a menu option to create a new smart playlist
            musicMenu          = (Globals.ActionManager.GetWidget("/MainMenu/MusicMenu") as MenuItem).Submenu as Menu;
            addItem            = new MenuItem(Catalog.GetString("New Smart Playlist..."));
            addItem.Activated += delegate {
                SmartPlaylistEditor ed = new SmartPlaylistEditor();
                ed.RunDialog();
            };
            // Insert right after the New Playlist item
            musicMenu.Insert(addItem, 2);
            addItem.Show();

            // Add option for editing smart playlists

            /*Globals.ActionManager.PlaylistActions.Add(new ActionEntry [] {
             *  new ActionEntry("EditSmartPlaylistAction", null,
             *      Catalog.GetString("Edit Smart Playlist"), "<shift>Delete",
             *      Catalog.GetString("Edit the active smart playlist"), null)
             * });
             *
             * Globals.ActionManager.PlaylistActions.GetAction ("EditSmartPlaylistAction").Visible = true;
             * Globals.ActionManager.PlaylistActions.GetAction ("EditSmartPlaylistAction").Sensitive = true;*/

            sourceMenu          = Globals.ActionManager.GetWidget("/SourceMenu") as Menu;
            editItem            = new MenuItem(Catalog.GetString("Edit Smart Playlist..."));
            editItem.Activated += delegate {
                SmartPlaylistEditor ed = new SmartPlaylistEditor(playlists[SourceManager.ActiveSource] as SmartPlaylist);
                ed.RunDialog();
            };
            sourceMenu.Insert(editItem, 2);
            editItem.Show();
        }
コード例 #2
0
        protected override void PluginInitialize()
        {
            // Check that our SmartPlaylists table exists in the database, otherwise make it
            if(!Globals.Library.Db.TableExists("SmartPlaylists")) {
                Globals.Library.Db.Execute(@"
                    CREATE TABLE SmartPlaylists (
                        PlaylistID INTEGER PRIMARY KEY,
                        Condition TEXT,
                        OrderBy TEXT,
                        LimitNumber TEXT)
                ");
            }

            // Listen for deleted playlists and new/changed songs
            SourceManager.SourceAdded += HandleSourceAdded;
            SourceManager.SourceRemoved += HandleSourceRemoved;
            Globals.Library.Reloaded += HandleLibraryReloaded;
            Globals.Library.TrackAdded += HandleTrackAdded;
            Globals.Library.TrackRemoved += HandleTrackRemoved;

            // Add a menu option to create a new smart playlist
            musicMenu = (Globals.ActionManager.GetWidget ("/MainMenu/MusicMenu") as MenuItem).Submenu as Menu;
            addItem = new MenuItem (Catalog.GetString("New Smart Playlist..."));
            addItem.Activated += delegate {
                SmartPlaylistEditor ed = new SmartPlaylistEditor ();
                ed.RunDialog ();
            };
            // Insert right after the New Playlist item
            musicMenu.Insert (addItem, 2);
            addItem.Show ();

            // Add option for editing smart playlists
            /*Globals.ActionManager.PlaylistActions.Add(new ActionEntry [] {
                new ActionEntry("EditSmartPlaylistAction", null,
                    Catalog.GetString("Edit Smart Playlist"), "<shift>Delete",
                    Catalog.GetString("Edit the active smart playlist"), null)
            });

            Globals.ActionManager.PlaylistActions.GetAction ("EditSmartPlaylistAction").Visible = true;
            Globals.ActionManager.PlaylistActions.GetAction ("EditSmartPlaylistAction").Sensitive = true;*/

            sourceMenu = Globals.ActionManager.GetWidget ("/SourceMenu") as Menu;
            editItem = new MenuItem (Catalog.GetString("Edit Smart Playlist..."));
            editItem.Activated += delegate {
                SmartPlaylistEditor ed = new SmartPlaylistEditor (playlists[SourceManager.ActiveSource] as SmartPlaylist);
                ed.RunDialog ();
            };
            sourceMenu.Insert (editItem, 2);
            editItem.Show ();
        }