Commit e5f36e40 authored by Moritz Lipp's avatar Moritz Lipp

Merge branch 'release/0.2.4'

parents b17c05c9 3978dc30
...@@ -22,9 +22,7 @@ And also note that rst2man from python-docutils is needed to build the man pages ...@@ -22,9 +22,7 @@ And also note that rst2man from python-docutils is needed to build the man pages
If it is not installed, the man pages won't be built. If it is not installed, the man pages won't be built.
If you don't want to build with support for sqlite databases, you can set If you don't want to build with support for sqlite databases, you can set
WITH_SQLITE=0 and sqlite support won't be available. Please note that sqlite3 WITH_SQLITE=0 and sqlite support won't be available.
with meta data support is required, i.e. sqlite3 has to be built with
SQLITE_ENABLE_COLUMN_METADATA defined.
The use of magic to detect mime types is optional and can be disabled by setting The use of magic to detect mime types is optional and can be disabled by setting
WITH_MAGIC=0. WITH_MAGIC=0.
......
...@@ -4,9 +4,11 @@ ...@@ -4,9 +4,11 @@
#include "bookmarks.h" #include "bookmarks.h"
#include "database.h" #include "database.h"
#include "document.h" #include "document.h"
#include "adjustment.h"
#include <girara/datastructures.h> #include <girara/datastructures.h>
#include <girara/utils.h> #include <girara/utils.h>
#include <girara/session.h>
static int static int
bookmark_compare_find(const void* item, const void* data) bookmark_compare_find(const void* item, const void* data)
...@@ -23,14 +25,35 @@ zathura_bookmark_add(zathura_t* zathura, const gchar* id, unsigned int page) ...@@ -23,14 +25,35 @@ zathura_bookmark_add(zathura_t* zathura, const gchar* id, unsigned int page)
g_return_val_if_fail(zathura && zathura->document && zathura->bookmarks.bookmarks, NULL); g_return_val_if_fail(zathura && zathura->document && zathura->bookmarks.bookmarks, NULL);
g_return_val_if_fail(id, NULL); g_return_val_if_fail(id, NULL);
zathura_bookmark_t* old = girara_list_find(zathura->bookmarks.bookmarks, bookmark_compare_find, id); double x = zathura_adjustment_get_ratio(gtk_scrolled_window_get_hadjustment(GTK_SCROLLED_WINDOW(zathura->ui.session->gtk.view)));
double y = zathura_adjustment_get_ratio(gtk_scrolled_window_get_vadjustment(GTK_SCROLLED_WINDOW(zathura->ui.session->gtk.view)));
zathura_bookmark_t* old = zathura_bookmark_get(zathura, id);
if (old != NULL) { if (old != NULL) {
return NULL; old->page = page;
old->x = x;
old->y = y;
if (zathura->database != NULL) {
const char* path = zathura_document_get_path(zathura->document);
if (zathura_db_remove_bookmark(zathura->database, path, old->id) == false) {
girara_warning("Failed to remove old bookmark from database.");
}
if (zathura_db_add_bookmark(zathura->database, path, old) == false) {
girara_warning("Failed to add new bookmark to database.");
}
}
return old;
} }
zathura_bookmark_t* bookmark = g_malloc0(sizeof(zathura_bookmark_t)); zathura_bookmark_t* bookmark = g_malloc0(sizeof(zathura_bookmark_t));
bookmark->id = g_strdup(id); bookmark->id = g_strdup(id);
bookmark->page = page; bookmark->page = page;
bookmark->x = x;
bookmark->y = y;
girara_list_append(zathura->bookmarks.bookmarks, bookmark); girara_list_append(zathura->bookmarks.bookmarks, bookmark);
if (zathura->database != NULL) { if (zathura->database != NULL) {
......
...@@ -10,6 +10,8 @@ struct zathura_bookmark_s ...@@ -10,6 +10,8 @@ struct zathura_bookmark_s
{ {
gchar* id; gchar* id;
unsigned int page; unsigned int page;
double x;
double y;
}; };
typedef struct zathura_bookmark_s zathura_bookmark_t; typedef struct zathura_bookmark_s zathura_bookmark_t;
......
...@@ -95,9 +95,9 @@ cb_view_vadjustment_value_changed(GtkAdjustment* GIRARA_UNUSED(adjustment), gpoi ...@@ -95,9 +95,9 @@ cb_view_vadjustment_value_changed(GtkAdjustment* GIRARA_UNUSED(adjustment), gpoi
if (gdk_rectangle_intersect(&view_rect, &page_rect, NULL) == TRUE) { if (gdk_rectangle_intersect(&view_rect, &page_rect, NULL) == TRUE) {
if (zathura_page_get_visibility(page) == false) { if (zathura_page_get_visibility(page) == false) {
zathura_page_set_visibility(page, true); zathura_page_set_visibility(page, true);
zathura_page_widget_update_view_time(ZATHURA_PAGE(page_widget)); zathura_page_widget_update_view_time(ZATHURA_PAGE(page_widget));
zathura_page_cache_add(zathura, zathura_page_get_index(page)); zathura_page_cache_add(zathura, zathura_page_get_index(page));
} }
if (zathura->global.update_page_number == true && updated == false if (zathura->global.update_page_number == true && updated == false
&& gdk_rectangle_intersect(&center, &page_rect, NULL) == TRUE) { && gdk_rectangle_intersect(&center, &page_rect, NULL) == TRUE) {
...@@ -106,6 +106,19 @@ cb_view_vadjustment_value_changed(GtkAdjustment* GIRARA_UNUSED(adjustment), gpoi ...@@ -106,6 +106,19 @@ cb_view_vadjustment_value_changed(GtkAdjustment* GIRARA_UNUSED(adjustment), gpoi
} }
} else { } else {
zathura_page_set_visibility(page, false); zathura_page_set_visibility(page, false);
/* if the page is not visible and not cached, but still has a surface, we
* need to get rid of the surface */
if (zathura_page_widget_have_surface(ZATHURA_PAGE(page_widget)) == true &&
zathura_page_cache_is_cached(zathura, zathura_page_get_index(page)) == false) {
zathura_page_widget_update_surface(ZATHURA_PAGE(page_widget), NULL);
}
girara_list_t* results = NULL;
g_object_get(page_widget, "search-results", &results, NULL);
if (results != NULL) {
g_object_set(page_widget, "search-current", 0, NULL);
}
} }
} }
...@@ -267,10 +280,7 @@ cb_index_row_activated(GtkTreeView* tree_view, GtkTreePath* path, ...@@ -267,10 +280,7 @@ cb_index_row_activated(GtkTreeView* tree_view, GtkTreePath* path,
} }
sc_toggle_index(zathura->ui.session, NULL, NULL, 0); sc_toggle_index(zathura->ui.session, NULL, NULL, 0);
/* zathura_jumplist_save is called when entering index mode */
zathura_link_evaluate(zathura, index_element->link); zathura_link_evaluate(zathura, index_element->link);
zathura_jumplist_add(zathura);
} }
g_object_unref(model); g_object_unref(model);
...@@ -326,9 +336,7 @@ handle_link(GtkEntry* entry, girara_session_t* session, ...@@ -326,9 +336,7 @@ handle_link(GtkEntry* entry, girara_session_t* session,
invalid_index = false; invalid_index = false;
switch (action) { switch (action) {
case ZATHURA_LINK_ACTION_FOLLOW: case ZATHURA_LINK_ACTION_FOLLOW:
zathura_jumplist_save(zathura);
zathura_link_evaluate(zathura, link); zathura_link_evaluate(zathura, link);
zathura_jumplist_add(zathura);
break; break;
case ZATHURA_LINK_ACTION_DISPLAY: case ZATHURA_LINK_ACTION_DISPLAY:
zathura_link_display(zathura, link); zathura_link_display(zathura, link);
...@@ -527,7 +535,7 @@ cb_unknown_command(girara_session_t* session, const char* input) ...@@ -527,7 +535,7 @@ cb_unknown_command(girara_session_t* session, const char* input)
} }
} }
zathura_jumplist_save(zathura); zathura_jumplist_add(zathura);
page_set(zathura, atoi(input) - 1); page_set(zathura, atoi(input) - 1);
zathura_jumplist_add(zathura); zathura_jumplist_add(zathura);
......
...@@ -18,6 +18,7 @@ ...@@ -18,6 +18,7 @@
#include "plugin.h" #include "plugin.h"
#include "internal.h" #include "internal.h"
#include "render.h" #include "render.h"
#include "adjustment.h"
#include <girara/session.h> #include <girara/session.h>
#include <girara/settings.h> #include <girara/settings.h>
...@@ -44,19 +45,24 @@ cmd_bookmark_create(girara_session_t* session, girara_list_t* argument_list) ...@@ -44,19 +45,24 @@ cmd_bookmark_create(girara_session_t* session, girara_list_t* argument_list)
const char* bookmark_name = girara_list_nth(argument_list, 0); const char* bookmark_name = girara_list_nth(argument_list, 0);
zathura_bookmark_t* bookmark = zathura_bookmark_get(zathura, bookmark_name); zathura_bookmark_t* bookmark = zathura_bookmark_get(zathura, bookmark_name);
if (bookmark != NULL) { bool update = bookmark != NULL ? true : false;
bookmark->page = zathura_document_get_current_page_number(zathura->document) + 1;
girara_notify(session, GIRARA_INFO, _("Bookmark successfuly updated: %s"), bookmark_name);
return true;
}
bookmark = zathura_bookmark_add(zathura, bookmark_name, zathura_document_get_current_page_number(zathura->document) + 1); bookmark = zathura_bookmark_add(zathura, bookmark_name, zathura_document_get_current_page_number(zathura->document) + 1);
if (bookmark == NULL) { if (bookmark == NULL) {
girara_notify(session, GIRARA_ERROR, _("Could not create bookmark: %s"), bookmark_name); if (update == true) {
girara_notify(session, GIRARA_ERROR, _("Could not update bookmark: %s"), bookmark_name);
} else {
girara_notify(session, GIRARA_ERROR, _("Could not create bookmark: %s"), bookmark_name);
}
return false; return false;
} else {
if (update == true) {
girara_notify(session, GIRARA_INFO, _("Bookmark successfully updated: %s"), bookmark_name);
} else {
girara_notify(session, GIRARA_INFO, _("Bookmark successfully created: %s"), bookmark_name);
}
} }
girara_notify(session, GIRARA_INFO, _("Bookmark successfuly created: %s"), bookmark_name);
return true; return true;
} }
...@@ -111,7 +117,20 @@ cmd_bookmark_open(girara_session_t* session, girara_list_t* argument_list) ...@@ -111,7 +117,20 @@ cmd_bookmark_open(girara_session_t* session, girara_list_t* argument_list)
return false; return false;
} }
return page_set(zathura, bookmark->page - 1); zathura_jumplist_add(zathura);
if (bookmark->x != DBL_MIN && bookmark->y != DBL_MIN) {
GtkAdjustment* hadjustment = gtk_scrolled_window_get_hadjustment(GTK_SCROLLED_WINDOW(zathura->ui.session->gtk.view));
GtkAdjustment* vadjustment = gtk_scrolled_window_get_vadjustment(GTK_SCROLLED_WINDOW(zathura->ui.session->gtk.view));
zathura_adjustment_set_value_from_ratio(hadjustment, bookmark->x);
zathura_adjustment_set_value_from_ratio(vadjustment, bookmark->y);
zathura_document_set_current_page_number(zathura->document, bookmark->page - 1);
statusbar_page_number_update(zathura);
} else {
page_set(zathura, bookmark->page - 1);
}
zathura_jumplist_add(zathura);
return true;
} }
bool bool
...@@ -339,7 +358,6 @@ cmd_search(girara_session_t* session, const char* input, girara_argument_t* argu ...@@ -339,7 +358,6 @@ cmd_search(girara_session_t* session, const char* input, girara_argument_t* argu
return false; return false;
} }
bool firsthit = true;
zathura_error_t error = ZATHURA_ERROR_OK; zathura_error_t error = ZATHURA_ERROR_OK;
/* set search direction */ /* set search direction */
...@@ -352,10 +370,6 @@ cmd_search(girara_session_t* session, const char* input, girara_argument_t* argu ...@@ -352,10 +370,6 @@ cmd_search(girara_session_t* session, const char* input, girara_argument_t* argu
bool nohlsearch = false; bool nohlsearch = false;
girara_setting_get(session, "nohlsearch", &nohlsearch); girara_setting_get(session, "nohlsearch", &nohlsearch);
if (nohlsearch == false) {
document_draw_search_results(zathura, true);
}
/* search pages */ /* search pages */
for (unsigned int page_id = 0; page_id < number_of_pages; ++page_id) { for (unsigned int page_id = 0; page_id < number_of_pages; ++page_id) {
unsigned int index = (page_id + current_page_number) % number_of_pages; unsigned int index = (page_id + current_page_number) % number_of_pages;
...@@ -383,20 +397,21 @@ cmd_search(girara_session_t* session, const char* input, girara_argument_t* argu ...@@ -383,20 +397,21 @@ cmd_search(girara_session_t* session, const char* input, girara_argument_t* argu
} }
g_object_set(page_widget, "search-results", result, NULL); g_object_set(page_widget, "search-results", result, NULL);
if (firsthit == true) {
if (page_id != 0) { if (argument->n == BACKWARD) {
page_set_delayed(zathura, zathura_page_get_index(page)); /* start at bottom hit in page */
} g_object_set(page_widget, "search-current", girara_list_size(result) - 1, NULL);
if (argument->n == BACKWARD) { } else {
/* start at bottom hit in page */ g_object_set(page_widget, "search-current", 0, NULL);
g_object_set(page_widget, "search-current", girara_list_size(result) - 1, NULL);
} else {
g_object_set(page_widget, "search-current", 0, NULL);
}
firsthit = false;
} }
} }
girara_argument_t* arg = g_malloc0(sizeof(girara_argument_t));
arg->n = FORWARD;
sc_search(session, arg, NULL, 0);
g_free(arg);
return true; return true;
} }
......
...@@ -27,10 +27,18 @@ cb_jumplist_change(girara_session_t* session, const char* name, ...@@ -27,10 +27,18 @@ cb_jumplist_change(girara_session_t* session, const char* name,
g_return_if_fail(session->global.data != NULL); g_return_if_fail(session->global.data != NULL);
g_return_if_fail(name != NULL); g_return_if_fail(name != NULL);
zathura_t* zathura = session->global.data; zathura_t* zathura = session->global.data;
if (g_strcmp0(name, "jumplist-size") == 0) {
int* max_size = (int*) value; if (g_strcmp0(name, "jumplist-size") != 0) {
zathura->jumplist.max_size = *max_size; return;
}
if (*(int *)value < 0) {
zathura->jumplist.max_size = 0;
} else {
zathura->jumplist.max_size = *(int *)value;
} }
zathura_jumplist_trim(zathura);
} }
static void static void
...@@ -157,7 +165,7 @@ config_load_default(zathura_t* zathura) ...@@ -157,7 +165,7 @@ config_load_default(zathura_t* zathura)
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 = ZATHURA_PAGE_CACHE_DEFAULT_SIZE; int_value = ZATHURA_PAGE_CACHE_DEFAULT_SIZE;
girara_setting_add(gsession, "page-cache-size", &int_value, INT, true, _("Maximum number of pages to keep in the cache"), NULL, NULL); girara_setting_add(gsession, "page-cache-size", &int_value, INT, true, _("Maximum number of pages to keep in the cache"), NULL, NULL);
int_value = 20; int_value = 2000;
girara_setting_add(gsession, "jumplist-size", &int_value, INT, false, _("Number of positions to remember in the jumplist"), cb_jumplist_change, NULL); girara_setting_add(gsession, "jumplist-size", &int_value, INT, false, _("Number of positions to remember in the jumplist"), cb_jumplist_change, NULL);
girara_setting_add(gsession, "recolor-darkcolor", NULL, STRING, false, _("Recoloring (dark color)"), cb_color_change, NULL); girara_setting_add(gsession, "recolor-darkcolor", NULL, STRING, false, _("Recoloring (dark color)"), cb_color_change, NULL);
...@@ -209,6 +217,8 @@ config_load_default(zathura_t* zathura) ...@@ -209,6 +217,8 @@ config_load_default(zathura_t* zathura)
bool_value = false; 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); 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; bool_value = false;
girara_setting_add(gsession, "window-title-page", &bool_value, BOOLEAN, false, _("Display the page number in the window title"), NULL, NULL);
bool_value = false;
girara_setting_add(gsession, "statusbar-basename", &bool_value, BOOLEAN, false, _("Use basename of the file in the statusbar"), NULL, NULL); girara_setting_add(gsession, "statusbar-basename", &bool_value, BOOLEAN, false, _("Use basename of the file in the statusbar"), NULL, NULL);
bool_value = false; bool_value = false;
girara_setting_add(gsession, "synctex", &bool_value, BOOLEAN, false, _("Enable synctex support"), NULL, NULL); girara_setting_add(gsession, "synctex", &bool_value, BOOLEAN, false, _("Enable synctex support"), NULL, 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 = 3 ZATHURA_VERSION_REV = 4
# 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.
......
This diff is collapsed.
This diff is collapsed.
...@@ -35,6 +35,22 @@ zathura_db_load_bookmarks(zathura_database_t* db, const char* file) ...@@ -35,6 +35,22 @@ zathura_db_load_bookmarks(zathura_database_t* db, const char* file)
return ZATHURA_DATABASE_GET_INTERFACE(db)->load_bookmarks(db, file); return ZATHURA_DATABASE_GET_INTERFACE(db)->load_bookmarks(db, file);
} }
girara_list_t*
zathura_db_load_jumplist(zathura_database_t* db, const char* file)
{
g_return_val_if_fail(ZATHURA_IS_DATABASE(db) && file != NULL, NULL);
return ZATHURA_DATABASE_GET_INTERFACE(db)->load_jumplist(db, file);
}
bool
zathura_db_save_jumplist(zathura_database_t* db, const char* file, girara_list_t* jumplist)
{
g_return_val_if_fail(ZATHURA_IS_DATABASE(db) && file != NULL && jumplist != NULL, NULL);
return ZATHURA_DATABASE_GET_INTERFACE(db)->save_jumplist(db, file, jumplist);
}
bool bool
zathura_db_set_fileinfo(zathura_database_t* db, const char* file, zathura_db_set_fileinfo(zathura_database_t* db, const char* file,
zathura_fileinfo_t* file_info) zathura_fileinfo_t* file_info)
......
...@@ -43,6 +43,10 @@ struct _ZathuraDatabaseInterface ...@@ -43,6 +43,10 @@ struct _ZathuraDatabaseInterface
girara_list_t* (*load_bookmarks)(ZathuraDatabase* db, const char* file); girara_list_t* (*load_bookmarks)(ZathuraDatabase* db, const char* file);
girara_list_t* (*load_jumplist)(ZathuraDatabase* db, const char* file);
bool (*save_jumplist)(ZathuraDatabase* db, const char* file, girara_list_t* jumplist);
bool (*set_fileinfo)(ZathuraDatabase* db, const char* file, zathura_fileinfo_t* file_info); bool (*set_fileinfo)(ZathuraDatabase* db, const char* file, zathura_fileinfo_t* file_info);
bool (*get_fileinfo)(ZathuraDatabase* db, const char* file, zathura_fileinfo_t* file_info); bool (*get_fileinfo)(ZathuraDatabase* db, const char* file, zathura_fileinfo_t* file_info);
...@@ -54,7 +58,7 @@ GType zathura_database_get_type(void); ...@@ -54,7 +58,7 @@ GType zathura_database_get_type(void);
* Add or update bookmark in the database. * Add or update bookmark in the database.
* *
* @param db The database instance * @param db The database instance
* @param file The file to which the bookmark belongs to. * @param file The file to which the bookmark belongs.
* @param bookmark The bookmark instance. * @param bookmark The bookmark instance.
* @return true on success, false otherwise * @return true on success, false otherwise
*/ */
...@@ -62,10 +66,10 @@ bool zathura_db_add_bookmark(zathura_database_t* db, const char* file, ...@@ -62,10 +66,10 @@ bool zathura_db_add_bookmark(zathura_database_t* db, const char* file,
zathura_bookmark_t* bookmark); zathura_bookmark_t* bookmark);
/** /**
* Add or update bookmark in the database. * Remove a bookmark from the database.
* *
* @param db The database instance * @param db The database instance
* @param file The file to which the bookmark belongs to. * @param file The file to which the bookmark belongs.
* @param id The id of the bookmark * @param id The id of the bookmark
* @return true on success, false otherwise * @return true on success, false otherwise
*/ */
...@@ -82,11 +86,32 @@ bool zathura_db_remove_bookmark(zathura_database_t* db, const char* file, const ...@@ -82,11 +86,32 @@ bool zathura_db_remove_bookmark(zathura_database_t* db, const char* file, const
girara_list_t* zathura_db_load_bookmarks(zathura_database_t* db, const char* girara_list_t* zathura_db_load_bookmarks(zathura_database_t* db, const char*
file); file);
/**
* Load the jumplist belonging to the specified file from the database.
*
* @param db The database instance.
* @param file The file to which the jumplist belongs.
*
* return A linked list constituting the jumplist of the specified file.
*/
girara_list_t* zathura_db_load_jumplist(ZathuraDatabase* db, const char* file);
/**
* Save the jumplist belonging to the specified file to the database.
*
* @param db The database instance.
* @param file The file to which the jumplist belongs.
* @param jumplist The jumplist to be saved
*
* return true on success, false otherwise.
*/
bool zathura_db_save_jumplist(ZathuraDatabase* db, const char* file, girara_list_t* jumplist);
/** /**
* Set file info (last site, ...) in the database. * Set file info (last site, ...) in the database.
* *
* @param db The database instance * @param db The database instance
* @param file The file to which the file info belongs to. * @param file The file to which the file info belongs.
* @param file_info The file info * @param file_info The file info
* @return true on success, false otherwise. * @return true on success, false otherwise.
*/ */
...@@ -96,7 +121,7 @@ bool zathura_db_set_fileinfo(zathura_database_t* db, const char* file, ...@@ -96,7 +121,7 @@ bool zathura_db_set_fileinfo(zathura_database_t* db, const char* file,
/* Get file info (last site, ...) from the database. /* Get file info (last site, ...) from the database.
* *
* @param db The database instance * @param db The database instance
* @param file The file to which the file info belongs to. * @param file The file to which the file info belongs.
* @param file_info The file info * @param file_info The file info
* @return true on success, false otherwise. * @return true on success, false otherwise.
*/ */
......
...@@ -14,6 +14,7 @@ ...@@ -14,6 +14,7 @@
#ifdef WITH_MAGIC #ifdef WITH_MAGIC
#include <magic.h> #include <magic.h>
#endif #endif
#include <unistd.h>
#include <girara/datastructures.h> #include <girara/datastructures.h>
#include <girara/utils.h> #include <girara/utils.h>
...@@ -40,6 +41,7 @@ static const gchar* guess_type(const char* path); ...@@ -40,6 +41,7 @@ static const gchar* guess_type(const char* path);
*/ */
struct zathura_document_s { struct zathura_document_s {
char* file_path; /**< File path of the document */ char* file_path; /**< File path of the document */
char* basename; /**< Basename of the document */
const char* password; /**< Password of the document */ const char* password; /**< Password of the document */
unsigned int current_page_number; /**< Current page number */ unsigned int current_page_number; /**< Current page number */
unsigned int number_of_pages; /**< Number of pages */ unsigned int number_of_pages; /**< Number of pages */
...@@ -110,12 +112,14 @@ zathura_document_open(zathura_plugin_manager_t* plugin_manager, const char* ...@@ -110,12 +112,14 @@ zathura_document_open(zathura_plugin_manager_t* plugin_manager, const char*
if (plugin == NULL) { if (plugin == NULL) {
girara_error("unknown file type\n"); girara_error("unknown file type\n");
*error = ZATHURA_ERROR_UNKNOWN;
goto error_free; goto error_free;
} }
document = g_malloc0(sizeof(zathura_document_t)); document = g_malloc0(sizeof(zathura_document_t));
document->file_path = real_path; document->file_path = real_path;
document->basename = g_path_get_basename(real_path);
document->password = password; document->password = password;
document->scale = 1.0; document->scale = 1.0;
document->plugin = plugin; document->plugin = plugin;
...@@ -198,6 +202,7 @@ zathura_document_free(zathura_document_t* document) ...@@ -198,6 +202,7 @@ zathura_document_free(zathura_document_t* document)
if (document->file_path != NULL) { if (document->file_path != NULL) {
free(document->file_path); free(document->file_path);
} }
g_free(document->basename);
g_free(document); g_free(document);
...@@ -214,6 +219,16 @@ zathura_document_get_path(zathura_document_t* document) ...@@ -214,6 +219,16 @@ zathura_document_get_path(zathura_document_t* document)
return document->file_path; return document->file_path;
} }
const char*
zathura_document_get_basename(zathura_document_t* document)
{
if (document == NULL) {
return NULL;
}
return document->basename;
}
const char* const char*
zathura_document_get_password(zathura_document_t* document) zathura_document_get_password(zathura_document_t* document)
{ {
......
...@@ -38,6 +38,14 @@ zathura_error_t zathura_document_free(zathura_document_t* document); ...@@ -38,6 +38,14 @@ zathura_error_t zathura_document_free(zathura_document_t* document);
*/ */
const char* zathura_document_get_path(zathura_document_t* document); const char* zathura_document_get_path(zathura_document_t* document);
/**
* Returns the basename of the document
*
* @param document The document
* @return The basename of the document
*/
const char* zathura_document_get_basename(zathura_document_t* document);
/** /**
* Returns the password of the document * Returns the password of the document
* *
......
...@@ -108,7 +108,7 @@ zathura_link_target_t ...@@ -108,7 +108,7 @@ zathura_link_target_t
zathura_link_get_target(zathura_link_t* link) zathura_link_get_target(zathura_link_t* link)
{ {
if (link == NULL) { if (link == NULL) {
zathura_link_target_t target = { 0 }; zathura_link_target_t target = { 0, NULL, 0, 0, 0, 0, 0, 0 };
return target; return target;
} }
...@@ -149,6 +149,8 @@ zathura_link_evaluate(zathura_t* zathura, zathura_link_t* link) ...@@ -149,6 +149,8 @@ zathura_link_evaluate(zathura_t* zathura, zathura_link_t* link)
} }
} }
zathura_jumplist_add(zathura);
/* jump to the page */ /* jump to the page */
page_set(zathura, link->target.page_number); page_set(zathura, link->target.page_number);
...@@ -157,10 +159,12 @@ zathura_link_evaluate(zathura_t* zathura, zathura_link_t* link) ...@@ -157,10 +159,12 @@ zathura_link_evaluate(zathura_t* zathura, zathura_link_t* link)
girara_setting_get(zathura->ui.session, "link-hadjust", &link_hadjust); girara_setting_get(zathura->ui.session, "link-hadjust", &link_hadjust);
if (link_hadjust == true) { if (link_hadjust == true) {
position_set_delayed(zathura, offset.x, offset.y); position_set(zathura, offset.x, offset.y);
} else { } else {
position_set_delayed(zathura, -1, offset.y); position_set(zathura, -1, offset.y);
} }
zathura_jumplist_add(zathura);
} }
break; break;
case ZATHURA_LINK_GOTO_REMOTE: case ZATHURA_LINK_GOTO_REMOTE:
......
...@@ -6,6 +6,7 @@ ...@@ -6,6 +6,7 @@
#include <glib/gi18n.h> #include <glib/gi18n.h>
#include <girara/utils.h> #include <girara/utils.h>
#include <locale.h> #include <locale.h>
#include <unistd.h>
#include "zathura.h" #include "zathura.h"
#include "utils.h" #include "utils.h"
......
...@@ -238,7 +238,9 @@ mark_evaluate(zathura_t* zathura, int key) ...@@ -238,7 +238,9 @@ mark_evaluate(zathura_t* zathura, int key)
zathura_document_set_scale(zathura->document, mark->scale); zathura_document_set_scale(zathura->document, mark->scale);
render_all(zathura); render_all(zathura);
position_set_delayed(zathura, mark->position_x, mark->position_y); zathura_jumplist_add(zathura);
position_set(zathura, mark->position_x, mark->position_y);
zathura_jumplist_add(zathura);
cb_view_vadjustment_value_changed(NULL, zathura); cb_view_vadjustment_value_changed(NULL, zathura);
......
...@@ -86,7 +86,7 @@ enum properties_e { ...@@ -86,7 +86,7 @@ enum properties_e {
PROP_SEARCH_RESULTS, PROP_SEARCH_RESULTS,
PROP_SEARCH_RESULTS_LENGTH, PROP_SEARCH_RESULTS_LENGTH,
PROP_SEARCH_RESULTS_CURRENT, PROP_SEARCH_RESULTS_CURRENT,
PROP_DRAW_SEACH_RESULTS, PROP_DRAW_SEARCH_RESULTS,
PROP_LAST_VIEW, PROP_LAST_VIEW,
}; };