Updated callbacks.c

This commit is contained in:
Moritz Lipp 2011-04-18 17:37:03 +02:00
parent a181c04775
commit daa523aaf5
2 changed files with 16 additions and 8 deletions

View File

@ -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]);
}
/*}*/
}

View File

@ -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;