Commit 057c7f82 authored by Alexander Larsson's avatar Alexander Larsson Committed by Alexander Larsson

Make progress setting be ratio based and not percent based and then ensure

2008-02-11  Alexander Larsson  <alexl@redhat.com>

        * libnautilus-private/nautilus-progress-info.[ch]:
        * libnautilus-private/nautilus-file-operations.c:
	Make progress setting be ratio based and not
	percent based and then ensure we handle division
	by zero correctly in all cases.



svn path=/trunk/; revision=13725
parent 0082cd73
2008-02-11 Alexander Larsson <alexl@redhat.com>
* libnautilus-private/nautilus-progress-info.[ch]:
* libnautilus-private/nautilus-file-operations.c:
Make progress setting be ratio based and not
percent based and then ensure we handle division
by zero correctly in all cases.
2008-02-11 Alexander Larsson <alexl@redhat.com>
* libnautilus-private/nautilus-file-operations.c:
......
......@@ -1209,7 +1209,7 @@ report_delete_progress (CommonJob *job,
}
if (source_info->num_files != 0) {
nautilus_progress_info_set_progress (job->progress, (double)transfer_info->num_files / source_info->num_files);
nautilus_progress_info_set_progress (job->progress, transfer_info->num_files, source_info->num_files);
}
}
......@@ -1501,7 +1501,7 @@ report_trash_progress (CommonJob *job,
nautilus_progress_info_take_details (job->progress, s);
if (total_files != 0) {
nautilus_progress_info_set_progress (job->progress, (double)files_trashed / total_files);
nautilus_progress_info_set_progress (job->progress, files_trashed, total_files);
}
}
......@@ -2591,7 +2591,7 @@ report_copy_progress (CopyMoveJob *copy_job,
nautilus_progress_info_take_details (job->progress, s);
}
nautilus_progress_info_set_progress (job->progress, (double)transfer_info->num_bytes / total_size);
nautilus_progress_info_set_progress (job->progress, transfer_info->num_bytes, total_size);
}
static GFile *
......@@ -4109,7 +4109,7 @@ report_link_progress (CopyMoveJob *link_job, int total, int left)
"Making links to %'d files",
left), left));
nautilus_progress_info_set_progress (job->progress, (double)left / total);
nautilus_progress_info_set_progress (job->progress, left, total);
}
......
......@@ -784,18 +784,27 @@ nautilus_progress_info_pulse_progress (NautilusProgressInfo *info)
void
nautilus_progress_info_set_progress (NautilusProgressInfo *info,
double current_percent)
double current,
double total)
{
G_LOCK (progress_info);
double current_percent;
if (total <= 0) {
current_percent = 1.0;
} else {
current_percent = current / total;
if (current_percent < 0) {
current_percent = 0;
}
if (current_percent < 0) {
current_percent = 0;
}
if (current_percent > 1.0) {
current_percent = 1.0;
if (current_percent > 1.0) {
current_percent = 1.0;
}
}
G_LOCK (progress_info);
if (info->activity_mode || /* emit on switch from activity mode */
fabs (current_percent - info->progress) > 0.005 /* Emit on change of 0.5 percent */
) {
......
......@@ -73,7 +73,8 @@ void nautilus_progress_info_set_details (NautilusProgressInfo *info
void nautilus_progress_info_take_details (NautilusProgressInfo *info,
char *details);
void nautilus_progress_info_set_progress (NautilusProgressInfo *info,
double current_percent);
double current,
double total);
void nautilus_progress_info_pulse_progress (NautilusProgressInfo *info);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment