mirror of
https://git.pwmt.org/pwmt/zathura.git
synced 2025-02-27 10:54:39 +01:00
Add types to handle signatures
This commit is contained in:
parent
7a8419cc95
commit
d9bdd00b53
3 changed files with 79 additions and 23 deletions
|
@ -526,32 +526,32 @@ get_safe_device_factors(cairo_surface_t* surface)
|
||||||
static gboolean
|
static gboolean
|
||||||
zathura_page_widget_draw(GtkWidget* widget, cairo_t* cairo)
|
zathura_page_widget_draw(GtkWidget* widget, cairo_t* cairo)
|
||||||
{
|
{
|
||||||
ZathuraPage* page = ZATHURA_PAGE(widget);
|
ZathuraPage* page = ZATHURA_PAGE(widget);
|
||||||
ZathuraPagePrivate* priv = zathura_page_widget_get_instance_private(page);
|
ZathuraPagePrivate* priv = zathura_page_widget_get_instance_private(page);
|
||||||
|
zathura_t* zathura = priv->zathura;
|
||||||
|
|
||||||
zathura_document_t* document = zathura_page_get_document(priv->page);
|
zathura_document_t* document = zathura_page_get_document(priv->page);
|
||||||
const unsigned int page_height = gtk_widget_get_allocated_height(widget);
|
const unsigned int page_height = gtk_widget_get_allocated_height(widget);
|
||||||
const unsigned int page_width = gtk_widget_get_allocated_width(widget);
|
const unsigned int page_width = gtk_widget_get_allocated_width(widget);
|
||||||
|
|
||||||
bool smooth_reload = true;
|
bool smooth_reload = true;
|
||||||
girara_setting_get(priv->zathura->ui.session, "smooth-reload", &smooth_reload);
|
girara_setting_get(zathura->ui.session, "smooth-reload", &smooth_reload);
|
||||||
|
|
||||||
bool surface_exists = priv->surface != NULL || priv->thumbnail != NULL;
|
bool surface_exists = priv->surface != NULL || priv->thumbnail != NULL;
|
||||||
|
|
||||||
if (priv->zathura->predecessor_document != NULL && priv->zathura->predecessor_pages != NULL
|
if (zathura->predecessor_document != NULL && zathura->predecessor_pages != NULL && smooth_reload && !surface_exists) {
|
||||||
&& smooth_reload && !surface_exists) {
|
unsigned int page_index = zathura_page_get_index(priv->page);
|
||||||
unsigned int page_index = zathura_page_get_index(priv->page);
|
|
||||||
|
|
||||||
if (page_index < zathura_document_get_number_of_pages(priv->zathura->predecessor_document)) {
|
if (page_index < zathura_document_get_number_of_pages(priv->zathura->predecessor_document)) {
|
||||||
/* render real page */
|
/* render real page */
|
||||||
zathura_render_request(priv->render_request, g_get_real_time());
|
zathura_render_request(priv->render_request, g_get_real_time());
|
||||||
|
|
||||||
girara_debug("using predecessor page for idx %d", page_index);
|
girara_debug("using predecessor page for idx %d", page_index);
|
||||||
document = priv->zathura->predecessor_document;
|
document = priv->zathura->predecessor_document;
|
||||||
page = ZATHURA_PAGE(priv->zathura->predecessor_pages[page_index]);
|
page = ZATHURA_PAGE(priv->zathura->predecessor_pages[page_index]);
|
||||||
priv = zathura_page_widget_get_instance_private(page);
|
priv = zathura_page_widget_get_instance_private(page);
|
||||||
}
|
}
|
||||||
surface_exists = priv->surface != NULL || priv->thumbnail != NULL;
|
surface_exists = priv->surface != NULL || priv->thumbnail != NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (surface_exists) {
|
if (surface_exists) {
|
||||||
|
@ -607,10 +607,10 @@ zathura_page_widget_draw(GtkWidget* widget, cairo_t* cairo)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* draw links */
|
/* draw links */
|
||||||
set_font_from_property(cairo, priv->zathura, CAIRO_FONT_WEIGHT_BOLD);
|
set_font_from_property(cairo, zathura, CAIRO_FONT_WEIGHT_BOLD);
|
||||||
|
|
||||||
float transparency = 0.5;
|
float transparency = 0.5;
|
||||||
girara_setting_get(priv->zathura->ui.session, "highlight-transparency", &transparency);
|
girara_setting_get(zathura->ui.session, "highlight-transparency", &transparency);
|
||||||
|
|
||||||
if (priv->links.draw == true && priv->links.n != 0) {
|
if (priv->links.draw == true && priv->links.n != 0) {
|
||||||
unsigned int link_counter = 0;
|
unsigned int link_counter = 0;
|
||||||
|
@ -620,14 +620,14 @@ zathura_page_widget_draw(GtkWidget* widget, cairo_t* cairo)
|
||||||
zathura_rectangle_t rectangle = recalc_rectangle(priv->page, zathura_link_get_position(link));
|
zathura_rectangle_t rectangle = recalc_rectangle(priv->page, zathura_link_get_position(link));
|
||||||
|
|
||||||
/* draw position */
|
/* draw position */
|
||||||
const GdkRGBA color = priv->zathura->ui.colors.highlight_color;
|
const GdkRGBA color = zathura->ui.colors.highlight_color;
|
||||||
cairo_set_source_rgba(cairo, color.red, color.green, color.blue, transparency);
|
cairo_set_source_rgba(cairo, color.red, color.green, color.blue, transparency);
|
||||||
cairo_rectangle(cairo, rectangle.x1, rectangle.y1,
|
cairo_rectangle(cairo, rectangle.x1, rectangle.y1, (rectangle.x2 - rectangle.x1),
|
||||||
(rectangle.x2 - rectangle.x1), (rectangle.y2 - rectangle.y1));
|
(rectangle.y2 - rectangle.y1));
|
||||||
cairo_fill(cairo);
|
cairo_fill(cairo);
|
||||||
|
|
||||||
/* draw text */
|
/* draw text */
|
||||||
const GdkRGBA color_fg = priv->zathura->ui.colors.highlight_color_fg;
|
const GdkRGBA color_fg = zathura->ui.colors.highlight_color_fg;
|
||||||
cairo_set_source_rgba(cairo, color_fg.red, color_fg.green, color_fg.blue, transparency);
|
cairo_set_source_rgba(cairo, color_fg.red, color_fg.green, color_fg.blue, transparency);
|
||||||
cairo_move_to(cairo, rectangle.x1 + 1, rectangle.y2 - 1);
|
cairo_move_to(cairo, rectangle.x1 + 1, rectangle.y2 - 1);
|
||||||
char* link_number = g_strdup_printf("%i", priv->links.offset + ++link_counter);
|
char* link_number = g_strdup_printf("%i", priv->links.offset + ++link_counter);
|
||||||
|
@ -646,10 +646,10 @@ zathura_page_widget_draw(GtkWidget* widget, cairo_t* cairo)
|
||||||
|
|
||||||
/* draw position */
|
/* draw position */
|
||||||
if (idx == priv->search.current) {
|
if (idx == priv->search.current) {
|
||||||
const GdkRGBA color = priv->zathura->ui.colors.highlight_color_active;
|
const GdkRGBA color = zathura->ui.colors.highlight_color_active;
|
||||||
cairo_set_source_rgba(cairo, color.red, color.green, color.blue, transparency);
|
cairo_set_source_rgba(cairo, color.red, color.green, color.blue, transparency);
|
||||||
} else {
|
} else {
|
||||||
const GdkRGBA color = priv->zathura->ui.colors.highlight_color;
|
const GdkRGBA color = zathura->ui.colors.highlight_color;
|
||||||
cairo_set_source_rgba(cairo, color.red, color.green, color.blue, transparency);
|
cairo_set_source_rgba(cairo, color.red, color.green, color.blue, transparency);
|
||||||
}
|
}
|
||||||
cairo_rectangle(cairo, rectangle.x1, rectangle.y1, (rectangle.x2 - rectangle.x1),
|
cairo_rectangle(cairo, rectangle.x1, rectangle.y1, (rectangle.x2 - rectangle.x1),
|
||||||
|
|
|
@ -120,3 +120,21 @@ zathura_document_information_entry_free(zathura_document_information_entry_t* en
|
||||||
g_free(entry->value);
|
g_free(entry->value);
|
||||||
g_free(entry);
|
g_free(entry);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
zathura_signature_info_t*
|
||||||
|
zathura_signature_info_new(void)
|
||||||
|
{
|
||||||
|
return g_try_malloc0(sizeof(zathura_signature_info_t));
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
zathura_signature_info_free(zathura_signature_info_t* signature)
|
||||||
|
{
|
||||||
|
if (signature == NULL) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
g_free(signature->signer);
|
||||||
|
g_date_time_unref(signature->time);
|
||||||
|
g_free(signature);
|
||||||
|
}
|
|
@ -4,6 +4,7 @@
|
||||||
#define TYPES_H
|
#define TYPES_H
|
||||||
|
|
||||||
#include <girara/datastructures.h>
|
#include <girara/datastructures.h>
|
||||||
|
#include <glib.h>
|
||||||
|
|
||||||
#include "macros.h"
|
#include "macros.h"
|
||||||
|
|
||||||
|
@ -286,4 +287,41 @@ typedef struct zathura_device_factors_s
|
||||||
double y;
|
double y;
|
||||||
} zathura_device_factors_t;
|
} zathura_device_factors_t;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Signature state
|
||||||
|
*/
|
||||||
|
typedef enum zathura_signature_state_e {
|
||||||
|
ZATHURA_SIGNATURE_INVALID,
|
||||||
|
ZATHURA_SIGNATURE_VALID,
|
||||||
|
ZATHURA_SIGNATURE_CERTIFICATE_UNTRUSTED,
|
||||||
|
ZATHURA_SIGNATURE_CERTIFICATE_EXPIRED,
|
||||||
|
ZATHURA_SIGNATURE_CERTIFICATE_REVOKED,
|
||||||
|
ZATHURA_SIGNATURE_CERTIFICATE_INVALID,
|
||||||
|
ZATHURA_SIGNATURE_ERROR,
|
||||||
|
} zathura_signature_state_t;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Signature information
|
||||||
|
*/
|
||||||
|
typedef struct zathura_signature_info_s {
|
||||||
|
char* signer;
|
||||||
|
GDateTime* time;
|
||||||
|
zathura_rectangle_t position;
|
||||||
|
zathura_signature_state_t state;
|
||||||
|
} zathura_signature_info_t;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a new siganture info.
|
||||||
|
*
|
||||||
|
* @return A new signature info or NULL if an error occurred
|
||||||
|
*/
|
||||||
|
ZATHURA_PLUGIN_API zathura_signature_info_t* zathura_signature_info_new(void);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Frees a signature info
|
||||||
|
*
|
||||||
|
* @param signature The signature info to be freed
|
||||||
|
*/
|
||||||
|
ZATHURA_PLUGIN_API void zathura_signature_info_free(zathura_signature_info_t* signature);
|
||||||
|
|
||||||
#endif // TYPES_H
|
#endif // TYPES_H
|
||||||
|
|
Loading…
Add table
Reference in a new issue