Verified Commit 1222a2a9 authored by Thomas Faughnan's avatar Thomas Faughnan
Browse files

Add option to display page number percent in statusbar

parent 660b2a24
......@@ -856,6 +856,12 @@ zathura
* Value type: Boolean
* Default value: false
*statusbar-page-percent*
Display (current page / total pages) as a percent in the statusbar.
* Value type: Boolean
* Default value: false
*statusbar-home-tilde*
Display a short version of the file path, which replaces $HOME with ~, in the statusbar.
......
......@@ -283,6 +283,8 @@ config_load_default(zathura_t* zathura)
girara_setting_add(gsession, "statusbar-basename", &bool_value, BOOLEAN, false, _("Use basename of the file in the statusbar"), cb_window_statbusbar_changed, NULL);
bool_value = false;
girara_setting_add(gsession, "statusbar-home-tilde", &bool_value, BOOLEAN, false, _("Use ~ instead of $HOME in the filename in the statusbar"), cb_window_statbusbar_changed, NULL);
bool_value = false;
girara_setting_add(gsession, "statusbar-page-percent", &bool_value, BOOLEAN, false, _("Display (current page / total pages) as a percent in the statusbar"), cb_window_statbusbar_changed, NULL);
bool_value = true;
girara_setting_add(gsession, "synctex", &bool_value, BOOLEAN, false, _("Enable synctex support"), NULL, NULL);
girara_setting_add(gsession, "synctex-editor-command", "", STRING, false, _("Synctex editor command"), NULL, NULL);
......
......@@ -1542,17 +1542,29 @@ statusbar_page_number_update(zathura_t* zathura)
unsigned int number_of_pages = zathura_document_get_number_of_pages(zathura->document);
unsigned int current_page_number = zathura_document_get_current_page_number(zathura->document);
unsigned int page_number_percent = number_of_pages ? 100 * (current_page_number + 1) / number_of_pages : 0;
if (zathura->document != NULL) {
zathura_page_t* page = zathura_document_get_page(zathura->document, current_page_number);
char* page_label = zathura_page_get_label(page, NULL);
bool show_percent = false;
girara_setting_get(zathura->ui.session, "statusbar-page-percent", &show_percent);
char* page_number_text = NULL;
if (page_label != NULL) {
page_number_text = g_strdup_printf("[%s (%d/%d)]", page_label, current_page_number + 1, number_of_pages);
if (show_percent) {
page_number_text = g_strdup_printf("[%s (%d/%d) (%d%%)]", page_label, current_page_number + 1, number_of_pages, page_number_percent);
} else {
page_number_text = g_strdup_printf("[%s (%d/%d)]", page_label, current_page_number + 1, number_of_pages);
}
g_free(page_label);
} else {
page_number_text = g_strdup_printf("[%d/%d]", current_page_number + 1, number_of_pages);
if (show_percent) {
page_number_text = g_strdup_printf("[%d/%d (%d%%)]", current_page_number + 1, number_of_pages, page_number_percent);
} else {
page_number_text = g_strdup_printf("[%d/%d]", current_page_number + 1, number_of_pages);
}
}
girara_statusbar_item_set_text(zathura->ui.session, zathura->ui.statusbar.page_number, page_number_text);
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment