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-11-12 13:48:18 +01:00
|
|
|
|
|
|
|
#include "zathura.h"
|
|
|
|
|
|
|
|
gboolean
|
|
|
|
cb_destroy(GtkWidget* widget, gpointer data)
|
|
|
|
{
|
2010-11-13 12:40:48 +01:00
|
|
|
if(Zathura.UI.session) {
|
2010-11-12 13:48:18 +01:00
|
|
|
girara_session_destroy(Zathura.UI.session);
|
2010-11-13 12:40:48 +01:00
|
|
|
}
|
2010-11-12 13:48:18 +01:00
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
2010-11-13 12:40:48 +01:00
|
|
|
|
2010-12-26 01:52:17 +01:00
|
|
|
gboolean
|
|
|
|
cb_draw(GtkWidget* widget, GdkEventExpose* expose, gpointer data)
|
|
|
|
{
|
2010-12-26 02:22:08 +01:00
|
|
|
if(!widget) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
gdk_window_clear(widget->window);
|
|
|
|
cairo_t *cairo = gdk_cairo_create(widget->window);
|
|
|
|
|
|
|
|
if(!cairo) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2010-12-26 01:52:17 +01:00
|
|
|
// FIXME: Split up
|
|
|
|
zathura_page_t* page = zathura_page_get(Zathura.document, Zathura.document->current_page_number);
|
|
|
|
if(!page) {
|
2010-12-26 02:22:08 +01:00
|
|
|
cairo_destroy(cairo);
|
2010-12-26 01:52:17 +01:00
|
|
|
goto error_out;
|
|
|
|
}
|
|
|
|
|
|
|
|
cairo_surface_t* surface = zathura_page_render(page);
|
|
|
|
if(!surface) {
|
|
|
|
zathura_page_free(page);
|
|
|
|
fprintf(stderr, "error: rendering failed\n");
|
|
|
|
goto error_out;
|
|
|
|
}
|
|
|
|
|
2010-12-26 02:22:08 +01:00
|
|
|
cairo_set_source_surface(cairo, surface, 0, 0);
|
|
|
|
cairo_paint(cairo);
|
|
|
|
cairo_destroy(cairo);
|
|
|
|
|
2010-12-26 01:52:17 +01:00
|
|
|
cairo_surface_destroy(surface);
|
|
|
|
zathura_page_free(page);
|
|
|
|
|
|
|
|
gtk_widget_set_size_request(Zathura.UI.drawing_area, page->width, page->height);
|
|
|
|
gtk_widget_queue_draw(Zathura.UI.drawing_area);
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
|
|
|
error_out:
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2010-11-13 12:40:48 +01:00
|
|
|
void
|
|
|
|
buffer_changed(girara_session_t* session)
|
|
|
|
{
|
|
|
|
g_return_if_fail(session != NULL);
|
|
|
|
|
|
|
|
char* buffer = girara_buffer_get(session);
|
|
|
|
|
|
|
|
if(buffer) {
|
2010-11-18 21:22:43 +01: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 {
|
2010-11-29 14:58:56 +01:00
|
|
|
girara_statusbar_item_set_text(session, Zathura.UI.statusbar.buffer, "");
|
|
|
|
}
|
2010-11-13 12:40:48 +01:00
|
|
|
}
|