Commit 601c6655 authored by Sebastian Ramacher's avatar Sebastian Ramacher

Imported Upstream version 0.2.1

parent 21a73f79
......@@ -3,7 +3,7 @@ zathura is written by:
Moritz Lipp <mlq@pwmt.org>
Sebastian Ramacher <s.ramacher@gmx.at>
Other contributors are (in alphabetical order):
Other contributors are (in no particular order):
Aepelzen <abietz@gmx.de>
Pavel Borzenkov <pavel.borzenkov@gmail.com>
......@@ -14,3 +14,6 @@ Felix Herrmann <felix@herrmann-koenigsberg.de>
int3 <jezreel@gmail.com>
karottenreibe <k@rottenrei.be>
Johannes Meng <j@jmeng.de>
J. Commelin <jcommeli@math.leidenuniv.nl>
Julian Orth <ju.orth@googlemail.com>
Roland Schatz <roland.schatz@students.jku.at>
......@@ -118,7 +118,35 @@ cb_pages_per_row_value_changed(girara_session_t* session, const char* UNUSED(nam
pages_per_row = 1;
}
page_widget_set_mode(zathura, pages_per_row);
unsigned int first_page_column = 1;
girara_setting_get(session, "first-page-column", &first_page_column);
page_widget_set_mode(zathura, pages_per_row, first_page_column);
if (zathura->document != NULL) {
unsigned int current_page = zathura_document_get_current_page_number(zathura->document);
page_set_delayed(zathura, current_page);
}
}
void
cb_first_page_column_value_changed(girara_session_t* session, const char* UNUSED(name), girara_setting_type_t UNUSED(type), void* value, void* UNUSED(data))
{
g_return_if_fail(value != NULL);
g_return_if_fail(session != NULL);
g_return_if_fail(session->global.data != NULL);
zathura_t* zathura = session->global.data;
int first_page_column = *(int*) value;
if (first_page_column < 1) {
first_page_column = 1;
}
unsigned int pages_per_row = 1;
girara_setting_get(session, "pages-per-row", &pages_per_row);
page_widget_set_mode(zathura, pages_per_row, first_page_column);
if (zathura->document != NULL) {
unsigned int current_page = zathura_document_get_current_page_number(zathura->document);
......@@ -337,6 +365,25 @@ cb_setting_recolor_change(girara_session_t* session, const char* name,
}
}
void
cb_setting_recolor_keep_hue_change(girara_session_t* session, const char* name,
girara_setting_type_t UNUSED(type), void* value, void* UNUSED(data))
{
g_return_if_fail(value != NULL);
g_return_if_fail(session != NULL);
g_return_if_fail(session->global.data != NULL);
g_return_if_fail(name != NULL);
zathura_t* zathura = session->global.data;
bool bool_value = *((bool*) value);
if (zathura->global.recolor_keep_hue != bool_value) {
zathura->global.recolor_keep_hue = bool_value;
render_all(zathura);
}
}
bool
cb_unknown_command(girara_session_t* session, const char* input)
{
......
......@@ -47,6 +47,18 @@ void cb_view_vadjustment_value_changed(GtkAdjustment *adjustment, gpointer data)
*/
void cb_pages_per_row_value_changed(girara_session_t* session, const char* name,
girara_setting_type_t type, void* value, void* data);
/**
* This function gets called when the value of the "first-page-column"
* variable changes
*
* @param session The current girara session
* @param name The name of the row
* @param type The settings type
* @param value The value
* @param data Custom data
*/
void cb_first_page_column_value_changed(girara_session_t* session, const char* name,
girara_setting_type_t type, void* value, void* data);
/**
* Called when an index element is activated (e.g.: double click)
......@@ -111,6 +123,19 @@ bool cb_view_resized(GtkWidget* widget, GtkAllocation* allocation, zathura_t* za
void cb_setting_recolor_change(girara_session_t* session, const char* name,
girara_setting_type_t type, void* value, void* data);
/**
* Emitted when the 'recolor-keephue' setting is changed
*
* @param session Girara session
* @param name Name of the setting ("recolor")
* @param type Type of the setting (BOOLEAN)
* @param value New value
* @param data Custom data
*/
void cb_setting_recolor_keep_hue_change(girara_session_t* session, const char* name,
girara_setting_type_t type, void* value, void* data);
/**
* Unknown command handler which is used to handle the strict numeric goto
* command
......
......@@ -15,11 +15,13 @@
#include "utils.h"
#include "page-widget.h"
#include "page.h"
#include "plugin.h"
#include "internal.h"
#include "render.h"
#include <girara/session.h>
#include <girara/settings.h>
#include <girara/commands.h>
#include <girara/datastructures.h>
#include <girara/utils.h>
......@@ -486,6 +488,27 @@ error_ret:
return true;
}
bool
cmd_exec(girara_session_t* session, girara_list_t* argument_list)
{
g_return_val_if_fail(session != NULL, false);
g_return_val_if_fail(session->global.data != NULL, false);
zathura_t* zathura = session->global.data;
if (zathura->document != NULL) {
const char* path = zathura_document_get_path(zathura->document);
GIRARA_LIST_FOREACH(argument_list, char*, iter, value)
char* r = NULL;
if ((r = replace_substring(value, "$FILE", path)) != NULL) {
girara_list_iterator_set(iter, r);
}
GIRARA_LIST_FOREACH_END(argument_list, char*, iter, value);
}
return girara_exec_with_argument_list(session, argument_list);
}
bool
cmd_offset(girara_session_t* session, girara_list_t* argument_list)
{
......@@ -518,3 +541,23 @@ cmd_offset(girara_session_t* session, girara_list_t* argument_list)
return true;
}
bool
cmd_version(girara_session_t* session, girara_list_t* UNUSED(argument_list))
{
g_return_val_if_fail(session != NULL, false);
g_return_val_if_fail(session->global.data != NULL, false);
zathura_t* zathura = session->global.data;
char* string = zathura_get_version_string(zathura, true);
if (string == NULL) {
return false;
}
/* display information */
girara_notify(session, GIRARA_INFO, "%s", string);
g_free(string);
return true;
}
......@@ -142,6 +142,15 @@ bool cmd_search(girara_session_t* session, const char* input, girara_argument_t*
*/
bool cmd_export(girara_session_t* session, girara_list_t* argument_list);
/**
* Execute command
*
* @param session The used girara session
* @param argument_list List of passed arguments
* @return true if no error occured
*/
bool cmd_exec(girara_session_t* session, girara_list_t* argument_list);
/**
* Set page offset
*
......@@ -151,4 +160,13 @@ bool cmd_export(girara_session_t* session, girara_list_t* argument_list);
*/
bool cmd_offset(girara_session_t* session, girara_list_t* argument_list);
/**
* Shows version information
*
* @param session The used girara session
* @param argument_list List of passed arguments
* @return true if no error occured
*/
bool cmd_version(girara_session_t* session, girara_list_t* argument_list);
#endif // COMMANDS_H
......@@ -32,7 +32,7 @@ compare_case_insensitive(const char* str1, const char* str2)
static girara_list_t*
list_files(zathura_t* zathura, const char* current_path, const char* current_file,
int current_file_length, bool is_dir, bool check_file_ext)
unsigned int current_file_length, bool is_dir, bool check_file_ext)
{
if (zathura == NULL || zathura->ui.session == NULL || current_path == NULL) {
return NULL;
......@@ -60,7 +60,7 @@ list_files(zathura_t* zathura, const char* current_path, const char* current_fil
goto error_free;
}
int e_length = strlen(e_name);
size_t e_length = strlen(e_name);
if (show_hidden == false && e_name[0] == '.') {
g_free(e_name);
......@@ -112,7 +112,7 @@ error_free:
return NULL;
}
girara_completion_t*
static girara_completion_t*
list_files_for_cc(zathura_t* zathura, const char* input, bool check_file_ext)
{
girara_completion_t* completion = girara_completion_init();
......
......@@ -53,8 +53,13 @@ cb_page_padding_changed(girara_session_t* session, const char* UNUSED(name),
int val = *(int*) value;
if (GTK_IS_TABLE(zathura->ui.page_widget) == TRUE) {
#if (GTK_MAJOR_VERSION == 3)
gtk_grid_set_row_spacing(GTK_GRID(zathura->ui.page_widget), val);
gtk_grid_set_column_spacing(GTK_GRID(zathura->ui.page_widget), val);
#else
gtk_table_set_row_spacings(GTK_TABLE(zathura->ui.page_widget), val);
gtk_table_set_col_spacings(GTK_TABLE(zathura->ui.page_widget), val);
#endif
}
}
......@@ -104,13 +109,17 @@ config_load_default(zathura_t* zathura)
girara_setting_add(gsession, "page-padding", &int_value, INT, false, _("Padding between pages"), cb_page_padding_changed, NULL);
int_value = 1;
girara_setting_add(gsession, "pages-per-row", &int_value, INT, false, _("Number of pages per row"), cb_pages_per_row_value_changed, NULL);
int_value = 1;
girara_setting_add(gsession, "first-page-column", &int_value, INT, false, _("Column of the first page"),cb_first_page_column_value_changed, NULL);
float_value = 40;
girara_setting_add(gsession, "scroll-step", &float_value, FLOAT, false, _("Scroll step"), NULL, NULL);
float_value = -1;
girara_setting_add(gsession, "scroll-hstep", &float_value, FLOAT, false, _("Horizontal scroll step"), NULL, NULL);
int_value = 10;
girara_setting_add(gsession, "zoom-min", &int_value, INT, false, _("Zoom minimum"), NULL, NULL);
int_value = 1000;
girara_setting_add(gsession, "zoom-max", &int_value, INT, false, _("Zoom maximum"), NULL, NULL);
int_value = 5;
int_value = 20;
girara_setting_add(gsession, "page-store-threshold", &int_value, INT, false, _("Life time (in seconds) of a hidden page"), NULL, NULL);
girara_setting_add(gsession, "page-store-interval", &int_value, INT, true, _("Amount of seconds between each cache purge"), NULL, NULL);
......@@ -126,9 +135,15 @@ config_load_default(zathura_t* zathura)
bool_value = false;
girara_setting_add(gsession, "recolor", &bool_value, BOOLEAN, false, _("Recolor pages"), cb_setting_recolor_change, NULL);
bool_value = false;
girara_setting_add(gsession, "recolor-keephue", &bool_value, BOOLEAN, false, _("When recoloring keep original hue and adjust lightness only"), cb_setting_recolor_keep_hue_change, NULL);
bool_value = false;
girara_setting_add(gsession, "scroll-wrap", &bool_value, BOOLEAN, false, _("Wrap scrolling"), NULL, NULL);
bool_value = false;
girara_setting_add(gsession, "advance-pages-per-row", &bool_value, BOOLEAN, false, _("Advance number of pages per row"), NULL, NULL);
bool_value = false;
girara_setting_add(gsession, "zoom-center", &bool_value, BOOLEAN, false, _("Horizontally centered zoom"), NULL, NULL);
bool_value = true;
girara_setting_add(gsession, "search-hadjust", &bool_value, BOOLEAN, false, _("Center result horizontally"), NULL, NULL);
float_value = 0.5;
girara_setting_add(gsession, "highlight-transparency", &float_value, FLOAT, false, _("Transparency for highlighting"), NULL, NULL);
bool_value = true;
......@@ -144,6 +159,10 @@ config_load_default(zathura_t* zathura)
girara_setting_add(gsession, "nohlsearch", &bool_value, BOOLEAN, false, _("Highlight search results"), cb_nohlsearch_changed, NULL);
bool_value = true;
girara_setting_add(gsession, "abort-clear-search", &bool_value, BOOLEAN, false, _("Clear search results on abort"), NULL, NULL);
bool_value = false;
girara_setting_add(gsession, "window-title-basename", &bool_value, BOOLEAN, false, _("Use basename of the file in the window title"), NULL, NULL);
bool_value = false;
girara_setting_add(gsession, "synctex", &bool_value, BOOLEAN, false, _("Enable synctex support"), NULL, NULL);
/* define default shortcuts */
girara_shortcut_add(gsession, GDK_CONTROL_MASK, GDK_KEY_c, NULL, sc_abort, 0, 0, NULL);
......@@ -242,14 +261,20 @@ config_load_default(zathura_t* zathura)
girara_shortcut_add(gsession, 0, GDK_KEY_minus, NULL, sc_zoom, FULLSCREEN, ZOOM_OUT, NULL);
girara_shortcut_add(gsession, 0, GDK_KEY_equal, NULL, sc_zoom, NORMAL, ZOOM_ORIGINAL, NULL);
girara_shortcut_add(gsession, 0, GDK_KEY_equal, NULL, sc_zoom, FULLSCREEN, ZOOM_ORIGINAL, NULL);
girara_shortcut_add(gsession, 0, 0, "zi", sc_zoom, NORMAL, ZOOM_IN, NULL);
girara_shortcut_add(gsession, 0, 0, "zi", sc_zoom, FULLSCREEN, ZOOM_IN, NULL);
girara_shortcut_add(gsession, 0, 0, "zI", sc_zoom, NORMAL, ZOOM_IN, NULL);
girara_shortcut_add(gsession, 0, 0, "zI", sc_zoom, FULLSCREEN, ZOOM_IN, NULL);
girara_shortcut_add(gsession, 0, 0, "zo", sc_zoom, NORMAL, ZOOM_OUT, NULL);
girara_shortcut_add(gsession, 0, 0, "zo", sc_zoom, FULLSCREEN, ZOOM_OUT, NULL);
girara_shortcut_add(gsession, 0, 0, "zO", sc_zoom, NORMAL, ZOOM_OUT, NULL);
girara_shortcut_add(gsession, 0, 0, "zO", sc_zoom, FULLSCREEN, ZOOM_OUT, NULL);
girara_shortcut_add(gsession, 0, 0, "z0", sc_zoom, NORMAL, ZOOM_ORIGINAL, NULL);
girara_shortcut_add(gsession, 0, 0, "z0", sc_zoom, FULLSCREEN, ZOOM_ORIGINAL, NULL);
girara_shortcut_add(gsession, 0, GDK_KEY_equal, NULL, sc_zoom, NORMAL, ZOOM_SPECIFIC, NULL);
girara_shortcut_add(gsession, 0, GDK_KEY_equal, NULL, sc_zoom, FULLSCREEN, ZOOM_SPECIFIC, NULL);
girara_shortcut_add(gsession, 0, 0, "zz", sc_zoom, NORMAL, ZOOM_SPECIFIC, NULL);
girara_shortcut_add(gsession, 0, 0, "zz", sc_zoom, FULLSCREEN, ZOOM_SPECIFIC, NULL);
girara_shortcut_add(gsession, 0, 0, "zZ", sc_zoom, NORMAL, ZOOM_SPECIFIC, NULL);
girara_shortcut_add(gsession, 0, 0, "zZ", sc_zoom, FULLSCREEN, ZOOM_SPECIFIC, NULL);
/* mouse events */
girara_mouse_event_add(gsession, 0, 0, sc_mouse_scroll, NORMAL, GIRARA_EVENT_SCROLL_UP, UP, NULL);
......@@ -270,6 +295,7 @@ config_load_default(zathura_t* zathura)
girara_inputbar_command_add(gsession, "blist", NULL, cmd_bookmark_open, cc_bookmarks, _("List all bookmarks"));
girara_inputbar_command_add(gsession, "close", NULL, cmd_close, NULL, _("Close current file"));
girara_inputbar_command_add(gsession, "info", NULL, cmd_info, NULL, _("Show file information"));
girara_inputbar_command_add(gsession, "exec", NULL, cmd_exec, NULL, _("Execute a command"));
girara_inputbar_command_add(gsession, "help", NULL, cmd_help, NULL, _("Show help"));
girara_inputbar_command_add(gsession, "open", "o", cmd_open, cc_open, _("Open document"));
girara_inputbar_command_add(gsession, "quit", "q", cmd_quit, NULL, _("Close zathura"));
......@@ -282,6 +308,7 @@ config_load_default(zathura_t* zathura)
girara_inputbar_command_add(gsession, "delmarks", "delm", cmd_marks_delete, NULL, _("Delete the specified marks"));
girara_inputbar_command_add(gsession, "nohlsearch", "nohl", cmd_nohlsearch, NULL, _("Don't highlight current search results"));
girara_inputbar_command_add(gsession, "hlsearch", NULL, cmd_hlsearch, NULL, _("Highlight current search results"));
girara_inputbar_command_add(gsession, "version", NULL, cmd_version, NULL, _("Show version information"));
girara_special_command_add(gsession, '/', cmd_search, true, FORWARD, NULL);
girara_special_command_add(gsession, '?', cmd_search, true, BACKWARD, NULL);
......
......@@ -3,7 +3,7 @@
ZATHURA_VERSION_MAJOR = 0
ZATHURA_VERSION_MINOR = 2
ZATHURA_VERSION_REV = 0
ZATHURA_VERSION_REV = 1
# If the API changes, the API version and the ABI version have to be bumped.
ZATHURA_API_VERSION = 2
# If the ABI breaks for any reason, this has to be bumped.
......@@ -16,7 +16,7 @@ ZATHURA_GTK_VERSION ?= 2
# minimum required zathura version
# If you want to disable the check, set GIRARA_VERSION_CHECK to 0.
GIRARA_MIN_VERSION = 0.1.3
GIRARA_MIN_VERSION = 0.1.4
GIRARA_VERSION_CHECK ?= $(shell pkg-config --atleast-version=$(GIRARA_MIN_VERSION) girara-gtk${ZATHURA_GTK_VERSION}; echo $$?)
# database
......
......@@ -21,6 +21,7 @@
#define KEY_SCALE "scale"
#define KEY_ROTATE "rotate"
#define KEY_PAGES_PER_ROW "pages-per-row"
#define KEY_FIRST_PAGE_COLUMN "first-page-column"
#define KEY_POSITION_X "position-x"
#define KEY_POSITION_Y "position-y"
......@@ -387,8 +388,9 @@ plain_set_fileinfo(zathura_database_t* db, const char* file, zathura_fileinfo_t*
g_key_file_set_string (priv->history, name, KEY_SCALE, tmp);
g_free(tmp);
g_key_file_set_integer(priv->history, name, KEY_ROTATE, file_info->rotation);
g_key_file_set_integer(priv->history, name, KEY_PAGES_PER_ROW, file_info->pages_per_row);
g_key_file_set_integer(priv->history, name, KEY_ROTATE, file_info->rotation);
g_key_file_set_integer(priv->history, name, KEY_PAGES_PER_ROW, file_info->pages_per_row);
g_key_file_set_integer(priv->history, name, KEY_FIRST_PAGE_COLUMN, file_info->first_page_column);
tmp = g_strdup_printf("%f", file_info->position_x);
g_key_file_set_string(priv->history, name, KEY_POSITION_X, tmp);
......@@ -424,10 +426,11 @@ plain_get_fileinfo(zathura_database_t* db, const char* file, zathura_fileinfo_t*
return false;
}
file_info->current_page = g_key_file_get_integer(priv->history, name, KEY_PAGE, NULL);
file_info->page_offset = g_key_file_get_integer(priv->history, name, KEY_OFFSET, NULL);
file_info->rotation = g_key_file_get_integer(priv->history, name, KEY_ROTATE, NULL);
file_info->pages_per_row = g_key_file_get_integer(priv->history, name, KEY_PAGES_PER_ROW, NULL);
file_info->current_page = g_key_file_get_integer(priv->history, name, KEY_PAGE, NULL);
file_info->page_offset = g_key_file_get_integer(priv->history, name, KEY_OFFSET, NULL);
file_info->rotation = g_key_file_get_integer(priv->history, name, KEY_ROTATE, NULL);
file_info->pages_per_row = g_key_file_get_integer(priv->history, name, KEY_PAGES_PER_ROW, NULL);
file_info->first_page_column = g_key_file_get_integer(priv->history, name, KEY_FIRST_PAGE_COLUMN, NULL);
char* scale_string = g_key_file_get_string(priv->history, name, KEY_SCALE, NULL);
if (scale_string != NULL) {
......
......@@ -120,6 +120,7 @@ sqlite_db_init(ZathuraSQLDatabase* db, const char* path)
"scale FLOAT,"
"rotation INTEGER,"
"pages_per_row INTEGER,"
"first_page_column INTEGER,"
"position_x FLOAT,"
"position_y FLOAT"
");";
......@@ -129,6 +130,9 @@ sqlite_db_init(ZathuraSQLDatabase* db, const char* path)
"ALTER TABLE fileinfo ADD COLUMN position_x FLOAT;"
"ALTER TABLE fileinfo ADD COLUMN position_y FLOAT;";
static const char SQL_FILEINFO_ALTER2[] =
"ALTER TABLE fileinfo ADD COLUMN first_page_column INTEGER;";
sqlite3* session = NULL;
if (sqlite3_open(path, &session) != SQLITE_OK) {
girara_error("Could not open database: %s\n", path);
......@@ -155,6 +159,14 @@ sqlite_db_init(ZathuraSQLDatabase* db, const char* path)
}
}
data_type = NULL;
if (sqlite3_table_column_metadata(session, NULL, "fileinfo", "first_page_column", &data_type, NULL, NULL, NULL, NULL) != SQLITE_OK) {
girara_debug("old database table layout detected; updating ...");
if (sqlite3_exec(session, SQL_FILEINFO_ALTER2, NULL, 0, NULL) != SQLITE_OK) {
girara_warning("failed to update database table layout");
}
}
priv->session = session;
}
......@@ -299,21 +311,22 @@ sqlite_set_fileinfo(zathura_database_t* db, const char* file,
zathura_sqldatabase_private_t* priv = ZATHURA_SQLDATABASE_GET_PRIVATE(db);
static const char SQL_FILEINFO_SET[] =
"REPLACE INTO fileinfo (file, page, offset, scale, rotation, pages_per_row, position_x, position_y) VALUES (?, ?, ?, ?, ?, ?, ?, ?);";
"REPLACE INTO fileinfo (file, page, offset, scale, rotation, pages_per_row, first_page_column, position_x, position_y) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?);";
sqlite3_stmt* stmt = prepare_statement(priv->session, SQL_FILEINFO_SET);
if (stmt == NULL) {
return false;
}
if (sqlite3_bind_text(stmt, 1, file, -1, NULL) != SQLITE_OK ||
sqlite3_bind_int(stmt, 2, file_info->current_page) != SQLITE_OK ||
sqlite3_bind_int(stmt, 3, file_info->page_offset) != SQLITE_OK ||
sqlite3_bind_double(stmt, 4, file_info->scale) != SQLITE_OK ||
sqlite3_bind_int(stmt, 5, file_info->rotation) != SQLITE_OK ||
sqlite3_bind_int(stmt, 6, file_info->pages_per_row) != SQLITE_OK ||
sqlite3_bind_double(stmt, 7, file_info->position_x) != SQLITE_OK ||
sqlite3_bind_double(stmt, 8, file_info->position_y) != SQLITE_OK) {
if (sqlite3_bind_text(stmt, 1, file, -1, NULL) != SQLITE_OK ||
sqlite3_bind_int(stmt, 2, file_info->current_page) != SQLITE_OK ||
sqlite3_bind_int(stmt, 3, file_info->page_offset) != SQLITE_OK ||
sqlite3_bind_double(stmt, 4, file_info->scale) != SQLITE_OK ||
sqlite3_bind_int(stmt, 5, file_info->rotation) != SQLITE_OK ||
sqlite3_bind_int(stmt, 6, file_info->pages_per_row) != SQLITE_OK ||
sqlite3_bind_int(stmt, 7, file_info->first_page_column) != SQLITE_OK ||
sqlite3_bind_double(stmt, 8, file_info->position_x) != SQLITE_OK ||
sqlite3_bind_double(stmt, 9, file_info->position_y) != SQLITE_OK) {
sqlite3_finalize(stmt);
girara_error("Failed to bind arguments.");
return false;
......@@ -336,7 +349,7 @@ sqlite_get_fileinfo(zathura_database_t* db, const char* file,
zathura_sqldatabase_private_t* priv = ZATHURA_SQLDATABASE_GET_PRIVATE(db);
static const char SQL_FILEINFO_GET[] =
"SELECT page, offset, scale, rotation, pages_per_row, position_x, position_y FROM fileinfo WHERE file = ?;";
"SELECT page, offset, scale, rotation, pages_per_row, first_page_column, position_x, position_y FROM fileinfo WHERE file = ?;";
sqlite3_stmt* stmt = prepare_statement(priv->session, SQL_FILEINFO_GET);
if (stmt == NULL) {
......@@ -355,13 +368,14 @@ sqlite_get_fileinfo(zathura_database_t* db, const char* file,
return false;
}
file_info->current_page = sqlite3_column_int(stmt, 0);
file_info->page_offset = sqlite3_column_int(stmt, 1);
file_info->scale = sqlite3_column_double(stmt, 2);
file_info->rotation = sqlite3_column_int(stmt, 3);
file_info->pages_per_row = sqlite3_column_int(stmt, 4);
file_info->position_x = sqlite3_column_double(stmt, 5);
file_info->position_y = sqlite3_column_double(stmt, 6);
file_info->current_page = sqlite3_column_int(stmt, 0);
file_info->page_offset = sqlite3_column_int(stmt, 1);
file_info->scale = sqlite3_column_double(stmt, 2);
file_info->rotation = sqlite3_column_int(stmt, 3);
file_info->pages_per_row = sqlite3_column_int(stmt, 4);
file_info->first_page_column = sqlite3_column_int(stmt, 5);
file_info->position_x = sqlite3_column_double(stmt, 6);
file_info->position_y = sqlite3_column_double(stmt, 7);
sqlite3_finalize(stmt);
......
......@@ -15,6 +15,7 @@ typedef struct zathura_fileinfo_s {
double scale;
unsigned int rotation;
unsigned int pages_per_row;
unsigned int first_page_column;
double position_x;
double position_y;
} zathura_fileinfo_t;
......
......@@ -121,12 +121,13 @@ zathura_document_open(zathura_plugin_manager_t* plugin_manager, const char*
document->adjust_mode = ZATHURA_ADJUST_NONE;
/* open document */
if (plugin->functions.document_open == NULL) {
zathura_plugin_functions_t* functions = zathura_plugin_get_functions(plugin);
if (functions->document_open == NULL) {
girara_error("plugin has no open function\n");
goto error_free;
}
zathura_error_t int_error = plugin->functions.document_open(document);
zathura_error_t int_error = functions->document_open(document);
if (int_error != ZATHURA_ERROR_OK) {
if (error != NULL) {
*error = int_error;
......@@ -186,10 +187,11 @@ zathura_document_free(zathura_document_t* document)
/* free document */
zathura_error_t error = ZATHURA_ERROR_OK;
if (document->plugin->functions.document_free == NULL) {
zathura_plugin_functions_t* functions = zathura_plugin_get_functions(document->plugin);
if (functions->document_free == NULL) {
error = ZATHURA_ERROR_NOT_IMPLEMENTED;
} else {
error = document->plugin->functions.document_free(document, document->data);
error = functions->document_free(document, document->data);
}
if (document->file_path != NULL) {
......@@ -395,11 +397,12 @@ zathura_document_save_as(zathura_document_t* document, const char* path)
return ZATHURA_ERROR_UNKNOWN;
}
if (document->plugin->functions.document_save_as == NULL) {
zathura_plugin_functions_t* functions = zathura_plugin_get_functions(document->plugin);
if (functions->document_save_as == NULL) {
return ZATHURA_ERROR_NOT_IMPLEMENTED;
}
return document->plugin->functions.document_save_as(document, document->data, path);
return functions->document_save_as(document, document->data, path);
}
girara_tree_node_t*
......@@ -412,14 +415,15 @@ zathura_document_index_generate(zathura_document_t* document, zathura_error_t* e
return NULL;
}
if (document->plugin->functions.document_index_generate == NULL) {
zathura_plugin_functions_t* functions = zathura_plugin_get_functions(document->plugin);
if (functions->document_index_generate == NULL) {
if (error != NULL) {
*error = ZATHURA_ERROR_NOT_IMPLEMENTED;
}
return NULL;
}
return document->plugin->functions.document_index_generate(document, document->data, error);
return functions->document_index_generate(document, document->data, error);
}
girara_list_t*
......@@ -432,14 +436,15 @@ zathura_document_attachments_get(zathura_document_t* document, zathura_error_t*
return NULL;
}
if (document->plugin->functions.document_attachments_get == NULL) {
zathura_plugin_functions_t* functions = zathura_plugin_get_functions(document->plugin);
if (functions->document_attachments_get == NULL) {
if (error != NULL) {
*error = ZATHURA_ERROR_NOT_IMPLEMENTED;
}
return NULL;
}
return document->plugin->functions.document_attachments_get(document, document->data, error);
return functions->document_attachments_get(document, document->data, error);
}
zathura_error_t
......@@ -449,11 +454,12 @@ zathura_document_attachment_save(zathura_document_t* document, const char* attac
return ZATHURA_ERROR_INVALID_ARGUMENTS;
}
if (document->plugin->functions.document_attachment_save == NULL) {
zathura_plugin_functions_t* functions = zathura_plugin_get_functions(document->plugin);
if (functions->document_attachment_save == NULL) {
return ZATHURA_ERROR_NOT_IMPLEMENTED;
}
return document->plugin->functions.document_attachment_save(document, document->data, attachment, file);
return functions->document_attachment_save(document, document->data, attachment, file);
}
girara_list_t*
......@@ -466,14 +472,15 @@ zathura_document_get_information(zathura_document_t* document, zathura_error_t*
return NULL;
}
if (document->plugin->functions.document_get_information == NULL) {
zathura_plugin_functions_t* functions = zathura_plugin_get_functions(document->plugin);
if (functions->document_get_information == NULL) {
if (error != NULL) {
*error = ZATHURA_ERROR_NOT_IMPLEMENTED;
}
return NULL;
}
girara_list_t* result = document->plugin->functions.document_get_information(document, document->data, error);
girara_list_t* result = functions->document_get_information(document, document->data, error);
if (result != NULL) {
girara_list_set_free_function(result, (girara_free_function_t) zathura_document_information_entry_free);
}
......
/* See LICENSE file for license and copyright information */
#include <stdio.h>
#include <stdlib.h>
#include <glib/gstdio.h>
#include <glib/gi18n.h>
#include <girara/utils.h>
#include <locale.h>
#include "zathura.h"
#include "utils.h"
/* main function */
int main(int argc, char* argv[])
int
main(int argc, char* argv[])
{
/* init locale */
setlocale(LC_ALL, "");
bindtextdomain(GETTEXT_PACKAGE, LOCALEDIR);
bind_textdomain_codeset(GETTEXT_PACKAGE, "UTF-8");
textdomain(GETTEXT_PACKAGE);
/* init gtk */
g_thread_init(NULL);
gdk_threads_init();
gtk_init(&argc, &argv);
zathura_t* zathura = zathura_init(argc, argv);
/* create zathura session */
zathura_t* zathura = zathura_create();
if (zathura == NULL) {
fprintf(stderr, "error: could not initialize zathura\n");
return -1;
}
/* parse command line arguments */
gchar* config_dir = NULL;
gchar* data_dir = NULL;
gchar* plugin_path = NULL;
gchar* loglevel = NULL;
gchar* password = NULL;
gchar* synctex_editor = NULL;
bool forkback = false;
bool print_version = false;
bool synctex = false;
#if (GTK_MAJOR_VERSION == 3)
Window embed = 0;
#else
GdkNativeWindow embed = 0;
#endif
GOptionEntry entries[] = {
{ "reparent", 'e', 0, G_OPTION_ARG_INT, &embed, _("Reparents to window specified by xid"), "xid" },
{ "config-dir", 'c', 0, G_OPTION_ARG_FILENAME, &config_dir, _("Path to the config directory"), "path" },
{ "data-dir", 'd', 0, G_OPTION_ARG_FILENAME, &data_dir, _("Path to the data directory"), "path" },
{ "plugins-dir", 'p', 0, G_OPTION_ARG_STRING, &plugin_path, _("Path to the directories containing plugins"), "path" },
{ "fork", '\0',0, G_OPTION_ARG_NONE, &forkback, _("Fork into the background"), NULL },
{ "password", 'w', 0, G_OPTION_ARG_STRING, &password, _("Document password"), "password" },
{ "debug", 'l', 0, G_OPTION_ARG_STRING, &loglevel, _("Log level (debug, info, warning, error)"), "level" },
{ "version", 'v', 0, G_OPTION_ARG_NONE, &print_version, _("Print version information"), NULL },
{ "synctex", 's', 0, G_OPTION_ARG_NONE, &synctex, _("Enable synctex support"), NULL },
{ "synctex-editor-command", 'x', 0, G_OPTION_ARG_STRING, &synctex_editor, _("Synctex editor (forwarded to the synctex command)"), "cmd" },
{ NULL, '\0', 0, 0, NULL, NULL, NULL }
};
GOptionContext* context = g_option_context_new(" [file1] [file2] [...]");
g_option_context_add_main_entries(context, entries, NULL);
GError* error = NULL;
if (g_option_context_parse(context, &argc, &argv, &error) == false) {
girara_error("Error parsing command line arguments: %s\n", error->message);
g_option_context_free(context);
g_error_free(error);
return -1;
}
g_option_context_free(context);
/* Fork into the background if the user really wants to ... */
if (forkback == true) {
int pid = fork();
if (pid > 0) { /* parent */
exit(0);
} else if (pid < 0) { /* error */
girara_error("Couldn't fork.");
}
setsid();
}
/* Set log level. */
if (loglevel == NULL || g_strcmp0(loglevel, "info") == 0) {
girara_set_debug_level(GIRARA_INFO);
} else if (g_strcmp0(loglevel, "warning") == 0) {
girara_set_debug_level(GIRARA_WARNING);
} else if (g_strcmp0(loglevel, "error") == 0) {
girara_set_debug_level(GIRARA_ERROR);
}
zathura_set_xid(zathura, embed);
zathura_set_config_dir(zathura, config_dir);
zathura_set_data_dir(zathura, data_dir);
zathura_set_plugin_dir(zathura, plugin_path);
zathura_set_synctex_editor_command(zathura, synctex_editor);
zathura_set_argv(zathura, argv);
/* Init zathura */