summary refs log tree commit diff stats
path: root/src/htm
diff options
context:
space:
mode:
Diffstat (limited to 'src/htm')
-rw-r--r--src/htm/Main.cs87
-rw-r--r--src/htm/htm-xp.csproj163
2 files changed, 224 insertions, 26 deletions
diff --git a/src/htm/Main.cs b/src/htm/Main.cs
index a342bbe4..6a7cd4d2 100644
--- a/src/htm/Main.cs
+++ b/src/htm/Main.cs
@@ -36,27 +36,50 @@ namespace thememan
 {

     public partial class HTM : Form

     {

-        public string appdata = (Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "\\HexChat\\");

-        public string home = (Environment.GetFolderPath(Environment.SpecialFolder.Personal) + "/.config/hexchat/");

-

-        public string xchatdir;

-        public string themedir = "themes\\";

+        public string hexchatdir;

+        public string themedir;

 

         OpenFileDialog importDialog;

 

         public HTM ()

-		{

-			InitializeComponent ();

-            

-			if (File.Exists ("portable-mode"))

-				xchatdir = ("config\\");

-			else if (Directory.Exists (appdata))

-				xchatdir = (appdata);

-			else if (Directory.Exists (home)) {

-				xchatdir = (home); themedir = "themes/";

-			} else

-				Console.WriteLine("Install not found");

+        {

+            InitializeComponent ();

+

+            if (RunningOnWindows() && File.Exists("portable-mode"))

+            {

+                hexchatdir = ("config\\");

+

+                if (!Directory.Exists(hexchatdir))

+                {

+                    MessageBox.Show("HexChat installation not found!\nCheck your .\\config folder", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);

+                    Environment.Exit(1);

+                }

+            }

+            else

+            {

+                /* Environment.SpecialFolder.ApplicationData

+                 * Windows: %APPDATA%

+                 * Unix: ~/.config

+                 * Windows is case-insensitive so 'hexchat' should be fine for both

+                 */

+                hexchatdir = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "hexchat");

+

+                if (!Directory.Exists(hexchatdir))

+                {

+                    if (RunningOnWindows())

+                    {

+                        MessageBox.Show("HexChat installation not found!\nCheck your %APPDATA%\\HexChat folder", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);    

+                    }

+                    else

+                    {

+                        MessageBox.Show("HexChat installation not found!\nCheck your ~/.config/hexchat folder", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);

+                    }

+                    

+                    Environment.Exit(1);

+                }

+            }

 

+            themedir = Path.Combine(hexchatdir, "themes");

             ListThemes();

 

             String[] arguments = Environment.GetCommandLineArgs();

@@ -67,20 +90,32 @@ namespace thememan
             }

         }

 

+        private bool RunningOnWindows()

+        {

+            if (Environment.OSVersion.ToString().ToLower().Contains("windows"))

+            {

+                return true;

+            }

+            else

+            {

+                return false;

+            }

+        }

+

         private void ListThemes()

         {

             themelist.Items.Clear();

 

-            if (Directory.Exists(xchatdir + themedir))

+            if (Directory.Exists(themedir))

             {

-                foreach (string theme in Directory.GetDirectories(xchatdir + themedir))

+                foreach (string theme in Directory.GetDirectories(themedir))

                 {

-                    themelist.Items.Add(theme.Remove(0, xchatdir.Length + themedir.Length));

+                    themelist.Items.Add(theme.Remove(0, themedir.Length + 1));

                 }

             }

             else

             {

-                Directory.CreateDirectory(xchatdir + themedir);

+                Directory.CreateDirectory(themedir);

             }

 

             if (themelist.Items.Count == 0)

@@ -122,7 +157,7 @@ namespace thememan
         private List<List<string>> ReadTheme(string theme)

         {

             List<List<string>> themecolors = new List<List<string>>();

-            foreach (string line in File.ReadLines(xchatdir + themedir + theme + "/colors.conf"))

+            foreach (string line in File.ReadLines(Path.Combine(themedir, theme, "colors.conf")))

             {

                 List<string> colors = new List<string>();

                 List<string> colorlist = new List<string>();

@@ -149,10 +184,10 @@ namespace thememan
             DialogResult result = MessageBox.Show("HexChat must be closed and this will overwrite your current theme!\n\nDo you wish to continue?", "Warning", MessageBoxButtons.OKCancel, MessageBoxIcon.Warning);

             if (result == DialogResult.OK)

             {

-                File.Copy(xchatdir + themedir + themelist.SelectedItem.ToString() + "\\colors.conf", xchatdir + "colors.conf", true);

-                if (File.Exists(xchatdir + themedir + themelist.SelectedItem.ToString() + "\\pevents.conf"))

+                File.Copy(Path.Combine(themedir, themelist.SelectedItem.ToString(), "colors.conf"), Path.Combine(hexchatdir, "colors.conf"), true);

+                if (File.Exists(Path.Combine(themedir, themelist.SelectedItem.ToString(), "pevents.conf")))

                 {

-                    File.Copy(xchatdir + themedir + themelist.SelectedItem.ToString() + "\\pevents.conf", xchatdir + "pevents.conf", true);

+                    File.Copy(Path.Combine(themedir, themelist.SelectedItem.ToString(), "pevents.conf"), Path.Combine(hexchatdir, "pevents.conf"), true);

                 }

             }

         }

@@ -242,7 +277,7 @@ namespace thememan
         private int extractTheme(FileInfo zipFile)

         {

             string themeName = zipFile.Name.Remove(zipFile.Name.Length - zipFile.Extension.Length);

-            string destFolder = xchatdir + themedir + themeName;

+            string destFolder = Path.Combine(themedir, themeName);

 

             try

             {

@@ -312,7 +347,7 @@ namespace thememan
             DialogResult result = MessageBox.Show("Are you sure you want to delete this theme from the theme repo?\n\nYour currently applied theme won't be affected.", "Warning", MessageBoxButtons.OKCancel, MessageBoxIcon.Warning);

             if (result == DialogResult.OK)

             {

-                Directory.Delete(xchatdir + themedir + themelist.SelectedItem.ToString(), true);

+                Directory.Delete(Path.Combine(themedir, themelist.SelectedItem.ToString()), true);

                 ListThemes();

                 if (themelist.Items.Count == 0)

                 {

diff --git a/src/htm/htm-xp.csproj b/src/htm/htm-xp.csproj
new file mode 100644
index 00000000..9959b74c
--- /dev/null
+++ b/src/htm/htm-xp.csproj
@@ -0,0 +1,163 @@
+<?xml version="1.0" encoding="utf-8"?>

+<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">

+  <PropertyGroup>

+    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>

+    <Platform Condition=" '$(Platform)' == '' ">x86</Platform>

+    <ProductVersion>8.0.30703</ProductVersion>

+    <SchemaVersion>2.0</SchemaVersion>

+    <ProjectGuid>{DE87FFCA-9606-4116-B747-062D88A56A28}</ProjectGuid>

+    <OutputType>WinExe</OutputType>

+    <AppDesignerFolder>Properties</AppDesignerFolder>

+    <RootNamespace>thememan</RootNamespace>

+    <AssemblyName>thememan</AssemblyName>

+    <FileAlignment>512</FileAlignment>

+    <IsWebBootstrapper>false</IsWebBootstrapper>

+    <TargetFrameworkVersion>v4.0</TargetFrameworkVersion>

+    <TargetFrameworkProfile>Client</TargetFrameworkProfile>

+    <PublishUrl>publish\</PublishUrl>

+    <Install>true</Install>

+    <InstallFrom>Disk</InstallFrom>

+    <UpdateEnabled>false</UpdateEnabled>

+    <UpdateMode>Foreground</UpdateMode>

+    <UpdateInterval>7</UpdateInterval>

+    <UpdateIntervalUnits>Days</UpdateIntervalUnits>

+    <UpdatePeriodically>false</UpdatePeriodically>

+    <UpdateRequired>false</UpdateRequired>

+    <MapFileExtensions>true</MapFileExtensions>

+    <AutorunEnabled>true</AutorunEnabled>

+    <ApplicationRevision>1</ApplicationRevision>

+    <ApplicationVersion>1.0.0.%2a</ApplicationVersion>

+    <UseApplicationTrust>false</UseApplicationTrust>

+    <PublishWizardCompleted>true</PublishWizardCompleted>

+    <BootstrapperEnabled>true</BootstrapperEnabled>

+  </PropertyGroup>

+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|x86' ">

+    <PlatformTarget>x86</PlatformTarget>

+    <DebugType>pdbonly</DebugType>

+    <Optimize>true</Optimize>

+    <OutputPath>..\..\win32\build-xp\Win32\bin\</OutputPath>

+    <DefineConstants>TRACE</DefineConstants>

+    <ErrorReport>prompt</ErrorReport>

+    <WarningLevel>4</WarningLevel>

+    <CodeAnalysisIgnoreGeneratedCode>false</CodeAnalysisIgnoreGeneratedCode>

+  </PropertyGroup>

+  <PropertyGroup>

+    <ApplicationIcon>Resources\htm.ico</ApplicationIcon>

+  </PropertyGroup>

+  <PropertyGroup>

+    <ManifestCertificateThumbprint>25412E3EF25458D894050F8209E4D9DCCDF432D7</ManifestCertificateThumbprint>

+  </PropertyGroup>

+  <PropertyGroup>

+    <ManifestKeyFile>htm_TemporaryKey.pfx</ManifestKeyFile>

+  </PropertyGroup>

+  <PropertyGroup>

+    <GenerateManifests>false</GenerateManifests>

+  </PropertyGroup>

+  <PropertyGroup>

+    <SignManifests>false</SignManifests>

+  </PropertyGroup>

+  <PropertyGroup>

+    <TargetZone>LocalIntranet</TargetZone>

+  </PropertyGroup>

+  <PropertyGroup />

+  <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x64'">

+    <OutputPath>..\..\win32\build-xp\x64\bin\</OutputPath>

+    <DefineConstants>TRACE</DefineConstants>

+    <Optimize>true</Optimize>

+    <DebugType>pdbonly</DebugType>

+    <PlatformTarget>x64</PlatformTarget>

+    <CodeAnalysisLogFile>bin\Release\thememan.exe.CodeAnalysisLog.xml</CodeAnalysisLogFile>

+    <CodeAnalysisUseTypeNameInSuppression>true</CodeAnalysisUseTypeNameInSuppression>

+    <CodeAnalysisModuleSuppressionsFile>GlobalSuppressions.cs</CodeAnalysisModuleSuppressionsFile>

+    <ErrorReport>prompt</ErrorReport>

+    <CodeAnalysisIgnoreGeneratedCode>false</CodeAnalysisIgnoreGeneratedCode>

+    <CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>

+    <CodeAnalysisRuleSetDirectories>;C:\Program Files (x86)\Microsoft Visual Studio 10.0\Team Tools\Static Analysis Tools\\Rule Sets</CodeAnalysisRuleSetDirectories>

+    <CodeAnalysisIgnoreBuiltInRuleSets>false</CodeAnalysisIgnoreBuiltInRuleSets>

+    <CodeAnalysisRuleDirectories>;C:\Program Files (x86)\Microsoft Visual Studio 10.0\Team Tools\Static Analysis Tools\FxCop\\Rules</CodeAnalysisRuleDirectories>

+    <CodeAnalysisIgnoreBuiltInRules>false</CodeAnalysisIgnoreBuiltInRules>

+    <CodeAnalysisFailOnMissingRules>false</CodeAnalysisFailOnMissingRules>

+  </PropertyGroup>

+  <ItemGroup>

+    <Reference Include="Microsoft.VisualBasic" />

+    <Reference Include="System" />

+    <Reference Include="System.Core" />

+    <Reference Include="System.Xml.Linq" />

+    <Reference Include="System.Data.DataSetExtensions" />

+    <Reference Include="Microsoft.CSharp" />

+    <Reference Include="System.Data" />

+    <Reference Include="System.Deployment" />

+    <Reference Include="System.Drawing" />

+    <Reference Include="System.Windows.Forms" />

+    <Reference Include="System.Xml" />

+    <Reference Include="WindowsBase" />

+  </ItemGroup>

+  <ItemGroup>

+    <Compile Include="Main.cs">

+      <SubType>Form</SubType>

+    </Compile>

+    <Compile Include="Main.Designer.cs">

+      <DependentUpon>Main.cs</DependentUpon>

+    </Compile>

+    <Compile Include="Program.cs" />

+    <Compile Include="Properties\AssemblyInfo.cs" />

+    <EmbeddedResource Include="Main.resx">

+      <DependentUpon>Main.cs</DependentUpon>

+    </EmbeddedResource>

+    <EmbeddedResource Include="Properties\Resources.resx">

+      <Generator>ResXFileCodeGenerator</Generator>

+      <LastGenOutput>Resources.Designer.cs</LastGenOutput>

+      <SubType>Designer</SubType>

+    </EmbeddedResource>

+    <Compile Include="Properties\Resources.Designer.cs">

+      <AutoGen>True</AutoGen>

+      <DependentUpon>Resources.resx</DependentUpon>

+      <DesignTime>True</DesignTime>

+    </Compile>

+    <None Include="app.config">

+      <SubType>Designer</SubType>

+    </None>

+    <None Include="Properties\Settings.settings">

+      <Generator>SettingsSingleFileGenerator</Generator>

+      <LastGenOutput>Settings.Designer.cs</LastGenOutput>

+    </None>

+    <Compile Include="Properties\Settings.Designer.cs">

+      <AutoGen>True</AutoGen>

+      <DependentUpon>Settings.settings</DependentUpon>

+      <DesignTimeSharedInput>True</DesignTimeSharedInput>

+    </Compile>

+  </ItemGroup>

+  <ItemGroup>

+    <BootstrapperPackage Include=".NETFramework,Version=v4.0,Profile=Client">

+      <Visible>False</Visible>

+      <ProductName>Microsoft .NET Framework 4 Client Profile %28x86 and x64%29</ProductName>

+      <Install>true</Install>

+    </BootstrapperPackage>

+    <BootstrapperPackage Include="Microsoft.Net.Client.3.5">

+      <Visible>False</Visible>

+      <ProductName>.NET Framework 3.5 SP1 Client Profile</ProductName>

+      <Install>false</Install>

+    </BootstrapperPackage>

+    <BootstrapperPackage Include="Microsoft.Net.Framework.3.5.SP1">

+      <Visible>False</Visible>

+      <ProductName>.NET Framework 3.5 SP1</ProductName>

+      <Install>false</Install>

+    </BootstrapperPackage>

+    <BootstrapperPackage Include="Microsoft.Windows.Installer.3.1">

+      <Visible>False</Visible>

+      <ProductName>Windows Installer 3.1</ProductName>

+      <Install>true</Install>

+    </BootstrapperPackage>

+  </ItemGroup>

+  <ItemGroup>

+    <Content Include="Resources\htm.ico" />

+  </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>
\ No newline at end of file