2015-01-03 07:20:34 +00:00
|
|
|
|
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
|
|
|
|
|
2015-01-03 07:20:34 +00:00
|
|
|
|
public List<Result> Query(Query query)
|
2014-01-06 11:03:20 +00:00
|
|
|
|
{
|
2021-05-10 10:15:33 +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.Terms.Length > 1)
|
|
|
|
|
|
return new List<Result>();
|
|
|
|
|
|
|
2015-11-07 03:50:15 +00:00
|
|
|
|
var results = from keyword in PluginManager.NonGlobalPlugins.Keys
|
2015-11-05 22:47:28 +00:00
|
|
|
|
where keyword.StartsWith(query.Terms[0])
|
2015-11-07 03:50:15 +00:00
|
|
|
|
let metadata = PluginManager.NonGlobalPlugins[keyword].Metadata
|
2020-02-22 09:02:07 +00:00
|
|
|
|
where !metadata.Disabled
|
2015-11-05 22:47:28 +00:00
|
|
|
|
select new Result
|
|
|
|
|
|
{
|
|
|
|
|
|
Title = keyword,
|
|
|
|
|
|
SubTitle = $"Activate {metadata.Name} plugin",
|
|
|
|
|
|
Score = 100,
|
2016-05-03 20:18:26 +00:00
|
|
|
|
IcoPath = metadata.IcoPath,
|
2016-01-06 21:34:42 +00:00
|
|
|
|
Action = c =>
|
2015-11-05 22:47:28 +00:00
|
|
|
|
{
|
|
|
|
|
|
context.API.ChangeQuery($"{keyword}{Plugin.Query.TermSeperater}");
|
|
|
|
|
|
return false;
|
2016-01-06 21:34:42 +00:00
|
|
|
|
}
|
2015-11-05 22:47:28 +00:00
|
|
|
|
};
|
|
|
|
|
|
return results.ToList();
|
2014-01-06 11:03:20 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
2015-01-03 07:20:34 +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
|
|
|
|
}
|
|
|
|
|
|
}
|