mirror of
https://gitlab.freedesktop.org/wayland/wayland.git
synced 2025-11-03 09:01:42 -05:00
clients/view: Don't try to show inexistant files
This commit is contained in:
parent
9aad08e91b
commit
6685aceae3
1 changed files with 13 additions and 5 deletions
|
|
@ -64,8 +64,6 @@ view_draw(struct view *view)
|
||||||
|
|
||||||
window_get_child_allocation(view->window, &allocation);
|
window_get_child_allocation(view->window, &allocation);
|
||||||
|
|
||||||
page = poppler_document_get_page(view->document, view->page);
|
|
||||||
|
|
||||||
surface = window_get_surface(view->window);
|
surface = window_get_surface(view->window);
|
||||||
|
|
||||||
cr = cairo_create(surface);
|
cr = cairo_create(surface);
|
||||||
|
|
@ -76,6 +74,15 @@ view_draw(struct view *view)
|
||||||
cairo_set_source_rgba(cr, 0, 0, 0, 0.8);
|
cairo_set_source_rgba(cr, 0, 0, 0, 0.8);
|
||||||
cairo_set_operator(cr, CAIRO_OPERATOR_SOURCE);
|
cairo_set_operator(cr, CAIRO_OPERATOR_SOURCE);
|
||||||
cairo_paint(cr);
|
cairo_paint(cr);
|
||||||
|
|
||||||
|
if(!view->document) {
|
||||||
|
cairo_destroy(cr);
|
||||||
|
cairo_surface_destroy(surface);
|
||||||
|
window_flush(view->window);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
page = poppler_document_get_page(view->document, view->page);
|
||||||
poppler_page_get_size(page, &width, &height);
|
poppler_page_get_size(page, &width, &height);
|
||||||
doc_aspect = width / height;
|
doc_aspect = width / height;
|
||||||
window_aspect = (double) allocation.width / allocation.height;
|
window_aspect = (double) allocation.width / allocation.height;
|
||||||
|
|
@ -119,8 +126,10 @@ view_page_up(struct view *view)
|
||||||
static void
|
static void
|
||||||
view_page_down(struct view *view)
|
view_page_down(struct view *view)
|
||||||
{
|
{
|
||||||
if(view->page >= poppler_document_get_n_pages(view->document) - 1)
|
if(!view->document ||
|
||||||
|
view->page >= poppler_document_get_n_pages(view->document) - 1) {
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
view->page++;
|
view->page++;
|
||||||
window_schedule_redraw(view->window);
|
window_schedule_redraw(view->window);
|
||||||
|
|
@ -215,7 +224,6 @@ view_create(struct display *display, uint32_t key, const char *filename)
|
||||||
|
|
||||||
if(error) {
|
if(error) {
|
||||||
title = "File not found";
|
title = "File not found";
|
||||||
view->document = NULL;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
view->window = window_create(display, 500, 400);
|
view->window = window_create(display, 500, 400);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue