mirror of
https://git.pwmt.org/pwmt/zathura.git
synced 2024-12-29 14:26:00 +01:00
Merge branch 'develop' of pwmt.org:zathura into develop
This commit is contained in:
commit
1fb49fbf06
9 changed files with 277 additions and 143 deletions
2
Makefile
2
Makefile
|
@ -6,7 +6,7 @@ include common.mk
|
|||
PROJECT = zathura
|
||||
OSOURCE = $(wildcard *.c)
|
||||
HEADER = $(wildcard *.h)
|
||||
HEADERINST = version.h zathura.h document.h macros.h page.h
|
||||
HEADERINST = version.h zathura.h document.h macros.h page.h types.h
|
||||
|
||||
ifneq (${WITH_SQLITE},0)
|
||||
INCS += $(SQLITE_INC)
|
||||
|
|
|
@ -202,7 +202,9 @@ cb_sc_follow(GtkEntry* entry, girara_session_t* session)
|
|||
page_set_delayed(zathura, link->target.page_number);
|
||||
break;
|
||||
case ZATHURA_LINK_EXTERNAL:
|
||||
girara_xdg_open(link->target.value);
|
||||
girara_xdg_open(link->target.uri);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
|
|
13
document.c
13
document.c
|
@ -644,16 +644,3 @@ zathura_type_plugin_mapping_free(zathura_type_plugin_mapping_t* mapping)
|
|||
g_free((void*)mapping->type);
|
||||
g_free(mapping);
|
||||
}
|
||||
|
||||
void
|
||||
zathura_link_free(zathura_link_t* link)
|
||||
{
|
||||
if (link == NULL) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (link->type == ZATHURA_LINK_EXTERNAL) {
|
||||
g_free(link->target.value);
|
||||
}
|
||||
g_free(link);
|
||||
}
|
||||
|
|
127
document.h
127
document.h
|
@ -10,6 +10,7 @@
|
|||
#include <girara/types.h>
|
||||
#include "zathura.h"
|
||||
#include "version.h"
|
||||
#include "types.h"
|
||||
|
||||
#define PLUGIN_REGISTER_FUNCTION "plugin_register"
|
||||
#define PLUGIN_API_VERSION_FUNCTION "plugin_api_version"
|
||||
|
@ -129,110 +130,6 @@ typedef unsigned int (*zathura_plugin_api_version_t)();
|
|||
*/
|
||||
typedef unsigned int (*zathura_plugin_abi_version_t)();
|
||||
|
||||
/**
|
||||
* Image buffer
|
||||
*/
|
||||
typedef struct zathura_image_buffer_s
|
||||
{
|
||||
unsigned char* data; /**< Image buffer data */
|
||||
unsigned int height; /**< Height of the image */
|
||||
unsigned int width; /**< Width of the image */
|
||||
unsigned int rowstride; /**< Rowstride of the image */
|
||||
} zathura_image_buffer_t;
|
||||
|
||||
/**
|
||||
* Creates an image buffer
|
||||
*
|
||||
* @param width Width of the image stored in the buffer
|
||||
* @param height Height of the image stored in the buffer
|
||||
* @return Image buffer or NULL if an error occured
|
||||
*/
|
||||
zathura_image_buffer_t* zathura_image_buffer_create(unsigned int width, unsigned int height);
|
||||
|
||||
/**
|
||||
* Frees the image buffer
|
||||
*
|
||||
* @param buffer The image buffer
|
||||
*/
|
||||
void zathura_image_buffer_free(zathura_image_buffer_t* buffer);
|
||||
|
||||
/**
|
||||
* Rectangle structure.
|
||||
* The coordinate system has its origin in the left upper corner. The x axes
|
||||
* goes to the right, the y access goes down.
|
||||
*/
|
||||
typedef struct zathura_rectangle_s
|
||||
{
|
||||
double x1; /**< X coordinate of point 1 */
|
||||
double y1; /**< Y coordinate of point 1 */
|
||||
double x2; /**< X coordinate of point 2 */
|
||||
double y2; /**< Y coordinate of point 2 */
|
||||
} zathura_rectangle_t;
|
||||
|
||||
/**
|
||||
* Image structure
|
||||
*/
|
||||
typedef struct zathura_image_s
|
||||
{
|
||||
zathura_rectangle_t position; /**< Coordinates of the image */
|
||||
void* data; /**< Custom data of the plugin */
|
||||
} zathura_image_t;
|
||||
|
||||
/**
|
||||
* Possible link types
|
||||
*/
|
||||
typedef enum zathura_link_type_e
|
||||
{
|
||||
ZATHURA_LINK_TO_PAGE, /**< Links to a page */
|
||||
ZATHURA_LINK_EXTERNAL, /**< Links to an external source */
|
||||
} zathura_link_type_t;
|
||||
|
||||
/**
|
||||
* Link
|
||||
*/
|
||||
typedef struct zathura_link_s
|
||||
{
|
||||
zathura_rectangle_t position; /**< Position of the link */
|
||||
zathura_link_type_t type; /**< Link type */
|
||||
union
|
||||
{
|
||||
unsigned int page_number; /**< Page number */
|
||||
char* value; /**< Value */
|
||||
} target;
|
||||
} zathura_link_t;
|
||||
|
||||
/**
|
||||
* Index element
|
||||
*/
|
||||
typedef struct zathura_index_element_s
|
||||
{
|
||||
char* title; /**< Title of the element */
|
||||
zathura_link_type_t type; /**< Type */
|
||||
union
|
||||
{
|
||||
unsigned int page_number; /**< Page number */
|
||||
char* uri; /**< Uri */
|
||||
} target;
|
||||
} zathura_index_element_t;
|
||||
|
||||
/**
|
||||
* Form type
|
||||
*/
|
||||
typedef enum zathura_form_type_e
|
||||
{
|
||||
ZATHURA_FORM_CHECKBOX, /**< Checkbox */
|
||||
ZATHURA_FORM_TEXTFIELD /**< Textfield */
|
||||
} zathura_form_type_t;
|
||||
|
||||
/**
|
||||
* Form element
|
||||
*/
|
||||
typedef struct zathura_form_s
|
||||
{
|
||||
zathura_rectangle_t position; /**< Position */
|
||||
zathura_form_type_t type; /**< Type */
|
||||
} zathura_form_t;
|
||||
|
||||
/**
|
||||
* Document
|
||||
*/
|
||||
|
@ -425,28 +322,6 @@ zathura_plugin_error_t zathura_document_attachment_save(zathura_document_t* docu
|
|||
*/
|
||||
char* zathura_document_meta_get(zathura_document_t* document, zathura_document_meta_t meta, zathura_plugin_error_t* error);
|
||||
|
||||
/**
|
||||
* Create new index element
|
||||
*
|
||||
* @param title Title of the index element
|
||||
* @return Index element
|
||||
*/
|
||||
zathura_index_element_t* zathura_index_element_new(const char* title);
|
||||
|
||||
/**
|
||||
* Free index element
|
||||
*
|
||||
* @param index The index element
|
||||
*/
|
||||
void zathura_index_element_free(zathura_index_element_t* index);
|
||||
|
||||
/**
|
||||
* Free link
|
||||
*
|
||||
* @param link The link
|
||||
*/
|
||||
void zathura_link_free(zathura_link_t* link);
|
||||
|
||||
/**
|
||||
* Add type -> plugin mapping
|
||||
* @param zathura zathura instance
|
||||
|
|
|
@ -550,7 +550,9 @@ cb_zathura_page_widget_button_release_event(GtkWidget* widget, GdkEventButton* b
|
|||
page_set_delayed(document->zathura, link->target.page_number);
|
||||
return false;
|
||||
case ZATHURA_LINK_EXTERNAL:
|
||||
girara_xdg_open(link->target.value);
|
||||
girara_xdg_open(link->target.uri);
|
||||
return false;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
2
page.h
2
page.h
|
@ -16,7 +16,7 @@
|
|||
* @return Page object or NULL if an error occured
|
||||
*/
|
||||
zathura_page_t* zathura_page_new(zathura_document_t* document, unsigned int
|
||||
index, zathura_plugin_error_t* error);
|
||||
index, zathura_plugin_error_t* error);
|
||||
|
||||
/**
|
||||
* Frees the page object
|
||||
|
|
16
shortcuts.c
16
shortcuts.c
|
@ -776,11 +776,27 @@ sc_toggle_index(girara_session_t* session, girara_argument_t* UNUSED(argument),
|
|||
gtk_widget_show(treeview);
|
||||
}
|
||||
|
||||
GtkAdjustment* vadjustment = gtk_scrolled_window_get_vadjustment(GTK_SCROLLED_WINDOW(session->gtk.view));
|
||||
GtkAdjustment* hadjustment = gtk_scrolled_window_get_hadjustment(GTK_SCROLLED_WINDOW(session->gtk.view));
|
||||
static double vvalue = 0;
|
||||
static double hvalue = 0;
|
||||
|
||||
if (gtk_widget_get_visible(GTK_WIDGET(zathura->ui.index))) {
|
||||
girara_set_view(session, zathura->ui.page_widget_alignment);
|
||||
gtk_widget_hide(GTK_WIDGET(zathura->ui.index));
|
||||
girara_mode_set(zathura->ui.session, zathura->modes.normal);
|
||||
|
||||
/* reset adjustment */
|
||||
gtk_adjustment_set_value(vadjustment, vvalue);
|
||||
gtk_adjustment_set_value(hadjustment, hvalue);
|
||||
|
||||
gtk_scrolled_window_set_vadjustment(GTK_SCROLLED_WINDOW(session->gtk.view), vadjustment);
|
||||
gtk_scrolled_window_set_hadjustment(GTK_SCROLLED_WINDOW(session->gtk.view), hadjustment);
|
||||
} else {
|
||||
/* save adjustment */
|
||||
vvalue = gtk_adjustment_get_value(vadjustment);
|
||||
hvalue = gtk_adjustment_get_value(hadjustment);
|
||||
|
||||
girara_set_view(session, zathura->ui.index);
|
||||
gtk_widget_show(GTK_WIDGET(zathura->ui.index));
|
||||
girara_mode_set(zathura->ui.session, zathura->modes.index);
|
||||
|
|
80
types.c
Normal file
80
types.c
Normal file
|
@ -0,0 +1,80 @@
|
|||
/* See LICENSE file for license and copyright information */
|
||||
|
||||
#include "types.h"
|
||||
|
||||
zathura_link_t*
|
||||
zathura_link_new(zathura_link_type_t type, zathura_rectangle_t position,
|
||||
zathura_link_target_t target)
|
||||
{
|
||||
zathura_link_t* link = g_malloc0(sizeof(zathura_link_t));
|
||||
|
||||
link->type = type;
|
||||
link->position = position;
|
||||
|
||||
switch (type) {
|
||||
case ZATHURA_LINK_TO_PAGE:
|
||||
link->target.page_number = target.page_number;
|
||||
break;
|
||||
case ZATHURA_LINK_EXTERNAL:
|
||||
if (target.uri == NULL) {
|
||||
g_free(link);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
link->target.uri = g_strdup(target.uri);
|
||||
break;
|
||||
default:
|
||||
g_free(link);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return link;
|
||||
}
|
||||
|
||||
void
|
||||
zathura_link_free(zathura_link_t* link)
|
||||
{
|
||||
if (link == NULL) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (link->type == ZATHURA_LINK_EXTERNAL) {
|
||||
if (link->target.uri != NULL) {
|
||||
g_free(link->target.uri);
|
||||
}
|
||||
}
|
||||
|
||||
g_free(link);
|
||||
}
|
||||
|
||||
zathura_link_type_t
|
||||
zathura_link_get_type(zathura_link_t* link)
|
||||
{
|
||||
if (link == NULL) {
|
||||
return ZATHURA_LINK_INVALID;
|
||||
}
|
||||
|
||||
return link->type;
|
||||
}
|
||||
|
||||
zathura_rectangle_t
|
||||
zathura_link_get_position(zathura_link_t* link)
|
||||
{
|
||||
if (link == NULL) {
|
||||
zathura_rectangle_t position = { 0, 0, 0, 0 };
|
||||
return position;
|
||||
}
|
||||
|
||||
return link->position;
|
||||
}
|
||||
|
||||
zathura_link_target_t
|
||||
zathura_link_get_target(zathura_link_t* link)
|
||||
{
|
||||
if (link == NULL) {
|
||||
zathura_link_target_t target = { 0 };
|
||||
return target;
|
||||
}
|
||||
|
||||
return link->target;
|
||||
}
|
172
types.h
Normal file
172
types.h
Normal file
|
@ -0,0 +1,172 @@
|
|||
/* See LICENSE file for license and copyright information */
|
||||
|
||||
#ifndef TYPES_H
|
||||
#define TYPES_H
|
||||
|
||||
#include "zathura.h"
|
||||
|
||||
/**
|
||||
* Image buffer
|
||||
*/
|
||||
typedef struct zathura_image_buffer_s
|
||||
{
|
||||
unsigned char* data; /**< Image buffer data */
|
||||
unsigned int height; /**< Height of the image */
|
||||
unsigned int width; /**< Width of the image */
|
||||
unsigned int rowstride; /**< Rowstride of the image */
|
||||
} zathura_image_buffer_t;
|
||||
|
||||
/**
|
||||
* Creates an image buffer
|
||||
*
|
||||
* @param width Width of the image stored in the buffer
|
||||
* @param height Height of the image stored in the buffer
|
||||
* @return Image buffer or NULL if an error occured
|
||||
*/
|
||||
zathura_image_buffer_t* zathura_image_buffer_create(unsigned int width, unsigned int height);
|
||||
|
||||
/**
|
||||
* Frees the image buffer
|
||||
*
|
||||
* @param buffer The image buffer
|
||||
*/
|
||||
void zathura_image_buffer_free(zathura_image_buffer_t* buffer);
|
||||
|
||||
/**
|
||||
* Rectangle structure.
|
||||
* The coordinate system has its origin in the left upper corner. The x axes
|
||||
* goes to the right, the y access goes down.
|
||||
*/
|
||||
typedef struct zathura_rectangle_s
|
||||
{
|
||||
double x1; /**< X coordinate of point 1 */
|
||||
double y1; /**< Y coordinate of point 1 */
|
||||
double x2; /**< X coordinate of point 2 */
|
||||
double y2; /**< Y coordinate of point 2 */
|
||||
} zathura_rectangle_t;
|
||||
|
||||
/**
|
||||
* Image structure
|
||||
*/
|
||||
typedef struct zathura_image_s
|
||||
{
|
||||
zathura_rectangle_t position; /**< Coordinates of the image */
|
||||
void* data; /**< Custom data of the plugin */
|
||||
} zathura_image_t;
|
||||
|
||||
/**
|
||||
* Possible link types
|
||||
*/
|
||||
typedef enum zathura_link_type_e
|
||||
{
|
||||
ZATHURA_LINK_INVALID, /**< Invalid type */
|
||||
ZATHURA_LINK_TO_PAGE, /**< Links to a page */
|
||||
ZATHURA_LINK_EXTERNAL, /**< Links to an external source */
|
||||
} zathura_link_type_t;
|
||||
|
||||
typedef union zathura_link_target_u
|
||||
{
|
||||
unsigned int page_number; /**< Page number */
|
||||
char* uri; /**< Value */
|
||||
} zathura_link_target_t;
|
||||
|
||||
/**
|
||||
* Link
|
||||
*/
|
||||
typedef struct zathura_link_s
|
||||
{
|
||||
zathura_rectangle_t position; /**< Position of the link */
|
||||
zathura_link_type_t type; /**< Link type */
|
||||
zathura_link_target_t target; /**< Link target */
|
||||
} zathura_link_t;
|
||||
|
||||
/**
|
||||
* Index element
|
||||
*/
|
||||
typedef struct zathura_index_element_s
|
||||
{
|
||||
char* title; /**< Title of the element */
|
||||
zathura_link_type_t type; /**< Type */
|
||||
union
|
||||
{
|
||||
unsigned int page_number; /**< Page number */
|
||||
char* uri; /**< Uri */
|
||||
} target;
|
||||
} zathura_index_element_t;
|
||||
|
||||
/**
|
||||
* Form type
|
||||
*/
|
||||
typedef enum zathura_form_type_e
|
||||
{
|
||||
ZATHURA_FORM_CHECKBOX, /**< Checkbox */
|
||||
ZATHURA_FORM_TEXTFIELD /**< Textfield */
|
||||
} zathura_form_type_t;
|
||||
|
||||
/**
|
||||
* Form element
|
||||
*/
|
||||
typedef struct zathura_form_s
|
||||
{
|
||||
zathura_rectangle_t position; /**< Position */
|
||||
zathura_form_type_t type; /**< Type */
|
||||
} zathura_form_t;
|
||||
|
||||
/**
|
||||
* Create new index element
|
||||
*
|
||||
* @param title Title of the index element
|
||||
* @return Index element
|
||||
*/
|
||||
zathura_index_element_t* zathura_index_element_new(const char* title);
|
||||
|
||||
/**
|
||||
* Free index element
|
||||
*
|
||||
* @param index The index element
|
||||
*/
|
||||
void zathura_index_element_free(zathura_index_element_t* index);
|
||||
|
||||
/**
|
||||
* Creates a new zathura link
|
||||
*
|
||||
* @param type Type of the link
|
||||
* @param position Position of the link
|
||||
* @param target Target
|
||||
* @return New zathura link
|
||||
*/
|
||||
zathura_link_t* zathura_link_new(zathura_link_type_t type, zathura_rectangle_t position,
|
||||
zathura_link_target_t target);
|
||||
|
||||
/**
|
||||
* Free link
|
||||
*
|
||||
* @param link The link
|
||||
*/
|
||||
void zathura_link_free(zathura_link_t* link);
|
||||
|
||||
/**
|
||||
* Returns the type of the link
|
||||
*
|
||||
* @param link The link
|
||||
* @return The target type of the link
|
||||
*/
|
||||
zathura_link_type_t zathura_link_get_type(zathura_link_t* link);
|
||||
|
||||
/**
|
||||
* Returns the position of the link
|
||||
*
|
||||
* @param link The link
|
||||
* @return The position of the link
|
||||
*/
|
||||
zathura_rectangle_t zathura_link_get_position(zathura_link_t* link);
|
||||
|
||||
/**
|
||||
* The target value of the link
|
||||
*
|
||||
* @param link The link
|
||||
* @return Returns the target of the link (depends on the link type)
|
||||
*/
|
||||
zathura_link_target_t zathura_link_get_target(zathura_link_t* link);
|
||||
|
||||
#endif // TYPES_H
|
Loading…
Reference in a new issue