Commit 12f7b393 authored by Guillaume Duranceau's avatar Guillaume Duranceau Committed by Sebastian Ramacher

new window-title-page option

When set to 'true', this option displays the page number in the title of
a zathura window.
parent 03ea66c6
......@@ -217,6 +217,8 @@ config_load_default(zathura_t* zathura)
bool_value = false;
girara_setting_add(gsession, "window-title-basename", &bool_value, BOOLEAN, false, _("Use basename of the file in the window title"), NULL, NULL);
bool_value = false;
girara_setting_add(gsession, "window-title-page", &bool_value, BOOLEAN, false, _("Display the page number in the window title"), NULL, NULL);
bool_value = false;
girara_setting_add(gsession, "statusbar-basename", &bool_value, BOOLEAN, false, _("Use basename of the file in the statusbar"), NULL, NULL);
bool_value = false;
girara_setting_add(gsession, "synctex", &bool_value, BOOLEAN, false, _("Enable synctex support"), NULL, NULL);
......
......@@ -41,6 +41,7 @@ static const gchar* guess_type(const char* path);
*/
struct zathura_document_s {
char* file_path; /**< File path of the document */
char* basename; /**< Basename of the document */
const char* password; /**< Password of the document */
unsigned int current_page_number; /**< Current page number */
unsigned int number_of_pages; /**< Number of pages */
......@@ -118,6 +119,7 @@ zathura_document_open(zathura_plugin_manager_t* plugin_manager, const char*
document = g_malloc0(sizeof(zathura_document_t));
document->file_path = real_path;
document->basename = g_path_get_basename(real_path);
document->password = password;
document->scale = 1.0;
document->plugin = plugin;
......@@ -200,6 +202,7 @@ zathura_document_free(zathura_document_t* document)
if (document->file_path != NULL) {
free(document->file_path);
}
g_free(document->basename);
g_free(document);
......@@ -216,6 +219,16 @@ zathura_document_get_path(zathura_document_t* document)
return document->file_path;
}
const char*
zathura_document_get_basename(zathura_document_t* document)
{
if (document == NULL) {
return NULL;
}
return document->basename;
}
const char*
zathura_document_get_password(zathura_document_t* document)
{
......
......@@ -38,6 +38,14 @@ zathura_error_t zathura_document_free(zathura_document_t* document);
*/
const char* zathura_document_get_path(zathura_document_t* document);
/**
* Returns the basename of the document
*
* @param document The document
* @return The basename of the document
*/
const char* zathura_document_get_basename(zathura_document_t* document);
/**
* Returns the password of the document
*
......
......@@ -665,9 +665,7 @@ document_open(zathura_t* zathura, const char* path, const char* password,
if (basename_only == false) {
girara_statusbar_item_set_text(zathura->ui.session, zathura->ui.statusbar.file, file_path);
} else {
char* tmp = g_path_get_basename(file_path);
girara_statusbar_item_set_text(zathura->ui.session, zathura->ui.statusbar.file, tmp);
g_free(tmp);
girara_statusbar_item_set_text(zathura->ui.session, zathura->ui.statusbar.file, zathura_document_get_basename(document));
}
/* install file monitor */
......@@ -787,9 +785,7 @@ document_open(zathura_t* zathura, const char* path, const char* password,
if (basename_only == false) {
girara_set_window_title(zathura->ui.session, file_path);
} else {
char* tmp = g_path_get_basename(file_path);
girara_set_window_title(zathura->ui.session, tmp);
g_free(tmp);
girara_set_window_title(zathura->ui.session, zathura_document_get_basename(document));
}
g_free(file_uri);
......@@ -1061,6 +1057,22 @@ statusbar_page_number_update(zathura_t* zathura)
if (zathura->document != NULL) {
char* 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);
bool page_number_in_window_title = false;
girara_setting_get(zathura->ui.session, "window-title-page", &page_number_in_window_title);
if (page_number_in_window_title == true) {
bool basename_only = false;
girara_setting_get(zathura->ui.session, "window-title-basename", &basename_only);
char* title = g_strdup_printf("%s %s",
(basename_only == true)
? zathura_document_get_basename(zathura->document)
: zathura_document_get_path(zathura->document),
page_number_text);
girara_set_window_title(zathura->ui.session, title);
g_free(title);
}
g_free(page_number_text);
} else {
girara_statusbar_item_set_text(zathura->ui.session, zathura->ui.statusbar.page_number, "");
......
......@@ -370,6 +370,15 @@ Defines the font that will be used
* Value type: String
* Default value: monospace normal 9
guioptions
^^^^^^^^^^
Shows or hides GUI elements.
When it contains 'c', the command line is showed.
When it contains 's', the statusbar is showed.
* Value type: String
* Default value: s
inputbar-bg
^^^^^^^^^^^
Defines the background color for the inputbar
......@@ -698,6 +707,13 @@ Use basename of the file in the window title.
* Value type: Boolean
* Default value: false
window-title-page
^^^^^^^^^^^^^^^^^
Display the page number in the window title.
* Value type: Boolean
* Default value: false
statusbar-basename
^^^^^^^^^^^^^^^^^^
Use basename of the file in the statusbar.
......
Markdown is supported
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