Esempio n. 1
0
        public void Dispose()
        {
            lock (this) {
                try {
                    AddinManager.RemoveExtensionNodeHandler("/Banshee/SourceManager/Source", OnExtensionChanged);
                } catch {}

                active_source  = null;
                default_source = null;
                music_library  = null;
                video_library  = null;

                // Do dispose extension sources
                foreach (Source source in extension_sources.Values)
                {
                    RemoveSource(source, true);
                }

                // But do not dispose non-extension sources
                while (sources.Count > 0)
                {
                    RemoveSource(sources[0], false);
                }

                sources.Clear();
                extension_sources.Clear();
            }
        }
Esempio n. 2
0
        public void AddSource(Source source, bool isDefault)
        {
            Banshee.Base.ThreadAssist.AssertInMainThread();
            if (source == null || ContainsSource(source))
            {
                return;
            }

            int position = FindSourceInsertPosition(source);

            sources.Insert(position, source);

            if (isDefault)
            {
                default_source = source;
            }

            source.Updated            += OnSourceUpdated;
            source.ChildSourceAdded   += OnChildSourceAdded;
            source.ChildSourceRemoved += OnChildSourceRemoved;

            SourceAddedHandler handler = SourceAdded;

            if (handler != null)
            {
                SourceAddedArgs args = new SourceAddedArgs();
                args.Position = position;
                args.Source   = source;
                handler(args);
            }

            if (source is MusicLibrarySource)
            {
                music_library = source as MusicLibrarySource;
            }
            else if (source is VideoLibrarySource)
            {
                video_library = source as VideoLibrarySource;
            }

            IDBusExportable exportable = source as IDBusExportable;

            if (exportable != null)
            {
                ServiceManager.DBusServiceManager.RegisterObject(exportable);
            }

            List <Source> children = new List <Source> (source.Children);

            foreach (Source child_source in children)
            {
                AddSource(child_source, false);
            }

            if (isDefault && ActiveSource == null)
            {
                SetActiveSource(source);
            }
        }
Esempio n. 3
0
        public void AddSource(Source source, bool isDefault)
        {
            ThreadAssist.AssertInMainThread();
            if (source == null || ContainsSource(source))
            {
                return;
            }

            GroupSource group_source = source as GroupSource;

            if (group_source != null && !group_sources.Contains(group_source))
            {
                group_sources.Add(group_source);
                return;
            }

            AddSource(FindAssociatedGroupSource(source.Order));

            int position = FindSourceInsertPosition(source);

            sources.Insert(position, source);

            if (isDefault)
            {
                default_source = source;
            }

            source.Updated            += OnSourceUpdated;
            source.ChildSourceAdded   += OnChildSourceAdded;
            source.ChildSourceRemoved += OnChildSourceRemoved;

            if (source is MusicLibrarySource)
            {
                music_library = source as MusicLibrarySource;
            }
            else if (source is VideoLibrarySource)
            {
                video_library = source as VideoLibrarySource;
            }

            SourceAdded.SafeInvoke(new SourceAddedArgs()
            {
                Position = position,
                Source   = source
            });

            IDBusExportable exportable = source as IDBusExportable;

            if (exportable != null)
            {
                ServiceManager.DBusServiceManager.RegisterObject(exportable);
            }

            List <Source> children = new List <Source> (source.Children);

            foreach (Source child_source in children)
            {
                AddSource(child_source, false);
            }

            if (isDefault && ActiveSource == null)
            {
                SetActiveSource(source);
            }
        }