1
0
mirror of https://github.com/moparisthebest/hexchat synced 2024-12-23 08:08:54 -05:00

Fix a few more crashes in XTM

This commit is contained in:
Berke Viktor 2012-06-17 06:41:29 +02:00
parent 6bca080d93
commit 8ec3e46978
6 changed files with 569 additions and 538 deletions

View File

@ -213,7 +213,7 @@
this.importbutton.Name = "importbutton";
this.importbutton.Size = new System.Drawing.Size(60, 23);
this.importbutton.TabIndex = 2;
this.importbutton.Text = "Import";
this.importbutton.Text = "Import...";
this.importbutton.UseVisualStyleBackColor = true;
this.importbutton.Click += new System.EventHandler(this.importbutton_Click_1);
//
@ -265,6 +265,7 @@
this.Controls.Add(this.themecolortextbg);
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle;
this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
this.MaximizeBox = false;
this.Name = "XTM";
this.SizeGripStyle = System.Windows.Forms.SizeGripStyle.Hide;
this.Text = "XChat Theme Manager";

View File

@ -170,9 +170,22 @@ namespace thememan
private void importdialog_FileOk(object sender, System.ComponentModel.CancelEventArgs e)
{
FileInfo fi = new FileInfo(importDialog.FileName);
string newTheme = extractTheme(fi);
string themeName = fi.Name.Remove(fi.Name.Length - fi.Extension.Length);
int result = extractTheme(fi);
ListThemes();
themelist.SetSelected(themelist.FindStringExact(newTheme), true);
/* although a check is added to ListThemes(), this would still fail if the theme file was invalid or the theme is already installed */
switch (result)
{
case 0:
themelist.SetSelected(themelist.FindStringExact(themeName), true);
break;
case 1:
MessageBox.Show("This theme is already installed!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
break;
case 2:
MessageBox.Show("Invalid theme file!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
break;
}
}
/* gzip solution, not good enough coz we need multiple files
@ -208,7 +221,7 @@ namespace thememan
private const long BUFFER_SIZE = 4096;
private string extractTheme(FileInfo zipFile)
private int extractTheme(FileInfo zipFile)
{
string themeName = zipFile.Name.Remove(zipFile.Name.Length - zipFile.Extension.Length);
string destFolder = xchatdir + themedir + themeName;
@ -217,7 +230,11 @@ namespace thememan
{
PackagePartCollection parts = zip.GetParts();
if (!Directory.Exists(destFolder))
if (Directory.Exists(destFolder))
{
return 1;
}
else
{
Directory.CreateDirectory(destFolder);
}
@ -250,11 +267,11 @@ namespace thememan
if (IsDirectoryEmpty(destFolder))
{
Directory.Delete(destFolder);
return null;
return 2;
}
else
{
return themeName;
return 0;
}
}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 9.4 KiB

After

Width:  |  Height:  |  Size: 26 KiB

View File

@ -127,9 +127,6 @@
<DesignTimeSharedInput>True</DesignTimeSharedInput>
</Compile>
</ItemGroup>
<ItemGroup>
<Content Include="Resources\xchat.ico" />
</ItemGroup>
<ItemGroup>
<BootstrapperPackage Include=".NETFramework,Version=v4.0,Profile=Client">
<Visible>False</Visible>
@ -152,6 +149,9 @@
<Install>true</Install>
</BootstrapperPackage>
</ItemGroup>
<ItemGroup>
<Content Include="Resources\xchat.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.

13
src/xtm/xtm.csproj.user Normal file
View File

@ -0,0 +1,13 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<PublishUrlHistory>publish\</PublishUrlHistory>
<InstallUrlHistory />
<SupportUrlHistory />
<UpdateUrlHistory />
<BootstrapperUrlHistory />
<ErrorReportUrlHistory />
<FallbackCulture>en-US</FallbackCulture>
<VerifyUploadedFiles>false</VerifyUploadedFiles>
</PropertyGroup>
</Project>