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: ...@@ -3,7 +3,7 @@ zathura is written by:
Moritz Lipp <mlq@pwmt.org> Moritz Lipp <mlq@pwmt.org>
Sebastian Ramacher <s.ramacher@gmx.at> Sebastian Ramacher <s.ramacher@gmx.at>
Other contributors are (in alphabetical order): Other contributors are (in no particular order):
Aepelzen <abietz@gmx.de> Aepelzen <abietz@gmx.de>
Pavel Borzenkov <pavel.borzenkov@gmail.com> Pavel Borzenkov <pavel.borzenkov@gmail.com>
...@@ -14,3 +14,6 @@ Felix Herrmann <felix@herrmann-koenigsberg.de> ...@@ -14,3 +14,6 @@ Felix Herrmann <felix@herrmann-koenigsberg.de>
int3 <jezreel@gmail.com> int3 <jezreel@gmail.com>
karottenreibe <k@rottenrei.be> karottenreibe <k@rottenrei.be>
Johannes Meng <j@jmeng.de> 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 ...@@ -118,7 +118,35 @@ cb_pages_per_row_value_changed(girara_session_t* session, const char* UNUSED(nam
pages_per_row = 1; 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) { if (zathura->document != NULL) {
unsigned int current_page = zathura_document_get_current_page_number(zathura->document); 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, ...@@ -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 bool
cb_unknown_command(girara_session_t* session, const char* input) cb_unknown_command(girara_session_t* session, const char* input)
{ {
......
...@@ -47,6 +47,18 @@ void cb_view_vadjustment_value_changed(GtkAdjustment *adjustment, gpointer data) ...@@ -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, void cb_pages_per_row_value_changed(girara_session_t* session, const char* name,
girara_setting_type_t type, void* value, void* data); 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) * 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 ...@@ -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, void cb_setting_recolor_change(girara_session_t* session, const char* name,
girara_setting_type_t type, void* value, void* data); 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 * Unknown command handler which is used to handle the strict numeric goto
* command * command
......
...@@ -15,11 +15,13 @@ ...@@ -15,11 +15,13 @@
#include "utils.h" #include "utils.h"
#include "page-widget.h" #include "page-widget.h"
#include "page.h" #include "page.h"
#include "plugin.h"
#include "internal.h" #include "internal.h"
#include "render.h" #include "render.h"
#include <girara/session.h> #include <girara/session.h>
#include <girara/settings.h> #include <girara/settings.h>
#include <girara/commands.h>
#include <girara/datastructures.h> #include <girara/datastructures.h>
#include <girara/utils.h> #include <girara/utils.h>
...@@ -486,6 +488,27 @@ error_ret: ...@@ -486,6 +488,27 @@ error_ret:
return true; 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 bool
cmd_offset(girara_session_t* session, girara_list_t* argument_list) 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) ...@@ -518,3 +541,23 @@ cmd_offset(girara_session_t* session, girara_list_t* argument_list)
return true; 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* ...@@ -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); 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 * Set page offset
* *
...@@ -151,4 +160,13 @@ bool cmd_export(girara_session_t* session, girara_list_t* argument_list); ...@@ -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); 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 #endif // COMMANDS_H
...@@ -32,7 +32,7 @@ compare_case_insensitive(const char* str1, const char* str2) ...@@ -32,7 +32,7 @@ compare_case_insensitive(const char* str1, const char* str2)
static girara_list_t* static girara_list_t*
list_files(zathura_t* zathura, const char* current_path, const char* current_file, 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) { if (zathura == NULL || zathura->ui.session == NULL || current_path == NULL) {
return NULL; return NULL;
...@@ -60,7 +60,7 @@ list_files(zathura_t* zathura, const char* current_path, const char* current_fil ...@@ -60,7 +60,7 @@ list_files(zathura_t* zathura, const char* current_path, const char* current_fil
goto error_free; goto error_free;
} }
int e_length = strlen(e_name); size_t e_length = strlen(e_name);
if (show_hidden == false && e_name[0] == '.') { if (show_hidden == false && e_name[0] == '.') {
g_free(e_name); g_free(e_name);
...@@ -112,7 +112,7 @@ error_free: ...@@ -112,7 +112,7 @@ error_free:
return NULL; return NULL;
} }
girara_completion_t* static girara_completion_t*
list_files_for_cc(zathura_t* zathura, const char* input, bool check_file_ext) list_files_for_cc(zathura_t* zathura, const char* input, bool check_file_ext)
{ {
girara_completion_t* completion = girara_completion_init(); girara_completion_t* completion = girara_completion_init();
......
...@@ -53,8 +53,13 @@ cb_page_padding_changed(girara_session_t* session, const char* UNUSED(name), ...@@ -53,8 +53,13 @@ cb_page_padding_changed(girara_session_t* session, const char* UNUSED(name),
int val = *(int*) value; int val = *(int*) value;
if (GTK_IS_TABLE(zathura->ui.page_widget) == TRUE) { 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_row_spacings(GTK_TABLE(zathura->ui.page_widget), val);
gtk_table_set_col_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) ...@@ -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); girara_setting_add(gsession, "page-padding", &int_value, INT, false, _("Padding between pages"), cb_page_padding_changed, NULL);
int_value = 1; 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); 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; float_value = 40;
girara_setting_add(gsession, "scroll-step", &float_value, FLOAT, false, _("Scroll step"), NULL, NULL); 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; int_value = 10;
girara_setting_add(gsession, "zoom-min", &int_value, INT, false, _("Zoom minimum"), NULL, NULL); girara_setting_add(gsession, "zoom-min", &int_value, INT, false, _("Zoom minimum"), NULL, NULL);
int_value = 1000; int_value = 1000;
girara_setting_add(gsession, "zoom-max", &int_value, INT, false, _("Zoom maximum"), NULL, NULL); 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-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); 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) ...@@ -126,9 +135,15 @@ config_load_default(zathura_t* zathura)
bool_value = false; bool_value = false;
girara_setting_add(gsession, "recolor", &bool_value, BOOLEAN, false, _("Recolor pages"), cb_setting_recolor_change, NULL); girara_setting_add(gsession, "recolor", &bool_value, BOOLEAN, false, _("Recolor pages"), cb_setting_recolor_change, NULL);
bool_value = false; 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); girara_setting_add(gsession, "scroll-wrap", &bool_value, BOOLEAN, false, _("Wrap scrolling"), NULL, NULL);
bool_value = false; bool_value = false;
girara_setting_add(gsession, "advance-pages-per-row", &bool_value, BOOLEAN, false, _("Advance number of pages per row"), NULL, NULL); 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; float_value = 0.5;
girara_setting_add(gsession, "highlight-transparency", &float_value, FLOAT, false, _("Transparency for highlighting"), NULL, NULL); girara_setting_add(gsession, "highlight-transparency", &float_value, FLOAT, false, _("Transparency for highlighting"), NULL, NULL);
bool_value = true; bool_value = true;
...@@ -144,6 +159,10 @@ config_load_default(zathura_t* zathura) ...@@ -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); girara_setting_add(gsession, "nohlsearch", &bool_value, BOOLEAN, false, _("Highlight search results"), cb_nohlsearch_changed, NULL);
bool_value = true; bool_value = true;
girara_setting_add(gsession, "abort-clear-search", &bool_value, BOOLEAN, false, _("Clear search results on abort"), NULL, NULL); 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 */ /* define default shortcuts */
girara_shortcut_add(gsession, GDK_CONTROL_MASK, GDK_KEY_c, NULL, sc_abort, 0, 0, NULL); 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) ...@@ -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_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, NORMAL, ZOOM_ORIGINAL, NULL);
girara_shortcut_add(gsession, 0, GDK_KEY_equal, NULL, sc_zoom, FULLSCREEN, 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, 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, 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, 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, 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, NORMAL, ZOOM_ORIGINAL, NULL);
girara_shortcut_add(gsession, 0, 0, "z0", sc_zoom, FULLSCREEN, 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, 0, "zz", 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, 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 */ /* mouse events */
girara_mouse_event_add(gsession, 0, 0, sc_mouse_scroll, NORMAL, GIRARA_EVENT_SCROLL_UP, UP, NULL); 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) ...@@ -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, "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, "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, "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, "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, "open", "o", cmd_open, cc_open, _("Open document"));
girara_inputbar_command_add(gsession, "quit", "q", cmd_quit, NULL, _("Close zathura")); girara_inputbar_command_add(gsession, "quit", "q", cmd_quit, NULL, _("Close zathura"));
...@@ -282,6 +308,7 @@ config_load_default(zathura_t* 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, "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, "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, "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, FORWARD, NULL);
girara_special_command_add(gsession, '?', cmd_search, true, BACKWARD, NULL); girara_special_command_add(gsession, '?', cmd_search, true, BACKWARD, NULL);
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
ZATHURA_VERSION_MAJOR = 0 ZATHURA_VERSION_MAJOR = 0
ZATHURA_VERSION_MINOR = 2 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. # If the API changes, the API version and the ABI version have to be bumped.
ZATHURA_API_VERSION = 2 ZATHURA_API_VERSION = 2
# If the ABI breaks for any reason, this has to be bumped. # If the ABI breaks for any reason, this has to be bumped.
...@@ -16,7 +16,7 @@ ZATHURA_GTK_VERSION ?= 2 ...@@ -16,7 +16,7 @@ ZATHURA_GTK_VERSION ?= 2
# minimum required zathura version # minimum required zathura version
# If you want to disable the check, set GIRARA_VERSION_CHECK to 0. # 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 $$?) GIRARA_VERSION_CHECK ?= $(shell pkg-config --atleast-version=$(GIRARA_MIN_VERSION) girara-gtk${ZATHURA_GTK_VERSION}; echo $$?)
# database # database
......
...@@ -21,6 +21,7 @@ ...@@ -21,6 +21,7 @@
#define KEY_SCALE "scale" #define KEY_SCALE "scale"
#define KEY_ROTATE "rotate" #define KEY_ROTATE "rotate"
#define KEY_PAGES_PER_ROW "pages-per-row" #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_X "position-x"
#define KEY_POSITION_Y "position-y" #define KEY_POSITION_Y "position-y"
...@@ -387,8 +388,9 @@ plain_set_fileinfo(zathura_database_t* db, const char* file, zathura_fileinfo_t* ...@@ -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_key_file_set_string (priv->history, name, KEY_SCALE, tmp);
g_free(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_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_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); tmp = g_strdup_printf("%f", file_info->position_x);
g_key_file_set_string(priv->history, name, KEY_POSITION_X, tmp); 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* ...@@ -424,10 +426,11 @@ plain_get_fileinfo(zathura_database_t* db, const char* file, zathura_fileinfo_t*
return false; return false;
} }
file_info->current_page = g_key_file_get_integer(priv->history, name, KEY_PAGE, 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->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->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->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); char* scale_string = g_key_file_get_string(priv->history, name, KEY_SCALE, NULL);
if (scale_string != NULL) { if (scale_string != NULL) {
......
...@@ -120,6 +120,7 @@ sqlite_db_init(ZathuraSQLDatabase* db, const char* path) ...@@ -120,6 +120,7 @@ sqlite_db_init(ZathuraSQLDatabase* db, const char* path)
"scale FLOAT," "scale FLOAT,"
"rotation INTEGER," "rotation INTEGER,"
"pages_per_row INTEGER," "pages_per_row INTEGER,"
"first_page_column INTEGER,"
"position_x FLOAT," "position_x FLOAT,"
"position_y FLOAT" "position_y FLOAT"
");"; ");";
...@@ -129,6 +130,9 @@ sqlite_db_init(ZathuraSQLDatabase* db, const char* path) ...@@ -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_x FLOAT;"
"ALTER TABLE fileinfo ADD COLUMN position_y 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; sqlite3* session = NULL;
if (sqlite3_open(path, &session) != SQLITE_OK) { if (sqlite3_open(path, &session) != SQLITE_OK) {
girara_error("Could not open database: %s\n", path); girara_error("Could not open database: %s\n", path);
...@@ -155,6 +159,14 @@ sqlite_db_init(ZathuraSQLDatabase* db, const char* 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; priv->session = session;
} }
...@@ -299,21 +311,22 @@ sqlite_set_fileinfo(zathura_database_t* db, const char* file, ...@@ -299,21 +311,22 @@ sqlite_set_fileinfo(zathura_database_t* db, const char* file,
zathura_sqldatabase_private_t* priv = ZATHURA_SQLDATABASE_GET_PRIVATE(db); zathura_sqldatabase_private_t* priv = ZATHURA_SQLDATABASE_GET_PRIVATE(db);
static const char SQL_FILEINFO_SET[] = 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); sqlite3_stmt* stmt = prepare_statement(priv->session, SQL_FILEINFO_SET);
if (stmt == NULL) { if (stmt == NULL) {
return false; return false;
} }
if (sqlite3_bind_text(stmt, 1, file, -1, NULL) != 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, 2, file_info->current_page) != SQLITE_OK ||
sqlite3_bind_int(stmt, 3, file_info->page_offset) != 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_double(stmt, 4, file_info->scale) != SQLITE_OK ||
sqlite3_bind_int(stmt, 5, file_info->rotation) != 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, 6, file_info->pages_per_row) != SQLITE_OK ||
sqlite3_bind_double(stmt, 7, file_info->position_x) != SQLITE_OK || sqlite3_bind_int(stmt, 7, file_info->first_page_column) != SQLITE_OK ||
sqlite3_bind_double(stmt, 8, file_info->position_y) != 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); sqlite3_finalize(stmt);
girara_error("Failed to bind arguments."); girara_error("Failed to bind arguments.");
return false; return false;
...@@ -336,7 +349,7 @@ sqlite_get_fileinfo(zathura_database_t* db, const char* file, ...@@ -336,7 +349,7 @@ sqlite_get_fileinfo(zathura_database_t* db, const char* file,
zathura_sqldatabase_private_t* priv = ZATHURA_SQLDATABASE_GET_PRIVATE(db); zathura_sqldatabase_private_t* priv = ZATHURA_SQLDATABASE_GET_PRIVATE(db);
static const char SQL_FILEINFO_GET[] = 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); sqlite3_stmt* stmt = prepare_statement(priv->session, SQL_FILEINFO_GET);
if (stmt == NULL) { if (stmt == NULL) {
...@@ -355,13 +368,14 @@ sqlite_get_fileinfo(zathura_database_t* db, const char* file, ...@@ -355,13 +368,14 @@ sqlite_get_fileinfo(zathura_database_t* db, const char* file,
return false; return false;
} }
file_info->current_page = sqlite3_column_int(stmt, 0); file_info->current_page = sqlite3_column_int(stmt, 0);
file_info->page_offset = sqlite3_column_int(stmt, 1); file_info->page_offset = sqlite3_column_int(stmt, 1);
file_info->scale = sqlite3_column_double(stmt, 2); file_info->scale = sqlite3_column_double(stmt, 2);
file_info->rotation = sqlite3_column_int(stmt, 3); file_info->rotation = sqlite3_column_int(stmt, 3);
file_info->pages_per_row = sqlite3_column_int(stmt, 4); file_info->pages_per_row = sqlite3_column_int(stmt, 4);
file_info->position_x = sqlite3_column_double(stmt, 5); file_info->first_page_column = sqlite3_column_int(stmt, 5);
file_info->position_y = sqlite3_column_double(stmt, 6); file_info->position_x = sqlite3_column_double(stmt, 6);
file_info->position_y = sqlite3_column_double(stmt, 7);
sqlite3_finalize(stmt); sqlite3_finalize(stmt);
......
...@@ -15,6 +15,7 @@ typedef struct zathura_fileinfo_s { ...@@ -15,6 +15,7 @@ typedef struct zathura_fileinfo_s {
double scale; double scale;
unsigned int rotation; unsigned int rotation;
unsigned int pages_per_row; unsigned int pages_per_row;
unsigned int first_page_column;
double position_x; double position_x;
double position_y; double position_y;
} zathura_fileinfo_t; } zathura_fileinfo_t;
......
...@@ -121,12 +121,13 @@ zathura_document_open(zathura_plugin_manager_t* plugin_manager, const char* ...@@ -121,12 +121,13 @@ zathura_document_open(zathura_plugin_manager_t* plugin_manager, const char*
document->adjust_mode = ZATHURA_ADJUST_NONE; document->adjust_mode = ZATHURA_ADJUST_NONE;
/* open document */ /* 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"); girara_error("plugin has no open function\n");
goto error_free; 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 (int_error != ZATHURA_ERROR_OK) {
if (error != NULL) { if (error != NULL) {
*error = int_error; *error = int_error;
...@@ -186,10 +187,11 @@ zathura_document_free(zathura_document_t* document) ...@@ -186,10 +187,11 @@ zathura_document_free(zathura_document_t* document)
/* free document */ /* free document */
zathura_error_t error = ZATHURA_ERROR_OK; 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; error = ZATHURA_ERROR_NOT_IMPLEMENTED;
} else { } else {
error = document->plugin->functions.document_free(document, document->data); error = functions->document_free(document, document->data);
} }
if (document->file_path != NULL) { if (document->file_path != NULL) {
...@@ -395,11 +397,12 @@ zathura_document_save_as(zathura_document_t* document, const char* path) ...@@ -395,11 +397,12 @@ zathura_document_save_as(zathura_document_t* document, const char* path)
return ZATHURA_ERROR_UNKNOWN; return ZATHURA_ERROR_UNKNOWN;
} }