mirror of
https://git.tartarus.org/simon/putty.git
synced 2025-06-30 19:12:48 -05:00
Add linear mode to the new progress reporting system.
The old system I removed in commit 79d3c1783b
had both linear and
exponential phase types, but the new one only had exponential, because
at that point I'd just thrown away all the clients of the linear phase
type. But I'm going to add another one shortly, so I have to put it
back in.
This commit is contained in:
@ -68,6 +68,7 @@ void nonfatal(const char *fmt, ...)
|
||||
|
||||
struct progressphase {
|
||||
double startpoint, total;
|
||||
/* For exponential phases */
|
||||
double exp_probability, exp_current_value;
|
||||
};
|
||||
|
||||
@ -81,6 +82,19 @@ struct progress {
|
||||
ProgressReceiver rec;
|
||||
};
|
||||
|
||||
static ProgressPhase win_progress_add_linear(
|
||||
ProgressReceiver *prog, double overall_cost) {
|
||||
struct progress *p = container_of(prog, struct progress, rec);
|
||||
|
||||
assert(p->nphases < MAXPHASE);
|
||||
int phase = p->nphases++;
|
||||
|
||||
p->phases[phase].total = overall_cost;
|
||||
|
||||
ProgressPhase ph = { .n = phase };
|
||||
return ph;
|
||||
}
|
||||
|
||||
static ProgressPhase win_progress_add_probabilistic(
|
||||
ProgressReceiver *prog, double cost_per_attempt, double probability) {
|
||||
struct progress *p = container_of(prog, struct progress, rec);
|
||||
@ -133,6 +147,13 @@ static void win_progress_update(struct progress *p, double phasepos)
|
||||
SendMessage(p->progbar, PBM_SETPOS, (WPARAM)position, 0);
|
||||
}
|
||||
|
||||
static void win_progress_report(ProgressReceiver *prog, double progress)
|
||||
{
|
||||
struct progress *p = container_of(prog, struct progress, rec);
|
||||
|
||||
win_progress_update(p, progress);
|
||||
}
|
||||
|
||||
static void win_progress_report_attempt(ProgressReceiver *prog)
|
||||
{
|
||||
struct progress *p = container_of(prog, struct progress, rec);
|
||||
@ -149,9 +170,11 @@ static void win_progress_report_phase_complete(ProgressReceiver *prog)
|
||||
}
|
||||
|
||||
static const ProgressReceiverVtable win_progress_vt = {
|
||||
win_progress_add_linear,
|
||||
win_progress_add_probabilistic,
|
||||
win_progress_ready,
|
||||
win_progress_start_phase,
|
||||
win_progress_report,
|
||||
win_progress_report_attempt,
|
||||
win_progress_report_phase_complete,
|
||||
};
|
||||
|
Reference in New Issue
Block a user