2010-11-10 20:31:15 +01:00
|
|
|
/* See LICENSE file for license and copyright information */
|
2010-11-12 13:48:18 +01:00
|
|
|
|
|
|
|
#include <callbacks.h>
|
|
|
|
#include <girara.h>
|
2010-11-13 12:40:48 +01:00
|
|
|
#include <stdlib.h>
|
2010-12-29 11:46:13 +01:00
|
|
|
#include <gtk/gtk.h>
|
2010-11-12 13:48:18 +01:00
|
|
|
|
|
|
|
#include "zathura.h"
|
2011-01-07 09:07:02 +01:00
|
|
|
#include "render.h"
|
2011-03-05 19:46:05 +01:00
|
|
|
#include "document.h"
|
2010-11-12 13:48:18 +01:00
|
|
|
|
|
|
|
gboolean
|
|
|
|
cb_destroy(GtkWidget* widget, gpointer data)
|
|
|
|
{
|
2011-04-18 17:27:49 +02:00
|
|
|
zathura_free(data);
|
2011-03-05 19:46:05 +01:00
|
|
|
|
2010-11-12 13:48:18 +01:00
|
|
|
return TRUE;
|
|
|
|
}
|
2010-11-13 12:40:48 +01:00
|
|
|
|
|
|
|
void
|
|
|
|
buffer_changed(girara_session_t* session)
|
|
|
|
{
|
|
|
|
g_return_if_fail(session != NULL);
|
2011-04-18 17:37:03 +02:00
|
|
|
g_return_if_fail(session->global.data != NULL);
|
|
|
|
|
|
|
|
zathura_t* zathura = session->global.data;
|
2010-11-13 12:40:48 +01:00
|
|
|
|
|
|
|
char* buffer = girara_buffer_get(session);
|
|
|
|
|
2011-02-09 12:29:09 +01:00
|
|
|
if (buffer) {
|
2011-04-18 17:37:03 +02:00
|
|
|
girara_statusbar_item_set_text(session, zathura->ui.statusbar.buffer, buffer);
|
2010-11-13 12:40:48 +01:00
|
|
|
free(buffer);
|
2010-12-26 01:12:20 +01:00
|
|
|
} else {
|
2011-04-18 17:37:03 +02:00
|
|
|
girara_statusbar_item_set_text(session, zathura->ui.statusbar.buffer, "");
|
2010-11-29 14:58:56 +01:00
|
|
|
}
|
2010-11-13 12:40:48 +01:00
|
|
|
}
|
2010-12-29 11:46:13 +01:00
|
|
|
|
|
|
|
void
|
|
|
|
cb_view_vadjustment_value_changed(GtkAdjustment *adjustment, gpointer data)
|
|
|
|
{
|
2011-04-18 17:37:03 +02:00
|
|
|
zathura_t* zathura = data;
|
2011-04-18 21:22:35 +02:00
|
|
|
if (!zathura || !zathura->document || !zathura->document->pages || !zathura->ui.page_view) {
|
2010-12-29 11:46:13 +01:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2011-03-18 18:40:20 +01:00
|
|
|
// FIXME
|
2010-12-29 11:46:13 +01:00
|
|
|
/* get current adjustment values */
|
2011-03-18 18:40:20 +01:00
|
|
|
/*gdouble lower = gtk_adjustment_get_value(adjustment);*/
|
|
|
|
/*gdouble upper = lower + gtk_adjustment_get_page_size(adjustment);*/
|
2010-12-29 11:46:13 +01:00
|
|
|
|
|
|
|
/* find page that fits */
|
2011-04-18 17:37:03 +02:00
|
|
|
for (unsigned int page_id = 0; page_id < zathura->document->number_of_pages; page_id++)
|
2010-12-29 11:46:13 +01:00
|
|
|
{
|
2011-04-18 17:37:03 +02:00
|
|
|
zathura_page_t* page = zathura->document->pages[page_id];
|
2011-01-06 08:59:10 +01:00
|
|
|
|
|
|
|
/* check for rendered attribute */
|
2011-02-09 12:29:09 +01:00
|
|
|
if (page->rendered) {
|
2011-01-06 08:59:10 +01:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2011-03-18 18:40:20 +01:00
|
|
|
/*double begin = page->offset;*/
|
|
|
|
/*double end = page->offset + page->height;*/
|
2011-01-06 08:59:10 +01:00
|
|
|
|
2011-03-18 18:40:20 +01:00
|
|
|
/*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 <]*/
|
|
|
|
/*) {*/
|
2011-03-20 02:09:04 +01:00
|
|
|
if (page_id < 1) {
|
2011-04-18 17:37:03 +02:00
|
|
|
render_page(zathura->sync.render_thread, zathura->document->pages[page_id]);
|
2010-12-29 11:46:13 +01:00
|
|
|
}
|
2011-03-18 18:40:20 +01:00
|
|
|
/*}*/
|
2010-12-29 11:46:13 +01:00
|
|
|
}
|
|
|
|
}
|