mirror of
https://git.pwmt.org/pwmt/zathura.git
synced 2024-12-29 11:46:01 +01:00
Updated coding standard
This commit is contained in:
parent
4c19c798f7
commit
5e7a774101
10 changed files with 175 additions and 176 deletions
12
callbacks.c
12
callbacks.c
|
@ -12,7 +12,7 @@
|
|||
gboolean
|
||||
cb_destroy(GtkWidget* widget, gpointer data)
|
||||
{
|
||||
if(Zathura.UI.session) {
|
||||
if (Zathura.UI.session) {
|
||||
girara_session_destroy(Zathura.UI.session);
|
||||
}
|
||||
|
||||
|
@ -28,7 +28,7 @@ buffer_changed(girara_session_t* session)
|
|||
|
||||
char* buffer = girara_buffer_get(session);
|
||||
|
||||
if(buffer) {
|
||||
if (buffer) {
|
||||
girara_statusbar_item_set_text(session, Zathura.UI.statusbar.buffer, buffer);
|
||||
free(buffer);
|
||||
} else {
|
||||
|
@ -39,7 +39,7 @@ buffer_changed(girara_session_t* session)
|
|||
void
|
||||
cb_view_vadjustment_value_changed(GtkAdjustment *adjustment, gpointer data)
|
||||
{
|
||||
if(!Zathura.document || !Zathura.document->pages || !Zathura.UI.page_view) {
|
||||
if (!Zathura.document || !Zathura.document->pages || !Zathura.UI.page_view) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -48,19 +48,19 @@ cb_view_vadjustment_value_changed(GtkAdjustment *adjustment, gpointer data)
|
|||
gdouble upper = lower + gtk_adjustment_get_page_size(adjustment);
|
||||
|
||||
/* find page that fits */
|
||||
for(unsigned int page_id = 0; page_id < Zathura.document->number_of_pages; page_id++)
|
||||
for (unsigned int page_id = 0; page_id < Zathura.document->number_of_pages; page_id++)
|
||||
{
|
||||
zathura_page_t* page = Zathura.document->pages[page_id];
|
||||
|
||||
/* check for rendered attribute */
|
||||
if(page->rendered) {
|
||||
if (page->rendered) {
|
||||
continue;
|
||||
}
|
||||
|
||||
double begin = page->offset;
|
||||
double end = page->offset + page->height;
|
||||
|
||||
if( ( (begin >= lower) && (end <= upper) ) /* page is in viewport */
|
||||
if ( ( (begin >= lower) && (end <= upper) ) /* page is in viewport */
|
||||
|| ( (begin <= lower) && (end >= lower) && (end <= upper) ) /* end of the page is in viewport */
|
||||
|| ( (begin >= lower) && (end >= upper) && (begin <= upper) ) /* begin of the page is in viewport */
|
||||
) {
|
||||
|
|
11
completion.c
11
completion.c
|
@ -13,7 +13,7 @@ cc_print(girara_session_t* session, char* input)
|
|||
girara_completion_t* completion = girara_completion_init();
|
||||
girara_completion_group_t* group = girara_completion_group_create(session, NULL);
|
||||
|
||||
if(!session || !input || !completion || !group)
|
||||
if (!session || !input || !completion || !group)
|
||||
return NULL;
|
||||
|
||||
girara_completion_add_group(completion, group);
|
||||
|
@ -23,7 +23,7 @@ cc_print(girara_session_t* session, char* input)
|
|||
};
|
||||
|
||||
char* output;
|
||||
if(!execute_command(list_printers, &output)) {
|
||||
if (!execute_command(list_printers, &output)) {
|
||||
girara_completion_free(completion);
|
||||
return false;
|
||||
}
|
||||
|
@ -33,9 +33,8 @@ cc_print(girara_session_t* session, char* input)
|
|||
char* p = strtok(output, "\n");
|
||||
char* q;
|
||||
|
||||
while(p)
|
||||
{
|
||||
if(!(p = strstr(p, "device for ")) || !(q = strchr(p, ':'))) {
|
||||
while (p) {
|
||||
if (!(p = strstr(p, "device for ")) || !(q = strchr(p, ':'))) {
|
||||
p = strtok(NULL, "\n");
|
||||
continue;
|
||||
}
|
||||
|
@ -43,7 +42,7 @@ cc_print(girara_session_t* session, char* input)
|
|||
unsigned int printer_length = q - p - prefix_length;
|
||||
char* printer_name = malloc(sizeof(char) * printer_length);
|
||||
|
||||
if(!printer_name) {
|
||||
if (!printer_name) {
|
||||
p = strtok(NULL, "\n");
|
||||
continue;
|
||||
}
|
||||
|
|
2
config.c
2
config.c
|
@ -8,7 +8,7 @@
|
|||
void
|
||||
config_load_default(void)
|
||||
{
|
||||
if(!Zathura.UI.session)
|
||||
if (!Zathura.UI.session)
|
||||
return;
|
||||
|
||||
/* general settings */
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
bool
|
||||
djvu_document_open(zathura_document_t* document)
|
||||
{
|
||||
if(!document) {
|
||||
if (!document) {
|
||||
goto error_out;
|
||||
}
|
||||
|
||||
|
@ -24,7 +24,7 @@ djvu_document_open(zathura_document_t* document)
|
|||
document->functions.page_free = djvu_page_free;
|
||||
|
||||
document->data = malloc(sizeof(djvu_document_t));
|
||||
if(!document->data) {
|
||||
if (!document->data) {
|
||||
goto error_out;
|
||||
}
|
||||
|
||||
|
@ -36,7 +36,7 @@ djvu_document_open(zathura_document_t* document)
|
|||
/* setup format */
|
||||
djvu_document->format = ddjvu_format_create(DDJVU_FORMAT_RGB24, 0, NULL);
|
||||
|
||||
if(!djvu_document->format) {
|
||||
if (!djvu_document->format) {
|
||||
goto error_free;
|
||||
}
|
||||
|
||||
|
@ -45,14 +45,14 @@ djvu_document_open(zathura_document_t* document)
|
|||
/* setup context */
|
||||
djvu_document->context = ddjvu_context_create("zathura");
|
||||
|
||||
if(!djvu_document->context) {
|
||||
if (!djvu_document->context) {
|
||||
goto error_free;
|
||||
}
|
||||
|
||||
/* setup document */
|
||||
djvu_document->document = ddjvu_document_create_by_filename(djvu_document->context, document->file_path, FALSE);
|
||||
|
||||
if(!djvu_document->document) {
|
||||
if (!djvu_document->document) {
|
||||
goto error_free;
|
||||
}
|
||||
|
||||
|
@ -60,8 +60,8 @@ djvu_document_open(zathura_document_t* document)
|
|||
ddjvu_message_t* msg;
|
||||
ddjvu_message_wait(djvu_document->context);
|
||||
|
||||
while((msg = ddjvu_message_peek(djvu_document->context)) && (msg->m_any.tag != DDJVU_DOCINFO)) {
|
||||
if(msg->m_any.tag == DDJVU_ERROR) {
|
||||
while ((msg = ddjvu_message_peek(djvu_document->context)) && (msg->m_any.tag != DDJVU_DOCINFO)) {
|
||||
if (msg->m_any.tag == DDJVU_ERROR) {
|
||||
goto error_free;
|
||||
}
|
||||
|
||||
|
@ -69,7 +69,7 @@ djvu_document_open(zathura_document_t* document)
|
|||
}
|
||||
|
||||
/* decoding error */
|
||||
if(ddjvu_document_decoding_error(djvu_document->document)) {
|
||||
if (ddjvu_document_decoding_error(djvu_document->document)) {
|
||||
goto error_free;
|
||||
}
|
||||
|
||||
|
@ -79,11 +79,11 @@ djvu_document_open(zathura_document_t* document)
|
|||
|
||||
error_free:
|
||||
|
||||
if(djvu_document->format) {
|
||||
if (djvu_document->format) {
|
||||
ddjvu_format_release(djvu_document->format);
|
||||
}
|
||||
|
||||
if(djvu_document->context) {
|
||||
if (djvu_document->context) {
|
||||
ddjvu_context_release(djvu_document->context);
|
||||
}
|
||||
|
||||
|
@ -98,11 +98,11 @@ error_out:
|
|||
bool
|
||||
djvu_document_free(zathura_document_t* document)
|
||||
{
|
||||
if(!document) {
|
||||
if (!document) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if(document->data) {
|
||||
if (document->data) {
|
||||
djvu_document_t* djvu_document = (djvu_document_t*) document->data;
|
||||
ddjvu_context_release(djvu_document->context);
|
||||
ddjvu_document_release(djvu_document->document);
|
||||
|
@ -122,14 +122,14 @@ djvu_document_index_generate(zathura_document_t* document)
|
|||
bool
|
||||
djvu_document_save_as(zathura_document_t* document, const char* path)
|
||||
{
|
||||
if(!document || !document->data || !path) {
|
||||
if (!document || !document->data || !path) {
|
||||
return false;
|
||||
}
|
||||
|
||||
djvu_document_t* djvu_document = (djvu_document_t*) document->data;
|
||||
|
||||
FILE* fp = fopen(path, "w");
|
||||
if(!fp) {
|
||||
if (!fp) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -148,14 +148,14 @@ djvu_document_attachments_get(zathura_document_t* document)
|
|||
zathura_page_t*
|
||||
djvu_page_get(zathura_document_t* document, unsigned int page)
|
||||
{
|
||||
if(!document || !document->data) {
|
||||
if (!document || !document->data) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
djvu_document_t* djvu_document = (djvu_document_t*) document->data;
|
||||
zathura_page_t* document_page = malloc(sizeof(zathura_page_t));
|
||||
|
||||
if(!document_page) {
|
||||
if (!document_page) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
@ -165,9 +165,9 @@ djvu_page_get(zathura_document_t* document, unsigned int page)
|
|||
ddjvu_status_t status;
|
||||
ddjvu_pageinfo_t page_info;
|
||||
|
||||
while((status = ddjvu_document_get_pageinfo(djvu_document->document, page, &page_info)) < DDJVU_JOB_OK);
|
||||
while ((status = ddjvu_document_get_pageinfo(djvu_document->document, page, &page_info)) < DDJVU_JOB_OK);
|
||||
|
||||
if(status >= DDJVU_JOB_FAILED) {
|
||||
if (status >= DDJVU_JOB_FAILED) {
|
||||
free(document_page);
|
||||
return NULL;
|
||||
}
|
||||
|
@ -181,7 +181,7 @@ djvu_page_get(zathura_document_t* document, unsigned int page)
|
|||
bool
|
||||
djvu_page_free(zathura_page_t* page)
|
||||
{
|
||||
if(!page) {
|
||||
if (!page) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -211,7 +211,7 @@ djvu_page_form_fields_get(zathura_page_t* page)
|
|||
GtkWidget*
|
||||
djvu_page_render(zathura_page_t* page)
|
||||
{
|
||||
if(!Zathura.document || !page || !page->document) {
|
||||
if (!Zathura.document || !page || !page->document) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
@ -219,7 +219,7 @@ djvu_page_render(zathura_page_t* page)
|
|||
unsigned int page_width = Zathura.document->scale * page->width;
|
||||
unsigned int page_height = Zathura.document->scale * page->height;
|
||||
|
||||
if(!page_width || !page_height) {
|
||||
if (!page_width || !page_height) {
|
||||
goto error_out;
|
||||
}
|
||||
|
||||
|
@ -227,17 +227,17 @@ djvu_page_render(zathura_page_t* page)
|
|||
djvu_document_t* djvu_document = (djvu_document_t*) page->document->data;
|
||||
ddjvu_page_t* djvu_page = ddjvu_page_create_by_pageno(djvu_document->document, page->number);
|
||||
|
||||
if(!djvu_page) {
|
||||
if (!djvu_page) {
|
||||
goto error_out;
|
||||
}
|
||||
|
||||
while(!ddjvu_page_decoding_done(djvu_page));
|
||||
while (!ddjvu_page_decoding_done(djvu_page));
|
||||
|
||||
ddjvu_rect_t rrect = { 0, 0, page_width, page_height };
|
||||
ddjvu_rect_t prect = { 0, 0, page_width, page_height };
|
||||
|
||||
guchar* buffer = malloc(sizeof(char) * (page_width * page_height * 3));
|
||||
if(!buffer) {
|
||||
if (!buffer) {
|
||||
goto error_free;
|
||||
}
|
||||
|
||||
|
@ -274,14 +274,14 @@ djvu_page_render(zathura_page_t* page)
|
|||
GdkPixbuf* pixbuf = gdk_pixbuf_new_from_data(buffer, GDK_COLORSPACE_RGB, FALSE, 8,
|
||||
page_width, page_height, 3 * page_width, NULL, NULL);
|
||||
|
||||
if(!pixbuf) {
|
||||
if (!pixbuf) {
|
||||
goto error_free;
|
||||
}
|
||||
|
||||
/* rotate page */
|
||||
if(Zathura.document->rotate != 0) {
|
||||
if (Zathura.document->rotate != 0) {
|
||||
GdkPixbuf* pixbuf_temp = gdk_pixbuf_rotate_simple(pixbuf, gdk_angle);
|
||||
if(!pixbuf_temp) {
|
||||
if (!pixbuf_temp) {
|
||||
goto error_free;
|
||||
}
|
||||
|
||||
|
@ -290,7 +290,7 @@ djvu_page_render(zathura_page_t* page)
|
|||
|
||||
GtkWidget* image = gtk_image_new();
|
||||
|
||||
if(!image) {
|
||||
if (!image) {
|
||||
goto error_free;
|
||||
}
|
||||
|
||||
|
|
|
@ -25,17 +25,17 @@ zathura_document_plugin_t zathura_document_plugins[] = {
|
|||
zathura_document_t*
|
||||
zathura_document_open(const char* path, const char* password)
|
||||
{
|
||||
if(!path) {
|
||||
if (!path) {
|
||||
goto error_out;
|
||||
}
|
||||
|
||||
if(!file_exists(path)) {
|
||||
if (!file_exists(path)) {
|
||||
fprintf(stderr, "error: file does not exist\n");
|
||||
goto error_out;
|
||||
}
|
||||
|
||||
const char* file_extension = file_get_extension(path);
|
||||
if(!file_extension) {
|
||||
if (!file_extension) {
|
||||
fprintf(stderr, "error: could not determine file type\n");
|
||||
goto error_out;
|
||||
}
|
||||
|
@ -46,7 +46,7 @@ zathura_document_open(const char* path, const char* password)
|
|||
path_max = PATH_MAX;
|
||||
#else
|
||||
path_max = pathconf(path,_PC_PATH_MAX);
|
||||
if(path_max <= 0)
|
||||
if (path_max <= 0)
|
||||
path_max = 4096;
|
||||
#endif
|
||||
|
||||
|
@ -54,16 +54,16 @@ zathura_document_open(const char* path, const char* password)
|
|||
zathura_document_t* document = NULL;
|
||||
|
||||
real_path = malloc(sizeof(char) * path_max);
|
||||
if(!real_path) {
|
||||
if (!real_path) {
|
||||
goto error_out;
|
||||
}
|
||||
|
||||
if(!realpath(path, real_path)) {
|
||||
if (!realpath(path, real_path)) {
|
||||
goto error_free;
|
||||
}
|
||||
|
||||
document = malloc(sizeof(zathura_document_t));
|
||||
if(!document) {
|
||||
if (!document) {
|
||||
goto error_free;
|
||||
}
|
||||
|
||||
|
@ -88,25 +88,25 @@ zathura_document_open(const char* path, const char* password)
|
|||
document->functions.page_render = NULL;
|
||||
|
||||
/* init plugin with associated file type */
|
||||
for(unsigned int i = 0; i < LENGTH(zathura_document_plugins); i++)
|
||||
for (unsigned int i = 0; i < LENGTH(zathura_document_plugins); i++)
|
||||
{
|
||||
if(!strcmp(file_extension, zathura_document_plugins[i].file_extension)) {
|
||||
if(zathura_document_plugins[i].open_function) {
|
||||
if(zathura_document_plugins[i].open_function(document)) {
|
||||
if (!strcmp(file_extension, zathura_document_plugins[i].file_extension)) {
|
||||
if (zathura_document_plugins[i].open_function) {
|
||||
if (zathura_document_plugins[i].open_function(document)) {
|
||||
/* update statusbar */
|
||||
girara_statusbar_item_set_text(Zathura.UI.session, Zathura.UI.statusbar.file, real_path);
|
||||
|
||||
/* read all pages */
|
||||
document->pages = calloc(document->number_of_pages, sizeof(zathura_page_t*));
|
||||
if(!document->pages) {
|
||||
if (!document->pages) {
|
||||
goto error_free;
|
||||
}
|
||||
|
||||
double offset = 0;
|
||||
for(unsigned int page_id = 0; page_id < document->number_of_pages; page_id++)
|
||||
for (unsigned int page_id = 0; page_id < document->number_of_pages; page_id++)
|
||||
{
|
||||
zathura_page_t* page = zathura_page_get(document, page_id);
|
||||
if(!page) {
|
||||
if (!page) {
|
||||
goto error_free;
|
||||
}
|
||||
|
||||
|
@ -131,8 +131,8 @@ error_free:
|
|||
|
||||
free(real_path);
|
||||
|
||||
if(document && document->pages) {
|
||||
for(unsigned int page_id = 0; page_id < document->number_of_pages; page_id++)
|
||||
if (document && document->pages) {
|
||||
for (unsigned int page_id = 0; page_id < document->number_of_pages; page_id++)
|
||||
{
|
||||
zathura_page_free(document->pages[page_id]);
|
||||
}
|
||||
|
@ -150,12 +150,12 @@ error_out:
|
|||
bool
|
||||
zathura_document_free(zathura_document_t* document)
|
||||
{
|
||||
if(!document) {
|
||||
if (!document) {
|
||||
return false;
|
||||
}
|
||||
|
||||
/* free pages */
|
||||
for(unsigned int page_id = 0; page_id < document->number_of_pages; page_id++)
|
||||
for (unsigned int page_id = 0; page_id < document->number_of_pages; page_id++)
|
||||
{
|
||||
zathura_page_free(document->pages[page_id]);
|
||||
}
|
||||
|
@ -163,10 +163,10 @@ zathura_document_free(zathura_document_t* document)
|
|||
free(document->pages);
|
||||
|
||||
/* free document */
|
||||
if(!document->functions.document_free) {
|
||||
if (!document->functions.document_free) {
|
||||
fprintf(stderr, "error: %s not implemented\n", __FUNCTION__);
|
||||
|
||||
if(document->file_path) {
|
||||
if (document->file_path) {
|
||||
free(document->file_path);
|
||||
}
|
||||
|
||||
|
@ -176,7 +176,7 @@ zathura_document_free(zathura_document_t* document)
|
|||
|
||||
bool r = document->functions.document_free(document);
|
||||
|
||||
if(document->file_path) {
|
||||
if (document->file_path) {
|
||||
free(document->file_path);
|
||||
}
|
||||
|
||||
|
@ -188,11 +188,11 @@ zathura_document_free(zathura_document_t* document)
|
|||
bool
|
||||
zathura_document_save_as(zathura_document_t* document, const char* path)
|
||||
{
|
||||
if(!document || !path) {
|
||||
if (!document || !path) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if(!document->functions.document_save_as) {
|
||||
if (!document->functions.document_save_as) {
|
||||
fprintf(stderr, "error: %s not implemented\n", __FUNCTION__);
|
||||
return false;
|
||||
}
|
||||
|
@ -203,11 +203,11 @@ zathura_document_save_as(zathura_document_t* document, const char* path)
|
|||
girara_tree_node_t*
|
||||
zathura_document_index_generate(zathura_document_t* document)
|
||||
{
|
||||
if(!document) {
|
||||
if (!document) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if(!document->functions.document_index_generate) {
|
||||
if (!document->functions.document_index_generate) {
|
||||
fprintf(stderr, "error: %s not implemented\n", __FUNCTION__);
|
||||
return NULL;
|
||||
}
|
||||
|
@ -224,11 +224,11 @@ zathura_document_index_free(zathura_list_t* list)
|
|||
zathura_list_t*
|
||||
zathura_document_attachments_get(zathura_document_t* document)
|
||||
{
|
||||
if(!document) {
|
||||
if (!document) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if(!document->functions.document_attachments_get) {
|
||||
if (!document->functions.document_attachments_get) {
|
||||
fprintf(stderr, "error: %s not implemented\n", __FUNCTION__);
|
||||
return NULL;
|
||||
}
|
||||
|
@ -245,18 +245,18 @@ zathura_document_attachments_free(zathura_list_t* list)
|
|||
zathura_page_t*
|
||||
zathura_page_get(zathura_document_t* document, unsigned int page_id)
|
||||
{
|
||||
if(!document) {
|
||||
if (!document) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if(!document->functions.page_get) {
|
||||
if (!document->functions.page_get) {
|
||||
fprintf(stderr, "error: %s not implemented\n", __FUNCTION__);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
zathura_page_t* page = document->functions.page_get(document, page_id);
|
||||
|
||||
if(page) {
|
||||
if (page) {
|
||||
page->number = page_id;
|
||||
page->rendered = false;
|
||||
g_static_mutex_init(&(page->lock));
|
||||
|
@ -268,11 +268,11 @@ zathura_page_get(zathura_document_t* document, unsigned int page_id)
|
|||
bool
|
||||
zathura_page_free(zathura_page_t* page)
|
||||
{
|
||||
if(!page || !page->document) {
|
||||
if (!page || !page->document) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if(!page->document->functions.page_free) {
|
||||
if (!page->document->functions.page_free) {
|
||||
fprintf(stderr, "error: %s not implemented\n", __FUNCTION__);
|
||||
return false;
|
||||
}
|
||||
|
@ -283,11 +283,11 @@ zathura_page_free(zathura_page_t* page)
|
|||
zathura_list_t*
|
||||
zathura_page_search_text(zathura_page_t* page, const char* text)
|
||||
{
|
||||
if(!page || !page->document || !text) {
|
||||
if (!page || !page->document || !text) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if(!page->document->functions.page_search_text) {
|
||||
if (!page->document->functions.page_search_text) {
|
||||
fprintf(stderr, "error: %s not implemented\n", __FUNCTION__);
|
||||
return NULL;
|
||||
}
|
||||
|
@ -298,11 +298,11 @@ zathura_page_search_text(zathura_page_t* page, const char* text)
|
|||
zathura_list_t*
|
||||
zathura_page_links_get(zathura_page_t* page)
|
||||
{
|
||||
if(!page || !page->document) {
|
||||
if (!page || !page->document) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if(!page->document->functions.page_links_get) {
|
||||
if (!page->document->functions.page_links_get) {
|
||||
fprintf(stderr, "error: %s not implemented\n", __FUNCTION__);
|
||||
return NULL;
|
||||
}
|
||||
|
@ -319,11 +319,11 @@ zathura_page_links_free(zathura_list_t* list)
|
|||
zathura_list_t*
|
||||
zathura_page_form_fields_get(zathura_page_t* page)
|
||||
{
|
||||
if(!page || !page->document) {
|
||||
if (!page || !page->document) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if(!page->document->functions.page_form_fields_get) {
|
||||
if (!page->document->functions.page_form_fields_get) {
|
||||
fprintf(stderr, "error: %s not implemented\n", __FUNCTION__);
|
||||
return NULL;
|
||||
}
|
||||
|
@ -340,18 +340,18 @@ zathura_page_form_fields_free(zathura_list_t* list)
|
|||
GtkWidget*
|
||||
zathura_page_render(zathura_page_t* page)
|
||||
{
|
||||
if(!page || !page->document) {
|
||||
if (!page || !page->document) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if(!page->document->functions.page_render) {
|
||||
if (!page->document->functions.page_render) {
|
||||
fprintf(stderr, "error: %s not implemented\n", __FUNCTION__);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
GtkWidget* widget = page->document->functions.page_render(page);
|
||||
|
||||
if(widget) {
|
||||
if (widget) {
|
||||
page->rendered = true;
|
||||
}
|
||||
|
||||
|
@ -361,13 +361,13 @@ 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;
|
||||
}
|
||||
|
||||
|
@ -379,13 +379,13 @@ zathura_index_element_new(const char* title)
|
|||
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);
|
||||
}
|
||||
|
||||
|
|
50
ft/pdf/pdf.c
50
ft/pdf/pdf.c
|
@ -9,7 +9,7 @@
|
|||
bool
|
||||
pdf_document_open(zathura_document_t* document)
|
||||
{
|
||||
if(!document) {
|
||||
if (!document) {
|
||||
goto error_out;
|
||||
}
|
||||
|
||||
|
@ -25,7 +25,7 @@ pdf_document_open(zathura_document_t* document)
|
|||
document->functions.page_free = pdf_page_free;
|
||||
|
||||
document->data = malloc(sizeof(pdf_document_t));
|
||||
if(!document->data) {
|
||||
if (!document->data) {
|
||||
goto error_out;
|
||||
}
|
||||
|
||||
|
@ -33,7 +33,7 @@ pdf_document_open(zathura_document_t* document)
|
|||
GError* error = NULL;
|
||||
char* file_uri = g_filename_to_uri(document->file_path, NULL, &error);
|
||||
|
||||
if(!file_uri) {
|
||||
if (!file_uri) {
|
||||
fprintf(stderr, "error: could not open file: %s\n", error->message);
|
||||
goto error_free;
|
||||
}
|
||||
|
@ -41,7 +41,7 @@ pdf_document_open(zathura_document_t* document)
|
|||
pdf_document_t* pdf_document = (pdf_document_t*) document->data;
|
||||
pdf_document->document = poppler_document_new_from_file(file_uri, document->password, &error);
|
||||
|
||||
if(!pdf_document->document) {
|
||||
if (!pdf_document->document) {
|
||||
fprintf(stderr, "error: could not open file: %s\n", error->message);
|
||||
goto error_free;
|
||||
}
|
||||
|
@ -54,11 +54,11 @@ pdf_document_open(zathura_document_t* document)
|
|||
|
||||
error_free:
|
||||
|
||||
if(error) {
|
||||
if (error) {
|
||||
g_error_free(error);
|
||||
}
|
||||
|
||||
if(file_uri) {
|
||||
if (file_uri) {
|
||||
g_free(file_uri);
|
||||
}
|
||||
|
||||
|
@ -73,11 +73,11 @@ error_out:
|
|||
bool
|
||||
pdf_document_free(zathura_document_t* document)
|
||||
{
|
||||
if(!document) {
|
||||
if (!document) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if(document->data) {
|
||||
if (document->data) {
|
||||
pdf_document_t* pdf_document = (pdf_document_t*) document->data;
|
||||
g_object_unref(pdf_document->document);
|
||||
free(document->data);
|
||||
|
@ -90,7 +90,7 @@ 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;
|
||||
}
|
||||
|
||||
|
@ -98,22 +98,22 @@ build_index(pdf_document_t* pdf, girara_tree_node_t* root, PopplerIndexIter* ite
|
|||
{
|
||||
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) {
|
||||
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);
|
||||
}
|
||||
|
@ -131,7 +131,7 @@ build_index(pdf_document_t* pdf, girara_tree_node_t* root, PopplerIndexIter* ite
|
|||
girara_tree_node_t* node = girara_node_append_data(root, indexelement);
|
||||
PopplerIndexIter* child = poppler_index_iter_get_child(iter);
|
||||
|
||||
if(child) {
|
||||
if (child) {
|
||||
build_index(pdf, node, child);
|
||||
}
|
||||
|
||||
|
@ -143,14 +143,14 @@ build_index(pdf_document_t* pdf, girara_tree_node_t* root, PopplerIndexIter* ite
|
|||
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) {
|
||||
if (!iter) {
|
||||
// XXX: error message?
|
||||
return NULL;
|
||||
}
|
||||
|
@ -166,7 +166,7 @@ pdf_document_index_generate(zathura_document_t* document)
|
|||
bool
|
||||
pdf_document_save_as(zathura_document_t* document, const char* path)
|
||||
{
|
||||
if(!document || !document->data || !path) {
|
||||
if (!document || !document->data || !path) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -188,21 +188,21 @@ pdf_document_attachments_get(zathura_document_t* document)
|
|||
zathura_page_t*
|
||||
pdf_page_get(zathura_document_t* document, unsigned int page)
|
||||
{
|
||||
if(!document || !document->data) {
|
||||
if (!document || !document->data) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
pdf_document_t* pdf_document = (pdf_document_t*) document->data;
|
||||
zathura_page_t* document_page = malloc(sizeof(zathura_page_t));
|
||||
|
||||
if(!document_page) {
|
||||
if (!document_page) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
document_page->document = document;
|
||||
document_page->data = poppler_document_get_page(pdf_document->document, page);
|
||||
|
||||
if(!document_page->data) {
|
||||
if (!document_page->data) {
|
||||
free(document_page);
|
||||
return NULL;
|
||||
}
|
||||
|
@ -215,7 +215,7 @@ pdf_page_get(zathura_document_t* document, unsigned int page)
|
|||
bool
|
||||
pdf_page_free(zathura_page_t* page)
|
||||
{
|
||||
if(!page) {
|
||||
if (!page) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -246,7 +246,7 @@ pdf_page_form_fields_get(zathura_page_t* page)
|
|||
GtkWidget*
|
||||
pdf_page_render(zathura_page_t* page)
|
||||
{
|
||||
if(!Zathura.document || !page || !page->data || !page->document) {
|
||||
if (!Zathura.document || !page || !page->data || !page->document) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
@ -254,7 +254,7 @@ pdf_page_render(zathura_page_t* page)
|
|||
unsigned int page_width = Zathura.document->scale * page->width;
|
||||
unsigned int page_height = Zathura.document->scale * page->height;
|
||||
|
||||
if(Zathura.document->rotate == 90 || Zathura.document->rotate == 270) {
|
||||
if (Zathura.document->rotate == 90 || Zathura.document->rotate == 270) {
|
||||
unsigned int dim_temp = 0;
|
||||
dim_temp = page_width;
|
||||
page_width = page_height;
|
||||
|
@ -265,7 +265,7 @@ pdf_page_render(zathura_page_t* page)
|
|||
GdkPixbuf* pixbuf = gdk_pixbuf_new(GDK_COLORSPACE_RGB, FALSE, 8,
|
||||
page_width, page_height);
|
||||
|
||||
if(!pixbuf) {
|
||||
if (!pixbuf) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
@ -275,7 +275,7 @@ pdf_page_render(zathura_page_t* page)
|
|||
/* write pixbuf */
|
||||
GtkWidget* image = gtk_image_new();
|
||||
|
||||
if(!image) {
|
||||
if (!image) {
|
||||
g_object_unref(pixbuf);
|
||||
return NULL;
|
||||
}
|
||||
|
|
36
render.c
36
render.c
|
@ -9,10 +9,10 @@ render_job(void* data)
|
|||
{
|
||||
render_thread_t* render_thread = (render_thread_t*) data;
|
||||
|
||||
while(true) {
|
||||
while (true) {
|
||||
g_mutex_lock(render_thread->lock);
|
||||
|
||||
if(girara_list_size(render_thread->list) <= 0) {
|
||||
if (girara_list_size(render_thread->list) <= 0) {
|
||||
g_cond_wait(render_thread->cond, render_thread->lock);
|
||||
}
|
||||
|
||||
|
@ -33,7 +33,7 @@ render_init(void)
|
|||
{
|
||||
render_thread_t* render_thread = malloc(sizeof(render_thread_t));
|
||||
|
||||
if(!render_thread) {
|
||||
if (!render_thread) {
|
||||
goto error_ret;
|
||||
}
|
||||
|
||||
|
@ -45,25 +45,25 @@ render_init(void)
|
|||
/* setup */
|
||||
render_thread->list = girara_list_new();
|
||||
|
||||
if(!render_thread->list) {
|
||||
if (!render_thread->list) {
|
||||
goto error_free;
|
||||
}
|
||||
|
||||
render_thread->thread = g_thread_create(render_job, render_thread, TRUE, NULL);
|
||||
|
||||
if(!render_thread->thread) {
|
||||
if (!render_thread->thread) {
|
||||
goto error_free;
|
||||
}
|
||||
|
||||
render_thread->cond = g_cond_new();
|
||||
|
||||
if(!render_thread->cond) {
|
||||
if (!render_thread->cond) {
|
||||
goto error_free;
|
||||
}
|
||||
|
||||
render_thread->lock = g_mutex_new();
|
||||
|
||||
if(!render_thread->lock) {
|
||||
if (!render_thread->lock) {
|
||||
goto error_free;
|
||||
}
|
||||
|
||||
|
@ -71,15 +71,15 @@ render_init(void)
|
|||
|
||||
error_free:
|
||||
|
||||
if(render_thread->list) {
|
||||
if (render_thread->list) {
|
||||
girara_list_free(render_thread->list);
|
||||
}
|
||||
|
||||
if(render_thread->cond) {
|
||||
if (render_thread->cond) {
|
||||
g_cond_free(render_thread->cond);
|
||||
}
|
||||
|
||||
if(render_thread->lock) {
|
||||
if (render_thread->lock) {
|
||||
g_mutex_free(render_thread->lock);
|
||||
}
|
||||
|
||||
|
@ -93,19 +93,19 @@ error_ret:
|
|||
void
|
||||
render_free(render_thread_t* render_thread)
|
||||
{
|
||||
if(!render_thread) {
|
||||
if (!render_thread) {
|
||||
return;
|
||||
}
|
||||
|
||||
if(render_thread->list) {
|
||||
if (render_thread->list) {
|
||||
girara_list_free(render_thread->list);
|
||||
}
|
||||
|
||||
if(render_thread->cond) {
|
||||
if (render_thread->cond) {
|
||||
g_cond_free(render_thread->cond);
|
||||
}
|
||||
|
||||
if(render_thread->lock) {
|
||||
if (render_thread->lock) {
|
||||
g_mutex_free(render_thread->lock);
|
||||
}
|
||||
}
|
||||
|
@ -113,12 +113,12 @@ render_free(render_thread_t* render_thread)
|
|||
bool
|
||||
render_page(render_thread_t* render_thread, zathura_page_t* page)
|
||||
{
|
||||
if(!render_thread || !page || !render_thread->list || page->rendered) {
|
||||
if (!render_thread || !page || !render_thread->list || page->rendered) {
|
||||
return false;
|
||||
}
|
||||
|
||||
g_mutex_lock(render_thread->lock);
|
||||
if(!girara_list_contains(render_thread->list, page)) {
|
||||
if (!girara_list_contains(render_thread->list, page)) {
|
||||
girara_list_append(render_thread->list, page);
|
||||
}
|
||||
g_cond_signal(render_thread->cond);
|
||||
|
@ -133,7 +133,7 @@ render(zathura_page_t* page)
|
|||
g_static_mutex_lock(&(page->lock));
|
||||
GtkWidget* image = zathura_page_render(page);
|
||||
|
||||
if(!image) {
|
||||
if (!image) {
|
||||
g_static_mutex_unlock(&(page->lock));
|
||||
printf("error: rendering failed\n");
|
||||
return false;
|
||||
|
@ -144,7 +144,7 @@ render(zathura_page_t* page)
|
|||
GtkWidget* widget = (GtkWidget*) g_list_nth_data(list, page->number);
|
||||
g_list_free(list);
|
||||
|
||||
if(!widget) {
|
||||
if (!widget) {
|
||||
g_static_mutex_unlock(&(page->lock));
|
||||
printf("error: page container does not exist\n");
|
||||
g_object_unref(image);
|
||||
|
|
12
shortcuts.c
12
shortcuts.c
|
@ -44,11 +44,11 @@ sc_focus_inputbar(girara_session_t* session, girara_argument_t* argument)
|
|||
{
|
||||
g_return_val_if_fail(session != NULL, false);
|
||||
|
||||
if(!(GTK_WIDGET_VISIBLE(GTK_WIDGET(session->gtk.inputbar)))) {
|
||||
if (!(GTK_WIDGET_VISIBLE(GTK_WIDGET(session->gtk.inputbar)))) {
|
||||
gtk_widget_show(GTK_WIDGET(session->gtk.inputbar));
|
||||
}
|
||||
|
||||
if(argument->data) {
|
||||
if (argument->data) {
|
||||
gtk_entry_set_text(session->gtk.inputbar, (char*) argument->data);
|
||||
gtk_widget_grab_focus(GTK_WIDGET(session->gtk.inputbar));
|
||||
gtk_editable_set_position(GTK_EDITABLE(session->gtk.inputbar), -1);
|
||||
|
@ -72,16 +72,16 @@ sc_goto(girara_session_t* session, girara_argument_t* argument)
|
|||
bool
|
||||
sc_navigate(girara_session_t* session, girara_argument_t* argument)
|
||||
{
|
||||
if(!session || !argument || !Zathura.document) {
|
||||
if (!session || !argument || !Zathura.document) {
|
||||
return false;
|
||||
}
|
||||
|
||||
unsigned int number_of_pages = Zathura.document->number_of_pages;
|
||||
unsigned int new_page = Zathura.document->current_page_number;
|
||||
|
||||
if(argument->n == NEXT) {
|
||||
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;
|
||||
}
|
||||
|
||||
|
@ -112,7 +112,7 @@ bool
|
|||
sc_scroll(girara_session_t* session, girara_argument_t* argument)
|
||||
{
|
||||
GtkAdjustment* adjustment = NULL;
|
||||
if( (argument->n == LEFT) || (argument->n == RIGHT) )
|
||||
if ( (argument->n == LEFT) || (argument->n == RIGHT) )
|
||||
adjustment = gtk_scrolled_window_get_hadjustment(GTK_SCROLLED_WINDOW(Zathura.UI.session->gtk.view));
|
||||
else
|
||||
adjustment = gtk_scrolled_window_get_vadjustment(GTK_SCROLLED_WINDOW(Zathura.UI.session->gtk.view));
|
||||
|
|
40
utils.c
40
utils.c
|
@ -14,7 +14,7 @@
|
|||
bool
|
||||
file_exists(const char* path)
|
||||
{
|
||||
if(!access(path, F_OK)) {
|
||||
if (!access(path, F_OK)) {
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
|
@ -24,21 +24,21 @@ file_exists(const char* path)
|
|||
const char*
|
||||
file_get_extension(const char* path)
|
||||
{
|
||||
if(!path) {
|
||||
if (!path) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
unsigned int i = strlen(path);
|
||||
for(; i > 0; i--)
|
||||
for (; i > 0; i--)
|
||||
{
|
||||
if(*(path + i) != '.') {
|
||||
if (*(path + i) != '.') {
|
||||
continue;
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if(!i) {
|
||||
if (!i) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
@ -48,24 +48,24 @@ file_get_extension(const char* path)
|
|||
bool
|
||||
execute_command(char* const argv[], char** output)
|
||||
{
|
||||
if(!output) {
|
||||
if (!output) {
|
||||
return false;
|
||||
}
|
||||
|
||||
int p[2];
|
||||
if(pipe(p)) {
|
||||
if (pipe(p)) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
pid_t pid = fork();
|
||||
|
||||
if(pid == -1) { // failure
|
||||
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) {
|
||||
if (execvp(argv[0], argv) == -1) {
|
||||
return false;
|
||||
}
|
||||
} else { // parent
|
||||
|
@ -78,20 +78,20 @@ execute_command(char* const argv[], char** output)
|
|||
char* buffer = malloc(sizeof(char) * bc);
|
||||
*output = NULL;
|
||||
|
||||
if(!buffer) {
|
||||
if (!buffer) {
|
||||
close(p[0]);
|
||||
return false;
|
||||
}
|
||||
|
||||
char c;
|
||||
while(1 == read(p[0], &c, 1)) {
|
||||
while (1 == read(p[0], &c, 1)) {
|
||||
buffer[i++] = c;
|
||||
|
||||
if(i == bc) {
|
||||
if (i == bc) {
|
||||
bc += BLOCK_SIZE;
|
||||
char* tmp = realloc(buffer, sizeof(char) * bc);
|
||||
|
||||
if(!tmp) {
|
||||
if (!tmp) {
|
||||
free(buffer);
|
||||
close(p[0]);
|
||||
return false;
|
||||
|
@ -102,7 +102,7 @@ execute_command(char* const argv[], char** output)
|
|||
}
|
||||
|
||||
char* tmp = realloc(buffer, sizeof(char) * (bc + 1));
|
||||
if(!tmp) {
|
||||
if (!tmp) {
|
||||
free(buffer);
|
||||
close(p[0]);
|
||||
return false;
|
||||
|
@ -124,31 +124,31 @@ execute_command(char* const argv[], char** output)
|
|||
GtkWidget*
|
||||
page_blank(unsigned int width, unsigned int height)
|
||||
{
|
||||
if((width == 0) || (height == 0)) {
|
||||
if ((width == 0) || (height == 0)) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
guchar* buffer = malloc(sizeof(guchar) * (width * height * 1));
|
||||
if(!buffer) {
|
||||
if (!buffer) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* draw white */
|
||||
for(unsigned int i = 0; i < width * height; i++) {
|
||||
for (unsigned int i = 0; i < width * height; i++) {
|
||||
buffer[i] = 255;
|
||||
}
|
||||
|
||||
GdkPixbuf* pixbuf = gdk_pixbuf_new_from_data(buffer, GDK_COLORSPACE_RGB, FALSE, 8,
|
||||
width, height, 1, NULL, NULL);
|
||||
|
||||
if(!pixbuf) {
|
||||
if (!pixbuf) {
|
||||
free(buffer);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* convert to image */
|
||||
GtkWidget* image = gtk_image_new();
|
||||
if(!image) {
|
||||
if (!image) {
|
||||
free(buffer);
|
||||
g_object_unref(pixbuf);
|
||||
return false;
|
||||
|
|
42
zathura.c
42
zathura.c
|
@ -14,11 +14,11 @@ bool
|
|||
init_zathura()
|
||||
{
|
||||
/* UI */
|
||||
if(!(Zathura.UI.session = girara_session_create())) {
|
||||
if (!(Zathura.UI.session = girara_session_create())) {
|
||||
goto error_out;
|
||||
}
|
||||
|
||||
if(!girara_session_init(Zathura.UI.session)) {
|
||||
if (!girara_session_init(Zathura.UI.session)) {
|
||||
goto error_out;
|
||||
}
|
||||
|
||||
|
@ -29,7 +29,7 @@ init_zathura()
|
|||
|
||||
/* page view */
|
||||
Zathura.UI.page_view = gtk_vbox_new(FALSE, 0);
|
||||
if(!Zathura.UI.page_view) {
|
||||
if (!Zathura.UI.page_view) {
|
||||
goto error_free;
|
||||
}
|
||||
|
||||
|
@ -38,17 +38,17 @@ init_zathura()
|
|||
|
||||
/* statusbar */
|
||||
Zathura.UI.statusbar.file = girara_statusbar_item_add(Zathura.UI.session, TRUE, TRUE, TRUE, NULL);
|
||||
if(!Zathura.UI.statusbar.file) {
|
||||
if (!Zathura.UI.statusbar.file) {
|
||||
goto error_free;
|
||||
}
|
||||
|
||||
Zathura.UI.statusbar.buffer = girara_statusbar_item_add(Zathura.UI.session, FALSE, FALSE, FALSE, NULL);
|
||||
if(!Zathura.UI.statusbar.buffer) {
|
||||
if (!Zathura.UI.statusbar.buffer) {
|
||||
goto error_free;
|
||||
}
|
||||
|
||||
Zathura.UI.statusbar.page_number = girara_statusbar_item_add(Zathura.UI.session, FALSE, FALSE, FALSE, NULL);
|
||||
if(!Zathura.UI.statusbar.page_number) {
|
||||
if (!Zathura.UI.statusbar.page_number) {
|
||||
goto error_free;
|
||||
}
|
||||
|
||||
|
@ -70,7 +70,7 @@ init_zathura()
|
|||
|
||||
error_free:
|
||||
|
||||
if(Zathura.UI.page_view) {
|
||||
if (Zathura.UI.page_view) {
|
||||
g_object_unref(Zathura.UI.page_view);
|
||||
}
|
||||
|
||||
|
@ -84,25 +84,25 @@ error_out:
|
|||
bool
|
||||
document_open(const char* path, const char* password)
|
||||
{
|
||||
if(!path) {
|
||||
if (!path) {
|
||||
goto error_out;
|
||||
}
|
||||
|
||||
zathura_document_t* document = zathura_document_open(path, password);
|
||||
|
||||
if(!document) {
|
||||
if (!document) {
|
||||
goto error_out;
|
||||
}
|
||||
|
||||
Zathura.document = document;
|
||||
|
||||
/* create blank pages */
|
||||
for(unsigned int i = 0; i < document->number_of_pages; i++)
|
||||
for (unsigned int i = 0; i < document->number_of_pages; i++)
|
||||
{
|
||||
/* create blank page */
|
||||
GtkWidget* image = page_blank(document->pages[i]->width, document->pages[i]->height);
|
||||
|
||||
if(!image) {
|
||||
if (!image) {
|
||||
goto error_free;
|
||||
}
|
||||
|
||||
|
@ -115,12 +115,12 @@ document_open(const char* path, const char* password)
|
|||
/* threads */
|
||||
Zathura.Sync.render_thread = render_init();
|
||||
|
||||
if(!Zathura.Sync.render_thread) {
|
||||
if (!Zathura.Sync.render_thread) {
|
||||
goto error_free;
|
||||
}
|
||||
|
||||
/* first page */
|
||||
if(!page_set(0)) {
|
||||
if (!page_set(0)) {
|
||||
goto error_free;
|
||||
}
|
||||
|
||||
|
@ -138,11 +138,11 @@ error_out:
|
|||
bool
|
||||
document_close()
|
||||
{
|
||||
if(!Zathura.document) {
|
||||
if (!Zathura.document) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if(Zathura.Sync.render_thread) {
|
||||
if (Zathura.Sync.render_thread) {
|
||||
render_free(Zathura.Sync.render_thread);
|
||||
}
|
||||
|
||||
|
@ -154,18 +154,18 @@ document_close()
|
|||
bool
|
||||
page_set(unsigned int page_id)
|
||||
{
|
||||
if(!Zathura.document || !Zathura.document->pages) {
|
||||
if (!Zathura.document || !Zathura.document->pages) {
|
||||
goto error_out;
|
||||
}
|
||||
|
||||
if(page_id >= Zathura.document->number_of_pages) {
|
||||
if (page_id >= Zathura.document->number_of_pages) {
|
||||
goto error_out;
|
||||
}
|
||||
|
||||
/* render page */
|
||||
zathura_page_t* page = Zathura.document->pages[page_id];
|
||||
|
||||
if(!page) {
|
||||
if (!page) {
|
||||
goto error_out;
|
||||
}
|
||||
|
||||
|
@ -193,13 +193,13 @@ int main(int argc, char* argv[])
|
|||
gdk_threads_init();
|
||||
gtk_init(&argc, &argv);
|
||||
|
||||
if(!init_zathura()) {
|
||||
if (!init_zathura()) {
|
||||
printf("error: coult not initialize zathura\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
if(argc > 1) {
|
||||
if(!document_open(argv[1], NULL)) {
|
||||
if (argc > 1) {
|
||||
if (!document_open(argv[1], NULL)) {
|
||||
printf("error: could not open document\n");
|
||||
return -1;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue