From: Michael Tremer Date: Sun, 1 Oct 2023 11:21:57 +0000 (+0000) Subject: repo: Use the new progress implementation X-Git-Tag: 0.9.30~1582 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=7acdd169257747b7bfcba3332c7fe311d7cd0f0a;p=pakfire.git repo: Use the new progress implementation Signed-off-by: Michael Tremer --- diff --git a/src/libpakfire/repo.c b/src/libpakfire/repo.c index b670bcee9..2c89269d6 100644 --- a/src/libpakfire/repo.c +++ b/src/libpakfire/repo.c @@ -43,7 +43,7 @@ #include #include #include -#include +#include #include #include #include @@ -1344,7 +1344,7 @@ ERROR: PAKFIRE_EXPORT int pakfire_repo_scan(struct pakfire_repo* repo, int flags) { struct pakfire_filelist* filelist = NULL; - struct pakfire_progressbar* progressbar = NULL; + struct pakfire_progress* progress = NULL; int r; const char* path = pakfire_repo_get_path(repo); @@ -1368,36 +1368,27 @@ PAKFIRE_EXPORT int pakfire_repo_scan(struct pakfire_repo* repo, int flags) { // Fetch how many files have been found const size_t num_files = pakfire_filelist_length(filelist); - // Create progressbar - r = pakfire_progressbar_create(&progressbar, NULL); + // Create progress indicator + r = pakfire_progress_create(&progress, repo->pakfire, + PAKFIRE_PROGRESS_SHOW_COUNTER|PAKFIRE_PROGRESS_SHOW_ELAPSED_TIME); if (r) goto ERROR; const char* name = pakfire_repo_get_name(repo); - // Add title to progressbar - r = pakfire_progressbar_add_string(progressbar, _("Scanning %s"), name); + // Add title to progress + r = pakfire_progress_set_title(progress, _("Scanning %s"), name); if (r) goto ERROR; - // Add the bar - r = pakfire_progressbar_add_bar(progressbar); - if (r) - goto ERROR; - - // Add a counter - r = pakfire_progressbar_add_counter(progressbar); - if (r) - goto ERROR; - - // Start progress bar - r = pakfire_progressbar_start(progressbar, num_files); + // Start progress + r = pakfire_progress_start(progress, num_files); for (unsigned int i = 0; i < num_files; i++) { struct pakfire_file* file = pakfire_filelist_get(filelist, i); // Increment progress bar - pakfire_progressbar_increment(progressbar, 1); + pakfire_progress_increment(progress, 1); // Skip anything that isn't a regular file int type = pakfire_file_get_type(file); @@ -1421,8 +1412,8 @@ PAKFIRE_EXPORT int pakfire_repo_scan(struct pakfire_repo* repo, int flags) { // Mark repository data as changed pakfire_repo_has_changed(repo); - // Finish the progress bar - r = pakfire_progressbar_finish(progressbar); + // Finish the progress + r = pakfire_progress_finish(progress); if (r) goto ERROR; @@ -1430,8 +1421,8 @@ PAKFIRE_EXPORT int pakfire_repo_scan(struct pakfire_repo* repo, int flags) { r = 0; ERROR: - if (progressbar) - pakfire_progressbar_unref(progressbar); + if (progress) + pakfire_progress_unref(progress); if (filelist) pakfire_filelist_unref(filelist);