Skip to content

Commit 87febda

Browse files
committed
Add ReplaceActionKeyword api function
1 parent 4632932 commit 87febda

File tree

5 files changed

+12
-6
lines changed

5 files changed

+12
-6
lines changed

Flow.Launcher.Plugin/Interfaces/IPublicAPI.cs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,6 @@ public interface IPublicAPI
151151
/// <param name="callback"></param>
152152
public void RemoveGlobalKeyboardCallback(Func<int, int, SpecialKeyState, bool> callback);
153153

154-
155154
/// <summary>
156155
/// Fuzzy Search the string with the given query. This is the core search mechanism Flow uses
157156
/// </summary>
@@ -334,5 +333,13 @@ public interface IPublicAPI
334333
/// <param name="forceClosed">When user closes the progress box manually by button or esc key, this action will be called.</param>
335334
/// <returns>A progress box interface.</returns>
336335
public Task ShowProgressBoxAsync(string caption, Func<Action<double>, Task> reportProgressAsync, Action forceClosed = null);
336+
337+
/// <summary>
338+
/// Replace ActionKeyword for specific plugin
339+
/// </summary>
340+
/// <param name="pluginId">ID for plugin that needs to remove action keyword</param>
341+
/// <param name="oldActionKeyword">The actionkeyword that is supposed to be removed</param>
342+
/// <param name="newActionKeyword">The actionkeyword that is supposed to be added</param>
343+
public void ReplaceActionKeyword(string pluginId, string oldActionKeyword, string newActionKeyword);
337344
}
338345
}

Flow.Launcher/PublicAPIInstance.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
using System.Diagnostics;
2727
using System.Collections.Specialized;
2828
using Flow.Launcher.Core;
29+
using Flow.Launcher.Infrastructure.UserSettings;
2930

3031
namespace Flow.Launcher
3132
{
@@ -311,7 +312,6 @@ public bool IsGameModeOn()
311312
return _mainVM.GameModeStatus;
312313
}
313314

314-
315315
private readonly List<Func<int, int, SpecialKeyState, bool>> _globalKeyboardHandlers = new();
316316

317317
public void RegisterGlobalKeyboardCallback(Func<int, int, SpecialKeyState, bool> callback) => _globalKeyboardHandlers.Add(callback);
@@ -326,6 +326,8 @@ public MessageBoxResult ShowMsgBox(string messageBoxText, string caption = "", M
326326

327327
public Task ShowProgressBoxAsync(string caption, Func<Action<double>, Task> reportProgressAsync, Action forceClosed = null) => ProgressBoxEx.ShowAsync(caption, reportProgressAsync, forceClosed);
328328

329+
public void ReplaceActionKeyword(string pluginId, string oldActionKeyword, string newActionKeyword) => PluginManager.ReplaceActionKeyword(pluginId, oldActionKeyword, newActionKeyword);
330+
329331
#endregion
330332

331333
#region Private Methods

Plugins/Flow.Launcher.Plugin.WebSearch/Flow.Launcher.Plugin.WebSearch.csproj

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,6 @@
5151
</ItemGroup>
5252

5353
<ItemGroup>
54-
<ProjectReference Include="..\..\Flow.Launcher.Core\Flow.Launcher.Core.csproj" />
5554
<ProjectReference Include="..\..\Flow.Launcher.Infrastructure\Flow.Launcher.Infrastructure.csproj" />
5655
<ProjectReference Include="..\..\Flow.Launcher.Plugin\Flow.Launcher.Plugin.csproj" />
5756
</ItemGroup>

Plugins/Flow.Launcher.Plugin.WebSearch/SearchSourceSetting.xaml.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
using System.Collections.Generic;
22
using System.Windows;
33
using Microsoft.Win32;
4-
using Flow.Launcher.Core.Plugin;
54

65
namespace Flow.Launcher.Plugin.WebSearch
76
{
@@ -103,7 +102,7 @@ private void EditSearchSource()
103102
if (!_context.API.ActionKeywordAssigned(newKeyword) || oldKeyword == newKeyword)
104103
{
105104
var id = _context.CurrentPluginMetadata.ID;
106-
PluginManager.ReplaceActionKeyword(id, oldKeyword, newKeyword);
105+
_context.API.ReplaceActionKeyword(id, oldKeyword, newKeyword);
107106

108107
var index = _searchSources.IndexOf(_oldSearchSource);
109108
_searchSources[index] = _searchSource;

Plugins/Flow.Launcher.Plugin.WebSearch/SettingsControl.xaml.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
using System.Windows;
22
using System.Windows.Controls;
3-
using Flow.Launcher.Core.Plugin;
43
using System.ComponentModel;
54
using System.Windows.Data;
65

0 commit comments

Comments
 (0)