Exemplo n.º 1
0
        private void UpdateForPlaylist (SmartPlaylistSource playlist)
        {
            PlaylistName = playlist.Name;
            Condition = playlist.ConditionTree;
            LimitEnabled = playlist.IsLimited;
            LimitValue = playlist.LimitValue;
            Limit = playlist.Limit;
            Order = playlist.QueryOrder;

            if (playlist.DbId > 0) {
                this.playlist = playlist;
                this.primary_source = playlist.PrimarySource;
                currently_editing = playlist;
            }
        }
Exemplo n.º 2
0
        public Editor(SmartPlaylistSource playlist)
        {
            currently_editing = playlist;
            this.playlist = playlist;
            this.primary_source = playlist.PrimarySource;
            /*Console.WriteLine ("Loading smart playlist into editor: {0}",
                playlist.ConditionTree == null ? "" : playlist.ConditionTree.ToXml (BansheeQuery.FieldSet, true));*/

            Initialize ();

            Title = Catalog.GetString ("Edit Smart Playlist");

            name_entry.Text = playlist.Name;

            UpdateForPlaylist (playlist);
        }
Exemplo n.º 3
0
        private void HandleAdvAdd(object sender, EventArgs args)
        {
            TreePath [] paths = adv_tree_view.Selection.GetSelectedRows ();

            foreach (TreePath path in paths) {
                TreeIter iter;
                if (adv_tree_view.Model.GetIter (out iter, path)) {
                    SmartPlaylistDefinition def = ((SmartPlaylistDefinition)adv_tree_view.Model.GetValue (iter, 1));
                    SmartPlaylistSource pl = def.ToSmartPlaylistSource (primary_source);
                    pl.Save ();
                    pl.PrimarySource.AddChildSource (pl);
                    //SmartPlaylistCore.Instance.StartTimer (pl);
                }
            }

            currently_editing = null;
            Destroy ();
        }
Exemplo n.º 4
0
        protected override void OnResponse(ResponseType response)
        {
            //int w = -1, h = -1;
            //dialog.GetSize (out w, out h);
            //Console.WriteLine ("w = {0}, h = {1}", w, h);

            QueryNode node = builder.QueryNode;
            if (node == null) {
                //Console.WriteLine ("Editor query is null");
            } else {
                //Console.WriteLine ("Editor query is: {0}", node.ToXml (BansheeQuery.FieldSet, true));
            }

            if (response == ResponseType.Ok) {
                string name = PlaylistName;
                QueryNode condition_tree = Condition;
                QueryLimit limit = Limit;
                QueryOrder order = Order;
                IntegerQueryValue limit_value = LimitValue;

                ThreadAssist.Spawn (delegate {
                    //Console.WriteLine ("Name = {0}, Cond = {1}, OrderAndLimit = {2}", name, condition, order_by, limit_number);
                    if (playlist == null) {
                        playlist = new SmartPlaylistSource (name, primary_source);

                        playlist.ConditionTree = condition_tree;
                        playlist.QueryOrder = order;
                        playlist.Limit = limit;
                        playlist.LimitValue = limit_value;

                        playlist.Save ();
                        primary_source.AddChildSource (playlist);
                        playlist.RefreshAndReload ();
                        //SmartPlaylistCore.Instance.StartTimer (playlist);
                    } else {
                        playlist.ConditionTree = condition_tree;
                        playlist.QueryOrder = order;
                        playlist.LimitValue = limit_value;
                        playlist.Limit = limit;

                        playlist.Name = name;
                        playlist.Save ();
                        playlist.RefreshAndReload ();

                        /*if (playlist.TimeDependent)
                            SmartPlaylistCore.Instance.StartTimer (playlist);
                        else
                            SmartPlaylistCore.Instance.StopTimer ();*/

                        //playlist.ListenToPlaylists ();
                        //SmartPlaylistCore.Instance.SortPlaylists ();
                    }
                });
            }

            currently_editing = null;
        }
        private void BuildSyncLists ()
        {
            // This smart playlist is the list of items we want on the device - nothing more, nothing less
            sync_src = new SmartPlaylistSource ("sync_list", library);
            sync_src.IsTemporary = true;
            sync_src.Save ();
            sync_src.AddCondition (library.AttributesCondition);
            sync_src.AddCondition (library.SyncCondition);

            // This is the same as the previous list with the items that are already on the device removed
            to_add = new SmartPlaylistSource ("to_add", library);
            to_add.IsTemporary = true;
            to_add.Save ();
            to_add.ConditionTree = UserQueryParser.Parse (String.Format ("smartplaylistid:{0}", sync_src.DbId),
                Banshee.Query.BansheeQuery.FieldSet);
            to_add.DatabaseTrackModel.AddCondition (String.Format (
                "MetadataHash NOT IN (SELECT MetadataHash FROM CoreTracks WHERE PrimarySourceId = {0})", sync.Dap.DbId
            ));

            // Any items on the device that aren't in the sync lists need to be removed
            to_remove = new SmartPlaylistSource ("to_remove", sync.Dap);
            to_remove.IsTemporary = true;
            to_remove.Save ();
            to_remove.AddCondition (library.AttributesCondition);
            to_remove.AddCondition (String.Format (
                @"MetadataHash NOT IN (SELECT MetadataHash FROM CoreTracks, CoreSmartPlaylistEntries
                    WHERE CoreSmartPlaylistEntries.SmartPlaylistID = {0} AND
                        CoreTracks.TrackID = CoreSmartPlaylistEntries.TrackID)",
                sync_src.DbId
            ));
        }
