Add option to disable rendering of 'Loading ...'

This commit is contained in:
Sebastian Ramacher 2012-02-01 17:30:43 +01:00
parent 7c2d6718f0
commit 3b5d29d52b
2 changed files with 25 additions and 10 deletions

View file

@ -23,6 +23,7 @@ config_load_default(zathura_t* zathura)
int int_value = 0;
float float_value = 0;
char* string_value = NULL;
bool bool_value = false;
girara_session_t* gsession = zathura->ui.session;
/* mode settings */
@ -57,6 +58,8 @@ config_load_default(zathura_t* zathura)
girara_setting_add(gsession, "highlight-color", string_value, STRING, false, "Color for highlighting", NULL, NULL);
float_value = 0.5;
girara_setting_add(gsession, "highlight-transparency", &float_value, FLOAT, false, "Transparency for highlighting", NULL, NULL);
bool_value = true;
girara_setting_add(gsession, "render-loading", &bool_value, BOOLEAN, false, "Render 'Loading ...'", NULL, NULL);
/* define default shortcuts */
girara_shortcut_add(gsession, GDK_CONTROL_MASK, GDK_c, NULL, sc_abort, 0, 0, NULL);

View file

@ -4,6 +4,7 @@
#include <girara/datastructures.h>
#include <girara/utils.h>
#include <girara/session.h>
#include <girara/settings.h>
#include "render.h"
#include "zathura.h"
@ -324,17 +325,28 @@ page_expose_event(GtkWidget* UNUSED(widget), GdkEventExpose* UNUSED(event),
cairo_rectangle(cairo, 0, 0, page_width, page->height * page->height);
cairo_fill(cairo);
bool render_loading = false;
bool* tmp = (page->document != NULL && page->document->zathura != NULL &&
page->document->zathura->ui.session != NULL) ?
girara_setting_get(page->document->zathura->ui.session, "render-loading") : NULL;
if (tmp != NULL) {
render_loading = *tmp;
g_free(tmp);
}
/* write text */
cairo_set_source_rgb(cairo, 0, 0, 0);
const char* text = "Loading...";
cairo_select_font_face(cairo, "Sans", CAIRO_FONT_SLANT_NORMAL, CAIRO_FONT_WEIGHT_NORMAL);
cairo_set_font_size(cairo, 16.0);
cairo_text_extents_t extents;
cairo_text_extents(cairo, text, &extents);
double x = page_width * 0.5 - (extents.width * 0.5 + extents.x_bearing);
double y = page_height * 0.5 - (extents.height * 0.5 + extents.y_bearing);
cairo_move_to(cairo, x, y);
cairo_show_text(cairo, text);
if (render_loading == true) {
cairo_set_source_rgb(cairo, 0, 0, 0);
const char* text = "Loading...";
cairo_select_font_face(cairo, "Sans", CAIRO_FONT_SLANT_NORMAL, CAIRO_FONT_WEIGHT_NORMAL);
cairo_set_font_size(cairo, 16.0);
cairo_text_extents_t extents;
cairo_text_extents(cairo, text, &extents);
double x = page_width * 0.5 - (extents.width * 0.5 + extents.x_bearing);
double y = page_height * 0.5 - (extents.height * 0.5 + extents.y_bearing);
cairo_move_to(cairo, x, y);
cairo_show_text(cairo, text);
}
/* render real page */
render_page(page->document->zathura->sync.render_thread, page);