Aggiunta anche parte relativa ai download, anche se parzialmente.

Leonardo Robol [2010-01-31 09:11]
Aggiunta anche parte relativa ai download, anche se parzialmente.
Filename
File.cs
FileTreeView.cs
MainWindow.cs
TaskTreeView.cs
gtk-gui/MainWindow.cs
gtk-gui/gui.stetic
diff --git a/File.cs b/File.cs
index 36b2d16..c294d7d 100644
--- a/File.cs
+++ b/File.cs
@@ -48,17 +48,16 @@ namespace Dizzy
 		public string path;
 		public FileType type;

-		public File (string fname, ulong fsize, string fuser)
+		public File (string path, ulong size, string user)
 		{
 			// Determino il tipo di file
-			type = new FileType(fname);
-
-			string[] pieces = fname.Split('/');
+			type = new FileType (path);
+			this.size = size;
+			this.user = user;
+			string[] pieces = path.Split ('/');

 			name = pieces[pieces.Length - 1];
-			path = fname;
-			size = fsize;
-			user = fuser;
+
 		}

 		public string SizeToString()
diff --git a/FileTreeView.cs b/FileTreeView.cs
index 04428ca..67ab71a 100644
--- a/FileTreeView.cs
+++ b/FileTreeView.cs
@@ -1,4 +1,4 @@
-
+using Gtk;
 using System;

 namespace Dizzy
@@ -20,11 +20,11 @@ namespace Dizzy
 		// che troviamo.
 		Gtk.ListStore fileListStore;

-		public FileTreeView (Gtk.TreeView treea)
+		public FileTreeView (Gtk.TreeView tree)
 		{
 			// Costruisco la ListStore e popolo di colonne
 			// la TreeView
-			this.tree = treea;
+			this.tree = tree;
 			this.filenameColumn = new Gtk.TreeViewColumn ();
 			filenameColumn.Title = "Nome del file";

@@ -34,16 +34,16 @@ namespace Dizzy
 			this.userColumn = new Gtk.TreeViewColumn ();
 			userColumn.Title = "Utente";

-			tree.AppendColumn (filenameColumn);
-			tree.AppendColumn (sizeColumn);
-			tree.AppendColumn (userColumn);
+			this.tree.AppendColumn (filenameColumn);
+			this.tree.AppendColumn (sizeColumn);
+			this.tree.AppendColumn (userColumn);

 			this.fileListStore = new Gtk.ListStore (typeof(string), // Nome del file
 				                                    typeof(string),    // Dimensione
 				                                    typeof(string), // Utente
 			                                        typeof(string));// Path del file.

-			tree.Model = fileListStore;
+			this.tree.Model = fileListStore;
 			CellSetup ();

 		}
@@ -57,12 +57,12 @@ namespace Dizzy

 			// Dimensione del file
 			Gtk.CellRendererText sizeRenderer = new Gtk.CellRendererText ();
-			sizeColumn.PackStart (sizeRenderer, false);
+			sizeColumn.PackStart (sizeRenderer, true);
 			sizeColumn.AddAttribute (sizeRenderer, "text", 1);

 			// Tipo di file
 			Gtk.CellRendererText userRenderer = new Gtk.CellRendererText ();
-			userColumn.PackStart (userRenderer, false);
+			userColumn.PackStart (userRenderer, true);
 			userColumn.AddAttribute (userRenderer, "text", 2);
 		}

diff --git a/MainWindow.cs b/MainWindow.cs
index 6e36a70..1d2e4c7 100644
--- a/MainWindow.cs
+++ b/MainWindow.cs
@@ -8,11 +8,16 @@ public partial class MainWindow : Gtk.Window
 		Build ();

 		// Inizializziamo la vista dei file.
-		Dizzy.FileTreeView tree = new Dizzy.FileTreeView (filelist);
+		Dizzy.FileTreeView files = new Dizzy.FileTreeView (filelist);
+
+		// .. e anche quella dei download
+		Dizzy.TaskTreeView tasks = new Dizzy.TaskTreeView (tasklist);

 		// Aggiungiamo un file di prova.
 		Dizzy.File f = new Dizzy.File("/nobackup/robol/Films/File di prova.avi", 1232131, "robol");
-		tree.AddFile (f);
+		files.AddFile (f);
+		TreeIter it = tasks.AddTask("prova", 56);
+
 	}


