add advanced progress bar option - modified extensively from patch by arnab

This commit is contained in:
Marcos Pinto 2007-11-10 05:10:28 +00:00
parent 6da46bc546
commit d1f2aed58b
9 changed files with 448 additions and 321 deletions

View file

@ -3,6 +3,7 @@ Deluge 0.5.7 (xx November 2007)
* Blocklist plugin will now display errors, instead of just crashing on a bad
list or wrong type
* Local discovery of peers
* Add advanced progress bar option - adapted from Arnab Bose
* Fix ratio bugs (hopefully for the last time)
* Fix ETA from going backwards
* UI warning on full HD - no longer just silently pauses torrents

1
TODO
View file

@ -1,3 +1,2 @@
for 0.5.7
* remap filenames
* decide what to do about the progress bar patch

View file

@ -73,7 +73,6 @@
<child>
<widget class="GtkFrame" id="frame1">
<property name="visible">True</property>
<property name="label_xalign">0</property>
<child>
<widget class="GtkAlignment" id="alignment2">
<property name="visible">True</property>
@ -85,6 +84,24 @@
<widget class="GtkVBox" id="vbox1">
<property name="visible">True</property>
<property name="spacing">5</property>
<child>
<widget class="GtkHBox" id="advanced_progressbar">
<property name="visible">True</property>
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
<child>
<widget class="GtkDrawingArea" id="custom_progress">
<property name="height_request">25</property>
<property name="visible">True</property>
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
<signal name="expose_event" handler="expose_event"/>
</widget>
</child>
</widget>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
</packing>
</child>
<child>
<widget class="GtkProgressBar" id="progressbar">
<property name="visible">True</property>
@ -93,6 +110,7 @@
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="position">1</property>
</packing>
</child>
<child>
@ -102,277 +120,18 @@
<property name="n_columns">4</property>
<property name="row_spacing">5</property>
<child>
<widget class="GtkLabel" id="summary_total_downloaded">
<property name="visible">True</property>
<property name="xalign">0</property>
</widget>
<packing>
<property name="left_attach">1</property>
<property name="right_attach">2</property>
</packing>
</child>
<child>
<widget class="GtkLabel" id="summary_download_speed">
<widget class="GtkLabel" id="summary_availability">
<property name="visible">True</property>
<property name="xalign">0</property>
<property name="wrap">True</property>
<property name="wrap_mode">PANGO_WRAP_WORD_CHAR</property>
</widget>
<packing>
<property name="left_attach">3</property>
<property name="right_attach">4</property>
</packing>
</child>
<child>
<widget class="GtkLabel" id="summary_total_uploaded">
<property name="visible">True</property>
<property name="xalign">0</property>
</widget>
<packing>
<property name="left_attach">1</property>
<property name="right_attach">2</property>
<property name="top_attach">1</property>
<property name="bottom_attach">2</property>
</packing>
</child>
<child>
<widget class="GtkLabel" id="summary_upload_speed">
<property name="visible">True</property>
<property name="xalign">0</property>
</widget>
<packing>
<property name="left_attach">3</property>
<property name="right_attach">4</property>
<property name="top_attach">1</property>
<property name="bottom_attach">2</property>
</packing>
</child>
<child>
<widget class="GtkLabel" id="summary_seeders">
<property name="visible">True</property>
<property name="xalign">0</property>
</widget>
<packing>
<property name="left_attach">1</property>
<property name="right_attach">2</property>
<property name="top_attach">2</property>
<property name="bottom_attach">3</property>
</packing>
</child>
<child>
<widget class="GtkLabel" id="summary_peers">
<property name="visible">True</property>
<property name="xalign">0</property>
</widget>
<packing>
<property name="left_attach">3</property>
<property name="right_attach">4</property>
<property name="top_attach">2</property>
<property name="bottom_attach">3</property>
</packing>
</child>
<child>
<widget class="GtkLabel" id="summary_share_ratio">
<property name="visible">True</property>
<property name="xalign">0</property>
</widget>
<packing>
<property name="left_attach">1</property>
<property name="right_attach">2</property>
<property name="top_attach">3</property>
<property name="bottom_attach">4</property>
</packing>
</child>
<child>
<widget class="GtkLabel" id="summary_eta">
<property name="visible">True</property>
<property name="xalign">0</property>
</widget>
<packing>
<property name="left_attach">3</property>
<property name="right_attach">4</property>
<property name="top_attach">3</property>
<property name="bottom_attach">4</property>
</packing>
</child>
<child>
<widget class="GtkAlignment" id="alignment3">
<property name="visible">True</property>
<property name="right_padding">5</property>
<child>
<widget class="GtkLabel" id="label1">
<property name="visible">True</property>
<property name="xalign">0</property>
<property name="label" translatable="yes">&lt;b&gt;Downloaded:&lt;/b&gt;</property>
<property name="use_markup">True</property>
</widget>
</child>
</widget>
</child>
<child>
<widget class="GtkAlignment" id="alignment4">
<property name="visible">True</property>
<property name="right_padding">5</property>
<child>
<widget class="GtkLabel" id="label2">
<property name="visible">True</property>
<property name="xalign">0</property>
<property name="label" translatable="yes">&lt;b&gt;Uploaded:&lt;/b&gt;</property>
<property name="use_markup">True</property>
</widget>
</child>
</widget>
<packing>
<property name="top_attach">1</property>
<property name="bottom_attach">2</property>
</packing>
</child>
<child>
<widget class="GtkAlignment" id="alignment6">
<property name="visible">True</property>
<property name="right_padding">5</property>
<child>
<widget class="GtkLabel" id="label3">
<property name="visible">True</property>
<property name="xalign">0</property>
<property name="label" translatable="yes">&lt;b&gt;Seeders:&lt;/b&gt;</property>
<property name="use_markup">True</property>
</widget>
</child>
</widget>
<packing>
<property name="top_attach">2</property>
<property name="bottom_attach">3</property>
</packing>
</child>
<child>
<widget class="GtkAlignment" id="alignment7">
<property name="visible">True</property>
<property name="right_padding">5</property>
<child>
<widget class="GtkLabel" id="label4">
<property name="visible">True</property>
<property name="xalign">0</property>
<property name="label" translatable="yes">&lt;b&gt;Share Ratio:&lt;/b&gt;</property>
<property name="use_markup">True</property>
</widget>
</child>
</widget>
<packing>
<property name="top_attach">3</property>
<property name="bottom_attach">4</property>
</packing>
</child>
<child>
<widget class="GtkAlignment" id="alignment8">
<property name="visible">True</property>
<property name="left_padding">15</property>
<property name="right_padding">5</property>
<child>
<widget class="GtkLabel" id="label5">
<property name="visible">True</property>
<property name="xalign">0</property>
<property name="label" translatable="yes">&lt;b&gt;Speed:&lt;/b&gt;</property>
<property name="use_markup">True</property>
</widget>
</child>
</widget>
<packing>
<property name="left_attach">2</property>
<property name="right_attach">3</property>
</packing>
</child>
<child>
<widget class="GtkAlignment" id="alignment9">
<property name="visible">True</property>
<property name="left_padding">15</property>
<property name="right_padding">5</property>
<child>
<widget class="GtkLabel" id="label6">
<property name="visible">True</property>
<property name="xalign">0</property>
<property name="label" translatable="yes">&lt;b&gt;Speed:&lt;/b&gt;</property>
<property name="use_markup">True</property>
</widget>
</child>
</widget>
<packing>
<property name="left_attach">2</property>
<property name="right_attach">3</property>
<property name="top_attach">1</property>
<property name="bottom_attach">2</property>
</packing>
</child>
<child>
<widget class="GtkAlignment" id="alignment10">
<property name="visible">True</property>
<property name="left_padding">15</property>
<property name="right_padding">5</property>
<child>
<widget class="GtkLabel" id="label7">
<property name="visible">True</property>
<property name="xalign">0</property>
<property name="label" translatable="yes">&lt;b&gt;Peers:&lt;/b&gt;</property>
<property name="use_markup">True</property>
</widget>
</child>
</widget>
<packing>
<property name="left_attach">2</property>
<property name="right_attach">3</property>
<property name="top_attach">2</property>
<property name="bottom_attach">3</property>
</packing>
</child>
<child>
<widget class="GtkAlignment" id="alignment11">
<property name="visible">True</property>
<property name="left_padding">15</property>
<property name="right_padding">5</property>
<child>
<widget class="GtkLabel" id="label8">
<property name="visible">True</property>
<property name="xalign">0</property>
<property name="label" translatable="yes">&lt;b&gt;ETA:&lt;/b&gt;</property>
<property name="use_markup">True</property>
</widget>
</child>
</widget>
<packing>
<property name="left_attach">2</property>
<property name="right_attach">3</property>
<property name="top_attach">3</property>
<property name="bottom_attach">4</property>
</packing>
</child>
<child>
<widget class="GtkLabel" id="label12">
<property name="visible">True</property>
<property name="xalign">0</property>
<property name="ypad">1</property>
<property name="label" translatable="yes">&lt;b&gt;Pieces:&lt;/b&gt;</property>
<property name="use_markup">True</property>
</widget>
<packing>
<property name="top_attach">4</property>
<property name="bottom_attach">5</property>
</packing>
</child>
<child>
<widget class="GtkAlignment" id="alignment16">
<property name="visible">True</property>
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
<property name="right_padding">5</property>
<child>
<widget class="GtkLabel" id="summary_pieces">
<property name="visible">True</property>
<property name="xalign">0</property>
</widget>
</child>
</widget>
<packing>
<property name="left_attach">1</property>
<property name="right_attach">2</property>
<property name="top_attach">4</property>
<property name="bottom_attach">5</property>
<property name="y_options"></property>
</packing>
</child>
<child>
@ -399,24 +158,283 @@
</packing>
</child>
<child>
<widget class="GtkLabel" id="summary_availability">
<widget class="GtkAlignment" id="alignment16">
<property name="visible">True</property>
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
<property name="right_padding">5</property>
<child>
<widget class="GtkLabel" id="summary_pieces">
<property name="visible">True</property>
<property name="xalign">0</property>
</widget>
</child>
</widget>
<packing>
<property name="left_attach">1</property>
<property name="right_attach">2</property>
<property name="top_attach">4</property>
<property name="bottom_attach">5</property>
</packing>
</child>
<child>
<widget class="GtkLabel" id="label12">
<property name="visible">True</property>
<property name="xalign">0</property>
<property name="ypad">1</property>
<property name="label" translatable="yes">&lt;b&gt;Pieces:&lt;/b&gt;</property>
<property name="use_markup">True</property>
</widget>
<packing>
<property name="top_attach">4</property>
<property name="bottom_attach">5</property>
</packing>
</child>
<child>
<widget class="GtkAlignment" id="alignment11">
<property name="visible">True</property>
<property name="left_padding">15</property>
<property name="right_padding">5</property>
<child>
<widget class="GtkLabel" id="label8">
<property name="visible">True</property>
<property name="xalign">0</property>
<property name="label" translatable="yes">&lt;b&gt;ETA:&lt;/b&gt;</property>
<property name="use_markup">True</property>
</widget>
</child>
</widget>
<packing>
<property name="left_attach">2</property>
<property name="right_attach">3</property>
<property name="top_attach">3</property>
<property name="bottom_attach">4</property>
</packing>
</child>
<child>
<widget class="GtkAlignment" id="alignment10">
<property name="visible">True</property>
<property name="left_padding">15</property>
<property name="right_padding">5</property>
<child>
<widget class="GtkLabel" id="label7">
<property name="visible">True</property>
<property name="xalign">0</property>
<property name="label" translatable="yes">&lt;b&gt;Peers:&lt;/b&gt;</property>
<property name="use_markup">True</property>
</widget>
</child>
</widget>
<packing>
<property name="left_attach">2</property>
<property name="right_attach">3</property>
<property name="top_attach">2</property>
<property name="bottom_attach">3</property>
</packing>
</child>
<child>
<widget class="GtkAlignment" id="alignment9">
<property name="visible">True</property>
<property name="left_padding">15</property>
<property name="right_padding">5</property>
<child>
<widget class="GtkLabel" id="label6">
<property name="visible">True</property>
<property name="xalign">0</property>
<property name="label" translatable="yes">&lt;b&gt;Speed:&lt;/b&gt;</property>
<property name="use_markup">True</property>
</widget>
</child>
</widget>
<packing>
<property name="left_attach">2</property>
<property name="right_attach">3</property>
<property name="top_attach">1</property>
<property name="bottom_attach">2</property>
</packing>
</child>
<child>
<widget class="GtkAlignment" id="alignment8">
<property name="visible">True</property>
<property name="left_padding">15</property>
<property name="right_padding">5</property>
<child>
<widget class="GtkLabel" id="label5">
<property name="visible">True</property>
<property name="xalign">0</property>
<property name="label" translatable="yes">&lt;b&gt;Speed:&lt;/b&gt;</property>
<property name="use_markup">True</property>
</widget>
</child>
</widget>
<packing>
<property name="left_attach">2</property>
<property name="right_attach">3</property>
</packing>
</child>
<child>
<widget class="GtkAlignment" id="alignment7">
<property name="visible">True</property>
<property name="right_padding">5</property>
<child>
<widget class="GtkLabel" id="label4">
<property name="visible">True</property>
<property name="xalign">0</property>
<property name="label" translatable="yes">&lt;b&gt;Share Ratio:&lt;/b&gt;</property>
<property name="use_markup">True</property>
</widget>
</child>
</widget>
<packing>
<property name="top_attach">3</property>
<property name="bottom_attach">4</property>
</packing>
</child>
<child>
<widget class="GtkAlignment" id="alignment6">
<property name="visible">True</property>
<property name="right_padding">5</property>
<child>
<widget class="GtkLabel" id="label3">
<property name="visible">True</property>
<property name="xalign">0</property>
<property name="label" translatable="yes">&lt;b&gt;Seeders:&lt;/b&gt;</property>
<property name="use_markup">True</property>
</widget>
</child>
</widget>
<packing>
<property name="top_attach">2</property>
<property name="bottom_attach">3</property>
</packing>
</child>
<child>
<widget class="GtkAlignment" id="alignment4">
<property name="visible">True</property>
<property name="right_padding">5</property>
<child>
<widget class="GtkLabel" id="label2">
<property name="visible">True</property>
<property name="xalign">0</property>
<property name="label" translatable="yes">&lt;b&gt;Uploaded:&lt;/b&gt;</property>
<property name="use_markup">True</property>
</widget>
</child>
</widget>
<packing>
<property name="top_attach">1</property>
<property name="bottom_attach">2</property>
</packing>
</child>
<child>
<widget class="GtkAlignment" id="alignment3">
<property name="visible">True</property>
<property name="right_padding">5</property>
<child>
<widget class="GtkLabel" id="label1">
<property name="visible">True</property>
<property name="xalign">0</property>
<property name="label" translatable="yes">&lt;b&gt;Downloaded:&lt;/b&gt;</property>
<property name="use_markup">True</property>
</widget>
</child>
</widget>
</child>
<child>
<widget class="GtkLabel" id="summary_eta">
<property name="visible">True</property>
<property name="xalign">0</property>
<property name="wrap">True</property>
<property name="wrap_mode">PANGO_WRAP_WORD_CHAR</property>
</widget>
<packing>
<property name="left_attach">3</property>
<property name="right_attach">4</property>
<property name="top_attach">4</property>
<property name="bottom_attach">5</property>
<property name="y_options"></property>
<property name="top_attach">3</property>
<property name="bottom_attach">4</property>
</packing>
</child>
<child>
<widget class="GtkLabel" id="summary_share_ratio">
<property name="visible">True</property>
<property name="xalign">0</property>
</widget>
<packing>
<property name="left_attach">1</property>
<property name="right_attach">2</property>
<property name="top_attach">3</property>
<property name="bottom_attach">4</property>
</packing>
</child>
<child>
<widget class="GtkLabel" id="summary_peers">
<property name="visible">True</property>
<property name="xalign">0</property>
</widget>
<packing>
<property name="left_attach">3</property>
<property name="right_attach">4</property>
<property name="top_attach">2</property>
<property name="bottom_attach">3</property>
</packing>
</child>
<child>
<widget class="GtkLabel" id="summary_seeders">
<property name="visible">True</property>
<property name="xalign">0</property>
</widget>
<packing>
<property name="left_attach">1</property>
<property name="right_attach">2</property>
<property name="top_attach">2</property>
<property name="bottom_attach">3</property>
</packing>
</child>
<child>
<widget class="GtkLabel" id="summary_upload_speed">
<property name="visible">True</property>
<property name="xalign">0</property>
</widget>
<packing>
<property name="left_attach">3</property>
<property name="right_attach">4</property>
<property name="top_attach">1</property>
<property name="bottom_attach">2</property>
</packing>
</child>
<child>
<widget class="GtkLabel" id="summary_total_uploaded">
<property name="visible">True</property>
<property name="xalign">0</property>
</widget>
<packing>
<property name="left_attach">1</property>
<property name="right_attach">2</property>
<property name="top_attach">1</property>
<property name="bottom_attach">2</property>
</packing>
</child>
<child>
<widget class="GtkLabel" id="summary_download_speed">
<property name="visible">True</property>
<property name="xalign">0</property>
</widget>
<packing>
<property name="left_attach">3</property>
<property name="right_attach">4</property>
</packing>
</child>
<child>
<widget class="GtkLabel" id="summary_total_downloaded">
<property name="visible">True</property>
<property name="xalign">0</property>
</widget>
<packing>
<property name="left_attach">1</property>
<property name="right_attach">2</property>
</packing>
</child>
</widget>
<packing>
<property name="expand">False</property>
<property name="position">1</property>
<property name="position">2</property>
</packing>
</child>
</widget>
@ -444,7 +462,6 @@
<widget class="GtkFrame" id="frame2">
<property name="visible">True</property>
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
<property name="label_xalign">0</property>
<child>
<widget class="GtkAlignment" id="alignment12">
<property name="visible">True</property>
@ -740,7 +757,6 @@
</child>
</widget>
<packing>
<property name="tab_expand">False</property>
<property name="reorderable">True</property>
</packing>
</child>
@ -751,7 +767,6 @@
</widget>
<packing>
<property name="type">tab</property>
<property name="tab_expand">False</property>
<property name="tab_fill">False</property>
</packing>
</child>
@ -1104,34 +1119,6 @@
<property name="y_options"></property>
</packing>
</child>
<child>
<widget class="GtkToolbar" id="tb_right">
<property name="visible">True</property>
<property name="show_arrow">False</property>
</widget>
<packing>
<property name="left_attach">2</property>
<property name="right_attach">3</property>
<property name="top_attach">1</property>
<property name="bottom_attach">2</property>
<property name="x_options"></property>
<property name="y_options">GTK_FILL</property>
</packing>
</child>
<child>
<widget class="GtkToolbar" id="tb_middle">
<property name="visible">True</property>
<property name="show_arrow">False</property>
</widget>
<packing>
<property name="left_attach">1</property>
<property name="right_attach">2</property>
<property name="top_attach">1</property>
<property name="bottom_attach">2</property>
<property name="x_options">GTK_FILL</property>
<property name="y_options">GTK_FILL</property>
</packing>
</child>
<child>
<widget class="GtkToolbar" id="tb_left">
<property name="visible">True</property>
@ -1285,5 +1272,3 @@
</child>
</widget>
</glade-interface>

