MCPcopy Create free account
hub / github.com/BernardoGiordano/Checkpoint / section_progress

Function section_progress

scripts/examples/example.c:313–353  ·  view source on GitHub ↗

Progress calls never block and never wait for a frame, so a copy loop can * report every single chunk. Bars nest: layer 0 is the outermost, up to 3 * layers. progress_begin(layer, ...) resets that layer and discards every * deeper one, so starting the next outer item cannot leave a stale inner bar * behind. A total <= 0 renders as an indeterminate bar showing a raw count. */

Source from the content-addressed store, hash-verified

311 * deeper one, so starting the next outer item cannot leave a stale inner bar
312 * behind. A total <= 0 renders as an indeterminate bar showing a raw count. */
313void section_progress(void)
314{
315 char label[LINEN];
316 int outer;
317 int inner;
318
319 gui_status("Progress demo");
320
321 progress_begin(0, "Overall", 3);
322 for (outer = 0; outer < 3; outer++) {
323 sprintf(label, "Item %d of 3", outer + 1);
324 progress_label(0, label);
325
326 progress_begin(1, "Steps", 4);
327 for (inner = 0; inner < 4; inner++) {
328 /* progress_note drives the innermost row: the stage you are in
329 * right now. Long native calls (zip_dir, unzip, web_upload_file)
330 * take that row over themselves while they run. */
331 sprintf(label, "step %d", inner + 1);
332 progress_note(label);
333 usleep(200000);
334 progress_set(1, inner + 1);
335 }
336 progress_end(1);
337
338 progress_set(0, outer + 1);
339 }
340
341 /* An unknown total: indeterminate bar, raw count. */
342 progress_begin(0, "Unknown length", 0);
343 for (outer = 0; outer < 20; outer++) {
344 progress_set(0, outer + 1);
345 usleep(50000);
346 }
347 progress_end(0);
348
349 /* progress_clear tears every layer down at once — the right thing to do
350 * before a dialog, or on an error path. */
351 progress_clear();
352 gui_message("Progress demo finished.");
353}
354
355/* ------------------------------------------------------------------------- */
356/* 5. SD card: paths, directories and plain stdio */

Callers 1

mainFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected