public void SetShuffler (Shuffler shuffler)
        {
            if (Shuffler != null)
                throw new InvalidOperationException ("RandomBy already has Shuffler");

            Shuffler = shuffler;
        }
示例#2
0
        public HeaderWidget(Shuffler shuffler, string shuffle_mode_id, string source_name)
            : base(0, 0, 0, 0)
        {
            ThreadAssist.AssertInMainThread ();

            var box = new HBox ();
            box.Spacing = 6;

            var fill_label = new Label (Catalog.GetString ("_Fill"));
            mode_combo = new DictionaryComboBox<RandomBy> ();
            foreach (var random_by in shuffler.RandomModes.OrderBy (r => r.Adverb)) {
                mode_combo.Add (random_by.Adverb, random_by);
                if (random_by.Id == "off") {
                    mode_combo.Default = random_by;
                }
            }

            fill_label.MnemonicWidget = mode_combo;
            mode_combo.Changed += OnModeComboChanged;

            var from_label = new Label (Catalog.GetString ("f_rom"));
            var source_combo_box = new QueueableSourceComboBox (source_name);
            from_label.MnemonicWidget = source_combo_box;

            sensitive_widgets.Add (source_combo_box);
            sensitive_widgets.Add (from_label);

            source_combo_box.Changed += delegate {
                var handler = SourceChanged;
                if (handler != null) {
                    handler (this, new EventArgs<DatabaseSource> (source_combo_box.Source));
                }
            };

            box.PackStart (fill_label, false, false, 0);
            box.PackStart (mode_combo, false, false, 0);
            box.PackStart (from_label, false, false, 0);
            box.PackStart (source_combo_box, false, false, 0);
            this.SetPadding (0, 0, 6, 6);
            this.Add (box);

            // Select the saved population mode.
            var default_randomby = shuffler.RandomModes.FirstOrDefault (r => r.Id == shuffle_mode_id);
            if (default_randomby != null) {
                mode_combo.ActiveValue = default_randomby;
            } else if (mode_combo.Default != null) {
                mode_combo.ActiveValue = mode_combo.Default;
            }

            shuffler.RandomModeAdded   += (r) => mode_combo.Add (r.Adverb, r);
            shuffler.RandomModeRemoved += (r) => mode_combo.Remove (r);
        }
 public TrackInfo GetRandom(DateTime notPlayedSince, string shuffle_mode, bool repeat, bool resetSinceTime, Shuffler shuffler)
 {
     lock (this) {
         shuffler.SetModelAndCache (this, cache);
         return shuffler.GetRandom (notPlayedSince, shuffle_mode, repeat, resetSinceTime);
     }
 }
示例#4
0
        protected override void Initialize ()
        {
            base.Initialize ();

            shuffler = new Shuffler (UniqueId);
            InstallPreferences ();
            header_widget = CreateHeaderWidget ();
            header_widget.ShowAll ();

            Properties.Set<Gtk.Widget> ("Nereid.SourceContents.HeaderWidget", header_widget);
        }
 public TrackInfo GetRandom(DateTime notPlayedSince, string shuffle_mode, bool repeat, bool resetSinceTime, Shuffler shuffler)
 {
     lock (this) {
         shuffler.SetModelAndCache(this, cache);
         return(shuffler.GetRandom(notPlayedSince, shuffle_mode, repeat, resetSinceTime));
     }
 }
示例#6
0
 public RandomByTrack(Shuffler shuffler) : base(PlaybackShuffleMode.Song, shuffler)
 {
     Condition = "1=1";
     OrderBy   = "RANDOM()";
 }
示例#7
0
 public RandomByAlbum(Shuffler shuffler) : base(PlaybackShuffleMode.Album, shuffler)
 {
     Condition = "CoreTracks.AlbumID = ?";
     OrderBy   = "Disc ASC, TrackNumber ASC";
 }
示例#8
0
 public RandomByRating(Shuffler shuffler) : base(PlaybackShuffleMode.Rating, shuffler)
 {
     Condition = "(CoreTracks.Rating = ? OR (? = 3 AND CoreTracks.Rating = 0))";
     OrderBy   = "RANDOM()";
 }
示例#9
0
 public RandomBySlot(PlaybackShuffleMode mode, Shuffler shuffler) : base(mode, shuffler)
 {
 }
示例#10
0
 public RandomByArtist(Shuffler shuffler) : base(PlaybackShuffleMode.Artist, shuffler)
 {
     Condition = "CoreAlbums.ArtistID = ?";
     OrderBy   = "CoreTracks.Year, CoreTracks.AlbumID ASC, Disc ASC, TrackNumber ASC";
 }
示例#11
0
 public RandomBy(PlaybackShuffleMode mode, Shuffler shuffler)
 {
     Shuffler       = shuffler;
     Mode           = mode;
     insert_shuffle = new HyenaSqliteCommand("INSERT OR REPLACE INTO CoreShuffles (ShufflerID, TrackID, LastShuffledAt) VALUES (?, ?, ?)");
 }
示例#12
0
 public RandomByScore(Shuffler shuffler) : base(PlaybackShuffleMode.Score, shuffler)
 {
     Condition = "(CoreTracks.Score BETWEEN ? AND ? OR (? = 50 AND CoreTracks.Score = 0))";
     OrderBy   = "RANDOM()";
 }