mirror of
https://git.pwmt.org/pwmt/zathura.git
synced 2025-01-30 18:54:56 +01:00
Split out fileinfo save
Signed-off-by: Sebastian Ramacher <sebastian+dev@ramacher.at>
This commit is contained in:
parent
1c6d31a8b1
commit
eda1dcec63
1 changed files with 31 additions and 24 deletions
|
@ -792,7 +792,7 @@ document_open(zathura_t* zathura, const char* path, const char* uri, const char*
|
||||||
}
|
}
|
||||||
goto error_out;
|
goto error_out;
|
||||||
}
|
}
|
||||||
|
|
||||||
zathura->document = document;
|
zathura->document = document;
|
||||||
|
|
||||||
const char* file_path = zathura_document_get_path(document);
|
const char* file_path = zathura_document_get_path(document);
|
||||||
|
@ -1193,6 +1193,35 @@ remove_page_from_table(GtkWidget* page, gpointer UNUSED(permanent))
|
||||||
gtk_container_remove(GTK_CONTAINER(gtk_widget_get_parent(page)), page);
|
gtk_container_remove(GTK_CONTAINER(gtk_widget_get_parent(page)), page);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
save_fileinfo_to_db(zathura_t* zathura)
|
||||||
|
{
|
||||||
|
const char* path = zathura_document_get_path(zathura->document);
|
||||||
|
|
||||||
|
zathura_fileinfo_t file_info = {
|
||||||
|
.current_page = zathura_document_get_current_page_number(zathura->document),
|
||||||
|
.page_offset = zathura_document_get_page_offset(zathura->document),
|
||||||
|
.scale = zathura_document_get_scale(zathura->document),
|
||||||
|
.rotation = zathura_document_get_rotation(zathura->document),
|
||||||
|
.pages_per_row = 1,
|
||||||
|
.first_page_column_list = "1:2",
|
||||||
|
.position_x = zathura_document_get_position_x(zathura->document),
|
||||||
|
.position_y = zathura_document_get_position_y(zathura->document)
|
||||||
|
};
|
||||||
|
|
||||||
|
girara_setting_get(zathura->ui.session, "pages-per-row",
|
||||||
|
&(file_info.pages_per_row));
|
||||||
|
girara_setting_get(zathura->ui.session, "first-page-column",
|
||||||
|
&(file_info.first_page_column_list));
|
||||||
|
|
||||||
|
/* save file info */
|
||||||
|
zathura_db_set_fileinfo(zathura->database, path, &file_info);
|
||||||
|
/* save jumplist */
|
||||||
|
zathura_db_save_jumplist(zathura->database, path, zathura->jumplist.list);
|
||||||
|
|
||||||
|
g_free(file_info.first_page_column_list);
|
||||||
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
document_close(zathura_t* zathura, bool keep_monitor)
|
document_close(zathura_t* zathura, bool keep_monitor)
|
||||||
{
|
{
|
||||||
|
@ -1234,32 +1263,10 @@ document_close(zathura_t* zathura, bool keep_monitor)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* store file information */
|
/* store file information */
|
||||||
const char* path = zathura_document_get_path(zathura->document);
|
|
||||||
|
|
||||||
zathura_fileinfo_t file_info = { 0, 0, 1, 0, 1, "1:2", 0, 0 };
|
|
||||||
file_info.current_page = zathura_document_get_current_page_number(zathura->document);
|
|
||||||
file_info.page_offset = zathura_document_get_page_offset(zathura->document);
|
|
||||||
file_info.scale = zathura_document_get_scale(zathura->document);
|
|
||||||
file_info.rotation = zathura_document_get_rotation(zathura->document);
|
|
||||||
|
|
||||||
girara_setting_get(zathura->ui.session, "pages-per-row", &(file_info.pages_per_row));
|
|
||||||
girara_setting_get(zathura->ui.session, "first-page-column", &(file_info.first_page_column_list));
|
|
||||||
|
|
||||||
/* get position */
|
|
||||||
file_info.position_x = zathura_document_get_position_x(zathura->document);
|
|
||||||
file_info.position_y = zathura_document_get_position_y(zathura->document);
|
|
||||||
|
|
||||||
if (zathura->database != NULL) {
|
if (zathura->database != NULL) {
|
||||||
/* save file info */
|
save_fileinfo_to_db(zathura);
|
||||||
zathura_db_set_fileinfo(zathura->database, path, &file_info);
|
|
||||||
|
|
||||||
/* save jumplist */
|
|
||||||
zathura_db_save_jumplist(zathura->database, path, zathura->jumplist.list);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* free buffers */
|
|
||||||
g_free(file_info.first_page_column_list);
|
|
||||||
|
|
||||||
girara_list_iterator_free(zathura->jumplist.cur);
|
girara_list_iterator_free(zathura->jumplist.cur);
|
||||||
zathura->jumplist.cur = NULL;
|
zathura->jumplist.cur = NULL;
|
||||||
girara_list_free(zathura->jumplist.list);
|
girara_list_free(zathura->jumplist.list);
|
||||||
|
|
Loading…
Reference in a new issue