[Xfce4-commits] <eatmonkey:aria2-xml-rpc> Update row immediately when resuming a download

Mike Massonnet noreply at xfce.org
Thu Feb 11 22:58:01 CET 2010


Updating branch refs/heads/aria2-xml-rpc
         to 32127e76efd4aa52c4fd4969a5f33e205197176a (commit)
       from d09905b159f534a1ff967ed999afaa88011ccf25 (commit)

commit 32127e76efd4aa52c4fd4969a5f33e205197176a
Author: Mike Massonnet <mmassonnet at xfce.org>
Date:   Wed Feb 10 00:10:06 2010 +0100

    Update row immediately when resuming a download
    
    The pause/resuming works by removing the download from aria2 and
    readding the same afterwards. This was currerntly done very raw by
    removing the row iter from the model and waiting for the callback to
    display the new one. Now the row is added immediately on resume with
    minimum information.

 src/eataria2.rb   |    2 +-
 src/eatmanager.rb |   24 +++++++++++++++++-------
 2 files changed, 18 insertions(+), 8 deletions(-)

diff --git a/src/eataria2.rb b/src/eataria2.rb
index c441b62..468978f 100644
--- a/src/eataria2.rb
+++ b/src/eataria2.rb
@@ -138,7 +138,7 @@ class Eat::Aria2 < GLib::Object
 					@@pid = spawn_server(command)
 				rescue Timeout::Error
 				begin
-					# Retry with even fewer arguments for aria2 < 1.5
+					# Retry with even fewer arguments for aria2 < 1.6
 					command = "aria2c --enable-xml-rpc --xml-rpc-listen-port=#{@port} " \
 						"--conf-path=#{@confdir}/aria2.conf --log=#{@confdir}/aria2.log --log-level=notice"
 					@@pid = spawn_server(command)
diff --git a/src/eatmanager.rb b/src/eatmanager.rb
index 6bb72fe..fea43f2 100644
--- a/src/eatmanager.rb
+++ b/src/eatmanager.rb
@@ -285,12 +285,11 @@ class Eat::Manager
 			gid = @aria2.add_uri(uri)
 			if gid != nil
 				puts "gid: %s" % gid
-
 				# Add new row to liststore
 				row_iter = @liststore.append
-				@liststore.set_value(row_iter, 0, gid.to_i)
-				@liststore.set_value(row_iter, 9, File.basename(uri))
-				@liststore.set_value(row_iter, 10, uri)
+				row_iter[0] = gid.to_i
+				row_iter[9] = File.basename(uri)
+				row_iter[10] = uri
 			end
 		end
 	end
@@ -304,16 +303,27 @@ class Eat::Manager
 
 	def action_resume()
 		@treeview.selection.selected_each do |model, path, iter|
-			gid = iter.get_value(0).to_s
+			gid = iter[0].to_s
 			status = @aria2.tell_status(gid)
 			case status["status"]
 			when "removed"
 				# Restart the download queued at position 0 and delete current row
 				# as new gid will be created
-				uri = iter.get_value(10)
+				uri = iter[10]
 				if !uri.empty?
-					@aria2.add_uri(uri, nil, 0)
+					percent = iter[8]
 					@liststore.remove(iter)
+					gid = @aria2.add_uri(uri, nil, 0)
+					if gid != nil
+						# TODO this is a little better than nothing, when
+						# the download is resumed it will reappear immediately
+						# but with incomplete information
+						iter = @liststore.append
+						iter[0] = gid.to_i
+						iter[8] = percent
+						iter[9] = File.basename(uri)
+						iter[10] = uri
+					end
 				end
 			end
 		end



More information about the Xfce4-commits mailing list