Add support for choosing compression algorithm.

This commit is contained in:
2017-05-11 03:46:19 +01:00
parent f7e5facc0e
commit 247e4ec4f4
7 changed files with 137 additions and 15 deletions

View File

@@ -1,3 +1,9 @@
2017-05-11 Natalia Portillo <claunia@claunia.com>
* Workers.cs:
* Settings.cs:
Add support for choosing compression algorithm.
2017-05-11 Natalia Portillo <claunia@claunia.com>
* Workers.cs:

View File

@@ -31,6 +31,7 @@ using System.IO;
using System.Xml.Serialization;
using Claunia.PropertyList;
using Microsoft.Win32;
using Ionic.Zip;
namespace osrepodbmgr.Core
{
@@ -40,6 +41,7 @@ namespace osrepodbmgr.Core
public string DatabasePath;
public string RepositoryPath;
public string UnArchiverPath;
public CompressionMethod CompressionAlgorithm;
}
public static class Settings
@@ -100,6 +102,13 @@ namespace osrepodbmgr.Core
else
Current.UnArchiverPath = null;
if(parsedPreferences.TryGetValue("CompressionAlgorithm", out obj))
{
if(!Enum.TryParse(((NSString)obj).ToString(), true, out Current.CompressionAlgorithm))
Current.CompressionAlgorithm = CompressionMethod.Deflate;
}
else
Current.CompressionAlgorithm = CompressionMethod.Deflate;
}
else {
SetDefaultSettings();
@@ -133,6 +142,8 @@ namespace osrepodbmgr.Core
Current.DatabasePath = (string)key.GetValue("DatabasePath");
Current.RepositoryPath = (string)key.GetValue("RepositoryPath");
Current.UnArchiverPath = (string)key.GetValue("UnArchiverPath");
if(!Enum.TryParse((string)key.GetValue("CompressionAlgorithm"), true, out Current.CompressionAlgorithm))
Current.CompressionAlgorithm = CompressionMethod.Deflate;
}
break;
default:
@@ -178,6 +189,7 @@ namespace osrepodbmgr.Core
root.Add("DatabasePath", Current.DatabasePath);
root.Add("RepositoryPath", Current.RepositoryPath);
root.Add("UnArchiverPath", Current.UnArchiverPath);
root.Add("CompressionAlgorithm", Current.CompressionAlgorithm);
string preferencesPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.UserProfile), "Library", "Preferences");
string preferencesFilePath = Path.Combine(preferencesPath, "com.claunia.museum.osrepodbmgr.plist");
@@ -200,6 +212,7 @@ namespace osrepodbmgr.Core
key.SetValue("DatabasePath", Current.DatabasePath);
key.SetValue("RepositoryPath", Current.RepositoryPath);
key.SetValue("UnArchiverPath", Current.UnArchiverPath);
key.SetValue("CompressionAlgorithm", Current.CompressionAlgorithm);
}
break;
default:
@@ -234,6 +247,7 @@ namespace osrepodbmgr.Core
Current.DatabasePath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments), "osrepodbmgr.db");
Current.RepositoryPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments), "osrepo");
Current.UnArchiverPath = null;
Current.CompressionAlgorithm = CompressionMethod.Deflate;
}
}
}

View File

@@ -831,7 +831,7 @@ namespace osrepodbmgr.Core
ZipFile zf = new ZipFile(destination);
zf.CompressionLevel = Ionic.Zlib.CompressionLevel.BestCompression;
zf.CompressionMethod = CompressionMethod.Deflate;
zf.CompressionMethod = Settings.Current.CompressionAlgorithm;
zf.UseZip64WhenSaving = Zip64Option.AsNecessary;
string filesPath;

View File

@@ -1,3 +1,10 @@
2017-05-11 Natalia Portillo <claunia@claunia.com>
* frmSettings.cs:
* gtk-gui/gui.stetic:
* gtk-gui/osrepodbmgr.frmSettings.cs:
Add support for choosing compression algorithm.
2017-05-11 Natalia Portillo <claunia@claunia.com>
* packages.config:

