public LibrarySyncOptions(DapLibrarySync library_sync) { this.library_sync = library_sync; var library = library_sync.Library; // Translators: {0} is the name of a library, eg 'Music' or 'Podcasts' var label = new Label(String.Format(Catalog.GetString("{0}:"), library.Name)) { Xalign = 1f }; // Create the combo for selecting what type of sync to do for this library combo = new DictionaryComboBox <DatabaseSource> (); combo.RowSeparatorFunc = (model, iter) => { return((string)model.GetValue(iter, 0) == "---"); }; combo.Add(null, Catalog.GetString("Manage manually"), -10); combo.Add(null, Catalog.GetString("Sync entire library"), -9); foreach (var child in library.Children) { AddPlaylist(child); } library.ChildSourceAdded += OnChildSourceAdded; library.ChildSourceRemoved += OnChildSourceRemoved; if (!library_sync.Enabled) { combo.Active = 0; } else if (library_sync.SyncEntireLibrary) { combo.Active = 1; } else if (library_sync.SyncSource != null) { combo.ActiveValue = library_sync.SyncSource; } combo.Changed += (o, a) => { library_sync.Enabled = combo.Active != 0; library_sync.SyncEntireLibrary = combo.Active == 1; if (combo.Active > 1) { library_sync.SyncSource = combo.ActiveValue; } library_sync.MaybeTriggerAutoSync(); }; RowCells = new Widget [] { label, combo }; }
private void AddPlaylist(Source source) { var db_src = source as DatabaseSource; if (db_src == null) { return; } if (playlist_count == 0) { sep_iter = combo.Add(null, "---", -8); } // Translators: {0} is the name of a playlist combo.Add(db_src, String.Format(Catalog.GetString("Sync from \u201c{0}\u201d"), db_src.Name), db_src.Order); db_src.Updated += OnPlaylistChanged; playlist_count++; }
public LibrarySyncOptions(DapLibrarySync library_sync) { this.library_sync = library_sync; var library = library_sync.Library; // Translators: {0} is the name of a library, eg 'Music' or 'Podcasts' var label = new Label (String.Format (Catalog.GetString ("{0}:"), library.Name)) { Xalign = 1f }; // Create the combo for selecting what type of sync to do for this library combo = new DictionaryComboBox<DatabaseSource> (); combo.RowSeparatorFunc = (model, iter) => { return (string)model.GetValue (iter, 0) == "---"; }; combo.Add (null, Catalog.GetString ("Manage manually"), -10); combo.Add (null, Catalog.GetString ("Sync entire library"), -9); foreach (var child in library.Children) { AddPlaylist (child); } library.ChildSourceAdded += OnChildSourceAdded; library.ChildSourceRemoved += OnChildSourceRemoved; if (!library_sync.Enabled) combo.Active = 0; else if (library_sync.SyncEntireLibrary) combo.Active = 1; else if (library_sync.SyncSource != null) combo.ActiveValue = library_sync.SyncSource; combo.Changed += (o, a) => { library_sync.Enabled = combo.Active != 0; library_sync.SyncEntireLibrary = combo.Active == 1; if (combo.Active > 1) { library_sync.SyncSource = combo.ActiveValue; } library_sync.MaybeTriggerAutoSync (); }; RowCells = new Widget [] { label, combo }; }
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 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); }