Merge pull request #51 from Rovak/python-optional

Make python plugins optional
This commit is contained in:
Yeechan Lu
2014-03-19 11:42:46 +08:00
4 changed files with 41 additions and 4 deletions

View File

@@ -12,6 +12,12 @@ namespace Wox.Infrastructure.UserSettings
public List<ProgramSource> ProgramSources { get; set; } public List<ProgramSource> ProgramSources { get; set; }
public List<CustomPluginHotkey> CustomPluginHotkeys { get; set; } public List<CustomPluginHotkey> CustomPluginHotkeys { get; set; }
public bool StartWoxOnSystemStartup { get; set; } public bool StartWoxOnSystemStartup { get; set; }
public bool EnablePythonPlugins { get; set; }
public UserSetting()
{
EnablePythonPlugins = false;
}
public List<WebSearch> LoadDefaultWebSearches() public List<WebSearch> LoadDefaultWebSearches()
{ {

View File

@@ -5,6 +5,7 @@ using System.Text;
using System.Threading; using System.Threading;
using Microsoft.CSharp; using Microsoft.CSharp;
using Wox.Helper; using Wox.Helper;
using Wox.Infrastructure;
using Wox.Plugin; using Wox.Plugin;
namespace Wox.PluginLoader namespace Wox.PluginLoader
@@ -18,7 +19,11 @@ namespace Wox.PluginLoader
plugins.Clear(); plugins.Clear();
BasePluginLoader.ParsePluginsConfig(); BasePluginLoader.ParsePluginsConfig();
plugins.AddRange(new PythonPluginLoader().LoadPlugin()); if (CommonStorage.Instance.UserSetting.EnablePythonPlugins)
{
plugins.AddRange(new PythonPluginLoader().LoadPlugin());
}
plugins.AddRange(new CSharpPluginLoader().LoadPlugin()); plugins.AddRange(new CSharpPluginLoader().LoadPlugin());
foreach (IPlugin plugin in plugins.Select(pluginPair => pluginPair.Plugin)) foreach (IPlugin plugin in plugins.Select(pluginPair => pluginPair.Plugin))
{ {

View File

@@ -23,9 +23,6 @@
<TextBlock Text="Theme:" /> <TextBlock Text="Theme:" />
<ComboBox x:Name="themeComboBox" SelectionChanged="ThemeComboBox_OnSelectionChanged" HorizontalAlignment="Left" VerticalAlignment="Top" Width="120"/> <ComboBox x:Name="themeComboBox" SelectionChanged="ThemeComboBox_OnSelectionChanged" HorizontalAlignment="Left" VerticalAlignment="Top" Width="120"/>
</StackPanel> </StackPanel>
<StackPanel Orientation="Horizontal" Margin="10">
<Button x:Name="btnEnableInstaller" Click="BtnEnableInstaller_OnClick">enable plugin installer</Button>
</StackPanel>
</StackPanel> </StackPanel>
</TabItem> </TabItem>
<TabItem Header="Hotkey"> <TabItem Header="Hotkey">
@@ -107,5 +104,16 @@
</StackPanel> </StackPanel>
</Grid> </Grid>
</TabItem> </TabItem>
<TabItem Header="Plugins">
<StackPanel Orientation="Vertical" Margin="10">
<StackPanel Orientation="Horizontal" Margin="10">
<CheckBox x:Name="cbEnablePythonPlugins" />
<TextBlock Text="Enable Python Plugins" />
</StackPanel>
<StackPanel Orientation="Horizontal" Margin="10">
<Button x:Name="btnEnableInstaller" Click="BtnEnableInstaller_OnClick">enable plugin installer</Button>
</StackPanel>
</StackPanel>
</TabItem>
</TabControl> </TabControl>
</Window> </Window>

View File

@@ -46,6 +46,18 @@ namespace Wox
CommonStorage.Instance.Save(); CommonStorage.Instance.Save();
}; };
cbEnablePythonPlugins.Checked += (o, e) =>
{
CommonStorage.Instance.UserSetting.EnablePythonPlugins = true;
CommonStorage.Instance.Save();
};
cbEnablePythonPlugins.Unchecked += (o, e) =>
{
CommonStorage.Instance.UserSetting.EnablePythonPlugins = false;
CommonStorage.Instance.Save();
};
foreach (string theme in LoadAvailableThemes()) foreach (string theme in LoadAvailableThemes())
{ {
string themeName = theme.Substring(theme.LastIndexOf('\\') + 1).Replace(".xaml", ""); string themeName = theme.Substring(theme.LastIndexOf('\\') + 1).Replace(".xaml", "");
@@ -56,6 +68,7 @@ namespace Wox
cbReplaceWinR.IsChecked = CommonStorage.Instance.UserSetting.ReplaceWinR; cbReplaceWinR.IsChecked = CommonStorage.Instance.UserSetting.ReplaceWinR;
webSearchView.ItemsSource = CommonStorage.Instance.UserSetting.WebSearches; webSearchView.ItemsSource = CommonStorage.Instance.UserSetting.WebSearches;
lvCustomHotkey.ItemsSource = CommonStorage.Instance.UserSetting.CustomPluginHotkeys; lvCustomHotkey.ItemsSource = CommonStorage.Instance.UserSetting.CustomPluginHotkeys;
cbEnablePythonPlugins.IsChecked = CommonStorage.Instance.UserSetting.EnablePythonPlugins;
cbStartWithWindows.IsChecked = File.Exists(woxLinkPath); cbStartWithWindows.IsChecked = File.Exists(woxLinkPath);
} }
@@ -118,6 +131,8 @@ namespace Wox
private void CbStartWithWindows_OnChecked(object sender, RoutedEventArgs e) private void CbStartWithWindows_OnChecked(object sender, RoutedEventArgs e)
{ {
CreateStartupFolderShortcut(); CreateStartupFolderShortcut();
CommonStorage.Instance.UserSetting.StartWoxOnSystemStartup = true;
CommonStorage.Instance.Save();
} }
private void CbStartWithWindows_OnUnchecked(object sender, RoutedEventArgs e) private void CbStartWithWindows_OnUnchecked(object sender, RoutedEventArgs e)
@@ -126,6 +141,9 @@ namespace Wox
{ {
File.Delete(woxLinkPath); File.Delete(woxLinkPath);
} }
CommonStorage.Instance.UserSetting.StartWoxOnSystemStartup = false;
CommonStorage.Instance.Save();
} }
private void CreateStartupFolderShortcut() private void CreateStartupFolderShortcut()