Ejemplo n.º 1
0
        private void RemovePlaylist(Source source, bool disposing)
        {
            var db_src = source as DatabaseSource;

            if (db_src == null)
            {
                return;
            }

            // If this was the selected playlist, change to manually manage
            if (!disposing && db_src == combo.ActiveValue)
            {
                combo.Active = 0;
            }

            if (combo.Remove(db_src))
            {
                db_src.Updated -= OnPlaylistChanged;
                playlist_count--;

                if (playlist_count == 0)
                {
                    combo.Remove(ref sep_iter);
                    sep_iter = TreeIter.Zero;
                }
            }
        }
Ejemplo n.º 2
0
        public HeaderWidget (Shuffler shuffler, string shuffle_mode_id, string source_name) : base ()
        {
            ThreadAssist.AssertInMainThread ();
            this.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));
                }
            };

            PackStart (fill_label, false, false, 0);
            PackStart (mode_combo, false, false, 0);
            PackStart (from_label, false, false, 0);
            PackStart (source_combo_box, false, false, 0);

            // 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);
        }
Ejemplo n.º 3
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);
        }