From daa523aaf5f6e4769ee9a8be679736f1da5c4f7d Mon Sep 17 00:00:00 2001 From: Moritz Lipp Date: Mon, 18 Apr 2011 17:37:03 +0200 Subject: [PATCH] Updated callbacks.c --- callbacks.c | 19 +++++++++++++------ zathura.c | 5 +++-- 2 files changed, 16 insertions(+), 8 deletions(-) diff --git a/callbacks.c b/callbacks.c index c16b6c5..8fb333d 100644 --- a/callbacks.c +++ b/callbacks.c @@ -21,33 +21,40 @@ void buffer_changed(girara_session_t* session) { g_return_if_fail(session != NULL); + g_return_if_fail(session->global.data != NULL); + + zathura_t* zathura = session->global.data; char* buffer = girara_buffer_get(session); if (buffer) { - girara_statusbar_item_set_text(session, Zathura.UI.statusbar.buffer, buffer); + girara_statusbar_item_set_text(session, zathura->ui.statusbar.buffer, buffer); free(buffer); } else { - girara_statusbar_item_set_text(session, Zathura.UI.statusbar.buffer, ""); + girara_statusbar_item_set_text(session, zathura->ui.statusbar.buffer, ""); } } void cb_view_vadjustment_value_changed(GtkAdjustment *adjustment, gpointer data) { - if (!Zathura.document || !Zathura.document->pages || !Zathura.UI.page_view) { + g_return_if_fail(data != NULL); + + zathura_t* zathura = data; + if (!zathura->document || !zathura->document->pages || !zathura->ui.page_view) { return; } + // FIXME /* get current adjustment values */ /*gdouble lower = gtk_adjustment_get_value(adjustment);*/ /*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]; + zathura_page_t* page = zathura->document->pages[page_id]; /* check for rendered attribute */ if (page->rendered) { @@ -62,7 +69,7 @@ cb_view_vadjustment_value_changed(GtkAdjustment *adjustment, gpointer data) /*|| ( (begin >= lower) && (end >= upper) && (begin <= upper) ) [> begin of the page is in viewport <]*/ /*) {*/ if (page_id < 1) { - render_page(Zathura.Sync.render_thread, Zathura.document->pages[page_id]); + render_page(zathura->sync.render_thread, zathura->document->pages[page_id]); } /*}*/ } diff --git a/zathura.c b/zathura.c index f889ae3..602cfb8 100644 --- a/zathura.c +++ b/zathura.c @@ -30,6 +30,7 @@ zathura_init(int argc, char* argv[]) goto error_out; } + zathura->ui.session->global.data = zathura; zathura->ui.statusbar.file = NULL; zathura->ui.statusbar.buffer = NULL; zathura->ui.statusbar.page_number = NULL; @@ -67,7 +68,7 @@ zathura_init(int argc, char* argv[]) g_signal_connect(G_OBJECT(zathura->ui.session->gtk.window), "destroy", G_CALLBACK(cb_destroy), NULL); GtkAdjustment* view_vadjustment = gtk_scrolled_window_get_vadjustment(GTK_SCROLLED_WINDOW(zathura->ui.session->gtk.view)); - g_signal_connect(G_OBJECT(view_vadjustment), "value-changed", G_CALLBACK(cb_view_vadjustment_value_changed), NULL); + g_signal_connect(G_OBJECT(view_vadjustment), "value-changed", G_CALLBACK(cb_view_vadjustment_value_changed), zathura); /* girara events */ zathura->ui.session->events.buffer_changed = buffer_changed; @@ -76,7 +77,7 @@ zathura_init(int argc, char* argv[]) zathura_document_plugins_load(); /* configuration */ - config_load_default(); + config_load_default(zathura); return zathura;