Skip to content
This repository has been archived by the owner on Jul 30, 2018. It is now read-only.

Commit

Permalink
fix #37 inaccurate filesize display
Browse files Browse the repository at this point in the history
  • Loading branch information
Jigoku committed May 20, 2015
1 parent f8276a0 commit 831d6f6
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 21 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Alluvion 0.3 (master/unreleased)
# Alluvion 0.3 (20/05/2015)

* implement file_lengths / file_names for hash lookup tool
* check for newer version of Alluvion (Help> Check for updates)
Expand Down
32 changes: 16 additions & 16 deletions alluvion-gtk.pl
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@
# default user settings
my %settings = (
"timeout" => "10",
"filesize_type" => "MB",
"filesize_type" => "mb",
"magnet_exec" => "/usr/bin/xdg-open",
"proxy_enabled" => 0,
"proxy_type" => "none",
Expand Down Expand Up @@ -925,13 +925,13 @@ sub on_menu_edit_preferences_activate {
$builder->get_object( 'checkbutton_proxy' )->set_active(0);
}

if ($settings{"filesize_type"} eq "Bytes") {
if ($settings{"filesize_type"} eq "bytes") {
$builder->get_object( 'radio_bytes' )->set_active(TRUE);
} elsif ($settings{"filesize_type"} eq "KB") {
} elsif ($settings{"filesize_type"} eq "kb") {
$builder->get_object( 'radio_kb' )->set_active(TRUE);
} elsif ($settings{"filesize_type"} eq "MB") {
} elsif ($settings{"filesize_type"} eq "mb") {
$builder->get_object( 'radio_mb' )->set_active(TRUE);
} elsif ($settings{"filesize_type"} eq "GB") {
} elsif ($settings{"filesize_type"} eq "gb") {
$builder->get_object( 'radio_gb' )->set_active(TRUE);
}

Expand Down Expand Up @@ -969,10 +969,10 @@ sub on_button_pref_ok_clicked {
$settings{"api_query"} = $builder->get_object( 'entry_apiquery' )->get_text();
$settings{"api_file"} = $builder->get_object( 'entry_apifile' )->get_text();

if ($builder->get_object( 'radio_bytes' )->get_active() == TRUE ) { $settings{"filesize_type"} = "Bytes"; }
if ($builder->get_object( 'radio_kb' )->get_active() == TRUE ) { $settings{"filesize_type"} = "KB"; }
if ($builder->get_object( 'radio_mb' )->get_active() == TRUE ) { $settings{"filesize_type"} = "MB"; }
if ($builder->get_object( 'radio_gb' )->get_active() == TRUE ) { $settings{"filesize_type"} = "GB"; }
if ($builder->get_object( 'radio_bytes' )->get_active() == TRUE ) { $settings{"filesize_type"} = "bytes"; }
if ($builder->get_object( 'radio_kb' )->get_active() == TRUE ) { $settings{"filesize_type"} = "kb"; }
if ($builder->get_object( 'radio_mb' )->get_active() == TRUE ) { $settings{"filesize_type"} = "mb"; }
if ($builder->get_object( 'radio_gb' )->get_active() == TRUE ) { $settings{"filesize_type"} = "gb"; }


# check if we enabled/disabled the HTTP/HTTPS proxy option
Expand Down Expand Up @@ -1197,16 +1197,16 @@ ($)

no warnings;
given ($settings{"filesize_type"}) {
when (m/^KB/) {
return sprintf "%.2f KB",($bytes / 1024);
when (m/^kb/) {
return sprintf "%.2f kb",($bytes / 1000);
}
when (m/^MB$/) {
return sprintf "%.2f MB",($bytes / (1024 * 1024));
when (m/^mb$/) {
return sprintf "%.2f mb",($bytes / (1000 * 1000));
}
when (m/^GB$/) {
return sprintf "%.2f GB",($bytes / (1024 * 1024 * 1024));
when (m/^gb$/) {
return sprintf "%.2f gb",($bytes / (1000 * 1000 * 1000));
}
return $bytes . " Bytes";
return $bytes . " bytes";
}

}
Expand Down
8 changes: 4 additions & 4 deletions data/alluvion.glade
Original file line number Diff line number Diff line change
Expand Up @@ -1252,7 +1252,7 @@ http://github.com/jigoku/</property>
</child>
<child>
<object class="GtkRadioButton" id="radio_bytes">
<property name="label" translatable="yes">Bytes</property>
<property name="label" translatable="yes">bytes</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">False</property>
Expand All @@ -1267,7 +1267,7 @@ http://github.com/jigoku/</property>
</child>
<child>
<object class="GtkRadioButton" id="radio_kb">
<property name="label" translatable="yes">KB</property>
<property name="label" translatable="yes">kb</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">False</property>
Expand All @@ -1283,7 +1283,7 @@ http://github.com/jigoku/</property>
</child>
<child>
<object class="GtkRadioButton" id="radio_mb">
<property name="label" translatable="yes">MB</property>
<property name="label" translatable="yes">mb</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">False</property>
Expand All @@ -1299,7 +1299,7 @@ http://github.com/jigoku/</property>
</child>
<child>
<object class="GtkRadioButton" id="radio_gb">
<property name="label" translatable="yes">GB</property>
<property name="label" translatable="yes">gb</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">False</property>
Expand Down

0 comments on commit 831d6f6

Please sign in to comment.