mirror of
https://git.pwmt.org/pwmt/zathura.git
synced 2025-01-01 08:36:00 +01:00
Consider link types in link_new and link_free
This commit is contained in:
parent
dbe0a5c84b
commit
7d2265c294
2 changed files with 22 additions and 12 deletions
31
links.c
31
links.c
|
@ -31,18 +31,16 @@ zathura_link_new(zathura_link_type_t type, zathura_rectangle_t position,
|
||||||
|
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case ZATHURA_LINK_GOTO_DEST:
|
case ZATHURA_LINK_GOTO_DEST:
|
||||||
link->target.page_number = target.page_number;
|
link->target = target;
|
||||||
|
|
||||||
|
if (target.value != NULL) {
|
||||||
|
link->target.value = g_strdup(target.value);
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case ZATHURA_LINK_GOTO_REMOTE:
|
case ZATHURA_LINK_GOTO_REMOTE:
|
||||||
case ZATHURA_LINK_URI:
|
case ZATHURA_LINK_URI:
|
||||||
if (target.value == NULL) {
|
|
||||||
g_free(link);
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
link->target.value = g_strdup(target.value);
|
|
||||||
break;
|
|
||||||
case ZATHURA_LINK_LAUNCH:
|
case ZATHURA_LINK_LAUNCH:
|
||||||
|
case ZATHURA_LINK_NAMED:
|
||||||
if (target.value == NULL) {
|
if (target.value == NULL) {
|
||||||
g_free(link);
|
g_free(link);
|
||||||
return NULL;
|
return NULL;
|
||||||
|
@ -66,8 +64,11 @@ zathura_link_free(zathura_link_t* link)
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (link->type) {
|
switch (link->type) {
|
||||||
|
case ZATHURA_LINK_GOTO_DEST:
|
||||||
|
case ZATHURA_LINK_GOTO_REMOTE:
|
||||||
case ZATHURA_LINK_URI:
|
case ZATHURA_LINK_URI:
|
||||||
case ZATHURA_LINK_LAUNCH:
|
case ZATHURA_LINK_LAUNCH:
|
||||||
|
case ZATHURA_LINK_NAMED:
|
||||||
if (link->target.value != NULL) {
|
if (link->target.value != NULL) {
|
||||||
g_free(link->target.value);
|
g_free(link->target.value);
|
||||||
}
|
}
|
||||||
|
@ -114,13 +115,23 @@ zathura_link_get_target(zathura_link_t* link)
|
||||||
void
|
void
|
||||||
zathura_link_evaluate(zathura_t* zathura, zathura_link_t* link)
|
zathura_link_evaluate(zathura_t* zathura, zathura_link_t* link)
|
||||||
{
|
{
|
||||||
if (zathura == NULL || link == NULL) {
|
if (zathura == NULL || zathura->document == NULL || link == NULL) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (link->type) {
|
switch (link->type) {
|
||||||
case ZATHURA_LINK_GOTO_DEST:
|
case ZATHURA_LINK_GOTO_DEST:
|
||||||
page_set_delayed(zathura, link->target.page_number);
|
switch (link->target.destination_type) {
|
||||||
|
case ZATHURA_LINK_DESTINATION_XYZ:
|
||||||
|
if (link->target.scale == 0) {
|
||||||
|
zathura_document_set_scale(zathura->document, link->target.scale);
|
||||||
|
}
|
||||||
|
|
||||||
|
page_set_delayed(zathura, link->target.page_number);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case ZATHURA_LINK_GOTO_REMOTE:
|
case ZATHURA_LINK_GOTO_REMOTE:
|
||||||
link_remote(zathura, link->target.value);
|
link_remote(zathura, link->target.value);
|
||||||
|
|
3
types.h
3
types.h
|
@ -150,8 +150,7 @@ typedef enum zathura_link_destination_type_e
|
||||||
ZATHURA_LINK_DESTINATION_FITR,
|
ZATHURA_LINK_DESTINATION_FITR,
|
||||||
ZATHURA_LINK_DESTINATION_FITB,
|
ZATHURA_LINK_DESTINATION_FITB,
|
||||||
ZATHURA_LINK_DESTINATION_FITBH,
|
ZATHURA_LINK_DESTINATION_FITBH,
|
||||||
ZATHURA_LINK_DESTINATION_FITBV,
|
ZATHURA_LINK_DESTINATION_FITBV
|
||||||
ZATHURA_LINK_DESTINATION_NAMED
|
|
||||||
} zathura_link_destination_type_t;
|
} zathura_link_destination_type_t;
|
||||||
|
|
||||||
typedef struct zathura_link_target_s
|
typedef struct zathura_link_target_s
|
||||||
|
|
Loading…
Reference in a new issue