Index: deluge/ui/web/js/Deluge.Add.File.js
===================================================================
--- deluge/ui/web/js/Deluge.Add.File.js	(revision 2ac545dec6ee4359e3f1f53b7f705cd2c2c0d26e)
+++ deluge/ui/web/js/Deluge.Add.File.js	(revision 858291517ed54b0f98ea4171eda9f7f3b7aba40e)
@@ -66,4 +66,5 @@
 	onAdd: function(field, e) {
 		if (this.form.getForm().isValid()) {
+			this.torrentId = this.createTorrentId();
 			this.form.getForm().submit({
 				url: '/upload',
@@ -72,6 +73,12 @@
 				scope: this
 			});
+			var name = this.form.getForm().findField('torrentFile').value;
+			this.fireEvent('beforeadd', this.torrentId, name);
 		}
-		this.fireEvent('beforeadd', null);
+	},
+	
+	onGotInfo: function(info, obj, response, request) {
+		info['filename'] = request.options.filename;
+		this.fireEvent('add', this.torrentId, info);
 	},
 	
@@ -85,9 +92,4 @@
 			filename: filename
 		});
-	},
-	
-	onGotInfo: function(info, obj, response, request) {
-		info['filename'] = request.options.filename;
-		this.fireEvent('add', info);
 	}
 });
Index: deluge/ui/web/js/Deluge.Add.Url.js
===================================================================
--- deluge/ui/web/js/Deluge.Add.Url.js	(revision 2ac545dec6ee4359e3f1f53b7f705cd2c2c0d26e)
+++ deluge/ui/web/js/Deluge.Add.Url.js	(revision 858291517ed54b0f98ea4171eda9f7f3b7aba40e)
@@ -71,19 +71,22 @@
 		var field = this.form.items.get('url');
 		var url = field.getValue();
+		var torrentId = this.createTorrentId();
 		
 		Deluge.Client.web.download_torrent_from_url(url, {
 			success: this.onDownload,
-			scope: this
+			scope: this,
+			torrentId: torrentId
 		});
 		this.hide();
-		this.fireEvent('beforeadd', url);
+		this.fireEvent('beforeadd', torrentId, url);
 	},
 	
-	onDownload: function(filename) {
+	onDownload: function(filename, obj, resp, req) {
 		this.form.items.get('url').setValue('');
 		Deluge.Client.web.get_torrent_info(filename, {
 			success: this.onGotInfo,
 			scope: this,
-			filename: filename
+			filename: filename,
+			torrentId: req.options.torrentId
 		});
 	},
@@ -91,5 +94,5 @@
 	onGotInfo: function(info, obj, response, request) {
 		info['filename'] = request.options.filename;
-		this.fireEvent('add', info);
+		this.fireEvent('add', request.options.torrentId, info);
 	}
 });
Index: deluge/ui/web/js/Deluge.Add.js
===================================================================
--- deluge/ui/web/js/Deluge.Add.js	(revision 2ac545dec6ee4359e3f1f53b7f705cd2c2c0d26e)
+++ deluge/ui/web/js/Deluge.Add.js	(revision 858291517ed54b0f98ea4171eda9f7f3b7aba40e)
@@ -63,4 +63,28 @@
 			folderSort: true
 		});
+		
+		this.form = this.add({
+			xtype: 'form',
+			labelWidth: 1,
+			frame: false,
+			title: _('Options'),
+			bodyStyle: 'padding: 5px;',
+			border: false,
+			
+			
+			items: [{
+				xtype: 'fieldset',
+				title: _('Download Location'),
+				border: false,
+				defaultType: 'textfield',
+				labelWidth: 1,
+				items: [{
+					fieldLabel: '',
+					labelSeperator: '',
+					name: 'download_location',
+					width: 330
+				}]
+			}]
+		});
 	},
 	
@@ -90,11 +114,11 @@
         ]
         Deluge.Client.core.get_config_values(keys, {
-            onSuccess: function(config) {
+            success: function(config) {
 				this.defaults = config;
-				$each(config, function(value, key) {
+				for (var key in config) {
 					var field = this.form.findField(key);
 					if (!field) return;
-					field.setValue(value);
-				}, this);
+					field.setValue(config[key]);
+				}
 				var field = this.form.findField('compact_allocation');
 				if (config['compact_allocation']) {
@@ -105,5 +129,6 @@
 					field.items.get('compact_allocation_true').setValue(false);
 				}
-			}.bindWithEvent(this)
+			},
+			scope: this
         });
 	}
