Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
pwmt
zathura
Commits
33730545
Commit
33730545
authored
Dec 07, 2015
by
Lukas K.
Browse files
display uri in statusbar/title
parent
bd25ce0a
Changes
8
Hide whitespace changes
Inline
Side-by-side
zathura/callbacks.c
View file @
33730545
...
...
@@ -440,11 +440,12 @@ cb_password_dialog(GtkEntry* entry, zathura_password_dialog_info_t* dialog)
}
/* try to open document again */
if
(
document_open
(
dialog
->
zathura
,
dialog
->
path
,
input
,
if
(
document_open
(
dialog
->
zathura
,
dialog
->
path
,
dialog
->
uri
,
input
,
ZATHURA_PAGE_NUMBER_UNSPECIFIED
)
==
false
)
{
gdk_threads_add_idle
(
password_dialog
,
dialog
);
}
else
{
g_free
(
dialog
->
path
);
g_free
(
dialog
->
uri
);
free
(
dialog
);
}
...
...
zathura/document.c
View file @
33730545
...
...
@@ -22,6 +22,7 @@
*/
struct
zathura_document_s
{
char
*
file_path
;
/**< File path of the document */
char
*
uri
;
/**< URI of the document */
char
*
basename
;
/**< Basename of the document */
const
char
*
password
;
/**< Password of the document */
unsigned
int
current_page_number
;
/**< Current page number */
...
...
@@ -61,7 +62,7 @@ check_set_error(zathura_error_t* error, zathura_error_t code) {
zathura_document_t
*
zathura_document_open
(
zathura_plugin_manager_t
*
plugin_manager
,
const
char
*
path
,
const
char
*
password
,
zathura_error_t
*
error
)
path
,
const
char
*
uri
,
const
char
*
password
,
zathura_error_t
*
error
)
{
if
(
path
==
NULL
)
{
return
NULL
;
...
...
@@ -116,6 +117,7 @@ zathura_document_open(zathura_plugin_manager_t* plugin_manager, const char*
document
->
file_path
=
real_path
;
document
->
basename
=
g_file_get_basename
(
file
);
document
->
uri
=
g_strdup
(
uri
);
document
->
password
=
password
;
document
->
scale
=
1
.
0
;
document
->
plugin
=
plugin
;
...
...
@@ -216,9 +218,8 @@ zathura_document_free(zathura_document_t* document)
error
=
functions
->
document_free
(
document
,
document
->
data
);
}
if
(
document
->
file_path
!=
NULL
)
{
free
(
document
->
file_path
);
}
g_free
(
document
->
file_path
);
g_free
(
document
->
uri
);
g_free
(
document
->
basename
);
g_free
(
document
);
...
...
@@ -236,6 +237,16 @@ zathura_document_get_path(zathura_document_t* document)
return
document
->
file_path
;
}
const
char
*
zathura_document_get_uri
(
zathura_document_t
*
document
)
{
if
(
document
==
NULL
)
{
return
NULL
;
}
return
document
->
uri
;
}
const
char
*
zathura_document_get_basename
(
zathura_document_t
*
document
)
{
...
...
zathura/document.h
View file @
33730545
...
...
@@ -18,7 +18,7 @@
* @return The document object and NULL if an error occurs
*/
zathura_document_t
*
zathura_document_open
(
zathura_plugin_manager_t
*
plugin_manager
,
const
char
*
path
,
const
char
*
password
,
zathura_error_t
*
plugin_manager
,
const
char
*
path
,
const
char
*
uri
,
const
char
*
password
,
zathura_error_t
*
error
);
/**
...
...
@@ -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 URI of the document
*
* @param document The document
* @return The URI of the document
*/
const
char
*
zathura_document_get_uri
(
zathura_document_t
*
document
);
/**
* Returns the basename of the document
*
...
...
zathura/internal.h
View file @
33730545
...
...
@@ -12,6 +12,7 @@
typedef
struct
zathura_password_dialog_info_s
{
char
*
path
;
/**< Path to the file */
char
*
uri
;
/**< URI to the file */
zathura_t
*
zathura
;
/**< Zathura session */
}
zathura_password_dialog_info_t
;
...
...
zathura/print.c
View file @
33730545
...
...
@@ -78,12 +78,10 @@ cb_print_end(GtkPrintOperation* UNUSED(print_operation), GtkPrintContext*
return
;
}
const
char
*
file_path
=
zathura_document_get_path
(
zathura
->
document
);
if
(
file_path
!=
NULL
)
{
girara_statusbar_item_set_text
(
zathura
->
ui
.
session
,
zathura
->
ui
.
statusbar
.
file
,
file_path
);
}
char
*
file_path
=
get_formatted_filename
(
zathura
,
true
);
girara_statusbar_item_set_text
(
zathura
->
ui
.
session
,
zathura
->
ui
.
statusbar
.
file
,
file_path
);
g_free
(
file_path
);
}
static
void
...
...
zathura/shortcuts.c
View file @
33730545
...
...
@@ -442,7 +442,7 @@ sc_reload(girara_session_t* session, girara_argument_t* UNUSED(argument),
document_close
(
zathura
,
true
);
/* reopen document */
document_open
(
zathura
,
zathura
->
file_monitor
.
file_path
,
document_open
(
zathura
,
zathura
->
file_monitor
.
file_path
,
NULL
,
zathura
->
file_monitor
.
password
,
ZATHURA_PAGE_NUMBER_UNSPECIFIED
);
...
...
zathura/zathura.c
View file @
33730545
...
...
@@ -569,6 +569,7 @@ document_info_open(gpointer data)
{
zathura_document_info_t
*
document_info
=
data
;
g_return_val_if_fail
(
document_info
!=
NULL
,
FALSE
);
char
*
uri
=
NULL
;
if
(
document_info
->
zathura
!=
NULL
&&
document_info
->
path
!=
NULL
)
{
char
*
file
=
NULL
;
...
...
@@ -589,6 +590,7 @@ document_info_open(gpointer data)
}
else
{
/* copy file with GIO */
uri
=
g_file_get_uri
(
gf
);
file
=
prepare_document_open_from_gfile
(
gf
);
if
(
file
==
NULL
)
{
girara_notify
(
document_info
->
zathura
->
ui
.
session
,
GIRARA_ERROR
,
...
...
@@ -602,13 +604,14 @@ document_info_open(gpointer data)
if
(
file
!=
NULL
)
{
if
(
document_info
->
synctex
!=
NULL
)
{
document_open_synctex
(
document_info
->
zathura
,
file
,
document_open_synctex
(
document_info
->
zathura
,
file
,
uri
,
document_info
->
password
,
document_info
->
synctex
);
}
else
{
document_open
(
document_info
->
zathura
,
file
,
document_info
->
password
,
document_open
(
document_info
->
zathura
,
file
,
uri
,
document_info
->
password
,
document_info
->
page_number
);
}
g_free
(
file
);
g_free
(
uri
);
if
(
document_info
->
mode
!=
NULL
)
{
if
(
g_strcmp0
(
document_info
->
mode
,
"presentation"
)
==
0
)
{
...
...
@@ -628,14 +631,18 @@ document_info_open(gpointer data)
return
FALSE
;
}
static
char
*
get_formatted_filename
(
zathura_t
*
zathura
,
const
char
*
file_path
,
bool
statusbar
)
char
*
get_formatted_filename
(
zathura_t
*
zathura
,
bool
statusbar
)
{
bool
basename_only
=
false
;
const
char
*
file_path
=
zathura_document_get_uri
(
zathura
->
document
);
if
(
file_path
==
NULL
)
{
file_path
=
zathura_document_get_path
(
zathura
->
document
);
}
if
(
statusbar
==
true
)
{
girara_setting_get
(
zathura
->
ui
.
session
,
"window-title-basename"
,
&
basename_only
);
}
else
{
girara_setting_get
(
zathura
->
ui
.
session
,
"statusbar-basename"
,
&
basename_only
);
}
else
{
girara_setting_get
(
zathura
->
ui
.
session
,
"window-title-basename"
,
&
basename_only
);
}
if
(
basename_only
==
false
)
{
...
...
@@ -666,8 +673,16 @@ get_formatted_filename(zathura_t* zathura, const char* file_path, bool statusbar
return
g_strdup
(
file_path
);
}
}
else
{
const
char
*
basename
=
zathura_document_get_basename
(
zathura
->
document
);
return
g_strdup
(
basename
);
char
*
basename
=
NULL
;
if
(
zathura_document_get_uri
(
zathura
->
document
)
==
NULL
)
{
basename
=
g_strdup
(
zathura_document_get_basename
(
zathura
->
document
));
}
else
{
GFile
*
gf
=
g_file_new_for_uri
(
zathura_document_get_uri
(
zathura
->
document
));
basename
=
g_file_get_basename
(
gf
);
g_object_unref
(
gf
);
}
return
basename
;
}
}
...
...
@@ -682,7 +697,7 @@ document_open_password_dialog(gpointer data)
}
bool
document_open
(
zathura_t
*
zathura
,
const
char
*
path
,
const
char
*
password
,
document_open
(
zathura_t
*
zathura
,
const
char
*
path
,
const
char
*
uri
,
const
char
*
password
,
int
page_number
)
{
if
(
zathura
==
NULL
||
zathura
->
plugins
.
manager
==
NULL
||
path
==
NULL
)
{
...
...
@@ -691,7 +706,7 @@ document_open(zathura_t* zathura, const char* path, const char* password,
gchar
*
file_uri
=
NULL
;
zathura_error_t
error
=
ZATHURA_ERROR_OK
;
zathura_document_t
*
document
=
zathura_document_open
(
zathura
->
plugins
.
manager
,
path
,
password
,
&
error
);
zathura_document_t
*
document
=
zathura_document_open
(
zathura
->
plugins
.
manager
,
path
,
uri
,
password
,
&
error
);
if
(
document
==
NULL
)
{
if
(
error
==
ZATHURA_ERROR_INVALID_PASSWORD
)
{
...
...
@@ -700,6 +715,7 @@ document_open(zathura_t* zathura, const char* path, const char* password,
if
(
password_dialog_info
!=
NULL
)
{
password_dialog_info
->
zathura
=
zathura
;
password_dialog_info
->
path
=
g_strdup
(
path
);
password_dialog_info
->
uri
=
g_strdup
(
uri
);
if
(
password_dialog_info
->
path
!=
NULL
)
{
gdk_threads_add_idle
(
document_open_password_dialog
,
password_dialog_info
);
...
...
@@ -715,6 +731,8 @@ document_open(zathura_t* zathura, const char* path, const char* password,
}
goto
error_out
;
}
zathura
->
document
=
document
;
const
char
*
file_path
=
zathura_document_get_path
(
document
);
unsigned
int
number_of_pages
=
zathura_document_get_number_of_pages
(
document
);
...
...
@@ -800,7 +818,7 @@ document_open(zathura_t* zathura, const char* path, const char* password,
zathura
->
bisect
.
end
=
number_of_pages
-
1
;
/* update statusbar */
char
*
filename
=
get_formatted_filename
(
zathura
,
file_path
,
true
);
char
*
filename
=
get_formatted_filename
(
zathura
,
true
);
girara_statusbar_item_set_text
(
zathura
->
ui
.
session
,
zathura
->
ui
.
statusbar
.
file
,
filename
);
g_free
(
filename
);
...
...
@@ -846,8 +864,6 @@ document_open(zathura_t* zathura, const char* path, const char* password,
goto
error_free
;
}
zathura
->
document
=
document
;
/* page cache size */
int
cache_size
=
0
;
girara_setting_get
(
zathura
->
ui
.
session
,
"page-cache-size"
,
&
cache_size
);
...
...
@@ -976,7 +992,7 @@ document_open(zathura_t* zathura, const char* path, const char* password,
}
/* update title */
char
*
formatted_filename
=
get_formatted_filename
(
zathura
,
file_path
,
false
);
char
*
formatted_filename
=
get_formatted_filename
(
zathura
,
false
);
girara_set_window_title
(
zathura
->
ui
.
session
,
formatted_filename
);
g_free
(
formatted_filename
);
...
...
@@ -1029,10 +1045,10 @@ error_out:
}
bool
document_open_synctex
(
zathura_t
*
zathura
,
const
char
*
path
,
document_open_synctex
(
zathura_t
*
zathura
,
const
char
*
path
,
const
char
*
uri
,
const
char
*
password
,
const
char
*
synctex
)
{
bool
ret
=
document_open
(
zathura
,
path
,
password
,
bool
ret
=
document_open
(
zathura
,
path
,
password
,
uri
,
ZATHURA_PAGE_NUMBER_UNSPECIFIED
);
if
(
ret
==
false
)
{
return
false
;
...
...
@@ -1264,7 +1280,7 @@ statusbar_page_number_update(zathura_t* zathura)
girara_setting_get
(
zathura
->
ui
.
session
,
"window-title-page"
,
&
page_number_in_window_title
);
if
(
page_number_in_window_title
==
true
)
{
char
*
filename
=
get_formatted_filename
(
zathura
,
zathura_document_get_path
(
zathura
->
document
),
false
);
char
*
filename
=
get_formatted_filename
(
zathura
,
false
);
char
*
title
=
g_strdup_printf
(
"%s %s"
,
filename
,
page_number_text
);
girara_set_window_title
(
zathura
->
ui
.
session
,
title
);
g_free
(
title
);
...
...
zathura/zathura.h
View file @
33730545
...
...
@@ -306,7 +306,7 @@ void zathura_set_argv(zathura_t* zathura, char** argv);
*
* @return If no error occured true, otherwise false, is returned.
*/
bool
document_open
(
zathura_t
*
zathura
,
const
char
*
path
,
const
char
*
password
,
bool
document_open
(
zathura_t
*
zathura
,
const
char
*
path
,
const
char
*
uri
,
const
char
*
password
,
int
page_number
);
/**
...
...
@@ -319,7 +319,7 @@ bool document_open(zathura_t* zathura, const char* path, const char* password,
*
* @return If no error occured true, otherwise false, is returned.
*/
bool
document_open_synctex
(
zathura_t
*
zathura
,
const
char
*
path
,
bool
document_open_synctex
(
zathura_t
*
zathura
,
const
char
*
path
,
const
char
*
uri
,
const
char
*
password
,
const
char
*
synctex
);
/**
...
...
@@ -470,4 +470,14 @@ void zathura_jumplist_trim(zathura_t* zathura);
*/
bool
zathura_jumplist_load
(
zathura_t
*
zathura
,
const
char
*
file
);
/**
* Gets the nicely formatted filename of the loaded document according to settings
*
* @param zathura The zathura session
* @param statusbar Whether return value will be dispalyed in status bar
*
* return Printable filename. Free with g_free.
*/
char
*
get_formatted_filename
(
zathura_t
*
zathura
,
bool
statusbar
);
#endif // ZATHURA_H
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment