Rivista la configurazione.
Leonardo Robol [2010-02-06 15:25]
Rivista la configurazione.
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 @@
</configuration>
<import>
<widget-library name="glade-sharp, Version=2.12.0.0, Culture=neutral, PublicKeyToken=35e10195dab3c99f" />
- <widget-library name="../bin/Debug/Dizzy.exe" internal="true" />
+ <widget-library name="../bin/Release/Dizzy.exe" internal="true" />
</import>
<widget class="Gtk.Window" id="MainWindow" design-size="474 300">
<property name="MemberName" />
@@ -167,6 +167,7 @@
<property name="MemberName" />
<property name="Title" translatable="yes">Seleziona una cartella</property>
<property name="Action">SelectFolder</property>
+ <signal name="SelectionChanged" handler="OnDownloadPathSelectionChanged" />
</widget>
<packing>
<property name="Position">1</property>