View File

@@ -30,6 +30,7 @@ using System.IO;
using System.Threading;
using Gtk;
using osrepodbmgr.Core;
using Ionic.Zip;
namespace osrepodbmgr
{
@@ -48,6 +49,30 @@ namespace osrepodbmgr
if(!string.IsNullOrWhiteSpace(txtUnar.Text))
CheckUnar();
CellRendererText textCell = new CellRendererText();
cmbCompAlg.Clear();
ListStore lstCompAlgs = new ListStore(typeof(string));
cmbCompAlg.PackStart(textCell, true);
cmbCompAlg.AddAttribute(textCell, "text", 0);
cmbCompAlg.Model = lstCompAlgs;
lstCompAlgs.Clear();
foreach(CompressionMethod type in Enum.GetValues(typeof(CompressionMethod)))
lstCompAlgs.AppendValues(type.ToString());
cmbCompAlg.Active = 0;
TreeIter iter;
cmbCompAlg.Model.GetIterFirst(out iter);
do
{
if((string)cmbCompAlg.Model.GetValue(iter, 0) == Core.Settings.Current.CompressionAlgorithm.ToString())
{
cmbCompAlg.SetActiveIter(iter);
break;
}
}
while(cmbCompAlg.Model.IterNext(ref iter));
}
protected void OnBtnCancelClicked(object sender, EventArgs e)
@@ -62,6 +87,7 @@ namespace osrepodbmgr
Core.Settings.Current.UnArchiverPath = txtUnar.Text;
Core.Settings.Current.DatabasePath = txtDatabase.Text;
Core.Settings.Current.RepositoryPath = txtRepository.Text;
Core.Settings.Current.CompressionAlgorithm = (CompressionMethod)Enum.Parse(typeof(CompressionMethod), cmbCompAlg.ActiveText);
Core.Settings.SaveSettings();
Core.Workers.CloseDB();
Core.Workers.InitDB();

View File

@@ -1192,6 +1192,43 @@ QNX/QNX/20090229/source.zip</property>
<property name="Fill">False</property>
</packing>
</child>
<child>
<widget class="Gtk.HBox" id="hbox1">
<property name="MemberName" />
<property name="Spacing">6</property>
<child>
<widget class="Gtk.Label" id="lblCompAlg">
<property name="MemberName" />
<property name="LabelProp" translatable="yes">Compression algorithm</property>
</widget>
<packing>
<property name="Position">0</property>
<property name="AutoSize">True</property>
<property name="Expand">False</property>
<property name="Fill">False</property>
</packing>
</child>
<child>
<widget class="Gtk.ComboBox" id="cmbCompAlg">
<property name="MemberName" />
<property name="IsTextCombo">True</property>
<property name="Items" translatable="yes" />
</widget>
<packing>
<property name="Position">1</property>
<property name="AutoSize">True</property>
<property name="Expand">False</property>
<property name="Fill">False</property>
</packing>
</child>
</widget>
<packing>
<property name="Position">5</property>
<property name="AutoSize">True</property>
<property name="Expand">False</property>
<property name="Fill">False</property>
</packing>
</child>
<child>
<widget class="Gtk.HBox" id="hbox18">
<property name="MemberName" />
@@ -1233,7 +1270,7 @@ QNX/QNX/20090229/source.zip</property>
</child>
</widget>
<packing>
<property name="Position">5</property>
<property name="Position">6</property>
<property name="AutoSize">True</property>
<property name="Expand">False</property>
<property name="Fill">False</property>

View File

