Commit 7dc30c9c authored by Lukas K.'s avatar Lukas K.
Browse files

move uri basename handling to zathura_document_open

parent 33730545
...@@ -116,8 +116,15 @@ zathura_document_open(zathura_plugin_manager_t* plugin_manager, const char* ...@@ -116,8 +116,15 @@ zathura_document_open(zathura_plugin_manager_t* plugin_manager, const char*
} }
document->file_path = real_path; document->file_path = real_path;
document->basename = g_file_get_basename(file);
document->uri = g_strdup(uri); document->uri = g_strdup(uri);
if (document->uri == NULL) {
document->basename = g_file_get_basename(file);
}
else {
GFile *gf = g_file_new_for_uri(document->uri);
document->basename = g_file_get_basename(gf);
g_object_unref(gf);
}
document->password = password; document->password = password;
document->scale = 1.0; document->scale = 1.0;
document->plugin = plugin; document->plugin = plugin;
......
...@@ -636,7 +636,7 @@ get_formatted_filename(zathura_t* zathura, bool statusbar) ...@@ -636,7 +636,7 @@ get_formatted_filename(zathura_t* zathura, bool statusbar)
{ {
bool basename_only = false; bool basename_only = false;
const char* file_path = zathura_document_get_uri(zathura->document); const char* file_path = zathura_document_get_uri(zathura->document);
if(file_path == NULL) { if (file_path == NULL) {
file_path = zathura_document_get_path(zathura->document); file_path = zathura_document_get_path(zathura->document);
} }
if (statusbar == true) { if (statusbar == true) {
...@@ -673,16 +673,8 @@ get_formatted_filename(zathura_t* zathura, bool statusbar) ...@@ -673,16 +673,8 @@ get_formatted_filename(zathura_t* zathura, bool statusbar)
return g_strdup(file_path); return g_strdup(file_path);
} }
} else { } else {
char *basename = NULL; const char* basename = zathura_document_get_basename(zathura->document);
if(zathura_document_get_uri(zathura->document) == NULL) { return g_strdup(basename);
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;
} }
} }
......
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