diff --git a/render.c b/render.c index ec7797a..81695b0 100644 --- a/render.c +++ b/render.c @@ -239,9 +239,14 @@ page_expose_event(GtkWidget* widget, GdkEventExpose* event, gpointer data) /* render real page */ render_page(page->document->zathura->sync.render_thread, page); + + /* update statusbar */ } cairo_destroy(cairo); + page->document->current_page_number = page->number; + statusbar_page_number_update(page->document->zathura); + g_static_mutex_unlock(&(page->lock)); return TRUE; diff --git a/zathura.c b/zathura.c index 430c009..76c78fd 100644 --- a/zathura.c +++ b/zathura.c @@ -318,10 +318,7 @@ page_set(zathura_t* zathura, unsigned int page_id) /* update page number */ zathura->document->current_page_number = page_id; - - char* page_number = g_strdup_printf("[%d/%d]", page_id + 1, zathura->document->number_of_pages); - girara_statusbar_item_set_text(zathura->ui.session, zathura->ui.statusbar.page_number, page_number); - g_free(page_number); + statusbar_page_number_update(zathura); return true; @@ -330,6 +327,18 @@ error_out: return false; } +void +statusbar_page_number_update(zathura_t* zathura) +{ + if (zathura == NULL || zathura->ui.statusbar.page_number == NULL) { + return; + } + + char* page_number_text = g_strdup_printf("[%d/%d]", zathura->document->current_page_number + 1, zathura->document->number_of_pages); + girara_statusbar_item_set_text(zathura->ui.session, zathura->ui.statusbar.page_number, page_number_text); + g_free(page_number_text); +} + void page_view_set_mode(zathura_t* zathura, unsigned int pages_per_row) { diff --git a/zathura.h b/zathura.h index 262ee74..2005082 100644 --- a/zathura.h +++ b/zathura.h @@ -78,21 +78,21 @@ typedef struct zathura_s * * @param argc Number of arguments * @param argv Values of arguments - * @return Zathura zathura object or NULL if zathura could not been initialized + * @return zathura session object or NULL if zathura could not been initialized */ zathura_t* zathura_init(int argc, char* argv[]); /** - * Free zathura zathura + * Free zathura session * - * @param zathura The zathura zathura + * @param zathura The zathura session */ void zathura_free(zathura_t* zathura); /** * Opens a file * - * @param zathura The zathura zathura + * @param zathura The zathura session * @param path The path to the file * @param password The password of the file * @@ -103,7 +103,7 @@ bool document_open(zathura_t* zathura, const char* path, const char* password); /** * Closes the current opened document * - * @param zathura The zathura zathura + * @param zathura The zathura session * @return If no error occured true, otherwise false, is returned. */ bool document_close(zathura_t* zathura); @@ -111,7 +111,7 @@ bool document_close(zathura_t* zathura); /** * Opens the page with the given number * - * @param zathura The zathura zathura + * @param zathura The zathura session * @return If no error occured true, otherwise false, is returned. */ bool page_set(zathura_t* zathura, unsigned int page_id); @@ -119,9 +119,17 @@ bool page_set(zathura_t* zathura, unsigned int page_id); /** * Builds the box structure to show the rendered pages * - * @param zathura The zathura zathura + * @param zathura The zathura session * @param pages_per_row Number of shown pages per row */ void page_view_set_mode(zathura_t* zathura, unsigned int pages_per_row); +/** + * Updates the page number in the statusbar. Note that 1 will be added to the + * displayed number + * + * @param zathura The zathura session + */ +void statusbar_page_number_update(zathura_t* zathura); + #endif // ZATHURA_H