View file

@ -2603,6 +2603,7 @@ Thunar</property>
</child>
<child>
<widget class="GtkFrame" id="frame3">
<property name="visible">True</property>
<property name="shadow_type">GTK_SHADOW_NONE</property>
<child>
<widget class="GtkAlignment" id="alignment3">
@ -2612,7 +2613,6 @@ Thunar</property>
<property name="left_padding">12</property>
<child>
<widget class="GtkHBox" id="hbox16">
<property name="visible">True</property>
<property name="spacing">15</property>
<child>
<widget class="GtkLabel" id="label28">
@ -2661,6 +2661,46 @@ Thunar</property>
<property name="position">2</property>
</packing>
</child>
<child>
<widget class="GtkFrame" id="frame21">
<property name="visible">True</property>
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
<property name="shadow_type">GTK_SHADOW_NONE</property>
<child>
<widget class="GtkAlignment" id="alignment38">
<property name="visible">True</property>
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
<property name="left_padding">12</property>
<child>
<widget class="GtkCheckButton" id="chk_use_advanced_bar">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
<property name="label" translatable="yes">Use the advanced progress bar (uses slightly more CPU/RAM)</property>
<property name="response_id">0</property>
<property name="draw_indicator">True</property>
</widget>
</child>
</widget>
</child>
<child>
<widget class="GtkLabel" id="label41">
<property name="visible">True</property>
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
<property name="label" translatable="yes">&lt;b&gt;Detailed Progress Bar&lt;/b&gt;</property>
<property name="use_markup">True</property>
</widget>
<packing>
<property name="type">label_item</property>
</packing>
</child>
</widget>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="position">3</property>
</packing>
</child>
<child>
<widget class="GtkFrame" id="frame4">
<property name="visible">True</property>
@ -2709,7 +2749,7 @@ Thunar</property>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="position">3</property>
<property name="position">4</property>
</packing>
</child>
<child>
@ -2751,7 +2791,7 @@ information is sent.</property>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="position">4</property>
<property name="position">5</property>
</packing>
</child>
</widget>

