Skip to content

Commit

Permalink
Show track count in library tree while add/update is in progress
Browse files Browse the repository at this point in the history
This is just to give a sense of progress now that the default status
line no longer shows the library duration. It felt a bit bloated to
print it all the time though.

(And fix typo in an existing check.)
  • Loading branch information
gavtroy authored and flyingmutant committed Sep 14, 2024
1 parent bad9b0c commit 67cbbe2
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 2 deletions.
8 changes: 7 additions & 1 deletion ui_curses.c
Original file line number Diff line number Diff line change
Expand Up @@ -965,7 +965,13 @@ static void update_window(struct window *win, int x, int y, int w, const char *t

static void update_tree_window(void)
{
update_window(lib_tree_win, tree_win_x, 0, tree_win_w + 1, "Library", print_tree);
static GBUF(buf);
gbuf_clear(&buf);

gbuf_add_str(&buf, "Library");
if (worker_has_job())
gbuf_addf(&buf, " - %d tracks", lib_editable.nr_tracks);
update_window(lib_tree_win, tree_win_x, 0, tree_win_w + 1, buf.buffer, print_tree);
}

static void update_track_window(void)
Expand Down
8 changes: 7 additions & 1 deletion worker.c
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,12 @@ void worker_remove_jobs_by_cb(worker_match_cb cb, void *opaque)
worker_unlock();
}

int worker_has_job(void)
{
/* lock not needed for this simple check */
return cur_job || !list_empty(&worker_job_head);
}

int worker_has_job_by_type(uint32_t pat)
{
return worker_has_job_by_cb(worker_matches_type, &pat);
Expand All @@ -204,7 +210,7 @@ int worker_has_job_by_cb(worker_match_cb cb, void *opaque)
break;
}
}
if (cur_job && cb(job->type, job->data, opaque))
if (cur_job && cb(cur_job->type, cur_job->data, opaque))
has_job = 1;
worker_unlock();
return has_job;
Expand Down
1 change: 1 addition & 0 deletions worker.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ void worker_add_job(uint32_t type, void (*job_cb)(void *job_data),
void worker_remove_jobs_by_type(uint32_t pat);
void worker_remove_jobs_by_cb(worker_match_cb cb, void *opaque);

int worker_has_job(void);
int worker_has_job_by_type(uint32_t pat);
int worker_has_job_by_cb(worker_match_cb cb, void *opaque);

Expand Down

0 comments on commit 67cbbe2

Please sign in to comment.