Merge branch 'render' of pwmt.org:zathura into render

Conflicts:
	render.h
This commit is contained in:
Sebastian Ramacher 2011-04-18 18:21:02 +02:00
commit 0aa9264732
6 changed files with 135 additions and 79 deletions

View file

@ -218,13 +218,13 @@ djvu_page_form_fields_get(zathura_page_t* page)
zathura_image_buffer_t* zathura_image_buffer_t*
djvu_page_render(zathura_page_t* page) djvu_page_render(zathura_page_t* page)
{ {
if (!Zathura.document || !page || !page->document) { if (!page || !page->document) {
return NULL; return NULL;
} }
/* calculate sizes */ /* calculate sizes */
unsigned int page_width = Zathura.document->scale * page->width; unsigned int page_width = page->document->scale * page->width;
unsigned int page_height = Zathura.document->scale * page->height; unsigned int page_height = page->document->scale * page->height;
if (!page_width || !page_height) { if (!page_width || !page_height) {
goto error_out; goto error_out;

View file

@ -176,15 +176,15 @@ pdf_page_form_fields_get(zathura_page_t* page)
zathura_image_buffer_t* zathura_image_buffer_t*
pdf_page_render(zathura_page_t* page) pdf_page_render(zathura_page_t* page)
{ {
if (!Zathura.document || !page || !page->data || !page->document) { if (!page || !page->data || !page->document) {
return NULL; return NULL;
} }
/* calculate sizes */ /* calculate sizes */
unsigned int page_width = Zathura.document->scale * page->width; unsigned int page_width = page->document->scale * page->width;
unsigned int page_height = Zathura.document->scale * page->height; unsigned int page_height = page->document->scale * page->height;
if (Zathura.document->rotate == 90 || Zathura.document->rotate == 270) { if (page->document->rotate == 90 || page->document->rotate == 270) {
unsigned int dim_temp = 0; unsigned int dim_temp = 0;
dim_temp = page_width; dim_temp = page_width;
page_width = page_height; page_width = page_height;
@ -215,9 +215,9 @@ pdf_page_render(zathura_page_t* page)
fz_matrix ctm = fz_identity; fz_matrix ctm = fz_identity;
ctm = fz_concat(ctm, fz_translate(0, -mupdf_page->page->mediabox.y1)); ctm = fz_concat(ctm, fz_translate(0, -mupdf_page->page->mediabox.y1));
ctm = fz_concat(ctm, fz_scale(Zathura.document->scale, -Zathura.document->scale)); ctm = fz_concat(ctm, fz_scale(page->document->scale, -page->document->scale));
ctm = fz_concat(ctm, fz_rotate(mupdf_page->page->rotate)); ctm = fz_concat(ctm, fz_rotate(mupdf_page->page->rotate));
ctm = fz_concat(ctm, fz_rotate(Zathura.document->rotate)); ctm = fz_concat(ctm, fz_rotate(page->document->rotate));
fz_bbox bbox = fz_roundrect(fz_transformrect(ctm, mupdf_page->page->mediabox)); fz_bbox bbox = fz_roundrect(fz_transformrect(ctm, mupdf_page->page->mediabox));
fz_pixmap* pixmap = fz_newpixmapwithrect(fz_devicergb, bbox); fz_pixmap* pixmap = fz_newpixmapwithrect(fz_devicergb, bbox);

View file

@ -253,13 +253,13 @@ pdf_page_form_fields_get(zathura_page_t* page)
zathura_image_buffer_t* zathura_image_buffer_t*
pdf_page_render(zathura_page_t* page) pdf_page_render(zathura_page_t* page)
{ {
if (!Zathura.document || !page || !page->data || !page->document) { if (!page || !page->data || !page->document) {
return NULL; return NULL;
} }
/* calculate sizes */ /* calculate sizes */
unsigned int page_width = Zathura.document->scale * page->width; unsigned int page_width = page->document->scale * page->width;
unsigned int page_height = Zathura.document->scale * page->height; unsigned int page_height = page->document->scale * page->height;
/* create pixbuf */ /* create pixbuf */
GdkPixbuf* pixbuf = gdk_pixbuf_new(GDK_COLORSPACE_RGB, FALSE, 8, GdkPixbuf* pixbuf = gdk_pixbuf_new(GDK_COLORSPACE_RGB, FALSE, 8,
@ -270,7 +270,7 @@ pdf_page_render(zathura_page_t* page)
} }
poppler_page_render_to_pixbuf(page->data, 0, 0, page_width, page_height, poppler_page_render_to_pixbuf(page->data, 0, 0, page_width, page_height,
Zathura.document->scale, 90, pixbuf); page->document->scale, 90, pixbuf);
/* create image buffer */ /* create image buffer */
zathura_image_buffer_t* image_buffer = zathura_image_buffer_create(page_width, page_height); zathura_image_buffer_t* image_buffer = zathura_image_buffer_create(page_width, page_height);

View file

@ -20,7 +20,7 @@ render_job(void* data)
girara_list_remove(render_thread->list, page); girara_list_remove(render_thread->list, page);
g_mutex_unlock(render_thread->lock); g_mutex_unlock(render_thread->lock);
if (render(page) != true) { if (render(render_thread->zathura, page) != true) {
fprintf(stderr, "rendering failed\n"); fprintf(stderr, "rendering failed\n");
} }
@ -31,7 +31,7 @@ render_job(void* data)
} }
render_thread_t* render_thread_t*
render_init(void) render_init(zathura_t* zathura)
{ {
render_thread_t* render_thread = malloc(sizeof(render_thread_t)); render_thread_t* render_thread = malloc(sizeof(render_thread_t));
@ -40,9 +40,10 @@ render_init(void)
} }
/* init */ /* init */
render_thread->list = NULL; render_thread->list = NULL;
render_thread->thread = NULL; render_thread->thread = NULL;
render_thread->cond = NULL; render_thread->cond = NULL;
render_thread->zathura = zathura;
/* setup */ /* setup */
render_thread->list = girara_list_new(); render_thread->list = girara_list_new();
@ -130,7 +131,7 @@ render_page(render_thread_t* render_thread, zathura_page_t* page)
} }
bool bool
render(zathura_page_t* page) render(zathura_t* zathura, zathura_page_t* page)
{ {
gdk_threads_enter(); gdk_threads_enter();
g_static_mutex_lock(&(page->lock)); g_static_mutex_lock(&(page->lock));
@ -149,8 +150,8 @@ render(zathura_page_t* page)
} }
/* create cairo surface */ /* create cairo surface */
unsigned int page_width = page->width * Zathura.document->scale; unsigned int page_width = page->width * zathura->document->scale;
unsigned int page_height = page->height * Zathura.document->scale; unsigned int page_height = page->height * zathura->document->scale;
cairo_surface_t* surface = cairo_image_surface_create(CAIRO_FORMAT_RGB24, page_width, page_height); cairo_surface_t* surface = cairo_image_surface_create(CAIRO_FORMAT_RGB24, page_width, page_height);
@ -183,18 +184,18 @@ render(zathura_page_t* page)
} }
void void
render_all(void) render_all(zathura_t* zathura)
{ {
if (Zathura.document == NULL) { if (zathura->document == NULL) {
return; return;
} }
/* unmark all pages */ /* unmark all pages */
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.document->pages[page_id]->rendered = false; zathura->document->pages[page_id]->rendered = false;
} }
/* redraw current page */ /* redraw current page */
GtkAdjustment* view_vadjustment = gtk_scrolled_window_get_vadjustment(GTK_SCROLLED_WINDOW(Zathura.UI.session->gtk.view)); GtkAdjustment* view_vadjustment = gtk_scrolled_window_get_vadjustment(GTK_SCROLLED_WINDOW(zathura->UI.session->gtk.view));
cb_view_vadjustment_value_changed(view_vadjustment, NULL); cb_view_vadjustment_value_changed(view_vadjustment, NULL);
} }

View file

@ -16,14 +16,16 @@ struct render_thread_s
GThread* thread; /**> The thread object */ GThread* thread; /**> The thread object */
GMutex* lock; /**> Lock */ GMutex* lock; /**> Lock */
GCond* cond; /**> Condition */ GCond* cond; /**> Condition */
zathura_t* zathura; /**> Zathura object */
}; };
/** /**
* This function initializes a render thread * This function initializes a render thread
* *
* @param Zathura object
* @return The render thread object or NULL if an error occured * @return The render thread object or NULL if an error occured
*/ */
render_thread_t* render_init(void); render_thread_t* render_init(zathura_t* zathura);
/** /**
* This function destroys the render thread object * This function destroys the render thread object
@ -46,7 +48,9 @@ bool render_page(render_thread_t* render_thread, zathura_page_t* page);
* This function is used to unmark all pages as not rendered. This should * This function is used to unmark all pages as not rendered. This should
* be used if all pages should be rendered again (e.g.: the zoom level or the * be used if all pages should be rendered again (e.g.: the zoom level or the
* colors have changed) * colors have changed)
*
* @param zathura Zathura object
*/ */
void render_all(void); void render_all(zathura_t* zathura);
#endif // RENDER_H #endif // RENDER_H

