From 55f9f414cac7550692609f5956f8089ed9b4fd57 Mon Sep 17 00:00:00 2001 From: Leonardo Robol Date: Sat, 6 Feb 2010 16:25:50 +0100 Subject: [PATCH] Rivista la configurazione. --- GlobalConfig.cs | 6 +++--- Main.cs | 2 +- MainWindow.cs | 17 +++++++++++++++-- Protocol.cs | 8 ++++---- gtk-gui/MainWindow.cs | 1 + gtk-gui/gui.stetic | 3 ++- 6 files changed, 26 insertions(+), 11 deletions(-) diff --git a/GlobalConfig.cs b/GlobalConfig.cs index b6566c4..382a01e 100644 --- a/GlobalConfig.cs +++ b/GlobalConfig.cs @@ -8,7 +8,7 @@ namespace Dizzy public class GlobalConfig { - public string user, password; + public string password; private SQLiteConnection conn; public GlobalConfig () @@ -84,12 +84,12 @@ namespace Dizzy // Tabelle delle configurazioni sqlCmd = this.conn.CreateCommand (); - sqlCmd.CommandText = "CREATE TABLE config (field TEXT, value TEXT);"; + sqlCmd.CommandText = "CREATE TABLE config (field TEXT PRIMARY KEY, value TEXT);"; sqlCmd.ExecuteNonQuery (); // Tabella della lista sqlCmd = this.conn.CreateCommand (); - sqlCmd.CommandText = "CREATE TABLE list (path TEXT, user TEXT);"; + sqlCmd.CommandText = "CREATE TABLE list (path TEXT PRIMARY KEY, user TEXT);"; sqlCmd.ExecuteNonQuery (); this.conn.Close (); diff --git a/Main.cs b/Main.cs index 187fcf3..591b8d6 100644 --- a/Main.cs +++ b/Main.cs @@ -25,7 +25,7 @@ namespace Dizzy try { - win = new MainWindow (config.GetValue("user"), config.password); + win = new MainWindow (ref config); win.ShowAll (); s.Destroy (); Application.Run (); diff --git a/MainWindow.cs b/MainWindow.cs index cf245d4..cb83325 100644 --- a/MainWindow.cs +++ b/MainWindow.cs @@ -8,11 +8,13 @@ public partial class MainWindow : Gtk.Window Protocol protocol; FileTreeView files; TaskTreeView tasks; + GlobalConfig config; - public MainWindow (string user, string password) : base(Gtk.WindowType.Toplevel) + public MainWindow (ref GlobalConfig config) : base(Gtk.WindowType.Toplevel) { Build (); + this.config = config; // Inizializziamo la vista dei file. files = new Dizzy.FileTreeView (filelist); @@ -20,7 +22,12 @@ public partial class MainWindow : Gtk.Window // .. e anche quella dei download tasks = new Dizzy.TaskTreeView (tasklist); - this.protocol = new Protocol (user, password); + // Carichiamo qualche impostazione di default + string downloadpath = config.GetValue("download_folder"); + if (downloadpath != "") + downloadpathchooser.SetFilename(downloadpath); + + this.protocol = new Protocol (ref config); } @@ -50,4 +57,10 @@ public partial class MainWindow : Gtk.Window } + protected virtual void OnDownloadPathSelectionChanged (object sender, System.EventArgs e) + { + config.InsertValue("download_folder", downloadpathchooser.Filename); + } + + } diff --git a/Protocol.cs b/Protocol.cs index 96755d3..bc86c6c 100644 --- a/Protocol.cs +++ b/Protocol.cs @@ -30,17 +30,17 @@ namespace Dizzy ArrayList fileList = new ArrayList (); - ArrayList threads = new ArrayList (); + ArrayList threads = new ArrayList (); Thread updater; SFTPConnection sftpUpdater; bool bootStrapped = false; - public Protocol (string user, string password) + public Protocol (ref GlobalConfig config) { - this.user = user; - this.password = password; + this.user = config.GetValue("user"); + this.password = config.password; try { diff --git a/gtk-gui/MainWindow.cs b/gtk-gui/MainWindow.cs index 6c97ee0..55b5af9 100644 --- a/gtk-gui/MainWindow.cs +++ b/gtk-gui/MainWindow.cs @@ -210,5 +210,6 @@ public partial class MainWindow { this.searchBox.Activated += new System.EventHandler(this.OnSearchRequested); this.button1.Clicked += new System.EventHandler(this.OnSearchRequested); this.filelist.RowActivated += new Gtk.RowActivatedHandler(this.OnRowActivated); + this.downloadpathchooser.SelectionChanged += new System.EventHandler(this.OnDownloadPathSelectionChanged); } } diff --git a/gtk-gui/gui.stetic b/gtk-gui/gui.stetic index 1ba0217..088b0ab 100644 --- a/gtk-gui/gui.stetic +++ b/gtk-gui/gui.stetic @@ -6,7 +6,7 @@ - + @@ -167,6 +167,7 @@ Seleziona una cartella SelectFolder + 1 -- 2.1.4