diff --git a/osrepodbmgr.Core/ChangeLog b/osrepodbmgr.Core/ChangeLog index 6ad8a22..2e524f8 100644 --- a/osrepodbmgr.Core/ChangeLog +++ b/osrepodbmgr.Core/ChangeLog @@ -1,3 +1,9 @@ +2017-05-11 Natalia Portillo + + * Workers.cs: + * Settings.cs: + Add support for choosing compression algorithm. + 2017-05-11 Natalia Portillo * Workers.cs: diff --git a/osrepodbmgr.Core/Settings.cs b/osrepodbmgr.Core/Settings.cs index 3302069..615a828 100644 --- a/osrepodbmgr.Core/Settings.cs +++ b/osrepodbmgr.Core/Settings.cs @@ -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; } } } diff --git a/osrepodbmgr.Core/Workers.cs b/osrepodbmgr.Core/Workers.cs index 7021f2d..eb068d8 100644 --- a/osrepodbmgr.Core/Workers.cs +++ b/osrepodbmgr.Core/Workers.cs @@ -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; diff --git a/osrepodbmgr/ChangeLog b/osrepodbmgr/ChangeLog index 5b104ee..28590f4 100644 --- a/osrepodbmgr/ChangeLog +++ b/osrepodbmgr/ChangeLog @@ -1,3 +1,10 @@ +2017-05-11 Natalia Portillo + + * frmSettings.cs: + * gtk-gui/gui.stetic: + * gtk-gui/osrepodbmgr.frmSettings.cs: + Add support for choosing compression algorithm. + 2017-05-11 Natalia Portillo * packages.config: diff --git a/osrepodbmgr/frmSettings.cs b/osrepodbmgr/frmSettings.cs index d0dec83..2d5721c 100644 --- a/osrepodbmgr/frmSettings.cs +++ b/osrepodbmgr/frmSettings.cs @@ -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(); diff --git a/osrepodbmgr/gtk-gui/gui.stetic b/osrepodbmgr/gtk-gui/gui.stetic index 452f8ec..c01b018 100644 --- a/osrepodbmgr/gtk-gui/gui.stetic +++ b/osrepodbmgr/gtk-gui/gui.stetic @@ -1192,6 +1192,43 @@ QNX/QNX/20090229/source.zip False + + + + 6 + + + + Compression algorithm + + + 0 + True + False + False + + + + + + True + + + + 1 + True + False + False + + + + + 5 + True + False + False + + @@ -1233,7 +1270,7 @@ QNX/QNX/20090229/source.zip - 5 + 6 True False False diff --git a/osrepodbmgr/gtk-gui/osrepodbmgr.frmSettings.cs b/osrepodbmgr/gtk-gui/osrepodbmgr.frmSettings.cs index 9e3d3a8..ef2f743 100644 --- a/osrepodbmgr/gtk-gui/osrepodbmgr.frmSettings.cs +++ b/osrepodbmgr/gtk-gui/osrepodbmgr.frmSettings.cs @@ -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)) {