zathura/database.h

132 lines
4.0 KiB
C
Raw Normal View History

/* See LICENSE file for license and copyright information */
#ifndef DATABASE_H
#define DATABASE_H
#include <stdbool.h>
#include <girara/types.h>
#include <glib-object.h>
#include "bookmarks.h"
typedef struct zathura_fileinfo_s {
unsigned int current_page;
unsigned int page_offset;
double scale;
unsigned int rotation;
unsigned int pages_per_row;
unsigned int first_page_column;
double position_x;
double position_y;
} zathura_fileinfo_t;
#define ZATHURA_TYPE_DATABASE \
(zathura_database_get_type ())
#define ZATHURA_DATABASE(obj) \
(G_TYPE_CHECK_INSTANCE_CAST ((obj), ZATHURA_TYPE_DATABASE, ZathuraDatabase))
#define ZATHURA_IS_DATABASE(obj) \
(G_TYPE_CHECK_INSTANCE_TYPE ((obj), ZATHURA_TYPE_DATABASE))
#define ZATHURA_DATABASE_GET_INTERFACE(obj) \
(G_TYPE_INSTANCE_GET_INTERFACE ((obj), ZATHURA_TYPE_DATABASE, ZathuraDatabaseInterface))
typedef struct _ZathuraDatabase ZathuraDatabase;
typedef struct _ZathuraDatabaseInterface ZathuraDatabaseInterface;
struct _ZathuraDatabaseInterface
{
GTypeInterface parent_iface;
/* interface methords */
bool (*add_bookmark)(ZathuraDatabase* db, const char* file, zathura_bookmark_t* bookmark);
bool (*remove_bookmark)(ZathuraDatabase* db, const char* file, const char* id);
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 (*get_fileinfo)(ZathuraDatabase* db, const char* file, zathura_fileinfo_t* file_info);
};
GType zathura_database_get_type(void);
2011-09-03 13:49:21 +02:00
/**
* Add or update bookmark in the database.
2012-02-08 15:30:13 +01:00
*
2011-09-03 13:49:21 +02:00
* @param db The database instance
* @param file The file to which the bookmark belongs.
2011-09-03 13:49:21 +02:00
* @param bookmark The bookmark instance.
* @return true on success, false otherwise
*/
2011-10-10 23:46:50 +02:00
bool zathura_db_add_bookmark(zathura_database_t* db, const char* file,
zathura_bookmark_t* bookmark);
2011-09-03 13:49:21 +02:00
/**
* Remove a bookmark from the database.
2012-02-08 15:30:13 +01:00
*
2011-09-03 13:49:21 +02:00
* @param db The database instance
* @param file The file to which the bookmark belongs.
2012-02-08 15:30:13 +01:00
* @param id The id of the bookmark
2011-09-03 13:49:21 +02:00
* @return true on success, false otherwise
*/
2011-10-10 23:46:50 +02:00
bool zathura_db_remove_bookmark(zathura_database_t* db, const char* file, const
char* id);
2011-09-03 13:49:21 +02:00
/**
* Loads all bookmarks from the database belonging to a specific file.
2012-02-08 15:30:13 +01:00
*
2011-09-03 13:49:21 +02:00
* @param db The database instance.
* @param file The file for which the bookmarks should be loaded.
* @return List of zathura_bookmark_t* or NULL on failure.
*/
2011-10-10 23:46:50 +02:00
girara_list_t* zathura_db_load_bookmarks(zathura_database_t* db, const char*
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.
2012-02-08 15:30:13 +01:00
*
* @param db The database instance
* @param file The file to which the file info belongs.
* @param file_info The file info
* @return true on success, false otherwise.
*/
bool zathura_db_set_fileinfo(zathura_database_t* db, const char* file,
zathura_fileinfo_t* file_info);
2011-09-22 15:47:58 +02:00
/* Get file info (last site, ...) from the database.
2012-02-08 15:30:13 +01:00
*
2011-09-22 15:47:58 +02:00
* @param db The database instance
* @param file The file to which the file info belongs.
* @param file_info The file info
2011-09-22 15:47:58 +02:00
* @return true on success, false otherwise.
*/
bool zathura_db_get_fileinfo(zathura_database_t* db, const char* file,
zathura_fileinfo_t* file_info);
2011-09-22 15:47:58 +02:00
#endif // DATABASE_H