mirror of
https://github.com/Flow-Launcher/Flow.Launcher.git
synced 2026-03-11 08:54:32 +00:00
Make GetPluginsForInterface private
This commit is contained in:
parent
f6574947a0
commit
2625f6fa41
3 changed files with 19 additions and 4 deletions
|
|
@ -28,6 +28,8 @@ namespace Flow.Launcher.Core.Plugin
|
|||
|
||||
private static IEnumerable<PluginPair> _contextMenuPlugins;
|
||||
private static IEnumerable<PluginPair> _homePlugins;
|
||||
private static IEnumerable<PluginPair> _resultUpdatePlugin;
|
||||
private static IEnumerable<PluginPair> _translationPlugins;
|
||||
private static IEnumerable<PluginPair> _hotkeyPlugins;
|
||||
|
||||
public static List<PluginPair> AllPlugins { get; private set; }
|
||||
|
|
@ -257,6 +259,8 @@ namespace Flow.Launcher.Core.Plugin
|
|||
|
||||
_contextMenuPlugins = GetPluginsForInterface<IContextMenu>();
|
||||
_homePlugins = GetPluginsForInterface<IAsyncHomeQuery>();
|
||||
_resultUpdatePlugin = GetPluginsForInterface<IResultUpdated>();
|
||||
_translationPlugins = GetPluginsForInterface<IPluginI18n>();
|
||||
_hotkeyPlugins = GetPluginsForInterface<IPluginHotkey>();
|
||||
var pluginHotkeyInfo = GetPluginHotkeyInfo();
|
||||
Settings.UpdatePluginHotkeyInfo(pluginHotkeyInfo);
|
||||
|
|
@ -420,7 +424,7 @@ namespace Flow.Launcher.Core.Plugin
|
|||
return AllPlugins.FirstOrDefault(o => o.Metadata.ID == id);
|
||||
}
|
||||
|
||||
public static IEnumerable<PluginPair> GetPluginsForInterface<T>() where T : IFeatures
|
||||
private static IEnumerable<PluginPair> GetPluginsForInterface<T>() where T : IFeatures
|
||||
{
|
||||
// Handle scenario where this is called before all plugins are instantiated, e.g. language change on startup
|
||||
return AllPlugins?.Where(p => p.Plugin is T) ?? Array.Empty<PluginPair>();
|
||||
|
|
@ -460,6 +464,17 @@ namespace Flow.Launcher.Core.Plugin
|
|||
return _homePlugins.Any(p => p.Metadata.ID == id);
|
||||
}
|
||||
|
||||
public static IList<PluginPair> GetResultUpdatePlugin()
|
||||
{
|
||||
return _resultUpdatePlugin.Where(p => !PluginModified(p.Metadata.ID)).ToList();
|
||||
}
|
||||
|
||||
public static IList<PluginPair> GetTranslationPlugins()
|
||||
{
|
||||
// Here we still return the modified plugins to update the possible string resources
|
||||
return _translationPlugins.ToList();
|
||||
}
|
||||
|
||||
public static Dictionary<PluginPair, List<BasePluginHotkey>> GetPluginHotkeyInfo()
|
||||
{
|
||||
var hotkeyPluginInfos = new Dictionary<PluginPair, List<BasePluginHotkey>>();
|
||||
|
|
|
|||
|
|
@ -74,7 +74,7 @@ namespace Flow.Launcher.Core.Resource
|
|||
|
||||
private void AddPluginLanguageDirectories()
|
||||
{
|
||||
foreach (var plugin in PluginManager.GetPluginsForInterface<IPluginI18n>())
|
||||
foreach (var plugin in PluginManager.GetTranslationPlugins())
|
||||
{
|
||||
var location = Assembly.GetAssembly(plugin.Plugin.GetType()).Location;
|
||||
var dir = Path.GetDirectoryName(location);
|
||||
|
|
@ -278,7 +278,7 @@ namespace Flow.Launcher.Core.Resource
|
|||
|
||||
private void UpdatePluginMetadataTranslations()
|
||||
{
|
||||
foreach (var p in PluginManager.GetPluginsForInterface<IPluginI18n>())
|
||||
foreach (var p in PluginManager.GetTranslationPlugins())
|
||||
{
|
||||
if (p.Plugin is not IPluginI18n pluginI18N) return;
|
||||
try
|
||||
|
|
|
|||
|
|
@ -260,7 +260,7 @@ namespace Flow.Launcher.ViewModel
|
|||
|
||||
public void RegisterResultsUpdatedEvent()
|
||||
{
|
||||
foreach (var pair in PluginManager.GetPluginsForInterface<IResultUpdated>())
|
||||
foreach (var pair in PluginManager.GetResultUpdatePlugin())
|
||||
{
|
||||
var plugin = (IResultUpdated)pair.Plugin;
|
||||
plugin.ResultsUpdated += (s, e) =>
|
||||
|
|
|
|||
Loading…
Reference in a new issue