mirror of
https://git.pwmt.org/pwmt/zathura.git
synced 2024-12-29 12:15:59 +01:00
new window-title-page option
When set to 'true', this option displays the page number in the title of a zathura window.
This commit is contained in:
parent
03ea66c6ff
commit
12f7b393a6
5 changed files with 57 additions and 6 deletions
2
config.c
2
config.c
|
@ -217,6 +217,8 @@ config_load_default(zathura_t* zathura)
|
||||||
bool_value = false;
|
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);
|
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;
|
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);
|
girara_setting_add(gsession, "statusbar-basename", &bool_value, BOOLEAN, false, _("Use basename of the file in the statusbar"), NULL, NULL);
|
||||||
bool_value = false;
|
bool_value = false;
|
||||||
girara_setting_add(gsession, "synctex", &bool_value, BOOLEAN, false, _("Enable synctex support"), NULL, NULL);
|
girara_setting_add(gsession, "synctex", &bool_value, BOOLEAN, false, _("Enable synctex support"), NULL, NULL);
|
||||||
|
|
13
document.c
13
document.c
|
@ -41,6 +41,7 @@ static const gchar* guess_type(const char* path);
|
||||||
*/
|
*/
|
||||||
struct zathura_document_s {
|
struct zathura_document_s {
|
||||||
char* file_path; /**< File path of the document */
|
char* file_path; /**< File path of the document */
|
||||||
|
char* basename; /**< Basename of the document */
|
||||||
const char* password; /**< Password of the document */
|
const char* password; /**< Password of the document */
|
||||||
unsigned int current_page_number; /**< Current page number */
|
unsigned int current_page_number; /**< Current page number */
|
||||||
unsigned int number_of_pages; /**< Number of pages */
|
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 = g_malloc0(sizeof(zathura_document_t));
|
||||||
|
|
||||||
document->file_path = real_path;
|
document->file_path = real_path;
|
||||||
|
document->basename = g_path_get_basename(real_path);
|
||||||
document->password = password;
|
document->password = password;
|
||||||
document->scale = 1.0;
|
document->scale = 1.0;
|
||||||
document->plugin = plugin;
|
document->plugin = plugin;
|
||||||
|
@ -200,6 +202,7 @@ zathura_document_free(zathura_document_t* document)
|
||||||
if (document->file_path != NULL) {
|
if (document->file_path != NULL) {
|
||||||
free(document->file_path);
|
free(document->file_path);
|
||||||
}
|
}
|
||||||
|
g_free(document->basename);
|
||||||
|
|
||||||
g_free(document);
|
g_free(document);
|
||||||
|
|
||||||
|
@ -216,6 +219,16 @@ zathura_document_get_path(zathura_document_t* document)
|
||||||
return document->file_path;
|
return document->file_path;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const char*
|
||||||
|
zathura_document_get_basename(zathura_document_t* document)
|
||||||
|
{
|
||||||
|
if (document == NULL) {
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
return document->basename;
|
||||||
|
}
|
||||||
|
|
||||||
const char*
|
const char*
|
||||||
zathura_document_get_password(zathura_document_t* document)
|
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);
|
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
|
* Returns the password of the document
|
||||||
*
|
*
|
||||||
|
|
24
zathura.c
24
zathura.c
|
@ -665,9 +665,7 @@ document_open(zathura_t* zathura, const char* path, const char* password,
|
||||||
if (basename_only == false) {
|
if (basename_only == false) {
|
||||||
girara_statusbar_item_set_text(zathura->ui.session, zathura->ui.statusbar.file, file_path);
|
girara_statusbar_item_set_text(zathura->ui.session, zathura->ui.statusbar.file, file_path);
|
||||||
} else {
|
} else {
|
||||||
char* tmp = g_path_get_basename(file_path);
|
girara_statusbar_item_set_text(zathura->ui.session, zathura->ui.statusbar.file, zathura_document_get_basename(document));
|
||||||
girara_statusbar_item_set_text(zathura->ui.session, zathura->ui.statusbar.file, tmp);
|
|
||||||
g_free(tmp);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* install file monitor */
|
/* install file monitor */
|
||||||
|
@ -787,9 +785,7 @@ document_open(zathura_t* zathura, const char* path, const char* password,
|
||||||
if (basename_only == false) {
|
if (basename_only == false) {
|
||||||
girara_set_window_title(zathura->ui.session, file_path);
|
girara_set_window_title(zathura->ui.session, file_path);
|
||||||
} else {
|
} else {
|
||||||
char* tmp = g_path_get_basename(file_path);
|
girara_set_window_title(zathura->ui.session, zathura_document_get_basename(document));
|
||||||
girara_set_window_title(zathura->ui.session, tmp);
|
|
||||||
g_free(tmp);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
g_free(file_uri);
|
g_free(file_uri);
|
||||||
|
@ -1061,6 +1057,22 @@ statusbar_page_number_update(zathura_t* zathura)
|
||||||
if (zathura->document != NULL) {
|
if (zathura->document != NULL) {
|
||||||
char* page_number_text = g_strdup_printf("[%d/%d]", current_page_number + 1, number_of_pages);
|
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);
|
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);
|
g_free(page_number_text);
|
||||||
} else {
|
} else {
|
||||||
girara_statusbar_item_set_text(zathura->ui.session, zathura->ui.statusbar.page_number, "");
|
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
|
* Value type: String
|
||||||
* Default value: monospace normal 9
|
* 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
|
inputbar-bg
|
||||||
^^^^^^^^^^^
|
^^^^^^^^^^^
|
||||||
Defines the background color for the inputbar
|
Defines the background color for the inputbar
|
||||||
|
@ -698,6 +707,13 @@ Use basename of the file in the window title.
|
||||||
* Value type: Boolean
|
* Value type: Boolean
|
||||||
* Default value: false
|
* Default value: false
|
||||||
|
|
||||||
|
window-title-page
|
||||||
|
^^^^^^^^^^^^^^^^^
|
||||||
|
Display the page number in the window title.
|
||||||
|
|
||||||
|
* Value type: Boolean
|
||||||
|
* Default value: false
|
||||||
|
|
||||||
statusbar-basename
|
statusbar-basename
|
||||||
^^^^^^^^^^^^^^^^^^
|
^^^^^^^^^^^^^^^^^^
|
||||||
Use basename of the file in the statusbar.
|
Use basename of the file in the statusbar.
|
||||||
|
|
Loading…
Reference in a new issue