Skip to content

Commit

Permalink
Add option to ignore Growl close commands. issue #1
Browse files Browse the repository at this point in the history
  • Loading branch information
BobVul committed Mar 20, 2016
1 parent 8faf6aa commit e32cb39
Show file tree
Hide file tree
Showing 7 changed files with 318 additions and 260 deletions.
15 changes: 11 additions & 4 deletions Growler/Growler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,17 +20,23 @@ protected override void HandleNotification(Notification notification, string dis
string title = notification.Title;
string message = notification.Description;

LaunchToaster(String.Format("show {0} {1} {2}", Base64Encode(title), Base64Encode(message), this.GetSettingOrDefault<bool>(GrowlerSettingsPanel.SETTING_SILENT, false)));
LaunchToaster(String.Format("show {0} {1} {2}", Base64Encode(title), Base64Encode(message), this.GetSettingOrDefault<bool>(GrowlerSetting.Silent, false)));
}

public override void CloseAllOpenNotifications()
{
LaunchToaster("closeall");
if (!this.GetSettingOrDefault<bool>(GrowlerSetting.IgnoreClose, false))
{
LaunchToaster("closeall");
}
}

public override void CloseLastNotification()
{
LaunchToaster("closelast");
if (!this.GetSettingOrDefault<bool>(GrowlerSetting.IgnoreClose, false))
{
LaunchToaster("closelast");
}
}

public override string Author
Expand Down Expand Up @@ -58,8 +64,9 @@ public override string Website
get { return "https://github.com/Elusive138/GrowlToToast"; }
}

private T GetSettingOrDefault<T>(string key, T def)
private T GetSettingOrDefault<T>(GrowlerSetting setting, T def)
{
string key = GrowlerSettingKeymap.GetKey(setting);
if (!this.SettingsCollection.ContainsKey(key))
return def;
return (T)this.SettingsCollection[key];
Expand Down
132 changes: 67 additions & 65 deletions Growler/Growler.csproj
Original file line number Diff line number Diff line change
@@ -1,72 +1,74 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{98B66CA8-8CDA-4958-B98B-4D9949B4A3B6}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>Growler</RootNamespace>
<AssemblyName>Growler</AssemblyName>
<TargetFrameworkVersion>v2.0</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<PlatformTarget>x86</PlatformTarget>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<PlatformTarget>x86</PlatformTarget>
</PropertyGroup>
<ItemGroup>
<Reference Include="Growl.CoreLibrary, Version=2.0.0.0, Culture=neutral, PublicKeyToken=13e59d82e007b064, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>.\Growl.CoreLibrary.dll</HintPath>
</Reference>
<Reference Include="Growl.DisplayStyle, Version=2.0.0.0, Culture=neutral, processorArchitecture=x86">
<SpecificVersion>False</SpecificVersion>
<HintPath>.\Growl.DisplayStyle.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Data" />
<Reference Include="System.Drawing" />
<Reference Include="System.Windows.Forms" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="Growler.cs" />
<Compile Include="GrowlerSettingsPanel.cs">
<SubType>UserControl</SubType>
</Compile>
<Compile Include="GrowlerSettingsPanel.Designer.cs">
<DependentUpon>GrowlerSettingsPanel.cs</DependentUpon>
</Compile>
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
<EmbeddedResource Include="GrowlerSettingsPanel.resx">
<DependentUpon>GrowlerSettingsPanel.cs</DependentUpon>
</EmbeddedResource>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{98B66CA8-8CDA-4958-B98B-4D9949B4A3B6}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>Growler</RootNamespace>
<AssemblyName>Growler</AssemblyName>
<TargetFrameworkVersion>v2.0</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<PlatformTarget>x86</PlatformTarget>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<PlatformTarget>x86</PlatformTarget>
</PropertyGroup>
<ItemGroup>
<Reference Include="Growl.CoreLibrary, Version=2.0.0.0, Culture=neutral, PublicKeyToken=13e59d82e007b064, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>.\Growl.CoreLibrary.dll</HintPath>
</Reference>
<Reference Include="Growl.DisplayStyle, Version=2.0.0.0, Culture=neutral, processorArchitecture=x86">
<SpecificVersion>False</SpecificVersion>
<HintPath>.\Growl.DisplayStyle.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Data" />
<Reference Include="System.Drawing" />
<Reference Include="System.Windows.Forms" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="Growler.cs" />
<Compile Include="GrowlerSetting.cs" />
<Compile Include="GrowlerSettingKeymap.cs" />
<Compile Include="GrowlerSettingsPanel.cs">
<SubType>UserControl</SubType>
</Compile>
<Compile Include="GrowlerSettingsPanel.Designer.cs">
<DependentUpon>GrowlerSettingsPanel.cs</DependentUpon>
</Compile>
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
<EmbeddedResource Include="GrowlerSettingsPanel.resx">
<DependentUpon>GrowlerSettingsPanel.cs</DependentUpon>
</EmbeddedResource>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
-->
</Project>
12 changes: 12 additions & 0 deletions Growler/GrowlerSetting.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
using System;
using System.Collections.Generic;
using System.Text;

namespace Growler
{
enum GrowlerSetting
{
Silent,
IgnoreClose
}
}
20 changes: 20 additions & 0 deletions Growler/GrowlerSettingKeymap.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
using System;
using System.Collections.Generic;
using System.Text;

namespace Growler
{
static class GrowlerSettingKeymap
{
private static readonly IDictionary<GrowlerSetting, string> GrowlerSettingKeys = new Dictionary<GrowlerSetting, string>
{
{ GrowlerSetting.Silent, "silent" },
{ GrowlerSetting.IgnoreClose, "ignore_close" }
};

public static string GetKey(GrowlerSetting setting)
{
return GrowlerSettingKeys[setting];
}
}
}
136 changes: 75 additions & 61 deletions Growler/GrowlerSettingsPanel.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

25 changes: 14 additions & 11 deletions Growler/GrowlerSettingsPanel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,30 +11,33 @@ namespace Growler
{
public partial class GrowlerSettingsPanel : SettingsPanelBase
{
public static readonly string SETTING_SILENT = "silent";

public GrowlerSettingsPanel()
{
InitializeComponent();
}

private void checkBoxSilent_CheckedChanged(object sender, EventArgs e)
{
this.SaveSetting(SETTING_SILENT, checkBoxSilent.Checked);
this.SaveSetting(GrowlerSettingKeymap.GetKey(GrowlerSetting.Silent), checkBoxSilent.Checked);
}

private void checkBoxIgnoreClose_CheckedChanged(object sender, EventArgs e)
{
this.SaveSetting(GrowlerSettingKeymap.GetKey(GrowlerSetting.IgnoreClose), checkBoxIgnoreClose.Checked);
}

private void GrowlerSettingsPanel_Load(object sender, EventArgs e)
{
Dictionary<string, object> settings = this.GetSettings();
if (!settings.ContainsKey(SETTING_SILENT))
{
this.SaveSetting(SETTING_SILENT, false);
object val;
if (settings.TryGetValue(GrowlerSettingKeymap.GetKey(GrowlerSetting.Silent), out val) && (bool)val)
{
checkBoxSilent.Checked = true;
}
bool silent = (bool)settings[SETTING_SILENT];
if (silent)
{
checkBoxSilent.Checked = true;
if (settings.TryGetValue(GrowlerSettingKeymap.GetKey(GrowlerSetting.IgnoreClose), out val) && (bool)val)
{
checkBoxIgnoreClose.Checked = true;
}
}
}
}
}
Loading

0 comments on commit e32cb39

Please sign in to comment.