Flow.Launcher/Plugins/Flow.Launcher.Plugin.PluginIndicator/Main.cs

54 lines
2 KiB
C#
Raw Permalink Normal View History

using System.Collections.Generic;
2014-01-06 11:03:20 +00:00
using System.Linq;
2020-04-21 09:12:17 +00:00
using Flow.Launcher.Core.Plugin;
2014-01-06 11:03:20 +00:00
2020-04-21 09:12:17 +00:00
namespace Flow.Launcher.Plugin.PluginIndicator
2014-01-06 11:03:20 +00:00
{
2016-05-07 02:55:09 +00:00
public class Main : IPlugin, IPluginI18n
2014-01-06 11:03:20 +00:00
{
2014-07-05 15:10:34 +00:00
private PluginInitContext context;
2014-01-06 11:03:20 +00:00
public List<Result> Query(Query query)
2014-01-06 11:03:20 +00:00
{
// if query contains more than one word, eg. github tips
// user has decided to type something else rather than wanting to see the available action keywords
if (query.SearchTerms.Length > 1)
return new List<Result>();
2015-11-07 03:50:15 +00:00
var results = from keyword in PluginManager.NonGlobalPlugins.Keys
where keyword.StartsWith(query.Search)
2015-11-07 03:50:15 +00:00
let metadata = PluginManager.NonGlobalPlugins[keyword].Metadata
where !metadata.Disabled
select new Result
{
Title = keyword,
SubTitle = $"Activate {metadata.Name} plugin",
Score = 100,
IcoPath = metadata.IcoPath,
AutoCompleteText = $"{keyword}{Plugin.Query.TermSeparator}",
2016-01-06 21:34:42 +00:00
Action = c =>
{
context.API.ChangeQuery($"{keyword}{Plugin.Query.TermSeparator}");
return false;
2016-01-06 21:34:42 +00:00
}
};
return results.ToList();
2014-01-06 11:03:20 +00:00
}
public void Init(PluginInitContext context)
2014-01-06 11:03:20 +00:00
{
2014-07-05 15:10:34 +00:00
this.context = context;
2014-01-06 11:03:20 +00:00
}
2015-02-07 13:27:48 +00:00
public string GetTranslatedPluginTitle()
{
2020-04-21 12:54:41 +00:00
return context.API.GetTranslation("flowlauncher_plugin_pluginindicator_plugin_name");
2015-02-07 13:27:48 +00:00
}
public string GetTranslatedPluginDescription()
{
2020-04-21 12:54:41 +00:00
return context.API.GetTranslation("flowlauncher_plugin_pluginindicator_plugin_description");
2015-02-07 13:27:48 +00:00
}
2014-01-06 11:03:20 +00:00
}
}