@@ -117,4 +142,8 @@
 			'add'
 		);
+	},
+	
+	createTorrentId: function() {
+		return new Date().getTime();
 	}
 });
@@ -146,9 +175,20 @@
 		this.addButton(_('Add'), this.onAdd, this);
 		
+		function torrentRenderer(value, p, r) {
+			if (r.data['infohash']) {
+				return String.format('<div class="x-add-torrent-name">{0}</div>', value);
+			} else {
+				return String.format('<div class="x-add-torrent-name-loading">{0}</div>', value);
+			}
+		}
+		
 		this.grid = this.add({
 			xtype: 'grid',
 			region: 'center',
 			store: new Ext.data.SimpleStore({
-				fields: [{name: 'torrent', mapping: 1}],
+				fields: [
+					{name: 'info_hash', mapping: 1},
+					{name: 'text', mapping: 2}
+				],
 				id: 0
 			}),
@@ -157,6 +197,6 @@
 					width: 150,
 					sortable: true,
-					renderer: fplain,
-					dataIndex: 'torrent'
+					renderer: torrentRenderer,
+					dataIndex: 'text'
 			}],	
 			stripeRows: true,
@@ -250,9 +290,9 @@
 		delete this.torrents[torrent.id];
 		this.grid.getStore().remove(torrent);