Exemplo n.º 6
0
        private void UpdateActions(bool force)
        {
            Source source = ActionSource;

            if ((force || source != last_source) && source != null)
            {
                IUnmapableSource    unmapable      = (source as IUnmapableSource);
                IImportSource       import_source  = (source as IImportSource);
                SmartPlaylistSource smart_playlist = (source as SmartPlaylistSource);
                PrimarySource       primary_source = (source as PrimarySource) ?? (source.Parent as PrimarySource);

                UpdateAction("UnmapSourceAction", unmapable != null, unmapable != null && unmapable.CanUnmap, source);
                UpdateAction("RenameSourceAction", source.CanRename, true, null);
                UpdateAction("ImportSourceAction", import_source != null, import_source != null && import_source.CanImport, source);
                UpdateAction("ExportPlaylistAction", source is AbstractPlaylistSource, true, source);
                UpdateAction("SourcePropertiesAction", source.HasProperties, true, source);
                UpdateAction("SourcePreferencesAction", source.PreferencesPageId != null, true, source);
                UpdateAction("RefreshSmartPlaylistAction", smart_playlist != null && smart_playlist.CanRefresh, true, source);
                this["OpenSourceSwitcher"].Visible = false;

                bool playlists_writable = primary_source != null && primary_source.SupportsPlaylists && !primary_source.PlaylistsReadOnly;
                UpdateAction("NewPlaylistAction", playlists_writable, true, source);
                UpdateAction("NewSmartPlaylistAction", playlists_writable, true, source);

                /*UpdateAction ("NewSmartPlaylistFromSearchAction", (source is LibrarySource || source.Parent is LibrarySource),
                 *      !String.IsNullOrEmpty (source.FilterQuery), source);*/

                IFilterableSource filterable_source = source as IFilterableSource;
                bool has_browser = filterable_source != null && filterable_source.AvailableFilters.Count > 0;

                ActionGroup browser_actions = Actions.FindActionGroup("BrowserView");
                if (browser_actions != null)
                {
                    UpdateAction(browser_actions["BrowserTopAction"], has_browser);
                    UpdateAction(browser_actions["BrowserLeftAction"], has_browser);
                    UpdateAction(browser_actions["BrowserVisibleAction"], has_browser);
                }

                ActionGroup browser_config_actions = Actions.FindActionGroup("BrowserConfiguration");
                if (browser_config_actions != null)
                {
                    // TODO: Be more specific than has_browser. Those actions have no effect
                    // on some sources that have a browser, like podcasts or radio.
                    UpdateAction(browser_config_actions["BrowserContentMenuAction"], has_browser);
                }

                last_source = source;
            }

            if (source != null)
            {
                UpdateAction("SortChildrenAction", source.ChildSortTypes.Length > 0 && source.Children.Count > 1, true, source);
            }

            Action <Source> handler = Updated;

            if (handler != null)
            {
                handler(source);
            }
        }