public void RemoveSource(Source source, bool recursivelyDispose) { if (source == null || !ContainsSource(source)) { return; } if (source == default_source) { default_source = null; } source.Updated -= OnSourceUpdated; source.ChildSourceAdded -= OnChildSourceAdded; source.ChildSourceRemoved -= OnChildSourceRemoved; sources.Remove(source); GroupSource associated_groupsource = FindAssociatedGroupSource(source.Order); if (!GroupSourceHasMembers(associated_groupsource)) { RemoveSource(associated_groupsource, recursivelyDispose); } foreach (Source child_source in source.Children) { RemoveSource(child_source, recursivelyDispose); } IDBusExportable exportable = source as IDBusExportable; if (exportable != null) { ServiceManager.DBusServiceManager.UnregisterObject(exportable); } if (recursivelyDispose) { IDisposable disposable = source as IDisposable; if (disposable != null) { disposable.Dispose(); } } ThreadAssist.ProxyToMain(delegate { if (source == active_source) { if (source.Parent != null && source.Parent.CanActivate) { SetActiveSource(source.Parent); } else { SetActiveSource(default_source); } } SourceEventHandler handler = SourceRemoved; if (handler != null) { SourceEventArgs args = new SourceEventArgs(); args.Source = source; handler(args); } }); }
public TrackListModel(IDBusExportable parent) : base(parent) { selection = new Selection(); }
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); } }
public ArtistListModel(IDBusExportable parent) : base(parent) { selection = new SelectAllSelection(); selection.SelectAll(); }
private static string GetObjectName(IDBusExportable o) { return(o is IDBusObjectName ? ((IDBusObjectName)o).ExportObjectName : o.ServiceName); }
public ObjectPath RegisterObject(string serviceName, IDBusExportable o) { return(RegisterObject(serviceName, o, MakeObjectPath(o))); }
public ObjectPath RegisterObject(IDBusExportable o) { return(RegisterObject(DBusConnection.DefaultServiceName, o)); }