...
 
Commits (6)
......@@ -17,7 +17,7 @@ The following dependencies are optional:
* sqlite3 (>= 3.6.23): splite3 database backend
* libmagic from file(1): for mime-type detection
* libsynctex from TeXLive: SyncTeX support
* libsynctex from TeXLive (>= 1.19): SyncTeX support
* libseccomp: sandbox support
For building zathura, the following dependencies are also required:
......
......@@ -69,7 +69,7 @@ flags = cc.get_supported_arguments(flags)
# optional dependencies
additional_sources = []
sqlite = dependency('sqlite3', version: '>=3.6.23', required: get_option('sqlite'))
synctex = dependency('synctex', required: get_option('synctex'))
synctex = dependency('synctex', version: '>=1.19', required: get_option('synctex'))
magic = cc.find_library('magic', required: get_option('magic'))
seccomp = dependency('libseccomp', required: get_option('seccomp'))
......@@ -82,12 +82,8 @@ endif
if synctex.found()
build_dependencies += synctex
defines += '-DWITH_SYNCTEX'
if synctex.version() < '2.0.0'
if synctex.version() >= '1.19.0'
warning('You are using a synctex version pre-SONAME bump, but post-ABI-break. Please make sure to always run zathura using the correct synctex version.')
else
defines += '-DWITH_SYNCTEX1'
endif
if synctex.version() < '2.0.0' and synctex.version() >= '1.19.0'
warning('You are using a synctex version pre-SONAME bump, but post-ABI-break. Please make sure to always run zathura using the correct synctex version.')
endif
endif
......
......@@ -16,27 +16,27 @@
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_type_t type; /**< Link type */
};
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_try_malloc0(sizeof(zathura_link_t));
zathura_link_t* link = g_slice_new(zathura_link_t);
if (link == NULL) {
return NULL;
}
link->type = type;
link->position = position;
link->target = target;
link->type = type;
/* duplicate target.value if necessary */
switch (type) {
case ZATHURA_LINK_NONE:
case ZATHURA_LINK_GOTO_DEST:
link->target = target;
if (target.value != NULL) {
link->target.value = g_strdup(target.value);
}
......@@ -45,15 +45,16 @@ zathura_link_new(zathura_link_type_t type, zathura_rectangle_t position,
case ZATHURA_LINK_URI:
case ZATHURA_LINK_LAUNCH:
case ZATHURA_LINK_NAMED:
/* target.value is required for these cases */
if (target.value == NULL) {
g_free(link);
g_slice_free(zathura_link_t, link);
return NULL;
}
link->target.value = g_strdup(target.value);
break;
default:
g_free(link);
g_slice_free(zathura_link_t, link);
return NULL;
}
......@@ -82,7 +83,7 @@ zathura_link_free(zathura_link_t* link)
break;
}
g_free(link);
g_slice_free(zathura_link_t, link);
}
zathura_link_type_t
......@@ -99,7 +100,7 @@ zathura_rectangle_t
zathura_link_get_position(zathura_link_t* link)
{
if (link == NULL) {
zathura_rectangle_t position = { 0, 0, 0, 0 };
const zathura_rectangle_t position = { 0, 0, 0, 0 };
return position;
}
......@@ -110,7 +111,7 @@ zathura_link_target_t
zathura_link_get_target(zathura_link_t* link)
{
if (link == NULL) {
zathura_link_target_t target = { 0, NULL, 0, 0, 0, 0, 0, 0 };
const zathura_link_target_t target = { 0, NULL, 0, 0, 0, 0, 0, 0 };
return target;
}
......@@ -163,22 +164,22 @@ link_goto_dest(zathura_t* zathura, const zathura_link_t* link)
girara_setting_get(zathura->ui.session, "link-hadjust", &link_hadjust);
/* scale and rotate */
double scale = zathura_document_get_scale(zathura->document);
double shiftx = link->target.left * scale / (double)cell_width;
double shifty = link->target.top * scale / (double)cell_height;
const double scale = zathura_document_get_scale(zathura->document);
double shiftx = link->target.left * scale / cell_width;
double shifty = link->target.top * scale / cell_height;
page_calc_position(zathura->document, shiftx, shifty, &shiftx, &shifty);
/* shift the position or set to auto */
if (link->target.destination_type == ZATHURA_LINK_DESTINATION_XYZ &&
link->target.left != -1 && link_hadjust == true) {
pos_x += shiftx / (double)doc_width;
pos_x += shiftx / doc_width;
} else {
pos_x = -1; /* -1 means automatic */
}
if (link->target.destination_type == ZATHURA_LINK_DESTINATION_XYZ &&
link->target.top != -1) {
pos_y += shifty / (double)doc_height;
pos_y += shifty / doc_height;
} else {
pos_y = -1; /* -1 means automatic */
}
......@@ -223,10 +224,10 @@ link_launch(zathura_t* zathura, const zathura_link_t* link)
/* get file path */
if (link->target.value == NULL) {
return;
};
}
const char* document = zathura_document_get_path(zathura->document);
char* dir = g_path_get_dirname(document);
char* dir = g_path_get_dirname(document);
if (girara_xdg_open_with_working_directory(link->target.value, dir) == false) {
girara_notify(zathura->ui.session, GIRARA_ERROR, _("Failed to run xdg-open."));
......@@ -249,15 +250,19 @@ zathura_link_evaluate(zathura_t* zathura, zathura_link_t* link)
switch (link->type) {
case ZATHURA_LINK_GOTO_DEST:
girara_debug("Going to link destination: page: %d", link->target.page_number);
link_goto_dest(zathura, link);
break;
case ZATHURA_LINK_GOTO_REMOTE:
girara_debug("Going to remote destination: %s", link->target.value);
link_remote(zathura, link->target.value);
break;
case ZATHURA_LINK_URI:
girara_debug("Opening URI: %s", link->target.value);
link_launch(zathura, link);
break;
case ZATHURA_LINK_LAUNCH:
girara_debug("Launching link: %s", link->target.value);
link_launch(zathura, link);
break;
default:
......
......@@ -1123,11 +1123,7 @@ zathura_page_widget_popup_menu(GtkWidget* widget, GdkEventButton* event)
/* attach and popup */
gtk_menu_attach_to_widget(GTK_MENU(menu), widget, NULL);
#if GTK_CHECK_VERSION(3, 22, 0)
gtk_menu_popup_at_pointer(GTK_MENU(menu), (GdkEvent*) event);
#else
gtk_menu_popup(GTK_MENU(menu), NULL, NULL, NULL, NULL, event->button, event->time);
#endif
}
static gboolean
......
......@@ -16,14 +16,6 @@
#include "adjustment.h"
#ifdef WITH_SYNCTEX
#ifdef WITH_SYNCTEX1
typedef synctex_scanner_t synctex_scanner_p;
typedef synctex_node_t synctex_node_p;
#define synctex_scanner_next_result(scanner) synctex_next_result(scanner)
#define synctex_display_query(scanner, file, line, column, page) synctex_display_query(scanner, file, line, column)
#endif
bool
synctex_get_input_line_column(const char* filename, unsigned int page, int x, int y,
char** input_file, unsigned int* line, unsigned int* column)
......