Change Python C Wrapper

This commit is contained in:
qianlifeng
2013-12-27 20:06:49 +08:00
parent bdf77b2782
commit 5893564f46
5 changed files with 123 additions and 64 deletions

View File

@@ -68,8 +68,8 @@ namespace WinAlfred
private void TextBoxBase_OnTextChanged(object sender, TextChangedEventArgs e)
{
string query = tbQuery.Text;
ThreadPool.QueueUserWorkItem(state =>
{
//ThreadPool.QueueUserWorkItem(state =>
//{
results.Clear();
foreach (PluginPair pair in plugins)
{
@@ -98,7 +98,7 @@ namespace WinAlfred
resultCtrl.AddResults(results.OrderByDescending(o => o.Score).ToList());
resultCtrl.SelectFirst();
}));
});
//});
}
private void HideWinAlfred()

View File

@@ -25,12 +25,24 @@ namespace WinAlfred.PluginLoader
try
{
string s = Marshal.PtrToStringAnsi(ExecPython(metadata.PluginDirecotry, metadata.ExecuteFileName.Replace(".py", ""), "query", query.RawQuery));
if (string.IsNullOrEmpty(s))
{
return new List<Result>();
}
if (s.StartsWith("PYTHONERROR"))
{
throw new ArgumentException(s);
}
List<PythonResult> o = JsonConvert.DeserializeObject<List<PythonResult>>(s);
List<Result> r = new List<Result>();
foreach (PythonResult pythonResult in o)
{
PythonResult ps = pythonResult;
ps.Action = () => ExecPython(metadata.PluginDirecotry, metadata.ExecuteFileName.Replace(".py", ""), ps.ActionName, ps.ActionPara);
if (!string.IsNullOrEmpty(ps.ActionName))
{
ps.Action = () => ExecPython(metadata.PluginDirecotry, metadata.ExecuteFileName.Replace(".py", ""), ps.ActionName, ps.ActionPara);
}
r.Add(ps);
}
return r;

View File

@@ -152,7 +152,7 @@ namespace WinAlfred
var resultItemControl = pnlContainer.Children[index] as ResultItem;
if (resultItemControl != null)
{
resultItemControl.Result.Action();
if (resultItemControl.Result.Action != null) resultItemControl.Result.Action();
}
}