Exemple #1
0
        private void OnLibraryChanged(Source sender, TrackEventArgs args)
        {
            if (!Enabled)
            {
                return;
            }

            DapLibrarySync lib_to_sync = null;

            lock (library_syncs_mutex) {
                lib_to_sync = library_syncs.FirstOrDefault(lib_sync => lib_sync.Library == sender);
            }
            if (lib_to_sync != null)
            {
                if (AutoSync && lib_to_sync.Enabled)
                {
                    Sync();
                }
                else
                {
                    lib_to_sync.CalculateSync();
                    OnUpdated();
                }
            }
        }
Exemple #2
0
        private void RemoveLibrary(Source source)
        {
            var library = GetSyncableLibrary(source);

            if (library != null)
            {
                DapLibrarySync sync = null;
                lock (library_syncs_mutex) {
                    sync = library_syncs.FirstOrDefault(s => s.Library == library);
                }
                if (sync == null)
                {
                    return;
                }

                library_syncs.Remove(sync);
                sync.Library.TracksAdded   -= OnLibraryChanged;
                sync.Library.TracksDeleted -= OnLibraryChanged;

                var h = LibraryRemoved;
                if (h != null)
                {
                    h(sync);
                }

                sync.Dispose();
            }
        }
Exemple #3
0
        private void AddLibrary(Source source, bool initialized)
        {
            var library = GetSyncableLibrary(source);

            if (library != null)
            {
                var sync = new DapLibrarySync(this, library);
                lock (library_syncs_mutex) {
                    library_syncs.Add(sync);
                }
                library.TracksAdded   += OnLibraryChanged;
                library.TracksDeleted += OnLibraryChanged;

                if (initialized)
                {
                    SortLibraries();

                    var h = LibraryAdded;
                    if (h != null)
                    {
                        h(sync);
                    }
                }
            }
        }
Exemple #4
0
        private void BuildSyncLists()
        {
            int i = 0;

            foreach (LibrarySource source in Libraries)
            {
                DapLibrarySync library_sync = new DapLibrarySync(this, source);
                library_syncs.Add(library_sync);
                pref_sections.Add(library_sync.PrefsSection);
                library_sync.PrefsSection.Order = ++i;

                source.TracksAdded   += OnLibraryChanged;
                source.TracksDeleted += OnLibraryChanged;
            }

            dap.TracksAdded   += OnDapChanged;
            dap.TracksDeleted += OnDapChanged;
        }
Exemple #5
0
        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 };
        }
Exemple #6
0
 public SyncPlaylist(string name, PrimarySource parent, DapLibrarySync libsync) : base(name, parent)
 {
     this.libsync = libsync;
 }
Exemple #7
0
        private void AddLibrary(Source source, bool initialized)
        {
            var library = GetSyncableLibrary (source);
            if (library != null) {
                var sync = new DapLibrarySync (this, library);
                lock (library_syncs_mutex) {
                    library_syncs.Add (sync);
                }
                library.TracksAdded += OnLibraryChanged;
                library.TracksDeleted += OnLibraryChanged;

                if (initialized) {
                    SortLibraries ();

                    var h = LibraryAdded;
                    if (h != null) {
                        h (sync);
                    }
                }
            }
        }
Exemple #8
0
 public SyncPlaylist(string name, PrimarySource parent, DapLibrarySync libsync)
     : base(name, parent)
 {
     this.libsync = libsync;
 }
Exemple #9
0
 private void RemoveLibrary(DapLibrarySync library_sync)
 {
     table.RemoveRow (library_sync);
     var opts = library_opts[library_sync];
     library_opts.Remove (library_sync);
     opts.Dispose ();
 }
Exemple #10
0
 private void AddLibrary(DapLibrarySync library_sync)
 {
     var opts = new LibrarySyncOptions (library_sync);
     table.AddRow (library_sync, opts.RowCells);
     table.ShowAll ();
     library_opts.Add (library_sync, opts);
 }