mirror of
https://git.pwmt.org/pwmt/zathura.git
synced 2024-12-29 14:35:59 +01:00
Update coding standard
This commit is contained in:
parent
abc7deadd3
commit
890d6b3299
5 changed files with 47 additions and 36 deletions
|
@ -26,8 +26,7 @@ buffer_changed(girara_session_t* session)
|
|||
if(buffer) {
|
||||
girara_statusbar_item_set_text(session, Zathura.UI.statusbar.buffer, buffer);
|
||||
free(buffer);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
girara_statusbar_item_set_text(session, Zathura.UI.statusbar.buffer, "");
|
||||
}
|
||||
}
|
||||
|
|
|
@ -302,24 +302,33 @@ zathura_page_render(zathura_page_t* page)
|
|||
zathura_index_element_t*
|
||||
zathura_index_element_new(const char* title)
|
||||
{
|
||||
if (!title)
|
||||
if(!title) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
zathura_index_element_t* res = g_malloc0(sizeof(zathura_index_element_t));
|
||||
if (!res)
|
||||
|
||||
if(!res) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
res->title = g_strdup(title);
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
void
|
||||
zathura_index_element_free(zathura_index_element_t* index)
|
||||
{
|
||||
if (!index)
|
||||
if(!index) {
|
||||
return;
|
||||
}
|
||||
|
||||
g_free(index->title);
|
||||
if (index->type == ZATHURA_LINK_EXTERNAL)
|
||||
|
||||
if(index->type == ZATHURA_LINK_EXTERNAL) {
|
||||
g_free(index->target.uri);
|
||||
}
|
||||
|
||||
g_free(index);
|
||||
}
|
||||
|
|
46
ft/pdf/pdf.c
46
ft/pdf/pdf.c
|
@ -89,63 +89,67 @@ pdf_document_free(zathura_document_t* document)
|
|||
static void
|
||||
build_index(pdf_document_t* pdf, girara_tree_node_t* root, PopplerIndexIter* iter)
|
||||
{
|
||||
if (!root || !iter)
|
||||
if(!root || !iter) {
|
||||
return;
|
||||
}
|
||||
|
||||
do
|
||||
{
|
||||
PopplerAction* action = poppler_index_iter_get_action(iter);
|
||||
if (!action)
|
||||
|
||||
if(!action) {
|
||||
continue;
|
||||
}
|
||||
|
||||
gchar* markup = g_markup_escape_text(action->any.title, -1);
|
||||
zathura_index_element_t* indexelement = zathura_index_element_new(markup);
|
||||
if (action->type == POPPLER_ACTION_URI)
|
||||
{
|
||||
|
||||
if(action->type == POPPLER_ACTION_URI) {
|
||||
indexelement->type = ZATHURA_LINK_EXTERNAL;
|
||||
indexelement->target.uri = g_strdup(action->uri.uri);
|
||||
}
|
||||
else if (action->type == POPPLER_ACTION_GOTO_DEST)
|
||||
{
|
||||
} else if (action->type == POPPLER_ACTION_GOTO_DEST) {
|
||||
indexelement->type = ZATHURA_LINK_TO_PAGE;
|
||||
if (action->goto_dest.dest->type == POPPLER_DEST_NAMED)
|
||||
{
|
||||
|
||||
if(action->goto_dest.dest->type == POPPLER_DEST_NAMED) {
|
||||
PopplerDest* dest = poppler_document_find_dest(pdf->document, action->goto_dest.dest->named_dest);
|
||||
if (dest)
|
||||
{
|
||||
if(dest) {
|
||||
indexelement->target.page_number = dest->page_num - 1;
|
||||
poppler_dest_free(dest);
|
||||
}
|
||||
}
|
||||
else
|
||||
} else {
|
||||
indexelement->target.page_number = action->goto_dest.dest->page_num - 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
}
|
||||
} else {
|
||||
poppler_action_free(action);
|
||||
zathura_index_element_free(indexelement);
|
||||
continue;
|
||||
}
|
||||
|
||||
poppler_action_free(action);
|
||||
|
||||
girara_tree_node_t* node = girara_node_append_data(root, indexelement);
|
||||
PopplerIndexIter* child = poppler_index_iter_get_child(iter);
|
||||
if (child)
|
||||
PopplerIndexIter* child = poppler_index_iter_get_child(iter);
|
||||
|
||||
if(child) {
|
||||
build_index(pdf, node, child);
|
||||
}
|
||||
|
||||
poppler_index_iter_free(child);
|
||||
|
||||
} while (poppler_index_iter_next(iter));
|
||||
}
|
||||
|
||||
girara_tree_node_t*
|
||||
pdf_document_index_generate(zathura_document_t* document)
|
||||
{
|
||||
if (!document || !document->data) {
|
||||
if(!document || !document->data) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
pdf_document_t* pdf_document = (pdf_document_t*) document->data;
|
||||
PopplerIndexIter* iter = poppler_index_iter_new(pdf_document->document);
|
||||
if (!iter) {
|
||||
PopplerIndexIter* iter = poppler_index_iter_new(pdf_document->document);
|
||||
|
||||
if(!iter) {
|
||||
// XXX: error message?
|
||||
return NULL;
|
||||
}
|
||||
|
|
|
@ -81,8 +81,7 @@ sc_navigate(girara_session_t* session, girara_argument_t* argument)
|
|||
|
||||
if(argument->n == NEXT) {
|
||||
new_page = (new_page + 1) % number_of_pages;
|
||||
}
|
||||
else if(argument->n == PREVIOUS) {
|
||||
} else if(argument->n == PREVIOUS) {
|
||||
new_page = (new_page + number_of_pages - 1) % number_of_pages;
|
||||
}
|
||||
|
||||
|
|
14
utils.c
14
utils.c
|
@ -31,10 +31,11 @@ file_get_extension(const char* path)
|
|||
unsigned int i = strlen(path);
|
||||
for(; i > 0; i--)
|
||||
{
|
||||
if(*(path + i) != '.')
|
||||
if(*(path + i) != '.') {
|
||||
continue;
|
||||
else
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if(!i) {
|
||||
|
@ -52,23 +53,22 @@ execute_command(char* const argv[], char** output)
|
|||
}
|
||||
|
||||
int p[2];
|
||||
if(pipe(p))
|
||||
if(pipe(p)) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
pid_t pid = fork();
|
||||
|
||||
if(pid == -1) { // failure
|
||||
return false;
|
||||
}
|
||||
else if(pid == 0) { // child
|
||||
} else if(pid == 0) { // child
|
||||
dup2(p[1], 1);
|
||||
close(p[0]);
|
||||
|
||||
if(execvp(argv[0], argv) == -1) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else { // parent
|
||||
} else { // parent
|
||||
dup2(p[0], 0);
|
||||
close(p[1]);
|
||||
|
||||
|
|
Loading…
Reference in a new issue