Display current page number in statusbar

This commit is contained in:
Moritz Lipp 2011-04-27 19:57:49 +02:00
parent 1ba891658c
commit 4763624dab
3 changed files with 33 additions and 11 deletions

View file

@ -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;

View file

@ -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)
{

View file

@ -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