mirror of
https://git.pwmt.org/pwmt/zathura.git
synced 2025-01-01 06:26:00 +01:00
load file info on start and jump to last seen page
This commit is contained in:
parent
4f53b083ef
commit
88c4dd6bbe
3 changed files with 45 additions and 18 deletions
19
callbacks.c
19
callbacks.c
|
@ -91,20 +91,6 @@ cb_pages_per_row_value_changed(girara_session_t* UNUSED(session), girara_setting
|
||||||
page_view_set_mode(zathura, pages_per_row);
|
page_view_set_mode(zathura, pages_per_row);
|
||||||
}
|
}
|
||||||
|
|
||||||
typedef struct page_set_delayed_s {
|
|
||||||
zathura_t* zathura;
|
|
||||||
unsigned int page;
|
|
||||||
} page_set_delayed_t;
|
|
||||||
|
|
||||||
static gboolean
|
|
||||||
page_set_delayed(gpointer data) {
|
|
||||||
page_set_delayed_t* p = data;
|
|
||||||
page_set(p->zathura, p->page);
|
|
||||||
|
|
||||||
g_free(p);
|
|
||||||
return FALSE;
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
void
|
||||||
cb_index_row_activated(GtkTreeView* tree_view, GtkTreePath* path,
|
cb_index_row_activated(GtkTreeView* tree_view, GtkTreePath* path,
|
||||||
GtkTreeViewColumn* UNUSED(column), zathura_t* zathura)
|
GtkTreeViewColumn* UNUSED(column), zathura_t* zathura)
|
||||||
|
@ -129,10 +115,7 @@ cb_index_row_activated(GtkTreeView* tree_view, GtkTreePath* path,
|
||||||
|
|
||||||
if (index_element->type == ZATHURA_LINK_TO_PAGE) {
|
if (index_element->type == ZATHURA_LINK_TO_PAGE) {
|
||||||
sc_toggle_index(zathura->ui.session, NULL, 0);
|
sc_toggle_index(zathura->ui.session, NULL, 0);
|
||||||
page_set_delayed_t* p = g_malloc(sizeof(page_set_delayed_t));
|
page_set_delayed(zathura, index_element->target.page_number);
|
||||||
p->zathura = zathura;
|
|
||||||
p->page = index_element->target.page_number;
|
|
||||||
g_idle_add(page_set_delayed, p);
|
|
||||||
} else if (index_element->type == ZATHURA_LINK_EXTERNAL) {
|
} else if (index_element->type == ZATHURA_LINK_EXTERNAL) {
|
||||||
// TODO
|
// TODO
|
||||||
}
|
}
|
||||||
|
|
36
zathura.c
36
zathura.c
|
@ -340,6 +340,13 @@ document_open(zathura_t* zathura, const char* path, const char* password)
|
||||||
girara_warning("Failed to load bookmarks for %s.\n", zathura->document->file_path);
|
girara_warning("Failed to load bookmarks for %s.\n", zathura->document->file_path);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
unsigned int page = 0u;
|
||||||
|
int offset = 0;
|
||||||
|
float scale = 1.0f;
|
||||||
|
if (zathura_db_get_fileinfo(zathura->database, zathura->document->file_path, &page, &offset, &scale)) {
|
||||||
|
page_set_delayed(zathura, page);
|
||||||
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
error_free:
|
error_free:
|
||||||
|
@ -408,6 +415,35 @@ document_close(zathura_t* zathura)
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
typedef struct page_set_delayed_s {
|
||||||
|
zathura_t* zathura;
|
||||||
|
unsigned int page;
|
||||||
|
} page_set_delayed_t;
|
||||||
|
|
||||||
|
static gboolean
|
||||||
|
page_set_delayed_impl(gpointer data) {
|
||||||
|
page_set_delayed_t* p = data;
|
||||||
|
page_set(p->zathura, p->page);
|
||||||
|
|
||||||
|
g_free(p);
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool
|
||||||
|
page_set_delayed(zathura_t* zathura, unsigned int page_id)
|
||||||
|
{
|
||||||
|
if (zathura == NULL || zathura->document == NULL || zathura->document->pages == NULL ||
|
||||||
|
page_id >= zathura->document->number_of_pages) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
page_set_delayed_t* p = g_malloc(sizeof(page_set_delayed_t));
|
||||||
|
p->zathura = zathura;
|
||||||
|
p->page = page_id;
|
||||||
|
g_idle_add(page_set_delayed_impl, p);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
page_set(zathura_t* zathura, unsigned int page_id)
|
page_set(zathura_t* zathura, unsigned int page_id)
|
||||||
{
|
{
|
||||||
|
|
|
@ -162,6 +162,14 @@ bool document_close(zathura_t* zathura);
|
||||||
*/
|
*/
|
||||||
bool page_set(zathura_t* zathura, unsigned int page_id);
|
bool page_set(zathura_t* zathura, unsigned int page_id);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Opens the page with the given number (delayed)
|
||||||
|
*
|
||||||
|
* @param zathura The zathura session
|
||||||
|
* @return If no error occured true, otherwise false, is returned.
|
||||||
|
*/
|
||||||
|
bool page_set_delayed(zathura_t* zathura, unsigned int page_id);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Builds the box structure to show the rendered pages
|
* Builds the box structure to show the rendered pages
|
||||||
*
|
*
|
||||||
|
|
Loading…
Reference in a new issue