mirror of
https://git.pwmt.org/pwmt/zathura.git
synced 2024-12-28 07:06:02 +01:00
Implement tilde feature for statusbar as well
This commit is contained in:
parent
1be84c6c3b
commit
7991618d25
4 changed files with 43 additions and 20 deletions
|
@ -863,6 +863,13 @@ Use basename of the file in the window title.
|
|||
* Value type: Boolean
|
||||
* Default value: false
|
||||
|
||||
window-title-home-tilde
|
||||
^^^^^^^^^^^^^^^^^^^^^^^
|
||||
Display a short version of the file path, which replaces $HOME with ~, in the window title.
|
||||
|
||||
* Value type: Boolean
|
||||
* Default value: false
|
||||
|
||||
window-title-page
|
||||
^^^^^^^^^^^^^^^^^
|
||||
Display the page number in the window title.
|
||||
|
@ -877,6 +884,13 @@ Use basename of the file 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.
|
||||
|
||||
* Value type: Boolean
|
||||
* Default value: false
|
||||
|
||||
zoom-center
|
||||
^^^^^^^^^^^
|
||||
En/Disables horizontally centered zooming.
|
||||
|
@ -965,13 +979,6 @@ Define the background color of the selected element in index mode.
|
|||
* Value type: String
|
||||
* Default value: #9FBC00
|
||||
|
||||
window-title-home-tilde
|
||||
^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
Display a short version of the file path, which replaces $HOME with ~, in the window title.
|
||||
|
||||
* Value type: Boolean
|
||||
* Default value: false
|
||||
|
||||
|
||||
SEE ALSO
|
||||
|
|
|
@ -229,6 +229,8 @@ config_load_default(zathura_t* zathura)
|
|||
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, "statusbar-home-tilde", &bool_value, BOOLEAN, false, _("Use ~ instead of $HOME in the filename in the statusbar"), NULL, NULL);
|
||||
bool_value = true;
|
||||
girara_setting_add(gsession, "synctex", &bool_value, BOOLEAN, false, _("Enable synctex support"), NULL, NULL);
|
||||
string_value = "";
|
||||
|
|
|
@ -547,13 +547,24 @@ document_info_open(gpointer data)
|
|||
}
|
||||
|
||||
const char*
|
||||
get_window_title_filename(zathura_t* zathura, const char* file_path)
|
||||
get_formatted_filename(zathura_t* zathura, const char* file_path, bool statusbar)
|
||||
{
|
||||
bool basename_only = false;
|
||||
girara_setting_get(zathura->ui.session, "window-title-basename", &basename_only);
|
||||
if (statusbar) {
|
||||
girara_setting_get(zathura->ui.session, "window-title-basename", &basename_only);
|
||||
} else {
|
||||
girara_setting_get(zathura->ui.session, "statusbar-basename", &basename_only);
|
||||
}
|
||||
|
||||
if (basename_only == false) {
|
||||
|
||||
bool home_tilde = false;
|
||||
girara_setting_get(zathura->ui.session, "window-title-home-tilde", &home_tilde);
|
||||
if (statusbar) {
|
||||
girara_setting_get(zathura->ui.session, "statusbar-home-tilde", &home_tilde);
|
||||
} else {
|
||||
girara_setting_get(zathura->ui.session, "window-title-home-tilde", &home_tilde);
|
||||
}
|
||||
|
||||
if (home_tilde) {
|
||||
char *home = getenv("HOME");
|
||||
size_t home_len = home ? strlen(home) : 0;
|
||||
|
@ -697,13 +708,8 @@ document_open(zathura_t* zathura, const char* path, const char* password,
|
|||
zathura->bisect.end = number_of_pages - 1;
|
||||
|
||||
/* update statusbar */
|
||||
bool basename_only = false;
|
||||
girara_setting_get(zathura->ui.session, "statusbar-basename", &basename_only);
|
||||
if (basename_only == false) {
|
||||
girara_statusbar_item_set_text(zathura->ui.session, zathura->ui.statusbar.file, file_path);
|
||||
} else {
|
||||
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,
|
||||
get_formatted_filename(zathura, file_path, true));
|
||||
|
||||
/* install file monitor */
|
||||
file_uri = g_filename_to_uri(file_path, NULL, NULL);
|
||||
|
@ -870,7 +876,7 @@ document_open(zathura_t* zathura, const char* path, const char* password,
|
|||
}
|
||||
|
||||
/* update title */
|
||||
girara_set_window_title(zathura->ui.session, get_window_title_filename(zathura, file_path));
|
||||
girara_set_window_title(zathura->ui.session, get_formatted_filename(zathura, file_path, false));
|
||||
|
||||
g_free(file_uri);
|
||||
|
||||
|
@ -1123,7 +1129,7 @@ statusbar_page_number_update(zathura_t* zathura)
|
|||
|
||||
if (page_number_in_window_title == true) {
|
||||
char* title = g_strdup_printf("%s %s",
|
||||
get_window_title_filename(zathura, zathura_document_get_path(zathura->document)),
|
||||
get_formatted_filename(zathura, zathura_document_get_path(zathura->document), false),
|
||||
page_number_text);
|
||||
girara_set_window_title(zathura->ui.session, title);
|
||||
g_free(title);
|
||||
|
|
|
@ -278,7 +278,15 @@ void zathura_set_plugin_dir(zathura_t* zathura, const char* dir);
|
|||
*/
|
||||
void zathura_set_argv(zathura_t* zathura, char** argv);
|
||||
|
||||
const char* get_window_title_filename(zathura_t* zathura, const char* file_path);
|
||||
/**
|
||||
* Returns the filename formatted according to the user config.
|
||||
* Takes into account the basename setting and the home-tilde setting.
|
||||
*
|
||||
* @param zatura The zathura session
|
||||
* @param file_path The filename to be formatted
|
||||
* @param statusbar True if for statusbar, false if for window title
|
||||
*/
|
||||
const char* get_formatted_filename(zathura_t* zathura, const char* file_path, bool statusbar);
|
||||
|
||||
/**
|
||||
* Opens a file
|
||||
|
|
Loading…
Reference in a new issue