[Xfce4-commits] <eatmonkey:aria2-xml-rpc> Reworked on a nicer "New Download" dialog
Mike Massonnet
noreply at xfce.org
Thu Feb 11 22:58:05 CET 2010
Updating branch refs/heads/aria2-xml-rpc
to f0797ba68bc8749d6550e33f02381a029be27ad2 (commit)
from e971e0a6229806185db22757413d5b0d1d1e10fa (commit)
commit f0797ba68bc8749d6550e33f02381a029be27ad2
Author: Mike Massonnet <mmassonnet at xfce.org>
Date: Thu Feb 11 22:46:53 2010 +0100
Reworked on a nicer "New Download" dialog
The Aria2#add_uri/torrent/metalink now accepts options properly and
the position. The "New Downlaod" dialog has a few options to customize
the download. The destination directory is hidden and unused in case
aria2 is not running as a local server.
src/eataria2.rb | 24 +++-
src/eatmanager.rb | 65 ++++++++--
src/manager.ui | 373 +++++++++++++++++++++++++++++++++++++++++++++++++----
src/settings.ui | 2 +-
4 files changed, 416 insertions(+), 48 deletions(-)
diff --git a/src/eataria2.rb b/src/eataria2.rb
index ff2bcbf..5d7fc72 100644
--- a/src/eataria2.rb
+++ b/src/eataria2.rb
@@ -305,25 +305,37 @@ class Eat::Aria2 < GLib::Object
end
# Adds new HTTP(S)/FTP/BitTorrent/Magnet URI.
- def add_uri(uris, options = nil, position = nil)
+ def add_uri(uris, options = [], position = nil)
uris = [ uris ] if uris.class == String
- gid = call("aria2.addUri", uris)
+ if position != nil
+ gid = call("aria2.addUri", uris, options, position)
+ else
+ gid = call("aria2.addUri", uris, options)
+ end
@new_downloads << gid if gid != nil
gid
end
# Adds BitTorrent download by uploading .torrent file.
- def add_torrent(torrent, uris = nil, options = nil, position = nil)
+ def add_torrent(torrent, uris = [], options = [], position = nil)
data = read(torrent)
- gid = call("aria2.addTorrent", XMLRPC::Base64.new(data))
+ if position != nil
+ gid = call("aria2.addTorrent", XMLRPC::Base64.new(data), uris, options, position)
+ else
+ gid = call("aria2.addTorrent", XMLRPC::Base64.new(data), uris, options)
+ end
@new_downloads << gid if gid != nil
gid
end
# Adds Metalink download by uploading .metalink file.
- def add_metalink(metalink, options = nil, position = nil)
+ def add_metalink(metalink, options = [], position = nil)
data = read(metalink)
- gid = call("aria2.addMetalink", XMLRPC::Base64.new(data))
+ if position != nil
+ gid = call("aria2.addMetalink", XMLRPC::Base64.new(data), options, position)
+ else
+ gid = call("aria2.addMetalink", XMLRPC::Base64.new(data), options)
+ end
@new_downloads << gid if gid != nil
gid
end
diff --git a/src/eatmanager.rb b/src/eatmanager.rb
index 458e213..1cbae6a 100644
--- a/src/eatmanager.rb
+++ b/src/eatmanager.rb
@@ -22,6 +22,7 @@ class Eat::Manager
# Setup aria2 listener
@aria2 = Eat::Aria2Listener.instance
@aria2.signal_connect("connected") {
+ update_newdl_dialog
set_sensitive(true)
@infobar.hide_all
@infobar.set_no_show_all(true)
@@ -47,9 +48,15 @@ class Eat::Manager
@statusbar = builder["statusbar-manager"]
@newdl_dialog = builder["dialog-new-download"]
- @custom_uri = builder["custom-uri"]
- @select_file = builder["select-file"]
- @select_file_dialog = builder["filechooserdialog-new-download"]
+ @file_uri = builder["file-uri"]
+ @file_select_file = builder["file-select-file"]
+ @file_select_file_dialog = builder["filechooserdialog-new-download"]
+ @file_max_download_speed = builder["file-max-download-speed"]
+ @file_split = builder["file-split"]
+ @hbox_download_dir = builder["hbox-download-dir"]
+ @file_download_dir = builder["file-download-dir-button"]
+ @file_max_upload_speed = builder["file-max-upload-speed"]
+ @file_seed_ratio = builder["file-seed-ratio"]
@action_add = builder["action-add"]
@action_pause = builder["action-pause"]
@@ -121,12 +128,12 @@ class Eat::Manager
file_filter.name = "Torrents, Metalinks"
file_filter.add_pattern("*.torrent")
file_filter.add_pattern("*.metalink")
- @select_file_dialog.filter = file_filter
- @select_file.signal_connect('clicked') do
- @select_file_dialog.unselect_all
- res = @select_file_dialog.run
- @custom_uri.text = @select_file_dialog.filename if res == Gtk::Dialog::RESPONSE_ACCEPT
- @select_file_dialog.hide
+ @file_select_file_dialog.filter = file_filter
+ @file_select_file.signal_connect('clicked') do
+ @file_select_file_dialog.unselect_all
+ res = @file_select_file_dialog.run
+ @file_uri.text = @file_select_file_dialog.filename if res == Gtk::Dialog::RESPONSE_ACCEPT
+ @file_select_file_dialog.hide
end
end
@@ -241,6 +248,7 @@ class Eat::Manager
if res == Dialog::RESPONSE_OK
settings = Eat::Settings.instance
+ update_newdl_dialog
set_sensitive(false)
if settings["custom-server"]
@@ -284,6 +292,20 @@ class Eat::Manager
private
+ def update_newdl_dialog()
+ settings = Eat::Settings.instance
+ @file_max_download_speed.value = settings.aria2["max-download-limit"].to_i
+ @file_split.value = settings.aria2["split"]
+ if @aria2.use_local_server?
+ @hbox_download_dir.show_all
+ @file_download_dir.current_folder = settings.aria2["dir"]
+ else
+ @hbox_download_dir.hide_all
+ end
+ @file_max_upload_speed.value = settings.aria2["max-upload-limit"].to_i
+ @file_seed_ratio.value = settings.aria2["seed-ratio"].to_f
+ end
+
def action_quit()
# TODO make this optional e.g. keep active downloads running
set_sensitive(false)
@@ -293,16 +315,33 @@ class Eat::Manager
end
def action_add()
- @custom_uri.text = ""
- @custom_uri.grab_focus
+ update_newdl_dialog
+ @file_uri.text = ""
+ @file_uri.grab_focus
res = @newdl_dialog.run
@newdl_dialog.hide
- uri = @custom_uri.text
+ uri = @file_uri.text
if res == Dialog::RESPONSE_OK and !uri.empty?
# TODO check if it is a uri or a torrent/metalink file and use the right
# method addUri/addTorrent/addMetalink
puts "download file %s" % uri
- gid = @aria2.add_uri(uri)
+ if @aria2.use_local_server?
+ options = {
+ "dir" => @file_download_dir.current_folder,
+ "max-download-limit" => @file_max_download_speed.value_as_int.to_s,
+ "split" => @file_split.value_as_int.to_s,
+ "max-upload-limit" => @file_max_upload_speed.value_as_int.to_s,
+ "seed-ratio" => @file_seed_ratio.value.to_s,
+ }
+ else
+ options = {
+ "max-download-limit" => @file_max_download_speed.value_as_int.to_s,
+ "split" => @file_split.value_as_int.to_s,
+ "max-upload-limit" => @file_max_upload_speed.value_as_int.to_s,
+ "seed-ratio" => @file_seed_ratio.value.to_s,
+ }
+ end
+ gid = @aria2.add_uri(uri, options)
if gid != nil
puts "gid: %s" % gid
# Add new row to liststore
diff --git a/src/manager.ui b/src/manager.ui
index 6306847..08fc56e 100644
--- a/src/manager.ui
+++ b/src/manager.ui
@@ -427,7 +427,7 @@
<property name="active">True</property>
</object>
<object class="GtkDialog" id="dialog-new-download">
- <property name="title" translatable="yes">New download</property>
+ <property name="title" translatable="yes">New Download</property>
<property name="modal">True</property>
<property name="window_position">center-on-parent</property>
<property name="destroy_with_parent">True</property>
@@ -451,10 +451,62 @@
<child>
<object class="GtkVBox" id="vbox1">
<property name="visible">True</property>
+ <property name="border_width">6</property>
<property name="orientation">vertical</property>
+ <property name="spacing">6</property>
<child>
- <object class="GtkComboBox" id="combobox1">
- <property name="model">liststore1</property>
+ <object class="GtkFrame" id="frame3">
+ <property name="visible">True</property>
+ <property name="label_xalign">0</property>
+ <property name="shadow_type">none</property>
+ <child>
+ <object class="GtkAlignment" id="alignment3">
+ <property name="visible">True</property>
+ <property name="top_padding">6</property>
+ <property name="left_padding">12</property>
+ <child>
+ <object class="GtkHBox" id="hbox1">
+ <property name="visible">True</property>
+ <property name="spacing">4</property>
+ <child>
+ <object class="GtkEntry" id="file-uri">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="invisible_char">•</property>
+ </object>
+ <packing>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkButton" id="file-select-file">
+ <property name="label">...</property>
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">True</property>
+ <property name="image">image2</property>
+ <property name="image_position">right</property>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ </object>
+ </child>
+ </object>
+ </child>
+ <child type="label">
+ <object class="GtkLabel" id="label6">
+ <property name="visible">True</property>
+ <property name="label" translatable="yes">Add new download from URI or File</property>
+ <property name="use_markup">True</property>
+ <attributes>
+ <attribute name="weight" value="bold"/>
+ </attributes>
+ </object>
+ </child>
</object>
<packing>
<property name="expand">False</property>
@@ -464,7 +516,7 @@
</child>
<child>
<object class="GtkFrame" id="frame1">
- <property name="border_width">6</property>
+ <property name="visible">True</property>
<property name="label_xalign">0</property>
<property name="shadow_type">none</property>
<child>
@@ -473,17 +525,138 @@
<property name="top_padding">6</property>
<property name="left_padding">12</property>
<child>
- <object class="GtkHBox" id="hbox3">
+ <object class="GtkVBox" id="vbox3">
<property name="visible">True</property>
+ <property name="orientation">vertical</property>
+ <property name="spacing">6</property>
<child>
- <object class="GtkFileChooserButton" id="filechooserbutton1">
+ <object class="GtkHBox" id="hbox6">
<property name="visible">True</property>
- <property name="create_folders">False</property>
+ <property name="spacing">4</property>
+ <child>
+ <object class="GtkLabel" id="label11">
+ <property name="visible">True</property>
+ <property name="label" translatable="yes">Maximum download speed:</property>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkSpinButton" id="file-max-download-speed">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="invisible_char">•</property>
+ <property name="adjustment">adjustment-file-max-download-speed</property>
+ <property name="numeric">True</property>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkLabel" id="label13">
+ <property name="visible">True</property>
+ <property name="label" translatable="yes">KiB/s</property>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ <property name="position">2</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkLabel" id="label20">
+ <property name="visible">True</property>
+ <property name="label" translatable="yes">(0=infinite)</property>
+ <attributes>
+ <attribute name="size" value="7500"/>
+ </attributes>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ <property name="position">3</property>
+ </packing>
+ </child>
</object>
<packing>
<property name="position">0</property>
</packing>
</child>
+ <child>
+ <object class="GtkHBox" id="hbox12">
+ <property name="visible">True</property>
+ <property name="tooltip_markup">Number of connections to open for this file (only for HTTP(s)/FTP)</property>
+ <property name="spacing">4</property>
+ <child>
+ <object class="GtkLabel" id="label25">
+ <property name="visible">True</property>
+ <property name="label" translatable="yes">Number of fragmentation:</property>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkSpinButton" id="file-split">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="invisible_char">•</property>
+ <property name="adjustment">adjustment-file-split</property>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkHBox" id="hbox-download-dir">
+ <property name="visible">True</property>
+ <property name="spacing">4</property>
+ <child>
+ <object class="GtkLabel" id="label9">
+ <property name="visible">True</property>
+ <property name="label" translatable="yes">Download directory:</property>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkFileChooserButton" id="file-download-dir-button">
+ <property name="visible">True</property>
+ <property name="create_folders">False</property>
+ <property name="action">select-folder</property>
+ <property name="width_chars">14</property>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ </object>
+ <packing>
+ <property name="position">2</property>
+ </packing>
+ </child>
</object>
</child>
</object>
@@ -491,8 +664,7 @@
<child type="label">
<object class="GtkLabel" id="label4">
<property name="visible">True</property>
- <property name="label" translatable="yes">Select from file</property>
- <property name="use_markup">True</property>
+ <property name="label" translatable="yes">Download Options</property>
<attributes>
<attribute name="weight" value="bold"/>
</attributes>
@@ -506,38 +678,108 @@
</packing>
</child>
<child>
- <object class="GtkFrame" id="frame3">
+ <object class="GtkFrame" id="frame4">
<property name="visible">True</property>
- <property name="border_width">6</property>
<property name="label_xalign">0</property>
<property name="shadow_type">none</property>
<child>
- <object class="GtkAlignment" id="alignment3">
+ <object class="GtkAlignment" id="alignment4">
<property name="visible">True</property>
<property name="top_padding">6</property>
<property name="left_padding">12</property>
<child>
- <object class="GtkHBox" id="hbox1">
+ <object class="GtkVBox" id="vbox4">
<property name="visible">True</property>
- <property name="spacing">4</property>
+ <property name="orientation">vertical</property>
+ <property name="spacing">6</property>
<child>
- <object class="GtkEntry" id="custom-uri">
+ <object class="GtkHBox" id="hbox3">
<property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="invisible_char">•</property>
+ <property name="spacing">4</property>
+ <child>
+ <object class="GtkImage" id="image3">
+ <property name="visible">True</property>
+ <property name="stock">gtk-info</property>
+ <property name="icon-size">1</property>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkLabel" id="label8">
+ <property name="visible">True</property>
+ <property name="xalign">0</property>
+ <property name="label" translatable="yes">These options only apply for BitTorrent</property>
+ <attributes>
+ <attribute name="style" value="italic"/>
+ </attributes>
+ </object>
+ <packing>
+ <property name="position">1</property>
+ </packing>
+ </child>
</object>
<packing>
<property name="position">0</property>
</packing>
</child>
<child>
- <object class="GtkButton" id="select-file">
- <property name="label">...</property>
+ <object class="GtkHBox" id="hbox7">
<property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="receives_default">True</property>
- <property name="image">image2</property>
- <property name="image_position">right</property>
+ <property name="spacing">4</property>
+ <child>
+ <object class="GtkLabel" id="label12">
+ <property name="visible">True</property>
+ <property name="label" translatable="yes">Maximum upload speed:</property>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkSpinButton" id="file-max-upload-speed">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="invisible_char">•</property>
+ <property name="adjustment">adjustment-file-max-upload-speed</property>
+ <property name="numeric">True</property>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkLabel" id="label14">
+ <property name="visible">True</property>
+ <property name="label" translatable="yes">KiB/s</property>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ <property name="position">2</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkLabel" id="label19">
+ <property name="visible">True</property>
+ <property name="label" translatable="yes">(0=infinite)</property>
+ <attributes>
+ <attribute name="size" value="7500"/>
+ </attributes>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ <property name="position">3</property>
+ </packing>
+ </child>
</object>
<packing>
<property name="expand">False</property>
@@ -545,15 +787,64 @@
<property name="position">1</property>
</packing>
</child>
+ <child>
+ <object class="GtkHBox" id="hbox8">
+ <property name="visible">True</property>
+ <property name="spacing">4</property>
+ <child>
+ <object class="GtkLabel" id="label10">
+ <property name="visible">True</property>
+ <property name="label" translatable="yes">Seed ratio:</property>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkSpinButton" id="file-seed-ratio">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="invisible_char">•</property>
+ <property name="adjustment">adjustment-file-seed-ratio</property>
+ <property name="digits">2</property>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkLabel" id="label21">
+ <property name="visible">True</property>
+ <property name="label" translatable="yes">(0=infinite)</property>
+ <attributes>
+ <attribute name="size" value="7500"/>
+ </attributes>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ <property name="position">2</property>
+ </packing>
+ </child>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ <property name="position">2</property>
+ </packing>
+ </child>
</object>
</child>
</object>
</child>
<child type="label">
- <object class="GtkLabel" id="label6">
+ <object class="GtkLabel" id="label7">
<property name="visible">True</property>
- <property name="label" translatable="yes">Open from URI/File</property>
- <property name="use_markup">True</property>
+ <property name="label" translatable="yes">Upload Options</property>
<attributes>
<attribute name="weight" value="bold"/>
</attributes>
@@ -744,10 +1035,10 @@
<property name="skip_pager_hint">True</property>
<property name="transient_for">dialog-new-download</property>
<property name="has_separator">False</property>
- <property name="use_preview_label">False</property>
<property name="create_folders">False</property>
- <property name="filter">filefilter-new-download</property>
<property name="preview_widget_active">False</property>
+ <property name="filter">filefilter-new-download</property>
+ <property name="use_preview_label">False</property>
<child internal-child="vbox">
<object class="GtkVBox" id="dialog-vbox2">
<property name="visible">True</property>
@@ -803,4 +1094,30 @@
</action-widgets>
</object>
<object class="GtkFileFilter" id="filefilter-new-download"/>
+ <object class="GtkAdjustment" id="adjustment-file-max-download-speed">
+ <property name="upper">9999</property>
+ <property name="step_increment">4</property>
+ <property name="page_increment">10</property>
+ </object>
+ <object class="GtkAdjustment" id="adjustment-file-max-upload-speed">
+ <property name="upper">9999</property>
+ <property name="step_increment">4</property>
+ <property name="page_increment">10</property>
+ </object>
+ <object class="GtkAdjustment" id="adjustment-file-seed-ratio">
+ <property name="upper">99</property>
+ <property name="step_increment">0.10000000000000001</property>
+ <property name="page_increment">0.10000000000000001</property>
+ </object>
+ <object class="GtkAdjustment" id="adjustment-file-split">
+ <property name="lower">1</property>
+ <property name="upper">100</property>
+ <property name="step_increment">1</property>
+ <property name="page_increment">10</property>
+ </object>
+ <object class="GtkAdjustment" id="adjustment-file-max-peers">
+ <property name="upper">9999</property>
+ <property name="step_increment">5</property>
+ <property name="page_increment">10</property>
+ </object>
</interface>
diff --git a/src/settings.ui b/src/settings.ui
index c520ef3..af46495 100644
--- a/src/settings.ui
+++ b/src/settings.ui
@@ -719,7 +719,7 @@
<child>
<object class="GtkHBox" id="hbox12">
<property name="visible">True</property>
- <property name="tooltip_text" translatable="yes">Number of connections to open for one file to download</property>
+ <property name="tooltip_text" translatable="yes">Number of connections to open for one file to download (only for HTTP(s)/FTP)</property>
<property name="spacing">4</property>
<child>
<object class="GtkLabel" id="label25">
More information about the Xfce4-commits
mailing list