View file

@ -13,6 +13,8 @@ bool
sc_abort(girara_session_t* session, girara_argument_t* argument, unsigned int t) sc_abort(girara_session_t* session, girara_argument_t* argument, unsigned int t)
{ {
g_return_val_if_fail(session != NULL, false); g_return_val_if_fail(session != NULL, false);
g_return_val_if_fail(session->global.data != NULL, false);
zathura_t* zathura = session->global.data;
girara_mode_set(session, NORMAL); girara_mode_set(session, NORMAL);
@ -22,12 +24,20 @@ sc_abort(girara_session_t* session, girara_argument_t* argument, unsigned int t)
bool bool
sc_adjust_window(girara_session_t* session, girara_argument_t* argument, unsigned int t) sc_adjust_window(girara_session_t* session, girara_argument_t* argument, unsigned int t)
{ {
g_return_val_if_fail(session != NULL, false);
g_return_val_if_fail(session->global.data != NULL, false);
zathura_t* zathura = session->global.data;
return false; return false;
} }
bool bool
sc_change_buffer(girara_session_t* session, girara_argument_t* argument, unsigned int t) sc_change_buffer(girara_session_t* session, girara_argument_t* argument, unsigned int t)
{ {
g_return_val_if_fail(session != NULL, false);
g_return_val_if_fail(session->global.data != NULL, false);
zathura_t* zathura = session->global.data;
return false; return false;
} }
@ -35,6 +45,8 @@ bool
sc_change_mode(girara_session_t* session, girara_argument_t* argument, unsigned int t) sc_change_mode(girara_session_t* session, girara_argument_t* argument, unsigned int t)
{ {
g_return_val_if_fail(session != NULL, false); g_return_val_if_fail(session != NULL, false);
g_return_val_if_fail(session->global.data != NULL, false);
zathura_t* zathura = session->global.data;
girara_mode_set(session, argument->n); girara_mode_set(session, argument->n);
@ -45,6 +57,8 @@ bool
sc_focus_inputbar(girara_session_t* session, girara_argument_t* argument, unsigned int t) sc_focus_inputbar(girara_session_t* session, girara_argument_t* argument, unsigned int t)
{ {
g_return_val_if_fail(session != NULL, false); g_return_val_if_fail(session != NULL, false);
g_return_val_if_fail(session->global.data != NULL, false);
zathura_t* zathura = session->global.data;
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)); gtk_widget_show(GTK_WIDGET(session->gtk.inputbar));
@ -62,15 +76,21 @@ sc_focus_inputbar(girara_session_t* session, girara_argument_t* argument, unsign
bool bool
sc_follow(girara_session_t* session, girara_argument_t* argument, unsigned int t) sc_follow(girara_session_t* session, girara_argument_t* argument, unsigned int t)
{ {
g_return_val_if_fail(session != NULL, false);
g_return_val_if_fail(session->global.data != NULL, false);
zathura_t* zathura = session->global.data;
return false; return false;
} }
bool bool
sc_goto(girara_session_t* session, girara_argument_t* argument, unsigned int t) sc_goto(girara_session_t* session, girara_argument_t* argument, unsigned int t)
{ {
if (session == NULL || argument == NULL || Zathura.document == NULL) { g_return_val_if_fail(session != NULL, false);
return false; g_return_val_if_fail(session->global.data != NULL, false);
} zathura_t* zathura = session->global.data;
g_return_val_if_fail(argument != NULL, false);
g_return_val_if_fail(zathura->document != NULL, false);
if (argument->n == TOP) { if (argument->n == TOP) {
girara_argument_t arg = { TOP, NULL }; girara_argument_t arg = { TOP, NULL };
@ -85,12 +105,12 @@ sc_goto(girara_session_t* session, girara_argument_t* argument, unsigned int t)
return true; return true;
} }
unsigned int number_of_pages = Zathura.document->number_of_pages; unsigned int number_of_pages = zathura->document->number_of_pages;
if (t > 0 && t <= number_of_pages) { if (t > 0 && t <= number_of_pages) {
// TODO: Calculate offset // TODO: Calculate offset
/*GtkAdjustment* adjustment = gtk_scrolled_window_get_vadjustment(GTK_SCROLLED_WINDOW(Zathura.UI.session->gtk.view));*/ /*GtkAdjustment* adjustment = gtk_scrolled_window_get_vadjustment(GTK_SCROLLED_WINDOW(zathura->UI.session->gtk.view));*/
/*unsigned int offset = Zathura.document->pages[t - 1]->offset * Zathura.document->scale;*/ /*unsigned int offset = zathura->document->pages[t - 1]->offset * zathura->document->scale;*/
/*gtk_adjustment_set_value(adjustment, offset);*/ /*gtk_adjustment_set_value(adjustment, offset);*/
} }
} }
@ -101,12 +121,14 @@ sc_goto(girara_session_t* session, girara_argument_t* argument, unsigned int t)
bool bool
sc_navigate(girara_session_t* session, girara_argument_t* argument, unsigned int t) sc_navigate(girara_session_t* session, girara_argument_t* argument, unsigned int t)
{ {
if (session == NULL || argument == NULL || Zathura.document == NULL) { g_return_val_if_fail(session != NULL, false);
return false; g_return_val_if_fail(session->global.data != NULL, false);
} zathura_t* zathura = session->global.data;
g_return_val_if_fail(argument != NULL, false);
g_return_val_if_fail(zathura->document != NULL, false);
unsigned int number_of_pages = Zathura.document->number_of_pages; unsigned int number_of_pages = zathura->document->number_of_pages;
unsigned int new_page = Zathura.document->current_page_number; 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; new_page = (new_page + 1) % number_of_pages;
@ -122,24 +144,35 @@ sc_navigate(girara_session_t* session, girara_argument_t* argument, unsigned int
bool bool
sc_recolor(girara_session_t* session, girara_argument_t* argument, unsigned int t) sc_recolor(girara_session_t* session, girara_argument_t* argument, unsigned int t)
{ {
g_return_val_if_fail(session != NULL, false);
g_return_val_if_fail(session->global.data != NULL, false);
zathura_t* zathura = session->global.data;
return false; return false;
} }
bool bool
sc_reload(girara_session_t* session, girara_argument_t* argument, unsigned int t) sc_reload(girara_session_t* session, girara_argument_t* argument, unsigned int t)
{ {
g_return_val_if_fail(session != NULL, false);
g_return_val_if_fail(session->global.data != NULL, false);
zathura_t* zathura = session->global.data;
return false; return false;
} }
bool bool
sc_rotate(girara_session_t* session, girara_argument_t* argument, unsigned int t) sc_rotate(girara_session_t* session, girara_argument_t* argument, unsigned int t)
{ {
if (session == NULL || Zathura.document == NULL) { g_return_val_if_fail(session != NULL, false);
return false; g_return_val_if_fail(session->global.data != NULL, false);
} zathura_t* zathura = session->global.data;
g_return_val_if_fail(zathura->document != NULL, false);
/* update rotate value */ /* update rotate value */
Zathura.document->rotate = (Zathura.document->rotate + 90) % 360; zathura->document->rotate = (zathura->document->rotate + 90) % 360;
/* render all pages again */ /* render all pages again */
render_all(); render_all();
@ -150,11 +183,17 @@ sc_rotate(girara_session_t* session, girara_argument_t* argument, unsigned int t
bool bool
sc_scroll(girara_session_t* session, girara_argument_t* argument, unsigned int t) sc_scroll(girara_session_t* session, girara_argument_t* argument, unsigned int t)
{ {
g_return_val_if_fail(session != NULL, false);
g_return_val_if_fail(session->global.data != NULL, false);
zathura_t* zathura = session->global.data;
g_return_val_if_fail(argument != NULL, false);
g_return_val_if_fail(zathura->document != NULL, false);
GtkAdjustment* adjustment = NULL; 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)); adjustment = gtk_scrolled_window_get_hadjustment(GTK_SCROLLED_WINDOW(zathura->UI.session->gtk.view));
else else
adjustment = gtk_scrolled_window_get_vadjustment(GTK_SCROLLED_WINDOW(Zathura.UI.session->gtk.view)); adjustment = gtk_scrolled_window_get_vadjustment(GTK_SCROLLED_WINDOW(zathura->UI.session->gtk.view));
gdouble view_size = gtk_adjustment_get_page_size(adjustment); gdouble view_size = gtk_adjustment_get_page_size(adjustment);
gdouble value = gtk_adjustment_get_value(adjustment); gdouble value = gtk_adjustment_get_value(adjustment);
@ -202,40 +241,54 @@ sc_scroll(girara_session_t* session, girara_argument_t* argument, unsigned int t
bool bool
sc_search(girara_session_t* session, girara_argument_t* argument, unsigned int t) sc_search(girara_session_t* session, girara_argument_t* argument, unsigned int t)
{ {
g_return_val_if_fail(session != NULL, false);
g_return_val_if_fail(session->global.data != NULL, false);
zathura_t* zathura = session->global.data;
g_return_val_if_fail(argument != NULL, false);
g_return_val_if_fail(zathura->document != NULL, false);
return false; return false;
} }
bool bool
sc_navigate_index(girara_session_t* session, girara_argument_t* argument, unsigned int t) sc_navigate_index(girara_session_t* session, girara_argument_t* argument, unsigned int t)
{ {
g_return_val_if_fail(session != NULL, false);
g_return_val_if_fail(session->global.data != NULL, false);
zathura_t* zathura = session->global.data;
g_return_val_if_fail(argument != NULL, false);
g_return_val_if_fail(zathura->document != NULL, false);
return false; return false;
} }
bool bool
sc_toggle_index(girara_session_t* session, girara_argument_t* argument, unsigned int t) sc_toggle_index(girara_session_t* session, girara_argument_t* argument, unsigned int t)
{ {
if (session == NULL || Zathura.document == NULL) { g_return_val_if_fail(session != NULL, false);
return false; g_return_val_if_fail(session->global.data != NULL, false);
} zathura_t* zathura = session->global.data;
g_return_val_if_fail(argument != NULL, false);
g_return_val_if_fail(zathura->document != NULL, false);
girara_tree_node_t* document_index = NULL; girara_tree_node_t* document_index = NULL;
GtkWidget* treeview = NULL; GtkWidget* treeview = NULL;
GtkTreeModel* model = NULL; GtkTreeModel* model = NULL;
GtkCellRenderer* renderer = NULL; GtkCellRenderer* renderer = NULL;
if (Zathura.UI.index == NULL) { if (zathura->UI.index == NULL) {
/* create new index widget */ /* create new index widget */
Zathura.UI.index = gtk_scrolled_window_new(NULL, NULL); zathura->UI.index = gtk_scrolled_window_new(NULL, NULL);
if (Zathura.UI.index == NULL) { if (zathura->UI.index == NULL) {
goto error_ret; goto error_ret;
} }
gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(Zathura.UI.index), gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(zathura->UI.index),
GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC); GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
/* create index */ /* create index */
document_index = zathura_document_index_generate(Zathura.document); document_index = zathura_document_index_generate(zathura->document);
if (document_index == NULL) { if (document_index == NULL) {
// TODO: Error message // TODO: Error message
goto error_free; goto error_free;
@ -269,31 +322,31 @@ sc_toggle_index(girara_session_t* session, girara_argument_t* argument, unsigned
gtk_tree_view_set_cursor(GTK_TREE_VIEW(treeview), gtk_tree_path_new_first(), NULL, FALSE); gtk_tree_view_set_cursor(GTK_TREE_VIEW(treeview), gtk_tree_path_new_first(), NULL, FALSE);
/*g_signal_connect(G_OBJECT(treeview), "row-activated", G_CALLBACK(cb_index_row_activated), NULL); TODO*/ /*g_signal_connect(G_OBJECT(treeview), "row-activated", G_CALLBACK(cb_index_row_activated), NULL); TODO*/
gtk_container_add(GTK_CONTAINER(Zathura.UI.index), treeview); gtk_container_add(GTK_CONTAINER(zathura->UI.index), treeview);
gtk_widget_show(treeview); gtk_widget_show(treeview);
} }
if (GTK_WIDGET_VISIBLE(GTK_WIDGET(Zathura.UI.index))) { if (GTK_WIDGET_VISIBLE(GTK_WIDGET(zathura->UI.index))) {
girara_set_view(session, Zathura.UI.page_view); girara_set_view(session, zathura->UI.page_view);
gtk_widget_hide(GTK_WIDGET(Zathura.UI.index)); gtk_widget_hide(GTK_WIDGET(zathura->UI.index));
} else { } else {
girara_set_view(session, Zathura.UI.index); girara_set_view(session, zathura->UI.index);
gtk_widget_show(GTK_WIDGET(Zathura.UI.index)); gtk_widget_show(GTK_WIDGET(zathura->UI.index));
} }
return false; return false;
error_free: error_free:
if (Zathura.UI.index != NULL) { if (zathura->UI.index != NULL) {
g_object_ref_sink(Zathura.UI.index); g_object_ref_sink(zathura->UI.index);
Zathura.UI.index = NULL; zathura->UI.index = NULL;
} }
if (document_index != NULL) { if (document_index != NULL) {
girara_node_free(document_index); girara_node_free(document_index);
} }
error_ret: error_ret:
return false; return false;
@ -302,9 +355,7 @@ error_ret:
bool bool
sc_toggle_inputbar(girara_session_t* session, girara_argument_t* argument, unsigned int t) sc_toggle_inputbar(girara_session_t* session, girara_argument_t* argument, unsigned int t)
{ {
if (session == NULL) { g_return_val_if_fail(session != NULL, false);
return false;
}
if (GTK_WIDGET_VISIBLE(GTK_WIDGET(session->gtk.inputbar))) { if (GTK_WIDGET_VISIBLE(GTK_WIDGET(session->gtk.inputbar))) {
gtk_widget_hide(GTK_WIDGET(session->gtk.inputbar)); gtk_widget_hide(GTK_WIDGET(session->gtk.inputbar));
@ -318,9 +369,7 @@ sc_toggle_inputbar(girara_session_t* session, girara_argument_t* argument, unsig
bool bool
sc_toggle_fullscreen(girara_session_t* session, girara_argument_t* argument, unsigned int t) sc_toggle_fullscreen(girara_session_t* session, girara_argument_t* argument, unsigned int t)
{ {
if (session == NULL) { g_return_val_if_fail(session != NULL, false);
return false;
}
static bool fullscreen = false; static bool fullscreen = false;
@ -338,9 +387,7 @@ sc_toggle_fullscreen(girara_session_t* session, girara_argument_t* argument, uns
bool bool
sc_toggle_statusbar(girara_session_t* session, girara_argument_t* argument, unsigned int t) sc_toggle_statusbar(girara_session_t* session, girara_argument_t* argument, unsigned int t)
{ {
if (session == NULL) { g_return_val_if_fail(session != NULL, false);
return false;
}
if (GTK_WIDGET_VISIBLE(GTK_WIDGET(session->gtk.statusbar))) { if (GTK_WIDGET_VISIBLE(GTK_WIDGET(session->gtk.statusbar))) {
gtk_widget_hide(GTK_WIDGET(session->gtk.statusbar)); gtk_widget_hide(GTK_WIDGET(session->gtk.statusbar));
@ -354,6 +401,8 @@ sc_toggle_statusbar(girara_session_t* session, girara_argument_t* argument, unsi
bool bool
sc_quit(girara_session_t* session, girara_argument_t* argument, unsigned int t) sc_quit(girara_session_t* session, girara_argument_t* argument, unsigned int t)
{ {
g_return_val_if_fail(session != NULL, false);
girara_argument_t arg = { GIRARA_HIDE, NULL }; girara_argument_t arg = { GIRARA_HIDE, NULL };
girara_isc_completion(session, &arg, 0); girara_isc_completion(session, &arg, 0);
@ -367,12 +416,14 @@ sc_quit(girara_session_t* session, girara_argument_t* argument, unsigned int t)
bool bool
sc_zoom(girara_session_t* session, girara_argument_t* argument, unsigned int t) sc_zoom(girara_session_t* session, girara_argument_t* argument, unsigned int t)
{ {
if (session == NULL || argument == NULL || Zathura.document == NULL) { g_return_val_if_fail(session != NULL, false);
return false; g_return_val_if_fail(session->global.data != NULL, false);
} zathura_t* zathura = session->global.data;
g_return_val_if_fail(argument != NULL, false);
g_return_val_if_fail(zathura->document != NULL, false);
/* retreive zoom step value */ /* retreive zoom step value */
int* value = girara_setting_get(Zathura.UI.session, "zoom-step"); int* value = girara_setting_get(zathura->UI.session, "zoom-step");
if (value == NULL) { if (value == NULL) {
return false; return false;
} }
@ -380,11 +431,11 @@ sc_zoom(girara_session_t* session, girara_argument_t* argument, unsigned int t)
float zoom_step = *value / 100.0f; float zoom_step = *value / 100.0f;
if (argument->n == ZOOM_IN) { if (argument->n == ZOOM_IN) {
Zathura.document->scale += zoom_step; zathura->document->scale += zoom_step;
} else if (argument->n == ZOOM_OUT) { } else if (argument->n == ZOOM_OUT) {
Zathura.document->scale -= zoom_step; zathura->document->scale -= zoom_step;
} else { } else {
Zathura.document->scale = 1.0; zathura->document->scale = 1.0;
} }
render_all(); render_all();