@@ -40,6 +40,12 @@ namespace osrepodbmgr
private global::Gtk.Label lblUnarVersion;
private global::Gtk.HBox hbox1;
private global::Gtk.Label lblCompAlg;
private global::Gtk.ComboBox cmbCompAlg;
private global::Gtk.HBox hbox18;
private global::Gtk.Button btnCancel;
@@ -231,6 +237,32 @@ namespace osrepodbmgr
w21.Expand = false;
w21.Fill = false;
// Container child vbox5.Gtk.Box+BoxChild
this.hbox1 = new global::Gtk.HBox();
this.hbox1.Name = "hbox1";
this.hbox1.Spacing = 6;
// Container child hbox1.Gtk.Box+BoxChild
this.lblCompAlg = new global::Gtk.Label();
this.lblCompAlg.Name = "lblCompAlg";
this.lblCompAlg.LabelProp = global::Mono.Unix.Catalog.GetString("Compression algorithm");
this.hbox1.Add(this.lblCompAlg);
global::Gtk.Box.BoxChild w22 = ((global::Gtk.Box.BoxChild)(this.hbox1[this.lblCompAlg]));
w22.Position = 0;
w22.Expand = false;
w22.Fill = false;
// Container child hbox1.Gtk.Box+BoxChild
this.cmbCompAlg = global::Gtk.ComboBox.NewText();
this.cmbCompAlg.Name = "cmbCompAlg";
this.hbox1.Add(this.cmbCompAlg);
global::Gtk.Box.BoxChild w23 = ((global::Gtk.Box.BoxChild)(this.hbox1[this.cmbCompAlg]));
w23.Position = 1;
w23.Expand = false;
w23.Fill = false;
this.vbox5.Add(this.hbox1);
global::Gtk.Box.BoxChild w24 = ((global::Gtk.Box.BoxChild)(this.vbox5[this.hbox1]));
w24.Position = 5;
w24.Expand = false;
w24.Fill = false;
// Container child vbox5.Gtk.Box+BoxChild
this.hbox18 = new global::Gtk.HBox();
this.hbox18.Name = "hbox18";
this.hbox18.Spacing = 6;
@@ -242,10 +274,10 @@ namespace osrepodbmgr
this.btnCancel.UseUnderline = true;
this.btnCancel.Label = "gtk-cancel";
this.hbox18.Add(this.btnCancel);
global::Gtk.Box.BoxChild w22 = ((global::Gtk.Box.BoxChild)(this.hbox18[this.btnCancel]));
w22.Position = 0;
w22.Expand = false;
w22.Fill = false;
global::Gtk.Box.BoxChild w25 = ((global::Gtk.Box.BoxChild)(this.hbox18[this.btnCancel]));
w25.Position = 0;
w25.Expand = false;
w25.Fill = false;
// Container child hbox18.Gtk.Box+BoxChild
this.btnApply = new global::Gtk.Button();
this.btnApply.CanFocus = true;
@@ -254,16 +286,16 @@ namespace osrepodbmgr
this.btnApply.UseUnderline = true;
this.btnApply.Label = "gtk-apply";
this.hbox18.Add(this.btnApply);
global::Gtk.Box.BoxChild w23 = ((global::Gtk.Box.BoxChild)(this.hbox18[this.btnApply]));
w23.PackType = ((global::Gtk.PackType)(1));
w23.Position = 1;
w23.Expand = false;
w23.Fill = false;
global::Gtk.Box.BoxChild w26 = ((global::Gtk.Box.BoxChild)(this.hbox18[this.btnApply]));
w26.PackType = ((global::Gtk.PackType)(1));
w26.Position = 1;
w26.Expand = false;
w26.Fill = false;
this.vbox5.Add(this.hbox18);
global::Gtk.Box.BoxChild w24 = ((global::Gtk.Box.BoxChild)(this.vbox5[this.hbox18]));
w24.Position = 5;
w24.Expand = false;
w24.Fill = false;
global::Gtk.Box.BoxChild w27 = ((global::Gtk.Box.BoxChild)(this.vbox5[this.hbox18]));
w27.Position = 6;
w27.Expand = false;
w27.Fill = false;
this.Add(this.vbox5);
if((this.Child != null))
{