View file

@ -929,8 +929,33 @@ static PyObject *torrent_get_torrent_state(PyObject *self, PyObject *args)
total_seeds = s.num_complete != -1? s.num_complete : connected_seeds;
total_peers = s.num_incomplete != -1? s.num_incomplete : connected_peers;
// The following section computes the ranges of pieces that have been downloaded
std::vector<int> downloaded_range;
bool range_opened=false;
for (unsigned int i=0; i<=s.pieces->size(); ++i) {
bool downloaded=(i<s.pieces->size() && s.pieces->at(i));
if (!range_opened) {
if (downloaded) {
range_opened=true;
downloaded_range.push_back(i);
}
} else {
if (!downloaded) {
range_opened=false;
downloaded_range.push_back(i-1);
}
}
}
PyObject *pieces_range = PyTuple_New(downloaded_range.size()/2);
for(unsigned long i=0; i<downloaded_range.size(); i+=2)
{
PyObject *rangepos;
rangepos = Py_BuildValue("[i,i]",downloaded_range[i],
downloaded_range[i+1]);
PyTuple_SetItem(pieces_range, i/2, rangepos);
}
return Py_BuildValue("{s:s,s:i,s:i,s:l,s:l,s:f,s:f,s:b,s:f,s:L,s:L,s:s,s:s,s:f,s:L,s:L,s:l,s:i,s:i,s:L,s:L,s:i,s:l,s:l,s:b,s:b,s:L,s:L,s:L}",
return Py_BuildValue("{s:s,s:i,s:i,s:l,s:l,s:f,s:f,s:b,s:f,s:L,s:L,s:s,s:s,s:f,s:L,s:L,s:O,s:i,s:i,s:L,s:L,s:i,s:l,s:l,s:b,s:b,s:L,s:L,s:L}",
"name", t.handle.get_torrent_info().name().c_str(),
"num_files", t.handle.get_torrent_info().num_files(),
"state", s.state,
@ -947,7 +972,7 @@ static PyObject *torrent_get_torrent_state(PyObject *self, PyObject *args)
"progress", s.progress,
"total_payload_download", s.total_payload_download,
"total_payload_upload", s.total_payload_upload,
"pieces", long(s.pieces), // this is really a std::vector<bool>*
"pieces", pieces_range,
"pieces_done", s.num_pieces,
"block_size", s.block_size,
"total_size", i.total_size(),

View file

@ -154,6 +154,7 @@ class PreferencesDlg:
self.glade.get_widget("ratio_spinner").set_value(self.preferences.get("auto_seed_ratio"))
self.glade.get_widget("chk_dht").set_active(self.preferences.get("enable_dht"))
self.glade.get_widget("spin_gui").set_value(self.preferences.get("gui_update_interval"))
self.glade.get_widget("chk_use_advanced_bar").set_active(self.preferences.get("use_advanced_bar"))
#smart dialog set sensitivities
if(self.preferences.get("use_default_dir")):
@ -269,6 +270,7 @@ class PreferencesDlg:
self.preferences.set("queue_seeds_to_bottom", self.glade.get_widget("chk_seedbottom").get_active())
self.preferences.set("enable_dht", self.glade.get_widget("chk_dht").get_active())
self.preferences.set("gui_update_interval", self.glade.get_widget("spin_gui").get_value())
self.preferences.set("use_advanced_bar", self.glade.get_widget("chk_use_advanced_bar").get_active())
self.preferences.set("clear_max_ratio_torrents", self.glade.get_widget("chk_clear_max_ratio_torrents").get_active())
self.preferences.set("queue_above_completed", self.glade.get_widget("chk_queue_above_completed").get_active())

View file

@ -1001,7 +1001,7 @@ window, please enter your password"))
# Call update now so everything is up-to-date when the window gains
# focus on startup
self.update()
gobject.timeout_add(1000, self.update)
gobject.timeout_add(int(1000*self.manager.config.get("gui_update_interval")+0.5), self.update)
# Load plugins after we showed main window (if not started in tray)
self.load_plugins()

View file

@ -147,7 +147,8 @@ if common.windows_check():
"status_width" : 150,
"filename_f_width" : 220,
"size_f_width" : 90,
"priority_f_width" : 140
"priority_f_width" : 140,
"use_advanced_bar" : False
}
else:
DEFAULT_PREFS = {
@ -257,7 +258,8 @@ else:
"status_width" : 150,
"filename_f_width" : 220,
"size_f_width" : 90,
"priority_f_width" : 140
"priority_f_width" : 140,
"use_advanced_bar" : False
}
class Preferences:
@ -273,6 +275,7 @@ class Preferences:
self.config_file = filename
if self.config_file is not None:
self.load(self.config_file)
self.change_hooks=[]
# Allows you to access an item in a Preferences objecy by calling
# instance[key] rather than instance.get(key). However, this will
@ -280,10 +283,16 @@ class Preferences:
# advisable to use get() if you need the value converted.
def __getitem__(self, key):
return self.mapping[key]
def onValueChanged(self,value,method):
self.change_hooks.append([value,method])
def __setitem__(self, key, value):
self.mapping[key] = value
if key not in self.mapping or self.mapping[key]!=value:
self.mapping[key] = value
for hook in self.change_hooks:
if (hook[0]==key): hook[1]()
def __delitem__(self, key):
del self.mapping[key]
@ -320,8 +329,8 @@ class Preferences:
pass
def set(self, key, value):
self.mapping[key] = value
self[key] = value
def get(self, key):
try:
value = self.mapping[key]

View file

@ -31,6 +31,7 @@
# statement from all source files in the program, then also delete it here.
import common
import gtk
class DetailsTabManager(object):
def __init__(self, glade, manager):
@ -40,6 +41,8 @@ class DetailsTabManager(object):
# Look into glade's widget prefix function
self.progress_bar = glade.get_widget("progressbar")
self.custom_progress = glade.get_widget("custom_progress")
self.custom_progress.connect("expose_event",self.paint_customprogress)
self.name = glade.get_widget("summary_name")
self.total_size = glade.get_widget("summary_total_size")
self.num_files = glade.get_widget("summary_num_files")
@ -58,7 +61,62 @@ class DetailsTabManager(object):
self.next_announce = glade.get_widget("summary_next_announce")
self.eta = glade.get_widget("summary_eta")
self.torrent_path = glade.get_widget("summary_torrent_path")
self.advanced_progressbar=glade.get_widget("advanced_progressbar")
self.last_state=None
self.prefchanged_progress()
self.manager.config.onValueChanged('use_advanced_bar',self.prefchanged_progress)
def prefchanged_progress(self):
self.use_advanced_bar=self.manager.config.get("use_advanced_bar")
if self.use_advanced_bar:
self.progress_bar.hide()
self.advanced_progressbar.show()
else:
self.progress_bar.show()
self.advanced_progressbar.hide()
# arg1 and arg2 are additional data which we do not need. Most probably
# arg1=widghet, and arg2=event specific data
# If anybody knows of documentation which includes the expose_event
# in PyGtk would be glad to see it. - hirak99
def paint_customprogress(self,arg1=None,arg2=None):
# Draw the custom progress bar
progress_window=self.custom_progress.window
colormap=self.custom_progress.get_colormap()
gc=progress_window.new_gc()
size=progress_window.get_size()
progress_window.begin_paint_rect(gtk.gdk.Rectangle(0,0,size[0],size[1]))
height=size[1]
if height>25: height=25
top=(size[1]-height)/2
gc.set_foreground(colormap.alloc_color('#F0F0FF'))
progress_window.draw_rectangle(gc,True,0,top,size[0],height-1)
gc.set_foreground(colormap.alloc_color('#A0A0AF'))
progress_window.draw_line(gc,0,top+4,size[0],top+4)
state=self.last_state
if state!=None:
gc.set_foreground(colormap.alloc_color('#2020FF'))
progress_window.draw_rectangle(gc,True,0,top,int(size[0]*float(state['progress'])),4)
num_pieces=state["num_pieces"]
for pieces_range in state['pieces']:
range_first=pieces_range[0]*size[0]/num_pieces
range_length=((pieces_range[1]-pieces_range[0]+1)*size[0]/num_pieces)
if range_length==0:
range_length=1
gc.set_foreground(colormap.alloc_color('#8080FF'))
else:
gc.set_foreground(colormap.alloc_color('#2020FF'))
progress_window.draw_rectangle(gc,True,range_first,top+5,range_length,height-5)
gc.set_foreground(colormap.alloc_color('dim gray'))
progress_window.draw_line(gc,0,top,0,top+height)
progress_window.draw_line(gc,0,top,size[0],top)
gc.set_foreground(colormap.alloc_color('white'))
progress_window.draw_line(gc,0,top+height,size[0]-1,top+height)
progress_window.draw_line(gc,size[0]-1,top,size[0]-1,top+height)
progress_window.end_paint()
# Done drawing custom progress bar
def update(self, unique_id):
state = self.manager.get_torrent_state(unique_id)
@ -108,10 +166,18 @@ class DetailsTabManager(object):
self.upload_speed.set_text(common.fspeed(state["upload_rate"]))
self.seeders.set_text(common.fseed(state))
self.peers.set_text(common.fpeer(state))
self.progress_bar.set_fraction(float(state['progress']))
self.progress_bar.set_text(common.fpcnt(state["progress"]))
# self.progress_bar.set_fraction(float(state['progress']))
# self.progress_bar.set_text(common.fpcnt(state["progress"]))
self.last_state=state
if self.use_advanced_bar:
self.paint_customprogress()
else:
self.progress_bar.set_fraction(float(state['progress']))
self.progress_bar.set_text(common.fpcnt(state["progress"]))
self.eta.set_text(common.estimate_eta(state))
self.share_ratio.set_text( '%.3f' % self.manager.calc_ratio(unique_id,
self.share_ratio.set_text('%.3f' % self.manager.calc_ratio(unique_id,
state))
self.torrent_path.set_text(self.manager.get_torrent_path(unique_id))