diff --git a/TaskTreeView.cs b/TaskTreeView.cs
new file mode 100644
index 0000000..3f3c79a
--- /dev/null
+++ b/TaskTreeView.cs
@@ -0,0 +1,63 @@
+using Gtk;
+using System;
+
+namespace Dizzy
+{
+
+
+	public class TaskTreeView
+	{
+
+		TreeView tree;
+
+		TreeViewColumn fileColumn;
+		TreeViewColumn progressColumn;
+		// Gtk.TreeViewColumn statusColumn;
+
+		ListStore tasklist;
+
+		public TaskTreeView (Gtk.TreeView tree)
+		{
+			this.tree = tree;
+
+			fileColumn = new TreeViewColumn ();
+			fileColumn.Title = "File";
+
+			progressColumn = new TreeViewColumn ();
+			progressColumn.Title = "Avanzamento";
+
+			this.tree.AppendColumn (fileColumn);
+			this.tree.AppendColumn (progressColumn);
+
+			tasklist = new ListStore (typeof(string),
+			                          typeof(int));
+
+			CellSetup ();
+			this.tree.Model = tasklist;
+		}
+
+		protected void CellSetup ()
+		{
+			CellRendererText fileRenderer = new CellRendererText ();
+			CellRendererProgress progressRenderer = new CellRendererProgress ();
+
+			fileColumn.PackStart (fileRenderer, true);
+			progressColumn.PackStart (progressRenderer, true);
+
+			fileColumn.AddAttribute (fileRenderer, "text", 0);
+			progressColumn.AddAttribute (progressRenderer, "value", 1);
+		}
+
+		// Ritorna un TreeIter all'elemento aggiunto
+		public TreeIter AddTask (string name, int progress)
+		{
+			TreeIter iter = tasklist.AppendValues (name, progress);
+			return iter;
+		}
+
+		public void SetProgress (TreeIter iter, int progress)
+		{
+
+		}
+	}
+}
diff --git a/gtk-gui/MainWindow.cs b/gtk-gui/MainWindow.cs
index c026187..65a5886 100644
--- a/gtk-gui/MainWindow.cs
+++ b/gtk-gui/MainWindow.cs
@@ -32,6 +32,18 @@ public partial class MainWindow {

     private Gtk.Label label1;

+    private Gtk.VBox vbox2;
+
+    private Gtk.ScrolledWindow GtkScrolledWindow1;
+
+    private Gtk.TreeView tasklist;
+
+    private Gtk.HBox hbox2;
+
+    private Gtk.Label label2;
+
+    private Gtk.FileChooserButton downloadpathchooser;
+
     private Gtk.Label label3;

     private Gtk.Statusbar statusbar2;
@@ -50,7 +62,7 @@ public partial class MainWindow {
         this.notebook1 = new Gtk.Notebook();
         this.notebook1.CanFocus = true;
         this.notebook1.Name = "notebook1";
-        this.notebook1.CurrentPage = 0;
+        this.notebook1.CurrentPage = 1;
         // Container child notebook1.Gtk.Notebook+NotebookChild
         this.vbox3 = new Gtk.VBox();
         this.vbox3.Name = "vbox3";
@@ -113,27 +125,68 @@ public partial class MainWindow {
         this.label1.LabelProp = Mono.Unix.Catalog.GetString("Ricerca");
         this.notebook1.SetTabLabel(this.vbox3, this.label1);
         this.label1.ShowAll();
+        // Container child notebook1.Gtk.Notebook+NotebookChild
+        this.vbox2 = new Gtk.VBox();
+        this.vbox2.Name = "vbox2";
+        this.vbox2.Spacing = 6;
+        // Container child vbox2.Gtk.Box+BoxChild
+        this.GtkScrolledWindow1 = new Gtk.ScrolledWindow();
+        this.GtkScrolledWindow1.Name = "GtkScrolledWindow1";
+        this.GtkScrolledWindow1.ShadowType = ((Gtk.ShadowType)(1));
+        // Container child GtkScrolledWindow1.Gtk.Container+ContainerChild
+        this.tasklist = new Gtk.TreeView();
+        this.tasklist.CanFocus = true;
+        this.tasklist.Name = "tasklist";
+        this.GtkScrolledWindow1.Add(this.tasklist);
+        this.vbox2.Add(this.GtkScrolledWindow1);
+        Gtk.Box.BoxChild w9 = ((Gtk.Box.BoxChild)(this.vbox2[this.GtkScrolledWindow1]));
+        w9.Position = 0;
+        // Container child vbox2.Gtk.Box+BoxChild
+        this.hbox2 = new Gtk.HBox();
+        this.hbox2.Name = "hbox2";
+        this.hbox2.Spacing = 6;
+        this.hbox2.BorderWidth = ((uint)(4));
+        // Container child hbox2.Gtk.Box+BoxChild
+        this.label2 = new Gtk.Label();
+        this.label2.Name = "label2";
+        this.label2.LabelProp = Mono.Unix.Catalog.GetString("Scarica in");
+        this.hbox2.Add(this.label2);
+        Gtk.Box.BoxChild w10 = ((Gtk.Box.BoxChild)(this.hbox2[this.label2]));
+        w10.Position = 0;
+        w10.Expand = false;
+        w10.Fill = false;
+        // Container child hbox2.Gtk.Box+BoxChild
+        this.downloadpathchooser = new Gtk.FileChooserButton(Mono.Unix.Catalog.GetString("Seleziona una cartella"), ((Gtk.FileChooserAction)(2)));
+        this.downloadpathchooser.Name = "downloadpathchooser";
+        this.hbox2.Add(this.downloadpathchooser);
+        Gtk.Box.BoxChild w11 = ((Gtk.Box.BoxChild)(this.hbox2[this.downloadpathchooser]));
+        w11.Position = 1;
+        this.vbox2.Add(this.hbox2);
+        Gtk.Box.BoxChild w12 = ((Gtk.Box.BoxChild)(this.vbox2[this.hbox2]));
+        w12.Position = 1;
+        w12.Expand = false;
+        w12.Fill = false;
+        this.notebook1.Add(this.vbox2);
+        Gtk.Notebook.NotebookChild w13 = ((Gtk.Notebook.NotebookChild)(this.notebook1[this.vbox2]));
+        w13.Position = 1;
         // Notebook tab
-        Gtk.Label w8 = new Gtk.Label();
-        w8.Visible = true;
-        this.notebook1.Add(w8);
         this.label3 = new Gtk.Label();
         this.label3.Name = "label3";
         this.label3.LabelProp = Mono.Unix.Catalog.GetString("Download");
-        this.notebook1.SetTabLabel(w8, this.label3);
+        this.notebook1.SetTabLabel(this.vbox2, this.label3);
         this.label3.ShowAll();
         this.vbox1.Add(this.notebook1);
-        Gtk.Box.BoxChild w9 = ((Gtk.Box.BoxChild)(this.vbox1[this.notebook1]));
-        w9.Position = 0;
+        Gtk.Box.BoxChild w14 = ((Gtk.Box.BoxChild)(this.vbox1[this.notebook1]));
+        w14.Position = 0;
         // Container child vbox1.Gtk.Box+BoxChild
         this.statusbar2 = new Gtk.Statusbar();
         this.statusbar2.Name = "statusbar2";
         this.statusbar2.Spacing = 6;
         this.vbox1.Add(this.statusbar2);
-        Gtk.Box.BoxChild w10 = ((Gtk.Box.BoxChild)(this.vbox1[this.statusbar2]));
-        w10.Position = 1;
-        w10.Expand = false;
-        w10.Fill = false;
+        Gtk.Box.BoxChild w15 = ((Gtk.Box.BoxChild)(this.vbox1[this.statusbar2]));
+        w15.Position = 1;
+        w15.Expand = false;
+        w15.Fill = false;
         this.Add(this.vbox1);
         if ((this.Child != null)) {
             this.Child.ShowAll();
diff --git a/gtk-gui/gui.stetic b/gtk-gui/gui.stetic
index 2986ced..22a97f4 100644
--- a/gtk-gui/gui.stetic
+++ b/gtk-gui/gui.stetic
@@ -21,7 +21,7 @@
           <widget class="Gtk.Notebook" id="notebook1">
             <property name="MemberName" />
             <property name="CanFocus">True</property>
-            <property name="CurrentPage">0</property>
+            <property name="CurrentPage">1</property>
             <child>
               <widget class="Gtk.VBox" id="vbox3">
                 <property name="MemberName" />
@@ -107,7 +107,66 @@
               </packing>
             </child>
             <child>
-              <placeholder />
+              <widget class="Gtk.VBox" id="vbox2">
+                <property name="MemberName" />
+                <property name="Spacing">6</property>
+                <child>
+                  <widget class="Gtk.ScrolledWindow" id="GtkScrolledWindow1">
+                    <property name="MemberName" />
+                    <property name="ShadowType">In</property>
+                    <child>
+                      <widget class="Gtk.TreeView" id="tasklist">
+                        <property name="MemberName" />
+                        <property name="CanFocus">True</property>
+                        <property name="ShowScrollbars">True</property>
+                      </widget>
+                    </child>
+                  </widget>
+                  <packing>
+                    <property name="Position">0</property>
+                    <property name="AutoSize">True</property>
+                  </packing>
+                </child>
+                <child>
+                  <widget class="Gtk.HBox" id="hbox2">
+                    <property name="MemberName" />
+                    <property name="Spacing">6</property>
+                    <property name="BorderWidth">4</property>
+                    <child>
+                      <widget class="Gtk.Label" id="label2">
+                        <property name="MemberName" />
+                        <property name="LabelProp" translatable="yes">Scarica in</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.FileChooserButton" id="downloadpathchooser">
+                        <property name="MemberName" />
+                        <property name="Title" translatable="yes">Seleziona una cartella</property>
+                        <property name="Action">SelectFolder</property>
+                      </widget>
+                      <packing>
+                        <property name="Position">1</property>
+                        <property name="AutoSize">True</property>
+                      </packing>
+                    </child>
+                  </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">1</property>
+              </packing>
             </child>
             <child>
               <widget class="Gtk.Label" id="label3">
ViewGit