-		this.clearFiles();
+		this.options.clear();
 	},
 	
 	onSelect: function(selModel, rowIndex, record) {
-		var torrentInfo = this.torrents[record.id];
+		var torrentInfo = this.torrents[record.get('info_hash')];
 		
 		function walk(files, parent) {
@@ -300,8 +340,10 @@
 	},
 	
-	onTorrentBeforeAdd: function(temptext) {
-	},
-	
-	onTorrentAdd: function(info) {
+	onTorrentBeforeAdd: function(torrentId, text) {
+		var store = this.grid.getStore();
+		store.loadData([[torrentId, null, text]], true);
+	},
+	
+	onTorrentAdd: function(torrentId, info) {
 		if (!info) {
 			Ext.MessageBox.show({
@@ -315,5 +357,9 @@
 			return;
 		}
-		this.grid.getStore().loadData([[info['info_hash'], info['name']]], true);
+		
+		var r = this.grid.getStore().getById(torrentId);
+		r.set('info_hash', info['info_hash']);
+		r.set('text', info['name']);
+		this.grid.getStore().commitChanges();
 		this.torrents[info['info_hash']] = info;
 	},
@@ -324,330 +370,2 @@
 });
 Deluge.Add = new Ext.deluge.add.AddWindow();
-
-/*Deluge.Add = {
-	onFile: function() {
-		this.File.Window.show();
-	},
-	
-	onOptionsRender: function(panel) {
-		panel.layout = new Ext.layout.FormLayout();
-		panel.layout.setContainer(panel);
-		panel.doLayout();
-		this.form = panel.getForm();
-		this.getDefaults();
-	},
-	
-	onRender: function(window) {
-		new Ext.tree.TreeSorter(this.Files, {
-			folderSort: true
-		});
-	},
-	
-	onSelect: function(selModel, rowIndex, record) {
-		var torrentInfo = Deluge.Add.torrents[record.id];
-		
-		function walk(files, parent) {
-			$each(files, function(item, file) {
-				if ($type(item) == 'object') {
-					var child = new Ext.tree.TreeNode({
-						text: file
-					});
-					walk(item, child);
-					parent.appendChild(child);
-				} else {
-					parent.appendChild(new Ext.tree.TreeNode({
-						filename: file,
-						text: file, // this needs to be here for sorting reasons
-						size: fsize(item[0]),
-						leaf: true,
-						checked: item[1],
-						iconCls: 'x-deluge-file',
-						uiProvider: Ext.tree.ColumnNodeUI
-					}));	
-				}
-			});
-		}
-		
-		this.clearFiles();
-		
-		var root = this.Files.getRootNode();
-		walk(torrentInfo['files_tree'], root);
-		root.firstChild.expand();
-	},
-	
-	onTorrentAdded: function(info, filename) {
-		if (!info) {
-			Ext.MessageBox.show({
-				title: _('Error'),
-				msg: _('Not a valid torrent'),
-				buttons: Ext.MessageBox.OK,
-				modal: false,
-				icon: Ext.MessageBox.ERROR,
-				iconCls: 'x-deluge-icon-error'
-			});
-			return;
-		}
-		info['filename'] = filename;
-		this.Store.loadData([[info['info_hash'], info['name']]], true);
-		this.torrents[info['info_hash']] = info;
-	},
-	
-	onUrl: function(button, event) {
-		this.Url.Window.show();
-	},
-	
-	onRemove: function() {
-		var selection = this.Grid.getSelectionModel();
-		if (!selection.hasSelection()) return;
-		var torrent = selection.getSelected();
-		
-		delete this.torrents[torrent.id];
-		this.Store.remove(torrent);
-		this.clearFiles();
-	}
-}
-
-Deluge.Add.Options = new Ext.TabPanel({
-	region: 'south',
-	margins: '5 5 5 5',
-	activeTab: 0,
-	height: 220,
-	items: [{
-		id: 'addFilesTab',
-		title: _('Files'),
-		items: [Deluge.Add.Files]
-	},{
-		id: 'addOptionsTab',
-		title: _('Options'),
-		layout: 'fit',
-		items: [new Ext.form.FormPanel({
-			id: 'addOptionsForm',
-			bodyStyle: 'padding: 5px;',
-			border: false,
-			items: [{
-				xtype: 'fieldset',
-				style: 'padding: 0px; padding-top: 5px;',
-				title: _('Download Location'),
-				border: false,
-				autoHeight: true,
-				border: false,
-				labelWidth: 1,
-				items: [{
-					layout: 'column',
-					border: false,
-					items: [{
-						xtype: 'textfield',
-						id: 'download_location',
-						fieldLabel: '',
-						labelSeparator: '',
-						width: 330
-					}, {
-						border: false,
-						style: 'padding-left: 5px;',
-						items: [{
-							xtype: 'button',
-							text: _('Browse') + '...',
-							disabled: true
-						}]
-					}]
-				}]
-			}, {
-				layout: 'column',
-				border: false,
-				defaults: {
-					border: false
-				},
-				items: [{
-					xtype: 'fieldset',
-					bodyStyle: 'margin-left: 5px; margin-right:5px;',
-					title: _('Allocation'),
-					autoHeight: true,
-					border: false,
-					labelWidth: 1,
-					width: 100,
-					items: [new Ext.form.RadioGroup({
-						id: 'compact_allocation',
-						name: 'compact_allocation',
-						columns: 1,
-						labelSeparator: '',
-						items: [{
-							boxLabel: _('Full'),
-							inputValue: 'false',
-							id: 'compact_allocation_false',
-							name: 'compact_allocation',
-							checked: true
-						},{
-							boxLabel: _('Compact'),
-							inputValue: 'true',
-							id: 'compact_allocation_true',
-							name: 'compact_allocation'
-						}]
-					})]
-				}, {
-					xtype: 'fieldset',
-					title: _('Bandwidth'),
-					layout: 'form',
-					autoHeight: true,
-					defaultType: 'uxspinner',
-					labelWidth: 100,
-					items: [{
-						id: 'max_download_speed_per_torrent',
-						fieldLabel: _('Max Down Speed'),
-						width: 60,
-						value: -1,
-						strategy: new Ext.ux.form.Spinner.NumberStrategy({
-							minValue: -1,
-							maxValue: 99999,
-							incrementValue: 1
-						})
-					}, {
-						id: 'max_upload_speed_per_torrent',
-						fieldLabel: _('Max Up Speed'),
-						width: 60,
-						value: -1,
-						strategy: new Ext.ux.form.Spinner.NumberStrategy({
-							minValue: -1,
-							maxValue: 99999,
-							incrementValue: 1
-						})
-					}, {
-						id: 'max_connections_per_torrent',
-						fieldLabel: _('Max Connections'),
-						width: 60,
-						value: -1,
-						strategy: new Ext.ux.form.Spinner.NumberStrategy({
-							minValue: -1,
-							maxValue: 99999,
-							incrementValue: 1
-						})
-					}, {
-						id: 'max_upload_slots_per_torrent',
-						fieldLabel: _('Max Upload Slots'),
-						colspan: 2,
-						width: 60,
-						value: -1,
-						strategy: new Ext.ux.form.Spinner.NumberStrategy({
-							minValue: -1,
-							maxValue: 99999,
-							incrementValue: 1
-						})
-					}]
-				}, {
-					xtype: 'fieldset',
-					title: _('General'),
-					autoHeight: true,
-					border: false,
-					labelWidth: 10,
-					defaultType: 'checkbox',
-					items: [{
-						fieldLabel: '',
-						labelSeparator: '',
-						boxLabel: _('Add In Paused State'),
-						id: 'add_paused'
-					}, {
-						fieldLabel: '',
-						labelSeparator: '',
-						boxLabel: _('Prioritize First/Last Piece'),
-						id: 'prioritize_first_last_pieces'
-					}, {
-						xtype: 'button',
-						text: _('Apply to All'),
-						style: 'margin-left: 20px; margin-top: 5px;'
-					}, {
-						xtype: 'button',
-						text: _('Revert to Defaults'),
-						style: 'margin-left: 20px; margin-top: 5px;'
-					}]
-				}]
-			}],
-			listeners: {
-				'render': {
-					fn: Deluge.Add.onOptionsRender,
-					scope: Deluge.Add
-				}
-			}
-		})]
-	}]
-});
-
-Deluge.Add.File = {
-	onAdd: function() {
-		if (this.form.getForm().isValid()) {
-			this.form.getForm().submit({
-				url: '/upload',
-				waitMsg: _('Uploading your torrent...'),
-				success: this.onUploadSuccess.bindWithEvent(this)
-			});
-		}
-	},
-	
-	onUploadSuccess: function(fp, upload) {
-		this.Window.hide();
-		var filename = upload.result.toString();
-		this.form.items.get('torrentFile').setValue('');
-		Deluge.Client.web.get_torrent_info(filename, {
-			onSuccess: Deluge.Add.onTorrentAdded.bindWithEvent(Deluge.Add, filename)
-		});
-	}
-}
-
-Deluge.Add.File.form = new Ext.form.FormPanel({
-	fileUpload: true,
-    id: 'fileAddForm',
-    baseCls: 'x-plain',
-    labelWidth: 55,
-	autoHeight: true,
-    items: [{
-		xtype: 'fileuploadfield',
-		id: 'torrentFile',
-		emptyText: _('Select a torrent'),
-        fieldLabel: _('File'),
-        name: 'file',
-		buttonCfg: {
-			text: _('Browse') + '...'
-		}
-    }]
-});
-
-Deluge.Add.File.Window = new Ext.Window({
-	layout: 'fit',
-    width: 350,
-    height: 115,
-    bodyStyle: 'padding: 10px 5px;',
-    buttonAlign: 'center',
-    closeAction: 'hide',
-    modal: true,
-    plain: true,
-    title: _('Add from File'),
-    iconCls: 'x-deluge-add-file',
-    items: Deluge.Add.File.form,
-    buttons: [{
-        text: _('Add'),
-        handler: Deluge.Add.File.onAdd,
-		scope: Deluge.Add.File
-    }]
-});
-
-Deluge.Add.Url = {
-	onAdd: function(field, e) {
-		if (field.id == 'url' && e.getKey() != e.ENTER) return;
-
-		var field = this.form.items.get('url');
-		var url = field.getValue();
-		
-		Deluge.Client.web.download_torrent_from_url(url, {
-			onSuccess: this.onDownload.bindWithEvent(this)
-		});
-		this.Window.hide();
-	},
-	
-	onDownload: function(filename) {
-		this.form.items.get('url').setValue('');
-		Deluge.Client.web.get_torrent_info(filename, {
-			onSuccess: Deluge.Add.onTorrentAdded.bindWithEvent(Deluge.Add, filename)
-		});
-	}
-}
-
-Deluge.Add.Url.form = ;
-*/
