mirror of
https://git.pwmt.org/pwmt/zathura.git
synced 2024-12-29 13:05:59 +01:00
Use G_ADD_PRIVATE
Fix deprecation warnings with glib 2.58.
This commit is contained in:
parent
04c3754455
commit
a4d1df87db
6 changed files with 213 additions and 219 deletions
|
@ -48,6 +48,18 @@ file_lock_set(int fd, short cmd)
|
||||||
static void zathura_database_interface_init(ZathuraDatabaseInterface* iface);
|
static void zathura_database_interface_init(ZathuraDatabaseInterface* iface);
|
||||||
static void io_interface_init(GiraraInputHistoryIOInterface* iface);
|
static void io_interface_init(GiraraInputHistoryIOInterface* iface);
|
||||||
|
|
||||||
|
typedef struct zathura_plaindatabase_private_s {
|
||||||
|
char* bookmark_path;
|
||||||
|
GKeyFile* bookmarks;
|
||||||
|
GFileMonitor* bookmark_monitor;
|
||||||
|
|
||||||
|
char* history_path;
|
||||||
|
GKeyFile* history;
|
||||||
|
GFileMonitor* history_monitor;
|
||||||
|
|
||||||
|
char* input_history_path;
|
||||||
|
} ZathuraPlainDatabasePrivate;
|
||||||
|
|
||||||
G_DEFINE_TYPE_WITH_CODE(ZathuraPlainDatabase, zathura_plaindatabase, G_TYPE_OBJECT,
|
G_DEFINE_TYPE_WITH_CODE(ZathuraPlainDatabase, zathura_plaindatabase, G_TYPE_OBJECT,
|
||||||
G_IMPLEMENT_INTERFACE(ZATHURA_TYPE_DATABASE, zathura_database_interface_init)
|
G_IMPLEMENT_INTERFACE(ZATHURA_TYPE_DATABASE, zathura_database_interface_init)
|
||||||
G_IMPLEMENT_INTERFACE(GIRARA_TYPE_INPUT_HISTORY_IO, io_interface_init))
|
G_IMPLEMENT_INTERFACE(GIRARA_TYPE_INPUT_HISTORY_IO, io_interface_init))
|
||||||
|
@ -72,21 +84,6 @@ static GKeyFile* zathura_db_read_key_file_from_file(const char* path);
|
||||||
static void zathura_db_write_key_file_to_file(const char* file, GKeyFile* key_file);
|
static void zathura_db_write_key_file_to_file(const char* file, GKeyFile* key_file);
|
||||||
static void cb_zathura_db_watch_file(GFileMonitor* monitor, GFile* file, GFile* other_file, GFileMonitorEvent event, zathura_database_t* database);
|
static void cb_zathura_db_watch_file(GFileMonitor* monitor, GFile* file, GFile* other_file, GFileMonitorEvent event, zathura_database_t* database);
|
||||||
|
|
||||||
typedef struct zathura_plaindatabase_private_s {
|
|
||||||
char* bookmark_path;
|
|
||||||
GKeyFile* bookmarks;
|
|
||||||
GFileMonitor* bookmark_monitor;
|
|
||||||
|
|
||||||
char* history_path;
|
|
||||||
GKeyFile* history;
|
|
||||||
GFileMonitor* history_monitor;
|
|
||||||
|
|
||||||
char* input_history_path;
|
|
||||||
} zathura_plaindatabase_private_t;
|
|
||||||
|
|
||||||
#define ZATHURA_PLAINDATABASE_GET_PRIVATE(obj) \
|
|
||||||
(G_TYPE_INSTANCE_GET_PRIVATE ((obj), ZATHURA_TYPE_PLAINDATABASE, zathura_plaindatabase_private_t))
|
|
||||||
|
|
||||||
enum {
|
enum {
|
||||||
PROP_0,
|
PROP_0,
|
||||||
PROP_PATH
|
PROP_PATH
|
||||||
|
@ -131,9 +128,6 @@ io_interface_init(GiraraInputHistoryIOInterface* iface)
|
||||||
static void
|
static void
|
||||||
zathura_plaindatabase_class_init(ZathuraPlainDatabaseClass* class)
|
zathura_plaindatabase_class_init(ZathuraPlainDatabaseClass* class)
|
||||||
{
|
{
|
||||||
/* add private members */
|
|
||||||
g_type_class_add_private(class, sizeof(zathura_plaindatabase_private_t));
|
|
||||||
|
|
||||||
/* override methods */
|
/* override methods */
|
||||||
GObjectClass* object_class = G_OBJECT_CLASS(class);
|
GObjectClass* object_class = G_OBJECT_CLASS(class);
|
||||||
object_class->dispose = plain_dispose;
|
object_class->dispose = plain_dispose;
|
||||||
|
@ -148,7 +142,7 @@ zathura_plaindatabase_class_init(ZathuraPlainDatabaseClass* class)
|
||||||
static void
|
static void
|
||||||
zathura_plaindatabase_init(ZathuraPlainDatabase* db)
|
zathura_plaindatabase_init(ZathuraPlainDatabase* db)
|
||||||
{
|
{
|
||||||
zathura_plaindatabase_private_t* priv = ZATHURA_PLAINDATABASE_GET_PRIVATE(db);
|
ZathuraPlainDatabasePrivate* priv = zathura_plaindatabase_get_instance_private(db);
|
||||||
|
|
||||||
priv->bookmark_path = NULL;
|
priv->bookmark_path = NULL;
|
||||||
priv->bookmark_monitor = NULL;
|
priv->bookmark_monitor = NULL;
|
||||||
|
@ -165,7 +159,7 @@ zathura_plaindatabase_new(const char* path)
|
||||||
g_return_val_if_fail(path != NULL && strlen(path) != 0, NULL);
|
g_return_val_if_fail(path != NULL && strlen(path) != 0, NULL);
|
||||||
|
|
||||||
zathura_database_t* db = g_object_new(ZATHURA_TYPE_PLAINDATABASE, "path", path, NULL);
|
zathura_database_t* db = g_object_new(ZATHURA_TYPE_PLAINDATABASE, "path", path, NULL);
|
||||||
zathura_plaindatabase_private_t* priv = ZATHURA_PLAINDATABASE_GET_PRIVATE(db);
|
ZathuraPlainDatabasePrivate* priv = zathura_plaindatabase_get_instance_private(ZATHURA_PLAINDATABASE(db));
|
||||||
if (priv->bookmark_path == NULL) {
|
if (priv->bookmark_path == NULL) {
|
||||||
g_object_unref(db);
|
g_object_unref(db);
|
||||||
return NULL;
|
return NULL;
|
||||||
|
@ -177,7 +171,7 @@ zathura_plaindatabase_new(const char* path)
|
||||||
static void
|
static void
|
||||||
plain_db_init(ZathuraPlainDatabase* db, const char* dir)
|
plain_db_init(ZathuraPlainDatabase* db, const char* dir)
|
||||||
{
|
{
|
||||||
zathura_plaindatabase_private_t* priv = ZATHURA_PLAINDATABASE_GET_PRIVATE(db);
|
ZathuraPlainDatabasePrivate* priv = zathura_plaindatabase_get_instance_private(db);
|
||||||
|
|
||||||
/* bookmarks */
|
/* bookmarks */
|
||||||
priv->bookmark_path = g_build_filename(dir, BOOKMARKS, NULL);
|
priv->bookmark_path = g_build_filename(dir, BOOKMARKS, NULL);
|
||||||
|
@ -288,7 +282,7 @@ static void
|
||||||
plain_dispose(GObject* object)
|
plain_dispose(GObject* object)
|
||||||
{
|
{
|
||||||
ZathuraPlainDatabase* db = ZATHURA_PLAINDATABASE(object);
|
ZathuraPlainDatabase* db = ZATHURA_PLAINDATABASE(object);
|
||||||
zathura_plaindatabase_private_t* priv = ZATHURA_PLAINDATABASE_GET_PRIVATE(db);
|
ZathuraPlainDatabasePrivate* priv = zathura_plaindatabase_get_instance_private(db);
|
||||||
|
|
||||||
g_clear_object(&priv->bookmark_monitor);
|
g_clear_object(&priv->bookmark_monitor);
|
||||||
g_clear_object(&priv->history_monitor);
|
g_clear_object(&priv->history_monitor);
|
||||||
|
@ -300,7 +294,7 @@ static void
|
||||||
plain_finalize(GObject* object)
|
plain_finalize(GObject* object)
|
||||||
{
|
{
|
||||||
ZathuraPlainDatabase* db = ZATHURA_PLAINDATABASE(object);
|
ZathuraPlainDatabase* db = ZATHURA_PLAINDATABASE(object);
|
||||||
zathura_plaindatabase_private_t* priv = ZATHURA_PLAINDATABASE_GET_PRIVATE(db);
|
ZathuraPlainDatabasePrivate* priv = zathura_plaindatabase_get_instance_private(db);
|
||||||
|
|
||||||
/* bookmarks */
|
/* bookmarks */
|
||||||
g_free(priv->bookmark_path);
|
g_free(priv->bookmark_path);
|
||||||
|
@ -326,7 +320,8 @@ static bool
|
||||||
plain_add_bookmark(zathura_database_t* db, const char* file,
|
plain_add_bookmark(zathura_database_t* db, const char* file,
|
||||||
zathura_bookmark_t* bookmark)
|
zathura_bookmark_t* bookmark)
|
||||||
{
|
{
|
||||||
zathura_plaindatabase_private_t* priv = ZATHURA_PLAINDATABASE_GET_PRIVATE(db);
|
ZathuraPlainDatabase* plaindb = ZATHURA_PLAINDATABASE(db);
|
||||||
|
ZathuraPlainDatabasePrivate* priv = zathura_plaindatabase_get_instance_private(plaindb);
|
||||||
if (priv->bookmarks == NULL || priv->bookmark_path == NULL ||
|
if (priv->bookmarks == NULL || priv->bookmark_path == NULL ||
|
||||||
bookmark->id == NULL) {
|
bookmark->id == NULL) {
|
||||||
return false;
|
return false;
|
||||||
|
@ -364,7 +359,8 @@ plain_add_bookmark(zathura_database_t* db, const char* file,
|
||||||
static bool
|
static bool
|
||||||
plain_remove_bookmark(zathura_database_t* db, const char* file, const char* id)
|
plain_remove_bookmark(zathura_database_t* db, const char* file, const char* id)
|
||||||
{
|
{
|
||||||
zathura_plaindatabase_private_t* priv = ZATHURA_PLAINDATABASE_GET_PRIVATE(db);
|
ZathuraPlainDatabase* plaindb = ZATHURA_PLAINDATABASE(db);
|
||||||
|
ZathuraPlainDatabasePrivate* priv = zathura_plaindatabase_get_instance_private(plaindb);
|
||||||
if (priv->bookmarks == NULL || priv->bookmark_path == NULL) {
|
if (priv->bookmarks == NULL || priv->bookmark_path == NULL) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -387,7 +383,8 @@ plain_remove_bookmark(zathura_database_t* db, const char* file, const char* id)
|
||||||
static girara_list_t*
|
static girara_list_t*
|
||||||
plain_load_bookmarks(zathura_database_t* db, const char* file)
|
plain_load_bookmarks(zathura_database_t* db, const char* file)
|
||||||
{
|
{
|
||||||
zathura_plaindatabase_private_t* priv = ZATHURA_PLAINDATABASE_GET_PRIVATE(db);
|
ZathuraPlainDatabase* plaindb = ZATHURA_PLAINDATABASE(db);
|
||||||
|
ZathuraPlainDatabasePrivate* priv = zathura_plaindatabase_get_instance_private(plaindb);
|
||||||
if (priv->bookmarks == NULL) {
|
if (priv->bookmarks == NULL) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
@ -498,9 +495,10 @@ plain_load_jumplist(zathura_database_t* db, const char* file)
|
||||||
{
|
{
|
||||||
g_return_val_if_fail(db != NULL && file != NULL, NULL);
|
g_return_val_if_fail(db != NULL && file != NULL, NULL);
|
||||||
|
|
||||||
zathura_plaindatabase_private_t* priv = ZATHURA_PLAINDATABASE_GET_PRIVATE(db);
|
ZathuraPlainDatabase* plaindb = ZATHURA_PLAINDATABASE(db);
|
||||||
char* str_value = g_key_file_get_string(priv->history, file, KEY_JUMPLIST, NULL);
|
ZathuraPlainDatabasePrivate* priv = zathura_plaindatabase_get_instance_private(plaindb);
|
||||||
|
|
||||||
|
char* str_value = g_key_file_get_string(priv->history, file, KEY_JUMPLIST, NULL);
|
||||||
if (str_value == NULL) {
|
if (str_value == NULL) {
|
||||||
return girara_list_new2(g_free);
|
return girara_list_new2(g_free);
|
||||||
}
|
}
|
||||||
|
@ -533,7 +531,8 @@ plain_save_jumplist(zathura_database_t* db, const char* file, girara_list_t* jum
|
||||||
GString* str_val = g_string_new(NULL);
|
GString* str_val = g_string_new(NULL);
|
||||||
girara_list_foreach(jumplist, jump_to_str, str_val);
|
girara_list_foreach(jumplist, jump_to_str, str_val);
|
||||||
|
|
||||||
zathura_plaindatabase_private_t* priv = ZATHURA_PLAINDATABASE_GET_PRIVATE(db);
|
ZathuraPlainDatabase* plaindb = ZATHURA_PLAINDATABASE(db);
|
||||||
|
ZathuraPlainDatabasePrivate* priv = zathura_plaindatabase_get_instance_private(plaindb);
|
||||||
|
|
||||||
g_key_file_set_string(priv->history, file, KEY_JUMPLIST, str_val->str);
|
g_key_file_set_string(priv->history, file, KEY_JUMPLIST, str_val->str);
|
||||||
zathura_db_write_key_file_to_file(priv->history_path, priv->history);
|
zathura_db_write_key_file_to_file(priv->history_path, priv->history);
|
||||||
|
@ -546,7 +545,8 @@ static bool
|
||||||
plain_set_fileinfo(zathura_database_t* db, const char* file, zathura_fileinfo_t*
|
plain_set_fileinfo(zathura_database_t* db, const char* file, zathura_fileinfo_t*
|
||||||
file_info)
|
file_info)
|
||||||
{
|
{
|
||||||
zathura_plaindatabase_private_t* priv = ZATHURA_PLAINDATABASE_GET_PRIVATE(db);
|
ZathuraPlainDatabase* plaindb = ZATHURA_PLAINDATABASE(db);
|
||||||
|
ZathuraPlainDatabasePrivate* priv = zathura_plaindatabase_get_instance_private(plaindb);
|
||||||
if (priv->history == NULL || file_info == NULL || file == NULL) {
|
if (priv->history == NULL || file_info == NULL || file == NULL) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -578,7 +578,8 @@ plain_get_fileinfo(zathura_database_t* db, const char* file, zathura_fileinfo_t*
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
zathura_plaindatabase_private_t* priv = ZATHURA_PLAINDATABASE_GET_PRIVATE(db);
|
ZathuraPlainDatabase* plaindb = ZATHURA_PLAINDATABASE(db);
|
||||||
|
ZathuraPlainDatabasePrivate* priv = zathura_plaindatabase_get_instance_private(plaindb);
|
||||||
if (priv->history == NULL) {
|
if (priv->history == NULL) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -742,7 +743,8 @@ cb_zathura_db_watch_file(GFileMonitor* UNUSED(monitor), GFile* file, GFile* UNUS
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
zathura_plaindatabase_private_t* priv = ZATHURA_PLAINDATABASE_GET_PRIVATE(database);
|
ZathuraPlainDatabase* plaindb = ZATHURA_PLAINDATABASE(database);
|
||||||
|
ZathuraPlainDatabasePrivate* priv = zathura_plaindatabase_get_instance_private(plaindb);
|
||||||
if (priv->bookmark_path && strcmp(priv->bookmark_path, path) == 0) {
|
if (priv->bookmark_path && strcmp(priv->bookmark_path, path) == 0) {
|
||||||
if (priv->bookmarks != NULL) {
|
if (priv->bookmarks != NULL) {
|
||||||
g_key_file_free(priv->bookmarks);
|
g_key_file_free(priv->bookmarks);
|
||||||
|
@ -763,7 +765,8 @@ cb_zathura_db_watch_file(GFileMonitor* UNUSED(monitor), GFile* file, GFile* UNUS
|
||||||
static girara_list_t*
|
static girara_list_t*
|
||||||
plain_io_read(GiraraInputHistoryIO* db)
|
plain_io_read(GiraraInputHistoryIO* db)
|
||||||
{
|
{
|
||||||
zathura_plaindatabase_private_t* priv = ZATHURA_PLAINDATABASE_GET_PRIVATE(db);
|
ZathuraPlainDatabase* plaindb = ZATHURA_PLAINDATABASE(db);
|
||||||
|
ZathuraPlainDatabasePrivate* priv = zathura_plaindatabase_get_instance_private(plaindb);
|
||||||
|
|
||||||
/* open file */
|
/* open file */
|
||||||
FILE* file = fopen(priv->input_history_path, "r");
|
FILE* file = fopen(priv->input_history_path, "r");
|
||||||
|
@ -794,7 +797,8 @@ plain_io_read(GiraraInputHistoryIO* db)
|
||||||
static void
|
static void
|
||||||
plain_io_append(GiraraInputHistoryIO* db, const char* input)
|
plain_io_append(GiraraInputHistoryIO* db, const char* input)
|
||||||
{
|
{
|
||||||
zathura_plaindatabase_private_t* priv = ZATHURA_PLAINDATABASE_GET_PRIVATE(db);
|
ZathuraPlainDatabase* plaindb = ZATHURA_PLAINDATABASE(db);
|
||||||
|
ZathuraPlainDatabasePrivate* priv = zathura_plaindatabase_get_instance_private(plaindb);
|
||||||
|
|
||||||
/* open file */
|
/* open file */
|
||||||
FILE* file = fopen(priv->input_history_path, "r+");
|
FILE* file = fopen(priv->input_history_path, "r+");
|
||||||
|
@ -859,7 +863,8 @@ compare_time(const void* l, const void* r, void* data)
|
||||||
static girara_list_t*
|
static girara_list_t*
|
||||||
plain_get_recent_files(zathura_database_t* db, int max, const char* basepath)
|
plain_get_recent_files(zathura_database_t* db, int max, const char* basepath)
|
||||||
{
|
{
|
||||||
zathura_plaindatabase_private_t* priv = ZATHURA_PLAINDATABASE_GET_PRIVATE(db);
|
ZathuraPlainDatabase* plaindb = ZATHURA_PLAINDATABASE(db);
|
||||||
|
ZathuraPlainDatabasePrivate* priv = zathura_plaindatabase_get_instance_private(plaindb);
|
||||||
|
|
||||||
girara_list_t* result = girara_list_new2(g_free);
|
girara_list_t* result = girara_list_new2(g_free);
|
||||||
if (result == NULL) {
|
if (result == NULL) {
|
||||||
|
|
|
@ -19,9 +19,14 @@ sqlite3_column_text_dup(sqlite3_stmt* stmt, int col)
|
||||||
static void zathura_database_interface_init(ZathuraDatabaseInterface* iface);
|
static void zathura_database_interface_init(ZathuraDatabaseInterface* iface);
|
||||||
static void io_interface_init(GiraraInputHistoryIOInterface* iface);
|
static void io_interface_init(GiraraInputHistoryIOInterface* iface);
|
||||||
|
|
||||||
|
typedef struct zathura_sqldatabase_private_s {
|
||||||
|
sqlite3* session;
|
||||||
|
} ZathuraSQLDatabasePrivate;
|
||||||
|
|
||||||
G_DEFINE_TYPE_WITH_CODE(ZathuraSQLDatabase, zathura_sqldatabase, G_TYPE_OBJECT,
|
G_DEFINE_TYPE_WITH_CODE(ZathuraSQLDatabase, zathura_sqldatabase, G_TYPE_OBJECT,
|
||||||
G_IMPLEMENT_INTERFACE(ZATHURA_TYPE_DATABASE, zathura_database_interface_init)
|
G_IMPLEMENT_INTERFACE(ZATHURA_TYPE_DATABASE, zathura_database_interface_init)
|
||||||
G_IMPLEMENT_INTERFACE(GIRARA_TYPE_INPUT_HISTORY_IO, io_interface_init))
|
G_IMPLEMENT_INTERFACE(GIRARA_TYPE_INPUT_HISTORY_IO, io_interface_init)
|
||||||
|
G_ADD_PRIVATE(ZathuraSQLDatabase))
|
||||||
|
|
||||||
static bool check_column(sqlite3* session, const char* table, const char* col, bool* result);
|
static bool check_column(sqlite3* session, const char* table, const char* col, bool* result);
|
||||||
static bool check_column_type(sqlite3* session, const char* table, const char* col, const char* type, bool* result);
|
static bool check_column_type(sqlite3* session, const char* table, const char* col, const char* type, bool* result);
|
||||||
|
@ -38,13 +43,6 @@ static void sqlite_io_append(GiraraInputHistoryIO* db, const char*);
|
||||||
static girara_list_t* sqlite_io_read(GiraraInputHistoryIO* db);
|
static girara_list_t* sqlite_io_read(GiraraInputHistoryIO* db);
|
||||||
static girara_list_t* sqlite_get_recent_files(zathura_database_t* db, int max, const char* basepath);
|
static girara_list_t* sqlite_get_recent_files(zathura_database_t* db, int max, const char* basepath);
|
||||||
|
|
||||||
typedef struct zathura_sqldatabase_private_s {
|
|
||||||
sqlite3* session;
|
|
||||||
} zathura_sqldatabase_private_t;
|
|
||||||
|
|
||||||
#define ZATHURA_SQLDATABASE_GET_PRIVATE(obj) \
|
|
||||||
(G_TYPE_INSTANCE_GET_PRIVATE ((obj), ZATHURA_TYPE_SQLDATABASE, zathura_sqldatabase_private_t))
|
|
||||||
|
|
||||||
enum {
|
enum {
|
||||||
PROP_0,
|
PROP_0,
|
||||||
PROP_PATH
|
PROP_PATH
|
||||||
|
@ -75,9 +73,6 @@ io_interface_init(GiraraInputHistoryIOInterface* iface)
|
||||||
static void
|
static void
|
||||||
zathura_sqldatabase_class_init(ZathuraSQLDatabaseClass* class)
|
zathura_sqldatabase_class_init(ZathuraSQLDatabaseClass* class)
|
||||||
{
|
{
|
||||||
/* add private members */
|
|
||||||
g_type_class_add_private(class, sizeof(zathura_sqldatabase_private_t));
|
|
||||||
|
|
||||||
/* override methods */
|
/* override methods */
|
||||||
GObjectClass* object_class = G_OBJECT_CLASS(class);
|
GObjectClass* object_class = G_OBJECT_CLASS(class);
|
||||||
object_class->finalize = sqlite_finalize;
|
object_class->finalize = sqlite_finalize;
|
||||||
|
@ -91,7 +86,7 @@ zathura_sqldatabase_class_init(ZathuraSQLDatabaseClass* class)
|
||||||
static void
|
static void
|
||||||
zathura_sqldatabase_init(ZathuraSQLDatabase* db)
|
zathura_sqldatabase_init(ZathuraSQLDatabase* db)
|
||||||
{
|
{
|
||||||
zathura_sqldatabase_private_t* priv = ZATHURA_SQLDATABASE_GET_PRIVATE(db);
|
ZathuraSQLDatabasePrivate* priv = zathura_sqldatabase_get_instance_private(db);
|
||||||
priv->session = NULL;
|
priv->session = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -101,7 +96,7 @@ zathura_sqldatabase_new(const char* path)
|
||||||
g_return_val_if_fail(path != NULL && strlen(path) != 0, NULL);
|
g_return_val_if_fail(path != NULL && strlen(path) != 0, NULL);
|
||||||
|
|
||||||
zathura_database_t* db = g_object_new(ZATHURA_TYPE_SQLDATABASE, "path", path, NULL);
|
zathura_database_t* db = g_object_new(ZATHURA_TYPE_SQLDATABASE, "path", path, NULL);
|
||||||
zathura_sqldatabase_private_t* priv = ZATHURA_SQLDATABASE_GET_PRIVATE(db);
|
ZathuraSQLDatabasePrivate* priv = zathura_sqldatabase_get_instance_private(ZATHURA_SQLDATABASE(db));
|
||||||
if (priv->session == NULL) {
|
if (priv->session == NULL) {
|
||||||
g_object_unref(G_OBJECT(db));
|
g_object_unref(G_OBJECT(db));
|
||||||
return NULL;
|
return NULL;
|
||||||
|
@ -114,7 +109,7 @@ static void
|
||||||
sqlite_finalize(GObject* object)
|
sqlite_finalize(GObject* object)
|
||||||
{
|
{
|
||||||
ZathuraSQLDatabase* db = ZATHURA_SQLDATABASE(object);
|
ZathuraSQLDatabase* db = ZATHURA_SQLDATABASE(object);
|
||||||
zathura_sqldatabase_private_t* priv = ZATHURA_SQLDATABASE_GET_PRIVATE(db);
|
ZathuraSQLDatabasePrivate* priv = zathura_sqldatabase_get_instance_private(db);
|
||||||
if (priv->session) {
|
if (priv->session) {
|
||||||
sqlite3_exec(priv->session, "VACUUM;", NULL, 0, NULL);
|
sqlite3_exec(priv->session, "VACUUM;", NULL, 0, NULL);
|
||||||
sqlite3_close(priv->session);
|
sqlite3_close(priv->session);
|
||||||
|
@ -126,7 +121,7 @@ sqlite_finalize(GObject* object)
|
||||||
static void
|
static void
|
||||||
sqlite_db_init(ZathuraSQLDatabase* db, const char* path)
|
sqlite_db_init(ZathuraSQLDatabase* db, const char* path)
|
||||||
{
|
{
|
||||||
zathura_sqldatabase_private_t* priv = ZATHURA_SQLDATABASE_GET_PRIVATE(db);
|
ZathuraSQLDatabasePrivate* priv = zathura_sqldatabase_get_instance_private(db);
|
||||||
|
|
||||||
/* create bookmarks table */
|
/* create bookmarks table */
|
||||||
static const char SQL_BOOKMARK_INIT[] =
|
static const char SQL_BOOKMARK_INIT[] =
|
||||||
|
@ -297,7 +292,7 @@ static void
|
||||||
sqlite_set_property(GObject* object, guint prop_id, const GValue* value, GParamSpec* pspec)
|
sqlite_set_property(GObject* object, guint prop_id, const GValue* value, GParamSpec* pspec)
|
||||||
{
|
{
|
||||||
ZathuraSQLDatabase* db = ZATHURA_SQLDATABASE(object);
|
ZathuraSQLDatabase* db = ZATHURA_SQLDATABASE(object);
|
||||||
zathura_sqldatabase_private_t* priv = ZATHURA_SQLDATABASE_GET_PRIVATE(db);
|
ZathuraSQLDatabasePrivate* priv = zathura_sqldatabase_get_instance_private(db);
|
||||||
|
|
||||||
switch (prop_id) {
|
switch (prop_id) {
|
||||||
case PROP_PATH:
|
case PROP_PATH:
|
||||||
|
@ -406,7 +401,8 @@ static bool
|
||||||
sqlite_add_bookmark(zathura_database_t* db, const char* file,
|
sqlite_add_bookmark(zathura_database_t* db, const char* file,
|
||||||
zathura_bookmark_t* bookmark)
|
zathura_bookmark_t* bookmark)
|
||||||
{
|
{
|
||||||
zathura_sqldatabase_private_t* priv = ZATHURA_SQLDATABASE_GET_PRIVATE(db);
|
ZathuraSQLDatabase* sqldb = ZATHURA_SQLDATABASE(db);
|
||||||
|
ZathuraSQLDatabasePrivate* priv = zathura_sqldatabase_get_instance_private(sqldb);
|
||||||
|
|
||||||
static const char SQL_BOOKMARK_ADD[] =
|
static const char SQL_BOOKMARK_ADD[] =
|
||||||
"REPLACE INTO bookmarks (file, id, page, hadj_ratio, vadj_ratio) VALUES (?, ?, ?, ?, ?);";
|
"REPLACE INTO bookmarks (file, id, page, hadj_ratio, vadj_ratio) VALUES (?, ?, ?, ?, ?);";
|
||||||
|
@ -436,7 +432,8 @@ static bool
|
||||||
sqlite_remove_bookmark(zathura_database_t* db, const char* file, const char*
|
sqlite_remove_bookmark(zathura_database_t* db, const char* file, const char*
|
||||||
id)
|
id)
|
||||||
{
|
{
|
||||||
zathura_sqldatabase_private_t* priv = ZATHURA_SQLDATABASE_GET_PRIVATE(db);
|
ZathuraSQLDatabase* sqldb = ZATHURA_SQLDATABASE(db);
|
||||||
|
ZathuraSQLDatabasePrivate* priv = zathura_sqldatabase_get_instance_private(sqldb);
|
||||||
|
|
||||||
static const char SQL_BOOKMARK_ADD[] =
|
static const char SQL_BOOKMARK_ADD[] =
|
||||||
"DELETE FROM bookmarks WHERE file = ? AND id = ?;";
|
"DELETE FROM bookmarks WHERE file = ? AND id = ?;";
|
||||||
|
@ -462,7 +459,8 @@ sqlite_remove_bookmark(zathura_database_t* db, const char* file, const char*
|
||||||
static girara_list_t*
|
static girara_list_t*
|
||||||
sqlite_load_bookmarks(zathura_database_t* db, const char* file)
|
sqlite_load_bookmarks(zathura_database_t* db, const char* file)
|
||||||
{
|
{
|
||||||
zathura_sqldatabase_private_t* priv = ZATHURA_SQLDATABASE_GET_PRIVATE(db);
|
ZathuraSQLDatabase* sqldb = ZATHURA_SQLDATABASE(db);
|
||||||
|
ZathuraSQLDatabasePrivate* priv = zathura_sqldatabase_get_instance_private(sqldb);
|
||||||
|
|
||||||
static const char SQL_BOOKMARK_SELECT[] =
|
static const char SQL_BOOKMARK_SELECT[] =
|
||||||
"SELECT id, page, hadj_ratio, vadj_ratio FROM bookmarks WHERE file = ?;";
|
"SELECT id, page, hadj_ratio, vadj_ratio FROM bookmarks WHERE file = ?;";
|
||||||
|
@ -513,7 +511,9 @@ sqlite_save_jumplist(zathura_database_t* db, const char* file, girara_list_t* ju
|
||||||
static const char SQL_INSERT_JUMP[] = "INSERT INTO jumplist (file, page, hadj_ratio, vadj_ratio) VALUES (?, ?, ?, ?);";
|
static const char SQL_INSERT_JUMP[] = "INSERT INTO jumplist (file, page, hadj_ratio, vadj_ratio) VALUES (?, ?, ?, ?);";
|
||||||
static const char SQL_REMOVE_JUMPLIST[] = "DELETE FROM jumplist WHERE file = ?;";
|
static const char SQL_REMOVE_JUMPLIST[] = "DELETE FROM jumplist WHERE file = ?;";
|
||||||
|
|
||||||
zathura_sqldatabase_private_t* priv = ZATHURA_SQLDATABASE_GET_PRIVATE(db);
|
ZathuraSQLDatabase* sqldb = ZATHURA_SQLDATABASE(db);
|
||||||
|
ZathuraSQLDatabasePrivate* priv = zathura_sqldatabase_get_instance_private(sqldb);
|
||||||
|
|
||||||
sqlite3_stmt* stmt = NULL;
|
sqlite3_stmt* stmt = NULL;
|
||||||
int res = 0;
|
int res = 0;
|
||||||
|
|
||||||
|
@ -591,9 +591,10 @@ sqlite_load_jumplist(zathura_database_t* db, const char* file)
|
||||||
|
|
||||||
static const char SQL_GET_JUMPLIST[] = "SELECT page, hadj_ratio, vadj_ratio FROM jumplist WHERE file = ? ORDER BY id ASC;";
|
static const char SQL_GET_JUMPLIST[] = "SELECT page, hadj_ratio, vadj_ratio FROM jumplist WHERE file = ? ORDER BY id ASC;";
|
||||||
|
|
||||||
zathura_sqldatabase_private_t* priv = ZATHURA_SQLDATABASE_GET_PRIVATE(db);
|
ZathuraSQLDatabase* sqldb = ZATHURA_SQLDATABASE(db);
|
||||||
sqlite3_stmt* stmt = prepare_statement(priv->session, SQL_GET_JUMPLIST);
|
ZathuraSQLDatabasePrivate* priv = zathura_sqldatabase_get_instance_private(sqldb);
|
||||||
|
|
||||||
|
sqlite3_stmt* stmt = prepare_statement(priv->session, SQL_GET_JUMPLIST);
|
||||||
if (stmt == NULL) {
|
if (stmt == NULL) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
@ -643,7 +644,8 @@ sqlite_set_fileinfo(zathura_database_t* db, const char* file,
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
zathura_sqldatabase_private_t* priv = ZATHURA_SQLDATABASE_GET_PRIVATE(db);
|
ZathuraSQLDatabase* sqldb = ZATHURA_SQLDATABASE(db);
|
||||||
|
ZathuraSQLDatabasePrivate* priv = zathura_sqldatabase_get_instance_private(sqldb);
|
||||||
|
|
||||||
static const char SQL_FILEINFO_SET[] =
|
static const char SQL_FILEINFO_SET[] =
|
||||||
"REPLACE INTO fileinfo (file, page, offset, zoom, rotation, pages_per_row, first_page_column, position_x, position_y, time) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, DATETIME('now'));";
|
"REPLACE INTO fileinfo (file, page, offset, zoom, rotation, pages_per_row, first_page_column, position_x, position_y, time) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, DATETIME('now'));";
|
||||||
|
@ -682,7 +684,8 @@ sqlite_get_fileinfo(zathura_database_t* db, const char* file,
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
zathura_sqldatabase_private_t* priv = ZATHURA_SQLDATABASE_GET_PRIVATE(db);
|
ZathuraSQLDatabase* sqldb = ZATHURA_SQLDATABASE(db);
|
||||||
|
ZathuraSQLDatabasePrivate* priv = zathura_sqldatabase_get_instance_private(sqldb);
|
||||||
|
|
||||||
static const char SQL_FILEINFO_GET[] =
|
static const char SQL_FILEINFO_GET[] =
|
||||||
"SELECT page, offset, zoom, rotation, pages_per_row, first_page_column, position_x, position_y FROM fileinfo WHERE file = ?;";
|
"SELECT page, offset, zoom, rotation, pages_per_row, first_page_column, position_x, position_y FROM fileinfo WHERE file = ?;";
|
||||||
|
@ -724,7 +727,9 @@ sqlite_io_append(GiraraInputHistoryIO* db, const char* input)
|
||||||
static const char SQL_HISTORY_SET[] =
|
static const char SQL_HISTORY_SET[] =
|
||||||
"REPLACE INTO history (line, time) VALUES (?, DATETIME('now'));";
|
"REPLACE INTO history (line, time) VALUES (?, DATETIME('now'));";
|
||||||
|
|
||||||
zathura_sqldatabase_private_t* priv = ZATHURA_SQLDATABASE_GET_PRIVATE(db);
|
ZathuraSQLDatabase* sqldb = ZATHURA_SQLDATABASE(db);
|
||||||
|
ZathuraSQLDatabasePrivate* priv = zathura_sqldatabase_get_instance_private(sqldb);
|
||||||
|
|
||||||
sqlite3_stmt* stmt = prepare_statement(priv->session, SQL_HISTORY_SET);
|
sqlite3_stmt* stmt = prepare_statement(priv->session, SQL_HISTORY_SET);
|
||||||
if (stmt == NULL) {
|
if (stmt == NULL) {
|
||||||
return;
|
return;
|
||||||
|
@ -746,7 +751,9 @@ sqlite_io_read(GiraraInputHistoryIO* db)
|
||||||
static const char SQL_HISTORY_GET[] =
|
static const char SQL_HISTORY_GET[] =
|
||||||
"SELECT line FROM history ORDER BY time";
|
"SELECT line FROM history ORDER BY time";
|
||||||
|
|
||||||
zathura_sqldatabase_private_t* priv = ZATHURA_SQLDATABASE_GET_PRIVATE(db);
|
ZathuraSQLDatabase* sqldb = ZATHURA_SQLDATABASE(db);
|
||||||
|
ZathuraSQLDatabasePrivate* priv = zathura_sqldatabase_get_instance_private(sqldb);
|
||||||
|
|
||||||
sqlite3_stmt* stmt = prepare_statement(priv->session, SQL_HISTORY_GET);
|
sqlite3_stmt* stmt = prepare_statement(priv->session, SQL_HISTORY_GET);
|
||||||
if (stmt == NULL) {
|
if (stmt == NULL) {
|
||||||
return NULL;
|
return NULL;
|
||||||
|
@ -774,7 +781,9 @@ sqlite_get_recent_files(zathura_database_t* db, int max, const char* basepath)
|
||||||
static const char SQL_HISTORY_GET_WITH_BASEPATH[] =
|
static const char SQL_HISTORY_GET_WITH_BASEPATH[] =
|
||||||
"SELECT file FROM fileinfo WHERE file LIKE ? || '%' ORDER BY time DESC LIMIT ?";
|
"SELECT file FROM fileinfo WHERE file LIKE ? || '%' ORDER BY time DESC LIMIT ?";
|
||||||
|
|
||||||
zathura_sqldatabase_private_t* priv = ZATHURA_SQLDATABASE_GET_PRIVATE(db);
|
ZathuraSQLDatabase* sqldb = ZATHURA_SQLDATABASE(db);
|
||||||
|
ZathuraSQLDatabasePrivate* priv = zathura_sqldatabase_get_instance_private(sqldb);
|
||||||
|
|
||||||
sqlite3_stmt* stmt = prepare_statement(priv->session, basepath == NULL ? SQL_HISTORY_GET : SQL_HISTORY_GET_WITH_BASEPATH);
|
sqlite3_stmt* stmt = prepare_statement(priv->session, basepath == NULL ? SQL_HISTORY_GET : SQL_HISTORY_GET_WITH_BASEPATH);
|
||||||
if (stmt == NULL) {
|
if (stmt == NULL) {
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
|
@ -30,7 +30,15 @@ static GBytes* load_xml_data(void)
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
G_DEFINE_TYPE(ZathuraDbus, zathura_dbus, G_TYPE_OBJECT)
|
typedef struct private_s {
|
||||||
|
zathura_t* zathura;
|
||||||
|
GDBusNodeInfo* introspection_data;
|
||||||
|
GDBusConnection* connection;
|
||||||
|
guint owner_id;
|
||||||
|
guint registration_id;
|
||||||
|
} ZathuraDbusPrivate;
|
||||||
|
|
||||||
|
G_DEFINE_TYPE_WITH_CODE(ZathuraDbus, zathura_dbus, G_TYPE_OBJECT, G_ADD_PRIVATE(ZathuraDbus))
|
||||||
|
|
||||||
/* template for bus name */
|
/* template for bus name */
|
||||||
static const char DBUS_NAME_TEMPLATE[] = "org.pwmt.zathura.PID-%d";
|
static const char DBUS_NAME_TEMPLATE[] = "org.pwmt.zathura.PID-%d";
|
||||||
|
@ -39,24 +47,13 @@ static const char DBUS_OBJPATH[] = "/org/pwmt/zathura";
|
||||||
/* interface name */
|
/* interface name */
|
||||||
static const char DBUS_INTERFACE[] = "org.pwmt.zathura";
|
static const char DBUS_INTERFACE[] = "org.pwmt.zathura";
|
||||||
|
|
||||||
typedef struct private_s {
|
|
||||||
zathura_t* zathura;
|
|
||||||
GDBusNodeInfo* introspection_data;
|
|
||||||
GDBusConnection* connection;
|
|
||||||
guint owner_id;
|
|
||||||
guint registration_id;
|
|
||||||
} private_t;
|
|
||||||
|
|
||||||
#define GET_PRIVATE(obj) \
|
|
||||||
(G_TYPE_INSTANCE_GET_PRIVATE((obj), ZATHURA_TYPE_DBUS, private_t))
|
|
||||||
|
|
||||||
static const GDBusInterfaceVTable interface_vtable;
|
static const GDBusInterfaceVTable interface_vtable;
|
||||||
|
|
||||||
static void
|
static void
|
||||||
finalize(GObject* object)
|
finalize(GObject* object)
|
||||||
{
|
{
|
||||||
ZathuraDbus* dbus = ZATHURA_DBUS(object);
|
ZathuraDbus* dbus = ZATHURA_DBUS(object);
|
||||||
private_t* priv = GET_PRIVATE(dbus);
|
ZathuraDbusPrivate* priv = zathura_dbus_get_instance_private(dbus);
|
||||||
|
|
||||||
if (priv->connection != NULL && priv->registration_id > 0) {
|
if (priv->connection != NULL && priv->registration_id > 0) {
|
||||||
g_dbus_connection_unregister_object(priv->connection, priv->registration_id);
|
g_dbus_connection_unregister_object(priv->connection, priv->registration_id);
|
||||||
|
@ -76,9 +73,6 @@ finalize(GObject* object)
|
||||||
static void
|
static void
|
||||||
zathura_dbus_class_init(ZathuraDbusClass* class)
|
zathura_dbus_class_init(ZathuraDbusClass* class)
|
||||||
{
|
{
|
||||||
/* add private members */
|
|
||||||
g_type_class_add_private(class, sizeof(private_t));
|
|
||||||
|
|
||||||
/* overwrite methods */
|
/* overwrite methods */
|
||||||
GObjectClass* object_class = G_OBJECT_CLASS(class);
|
GObjectClass* object_class = G_OBJECT_CLASS(class);
|
||||||
object_class->finalize = finalize;
|
object_class->finalize = finalize;
|
||||||
|
@ -87,7 +81,7 @@ zathura_dbus_class_init(ZathuraDbusClass* class)
|
||||||
static void
|
static void
|
||||||
zathura_dbus_init(ZathuraDbus* dbus)
|
zathura_dbus_init(ZathuraDbus* dbus)
|
||||||
{
|
{
|
||||||
private_t* priv = GET_PRIVATE(dbus);
|
ZathuraDbusPrivate* priv = zathura_dbus_get_instance_private(dbus);
|
||||||
priv->zathura = NULL;
|
priv->zathura = NULL;
|
||||||
priv->introspection_data = NULL;
|
priv->introspection_data = NULL;
|
||||||
priv->connection = NULL;
|
priv->connection = NULL;
|
||||||
|
@ -114,7 +108,7 @@ bus_acquired(GDBusConnection* connection, const gchar* name, void* data)
|
||||||
G_CALLBACK(gdbus_connection_closed), NULL);
|
G_CALLBACK(gdbus_connection_closed), NULL);
|
||||||
|
|
||||||
ZathuraDbus* dbus = data;
|
ZathuraDbus* dbus = data;
|
||||||
private_t* priv = GET_PRIVATE(dbus);
|
ZathuraDbusPrivate* priv = zathura_dbus_get_instance_private(dbus);
|
||||||
|
|
||||||
GError* error = NULL;
|
GError* error = NULL;
|
||||||
priv->registration_id = g_dbus_connection_register_object(
|
priv->registration_id = g_dbus_connection_register_object(
|
||||||
|
@ -154,7 +148,7 @@ zathura_dbus_new(zathura_t* zathura)
|
||||||
}
|
}
|
||||||
|
|
||||||
ZathuraDbus* dbus = ZATHURA_DBUS(obj);
|
ZathuraDbus* dbus = ZATHURA_DBUS(obj);
|
||||||
private_t* priv = GET_PRIVATE(dbus);
|
ZathuraDbusPrivate* priv = zathura_dbus_get_instance_private(dbus);
|
||||||
priv->zathura = zathura;
|
priv->zathura = zathura;
|
||||||
|
|
||||||
GBytes* xml_data = load_xml_data();
|
GBytes* xml_data = load_xml_data();
|
||||||
|
@ -187,7 +181,7 @@ zathura_dbus_new(zathura_t* zathura)
|
||||||
|
|
||||||
void
|
void
|
||||||
zathura_dbus_edit(ZathuraDbus* edit, unsigned int page, unsigned int x, unsigned int y) {
|
zathura_dbus_edit(ZathuraDbus* edit, unsigned int page, unsigned int x, unsigned int y) {
|
||||||
private_t* priv = GET_PRIVATE(edit);
|
ZathuraDbusPrivate* priv = zathura_dbus_get_instance_private(edit);
|
||||||
|
|
||||||
const char* filename = zathura_document_get_path(priv->zathura->document);
|
const char* filename = zathura_document_get_path(priv->zathura->document);
|
||||||
|
|
||||||
|
@ -393,7 +387,7 @@ handle_method_call(GDBusConnection* UNUSED(connection),
|
||||||
void* data)
|
void* data)
|
||||||
{
|
{
|
||||||
ZathuraDbus* dbus = data;
|
ZathuraDbus* dbus = data;
|
||||||
private_t* priv = GET_PRIVATE(dbus);
|
ZathuraDbusPrivate* priv = zathura_dbus_get_instance_private(dbus);
|
||||||
|
|
||||||
girara_debug("Handling call '%s.%s' on '%s'.", interface_name, method_name,
|
girara_debug("Handling call '%s.%s' on '%s'.", interface_name, method_name,
|
||||||
object_path);
|
object_path);
|
||||||
|
@ -435,7 +429,7 @@ handle_get_property(GDBusConnection* UNUSED(connection),
|
||||||
const gchar* property_name, GError** error, void* data)
|
const gchar* property_name, GError** error, void* data)
|
||||||
{
|
{
|
||||||
ZathuraDbus* dbus = data;
|
ZathuraDbus* dbus = data;
|
||||||
private_t* priv = GET_PRIVATE(dbus);
|
ZathuraDbusPrivate* priv = zathura_dbus_get_instance_private(dbus);
|
||||||
|
|
||||||
if (priv->zathura->document == NULL) {
|
if (priv->zathura->document == NULL) {
|
||||||
g_set_error(error, G_IO_ERROR, G_IO_ERROR_FAILED, "No document open.");
|
g_set_error(error, G_IO_ERROR, G_IO_ERROR_FAILED, "No document open.");
|
||||||
|
|
|
@ -9,14 +9,11 @@
|
||||||
|
|
||||||
#include <girara/utils.h>
|
#include <girara/utils.h>
|
||||||
|
|
||||||
G_DEFINE_TYPE(ZathuraFileMonitor, zathura_filemonitor, G_TYPE_OBJECT)
|
|
||||||
|
|
||||||
typedef struct private_s {
|
typedef struct private_s {
|
||||||
char* file_path;
|
char* file_path;
|
||||||
} private_t;
|
} ZathuraFileMonitorPrivate;
|
||||||
|
|
||||||
#define GET_PRIVATE(obj) \
|
G_DEFINE_TYPE_WITH_CODE(ZathuraFileMonitor, zathura_filemonitor, G_TYPE_OBJECT, G_ADD_PRIVATE(ZathuraFileMonitor))
|
||||||
(G_TYPE_INSTANCE_GET_PRIVATE((obj), ZATHURA_TYPE_FILEMONITOR, private_t))
|
|
||||||
|
|
||||||
enum {
|
enum {
|
||||||
PROP_0,
|
PROP_0,
|
||||||
|
@ -34,7 +31,7 @@ static void
|
||||||
finalize(GObject* object)
|
finalize(GObject* object)
|
||||||
{
|
{
|
||||||
ZathuraFileMonitor* file_monitor = ZATHURA_FILEMONITOR(object);
|
ZathuraFileMonitor* file_monitor = ZATHURA_FILEMONITOR(object);
|
||||||
private_t* private = GET_PRIVATE(file_monitor);
|
ZathuraFileMonitorPrivate* private = zathura_filemonitor_get_instance_private(file_monitor);
|
||||||
|
|
||||||
if (private->file_path != NULL) {
|
if (private->file_path != NULL) {
|
||||||
g_free(private->file_path);
|
g_free(private->file_path);
|
||||||
|
@ -47,7 +44,7 @@ static void
|
||||||
set_property(GObject* object, guint prop_id, const GValue* value, GParamSpec* pspec)
|
set_property(GObject* object, guint prop_id, const GValue* value, GParamSpec* pspec)
|
||||||
{
|
{
|
||||||
ZathuraFileMonitor* file_monitor = ZATHURA_FILEMONITOR(object);
|
ZathuraFileMonitor* file_monitor = ZATHURA_FILEMONITOR(object);
|
||||||
private_t* private = GET_PRIVATE(file_monitor);
|
ZathuraFileMonitorPrivate* private = zathura_filemonitor_get_instance_private(file_monitor);
|
||||||
|
|
||||||
switch (prop_id) {
|
switch (prop_id) {
|
||||||
case PROP_FILE_PATH:
|
case PROP_FILE_PATH:
|
||||||
|
@ -65,7 +62,7 @@ static void
|
||||||
get_property(GObject* object, guint prop_id, GValue* value, GParamSpec* pspec)
|
get_property(GObject* object, guint prop_id, GValue* value, GParamSpec* pspec)
|
||||||
{
|
{
|
||||||
ZathuraFileMonitor* file_monitor = ZATHURA_FILEMONITOR(object);
|
ZathuraFileMonitor* file_monitor = ZATHURA_FILEMONITOR(object);
|
||||||
private_t* private = GET_PRIVATE(file_monitor);
|
ZathuraFileMonitorPrivate* private = zathura_filemonitor_get_instance_private(file_monitor);
|
||||||
|
|
||||||
switch (prop_id) {
|
switch (prop_id) {
|
||||||
case PROP_FILE_PATH:
|
case PROP_FILE_PATH:
|
||||||
|
@ -79,9 +76,6 @@ get_property(GObject* object, guint prop_id, GValue* value, GParamSpec* pspec)
|
||||||
static void
|
static void
|
||||||
zathura_filemonitor_class_init(ZathuraFileMonitorClass* class)
|
zathura_filemonitor_class_init(ZathuraFileMonitorClass* class)
|
||||||
{
|
{
|
||||||
/* add private members */
|
|
||||||
g_type_class_add_private(class, sizeof(private_t));
|
|
||||||
|
|
||||||
/* set up methods */
|
/* set up methods */
|
||||||
class->start = NULL;
|
class->start = NULL;
|
||||||
class->stop = NULL;
|
class->stop = NULL;
|
||||||
|
@ -107,14 +101,13 @@ zathura_filemonitor_class_init(ZathuraFileMonitorClass* class)
|
||||||
static void
|
static void
|
||||||
zathura_filemonitor_init(ZathuraFileMonitor* file_monitor)
|
zathura_filemonitor_init(ZathuraFileMonitor* file_monitor)
|
||||||
{
|
{
|
||||||
private_t* private = GET_PRIVATE(file_monitor);
|
ZathuraFileMonitorPrivate* private = zathura_filemonitor_get_instance_private(file_monitor);
|
||||||
private->file_path = NULL;
|
private->file_path = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
const char* zathura_filemonitor_get_filepath(ZathuraFileMonitor* file_monitor)
|
const char* zathura_filemonitor_get_filepath(ZathuraFileMonitor* file_monitor)
|
||||||
{
|
{
|
||||||
private_t* private = GET_PRIVATE(file_monitor);
|
ZathuraFileMonitorPrivate* private = zathura_filemonitor_get_instance_private(file_monitor);
|
||||||
|
|
||||||
return private->file_path;
|
return private->file_path;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -16,8 +16,6 @@
|
||||||
#include "shortcuts.h"
|
#include "shortcuts.h"
|
||||||
#include "zathura.h"
|
#include "zathura.h"
|
||||||
|
|
||||||
G_DEFINE_TYPE(ZathuraPage, zathura_page_widget, GTK_TYPE_DRAWING_AREA)
|
|
||||||
|
|
||||||
typedef struct zathura_page_widget_private_s {
|
typedef struct zathura_page_widget_private_s {
|
||||||
zathura_page_t* page; /**< Page object */
|
zathura_page_t* page; /**< Page object */
|
||||||
zathura_t* zathura; /**< Zathura object */
|
zathura_t* zathura; /**< Zathura object */
|
||||||
|
@ -54,11 +52,9 @@ typedef struct zathura_page_widget_private_s {
|
||||||
} selection_basepoint;
|
} selection_basepoint;
|
||||||
gboolean over_link;
|
gboolean over_link;
|
||||||
} mouse;
|
} mouse;
|
||||||
} zathura_page_widget_private_t;
|
} ZathuraPagePrivate;
|
||||||
|
|
||||||
#define ZATHURA_PAGE_GET_PRIVATE(obj) \
|
G_DEFINE_TYPE_WITH_CODE(ZathuraPage, zathura_page_widget, GTK_TYPE_DRAWING_AREA, G_ADD_PRIVATE(ZathuraPage))
|
||||||
(G_TYPE_INSTANCE_GET_PRIVATE((obj), ZATHURA_TYPE_PAGE, \
|
|
||||||
zathura_page_widget_private_t))
|
|
||||||
|
|
||||||
static gboolean zathura_page_widget_draw(GtkWidget* widget, cairo_t* cairo);
|
static gboolean zathura_page_widget_draw(GtkWidget* widget, cairo_t* cairo);
|
||||||
static void zathura_page_widget_finalize(GObject* object);
|
static void zathura_page_widget_finalize(GObject* object);
|
||||||
|
@ -110,9 +106,6 @@ static guint signals[LAST_SIGNAL] = { 0 };
|
||||||
static void
|
static void
|
||||||
zathura_page_widget_class_init(ZathuraPageClass* class)
|
zathura_page_widget_class_init(ZathuraPageClass* class)
|
||||||
{
|
{
|
||||||
/* add private members */
|
|
||||||
g_type_class_add_private(class, sizeof(zathura_page_widget_private_t));
|
|
||||||
|
|
||||||
/* overwrite methods */
|
/* overwrite methods */
|
||||||
GtkWidgetClass* widget_class = GTK_WIDGET_CLASS(class);
|
GtkWidgetClass* widget_class = GTK_WIDGET_CLASS(class);
|
||||||
widget_class->draw = zathura_page_widget_draw;
|
widget_class->draw = zathura_page_widget_draw;
|
||||||
|
@ -207,7 +200,7 @@ zathura_page_widget_class_init(ZathuraPageClass* class)
|
||||||
static void
|
static void
|
||||||
zathura_page_widget_init(ZathuraPage* widget)
|
zathura_page_widget_init(ZathuraPage* widget)
|
||||||
{
|
{
|
||||||
zathura_page_widget_private_t* priv = ZATHURA_PAGE_GET_PRIVATE(widget);
|
ZathuraPagePrivate* priv = zathura_page_widget_get_instance_private(widget);
|
||||||
priv->page = NULL;
|
priv->page = NULL;
|
||||||
priv->surface = NULL;
|
priv->surface = NULL;
|
||||||
priv->thumbnail = NULL;
|
priv->thumbnail = NULL;
|
||||||
|
@ -249,7 +242,7 @@ zathura_page_widget_new(zathura_t* zathura, zathura_page_t* page)
|
||||||
}
|
}
|
||||||
|
|
||||||
ZathuraPage* widget = ZATHURA_PAGE(ret);
|
ZathuraPage* widget = ZATHURA_PAGE(ret);
|
||||||
zathura_page_widget_private_t* priv = ZATHURA_PAGE_GET_PRIVATE(widget);
|
ZathuraPagePrivate* priv = zathura_page_widget_get_instance_private(widget);
|
||||||
priv->render_request = zathura_render_request_new(zathura->sync.render_thread, page);
|
priv->render_request = zathura_render_request_new(zathura->sync.render_thread, page);
|
||||||
g_signal_connect_object(priv->render_request, "completed",
|
g_signal_connect_object(priv->render_request, "completed",
|
||||||
G_CALLBACK(cb_update_surface), widget, 0);
|
G_CALLBACK(cb_update_surface), widget, 0);
|
||||||
|
@ -265,7 +258,7 @@ static void
|
||||||
zathura_page_widget_dispose(GObject* object)
|
zathura_page_widget_dispose(GObject* object)
|
||||||
{
|
{
|
||||||
ZathuraPage* widget = ZATHURA_PAGE(object);
|
ZathuraPage* widget = ZATHURA_PAGE(object);
|
||||||
zathura_page_widget_private_t* priv = ZATHURA_PAGE_GET_PRIVATE(widget);
|
ZathuraPagePrivate* priv = zathura_page_widget_get_instance_private(widget);
|
||||||
|
|
||||||
g_clear_object(&priv->render_request);
|
g_clear_object(&priv->render_request);
|
||||||
|
|
||||||
|
@ -276,7 +269,7 @@ static void
|
||||||
zathura_page_widget_finalize(GObject* object)
|
zathura_page_widget_finalize(GObject* object)
|
||||||
{
|
{
|
||||||
ZathuraPage* widget = ZATHURA_PAGE(object);
|
ZathuraPage* widget = ZATHURA_PAGE(object);
|
||||||
zathura_page_widget_private_t* priv = ZATHURA_PAGE_GET_PRIVATE(widget);
|
ZathuraPagePrivate* priv = zathura_page_widget_get_instance_private(widget);
|
||||||
|
|
||||||
if (priv->surface != NULL) {
|
if (priv->surface != NULL) {
|
||||||
cairo_surface_destroy(priv->surface);
|
cairo_surface_destroy(priv->surface);
|
||||||
|
@ -377,7 +370,7 @@ static void
|
||||||
zathura_page_widget_set_property(GObject* object, guint prop_id, const GValue* value, GParamSpec* pspec)
|
zathura_page_widget_set_property(GObject* object, guint prop_id, const GValue* value, GParamSpec* pspec)
|
||||||
{
|
{
|
||||||
ZathuraPage* pageview = ZATHURA_PAGE(object);
|
ZathuraPage* pageview = ZATHURA_PAGE(object);
|
||||||
zathura_page_widget_private_t* priv = ZATHURA_PAGE_GET_PRIVATE(pageview);
|
ZathuraPagePrivate* priv = zathura_page_widget_get_instance_private(pageview);
|
||||||
|
|
||||||
cairo_text_extents_t text;
|
cairo_text_extents_t text;
|
||||||
|
|
||||||
|
@ -473,7 +466,7 @@ static void
|
||||||
zathura_page_widget_get_property(GObject* object, guint prop_id, GValue* value, GParamSpec* pspec)
|
zathura_page_widget_get_property(GObject* object, guint prop_id, GValue* value, GParamSpec* pspec)
|
||||||
{
|
{
|
||||||
ZathuraPage* pageview = ZATHURA_PAGE(object);
|
ZathuraPage* pageview = ZATHURA_PAGE(object);
|
||||||
zathura_page_widget_private_t* priv = ZATHURA_PAGE_GET_PRIVATE(pageview);
|
ZathuraPagePrivate* priv = zathura_page_widget_get_instance_private(pageview);
|
||||||
|
|
||||||
switch (prop_id) {
|
switch (prop_id) {
|
||||||
case PROP_LINKS_NUMBER:
|
case PROP_LINKS_NUMBER:
|
||||||
|
@ -515,7 +508,8 @@ get_safe_device_factors(cairo_surface_t* surface)
|
||||||
static gboolean
|
static gboolean
|
||||||
zathura_page_widget_draw(GtkWidget* widget, cairo_t* cairo)
|
zathura_page_widget_draw(GtkWidget* widget, cairo_t* cairo)
|
||||||
{
|
{
|
||||||
zathura_page_widget_private_t* priv = ZATHURA_PAGE_GET_PRIVATE(widget);
|
ZathuraPage* page = ZATHURA_PAGE(widget);
|
||||||
|
ZathuraPagePrivate* priv = zathura_page_widget_get_instance_private(page);
|
||||||
|
|
||||||
zathura_document_t* document = zathura_page_get_document(priv->page);
|
zathura_document_t* document = zathura_page_get_document(priv->page);
|
||||||
const unsigned int page_height = gtk_widget_get_allocated_height(widget);
|
const unsigned int page_height = gtk_widget_get_allocated_height(widget);
|
||||||
|
@ -754,7 +748,7 @@ draw_thumbnail_image(cairo_surface_t* surface, size_t max_size)
|
||||||
void
|
void
|
||||||
zathura_page_widget_update_surface(ZathuraPage* widget, cairo_surface_t* surface, bool keep_thumbnail)
|
zathura_page_widget_update_surface(ZathuraPage* widget, cairo_surface_t* surface, bool keep_thumbnail)
|
||||||
{
|
{
|
||||||
zathura_page_widget_private_t* priv = ZATHURA_PAGE_GET_PRIVATE(widget);
|
ZathuraPagePrivate* priv = zathura_page_widget_get_instance_private(widget);
|
||||||
int thumbnail_size = 0;
|
int thumbnail_size = 0;
|
||||||
girara_setting_get(priv->zathura->ui.session, "page-thumbnail-size", &thumbnail_size);
|
girara_setting_get(priv->zathura->ui.session, "page-thumbnail-size", &thumbnail_size);
|
||||||
if (thumbnail_size <= 0) {
|
if (thumbnail_size <= 0) {
|
||||||
|
@ -804,7 +798,7 @@ cb_cache_added(ZathuraRenderRequest* UNUSED(request), void* data)
|
||||||
ZathuraPage* widget = data;
|
ZathuraPage* widget = data;
|
||||||
g_return_if_fail(ZATHURA_IS_PAGE(widget));
|
g_return_if_fail(ZATHURA_IS_PAGE(widget));
|
||||||
|
|
||||||
zathura_page_widget_private_t* priv = ZATHURA_PAGE_GET_PRIVATE(widget);
|
ZathuraPagePrivate* priv = zathura_page_widget_get_instance_private(widget);
|
||||||
priv->cached = true;
|
priv->cached = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -814,7 +808,7 @@ cb_cache_invalidated(ZathuraRenderRequest* UNUSED(request), void* data)
|
||||||
ZathuraPage* widget = data;
|
ZathuraPage* widget = data;
|
||||||
g_return_if_fail(ZATHURA_IS_PAGE(widget));
|
g_return_if_fail(ZATHURA_IS_PAGE(widget));
|
||||||
|
|
||||||
zathura_page_widget_private_t* priv = ZATHURA_PAGE_GET_PRIVATE(widget);
|
ZathuraPagePrivate* priv = zathura_page_widget_get_instance_private(widget);
|
||||||
if (zathura_page_widget_have_surface(widget) == true &&
|
if (zathura_page_widget_have_surface(widget) == true &&
|
||||||
priv->cached == true &&
|
priv->cached == true &&
|
||||||
zathura_page_get_visibility(priv->page) == false) {
|
zathura_page_get_visibility(priv->page) == false) {
|
||||||
|
@ -850,7 +844,7 @@ redraw_rect(ZathuraPage* widget, zathura_rectangle_t* rectangle)
|
||||||
static void
|
static void
|
||||||
redraw_all_rects(ZathuraPage* widget, girara_list_t* rectangles)
|
redraw_all_rects(ZathuraPage* widget, girara_list_t* rectangles)
|
||||||
{
|
{
|
||||||
zathura_page_widget_private_t* priv = ZATHURA_PAGE_GET_PRIVATE(widget);
|
ZathuraPagePrivate* priv = zathura_page_widget_get_instance_private(widget);
|
||||||
|
|
||||||
GIRARA_LIST_FOREACH_BODY(rectangles, zathura_rectangle_t*, rect,
|
GIRARA_LIST_FOREACH_BODY(rectangles, zathura_rectangle_t*, rect,
|
||||||
zathura_rectangle_t rectangle = recalc_rectangle(priv->page, *rect);
|
zathura_rectangle_t rectangle = recalc_rectangle(priv->page, *rect);
|
||||||
|
@ -862,7 +856,7 @@ zathura_link_t*
|
||||||
zathura_page_widget_link_get(ZathuraPage* widget, unsigned int index)
|
zathura_page_widget_link_get(ZathuraPage* widget, unsigned int index)
|
||||||
{
|
{
|
||||||
g_return_val_if_fail(widget != NULL, NULL);
|
g_return_val_if_fail(widget != NULL, NULL);
|
||||||
zathura_page_widget_private_t* priv = ZATHURA_PAGE_GET_PRIVATE(widget);
|
ZathuraPagePrivate* priv = zathura_page_widget_get_instance_private(widget);
|
||||||
g_return_val_if_fail(priv != NULL, NULL);
|
g_return_val_if_fail(priv != NULL, NULL);
|
||||||
|
|
||||||
if (priv->links.list != NULL && index >= priv->links.offset &&
|
if (priv->links.list != NULL && index >= priv->links.offset &&
|
||||||
|
@ -879,7 +873,8 @@ cb_zathura_page_widget_button_press_event(GtkWidget* widget, GdkEventButton* but
|
||||||
g_return_val_if_fail(widget != NULL, false);
|
g_return_val_if_fail(widget != NULL, false);
|
||||||
g_return_val_if_fail(button != NULL, false);
|
g_return_val_if_fail(button != NULL, false);
|
||||||
|
|
||||||
zathura_page_widget_private_t* priv = ZATHURA_PAGE_GET_PRIVATE(widget);
|
ZathuraPage* page = ZATHURA_PAGE(widget);
|
||||||
|
ZathuraPagePrivate* priv = zathura_page_widget_get_instance_private(page);
|
||||||
|
|
||||||
if (girara_callback_view_button_press_event(widget, button, priv->zathura->ui.session) == true) {
|
if (girara_callback_view_button_press_event(widget, button, priv->zathura->ui.session) == true) {
|
||||||
return true;
|
return true;
|
||||||
|
@ -928,15 +923,16 @@ cb_zathura_page_widget_button_release_event(GtkWidget* widget, GdkEventButton* b
|
||||||
const int oldx = button->x;
|
const int oldx = button->x;
|
||||||
const int oldy = button->y;
|
const int oldy = button->y;
|
||||||
|
|
||||||
zathura_page_widget_private_t* priv = ZATHURA_PAGE_GET_PRIVATE(widget);
|
ZathuraPage* page = ZATHURA_PAGE(widget);
|
||||||
zathura_document_t* document = zathura_page_get_document(priv->page);
|
ZathuraPagePrivate* priv = zathura_page_widget_get_instance_private(page);
|
||||||
|
|
||||||
|
zathura_document_t* document = zathura_page_get_document(priv->page);
|
||||||
const double scale = zathura_document_get_scale(document);
|
const double scale = zathura_document_get_scale(document);
|
||||||
|
|
||||||
button->x /= scale;
|
button->x /= scale;
|
||||||
button->y /= scale;
|
button->y /= scale;
|
||||||
|
|
||||||
g_signal_emit(ZATHURA_PAGE(widget), signals[BUTTON_RELEASE], 0, button);
|
g_signal_emit(page, signals[BUTTON_RELEASE], 0, button);
|
||||||
|
|
||||||
button->x = oldx;
|
button->x = oldx;
|
||||||
button->y = oldy;
|
button->y = oldy;
|
||||||
|
@ -999,8 +995,10 @@ cb_zathura_page_widget_motion_notify(GtkWidget* widget, GdkEventMotion* event)
|
||||||
g_return_val_if_fail(widget != NULL, false);
|
g_return_val_if_fail(widget != NULL, false);
|
||||||
g_return_val_if_fail(event != NULL, false);
|
g_return_val_if_fail(event != NULL, false);
|
||||||
|
|
||||||
|
ZathuraPage* page = ZATHURA_PAGE(widget);
|
||||||
|
ZathuraPagePrivate* priv = zathura_page_widget_get_instance_private(page);
|
||||||
|
|
||||||
if ((event->state & GDK_BUTTON1_MASK) == 0) {
|
if ((event->state & GDK_BUTTON1_MASK) == 0) {
|
||||||
zathura_page_widget_private_t* priv = ZATHURA_PAGE_GET_PRIVATE(widget);
|
|
||||||
if (priv->links.retrieved == false) {
|
if (priv->links.retrieved == false) {
|
||||||
priv->links.list = zathura_page_links_get(priv->page, NULL);
|
priv->links.list = zathura_page_links_get(priv->page, NULL);
|
||||||
priv->links.retrieved = true;
|
priv->links.retrieved = true;
|
||||||
|
@ -1030,7 +1028,6 @@ cb_zathura_page_widget_motion_notify(GtkWidget* widget, GdkEventMotion* event)
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
zathura_page_widget_private_t* priv = ZATHURA_PAGE_GET_PRIVATE(widget);
|
|
||||||
zathura_rectangle_t tmp = priv->mouse.selection;
|
zathura_rectangle_t tmp = priv->mouse.selection;
|
||||||
if (event->x < priv->mouse.selection_basepoint.x) {
|
if (event->x < priv->mouse.selection_basepoint.x) {
|
||||||
tmp.x1 = event->x;
|
tmp.x1 = event->x;
|
||||||
|
@ -1059,7 +1056,8 @@ cb_zathura_page_widget_leave_notify(GtkWidget* widget, GdkEventCrossing* UNUSED(
|
||||||
{
|
{
|
||||||
g_return_val_if_fail(widget != NULL, false);
|
g_return_val_if_fail(widget != NULL, false);
|
||||||
|
|
||||||
zathura_page_widget_private_t* priv = ZATHURA_PAGE_GET_PRIVATE(widget);
|
ZathuraPage* page = ZATHURA_PAGE(widget);
|
||||||
|
ZathuraPagePrivate* priv = zathura_page_widget_get_instance_private(page);
|
||||||
if (priv->mouse.over_link == true) {
|
if (priv->mouse.over_link == true) {
|
||||||
g_signal_emit(ZATHURA_PAGE(widget), signals[LEAVE_LINK], 0);
|
g_signal_emit(ZATHURA_PAGE(widget), signals[LEAVE_LINK], 0);
|
||||||
priv->mouse.over_link = false;
|
priv->mouse.over_link = false;
|
||||||
|
@ -1076,7 +1074,8 @@ zathura_page_widget_popup_menu(GtkWidget* widget, GdkEventButton* event)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
zathura_page_widget_private_t* priv = ZATHURA_PAGE_GET_PRIVATE(widget);
|
ZathuraPage* page = ZATHURA_PAGE(widget);
|
||||||
|
ZathuraPagePrivate* priv = zathura_page_widget_get_instance_private(page);
|
||||||
|
|
||||||
if (priv->images.retrieved == false) {
|
if (priv->images.retrieved == false) {
|
||||||
priv->images.list = zathura_page_images_get(priv->page, NULL);
|
priv->images.list = zathura_page_images_get(priv->page, NULL);
|
||||||
|
@ -1144,7 +1143,7 @@ cb_menu_image_copy(GtkMenuItem* item, ZathuraPage* page)
|
||||||
{
|
{
|
||||||
g_return_if_fail(item != NULL);
|
g_return_if_fail(item != NULL);
|
||||||
g_return_if_fail(page != NULL);
|
g_return_if_fail(page != NULL);
|
||||||
zathura_page_widget_private_t* priv = ZATHURA_PAGE_GET_PRIVATE(page);
|
ZathuraPagePrivate* priv = zathura_page_widget_get_instance_private(page);
|
||||||
g_return_if_fail(priv->images.current != NULL);
|
g_return_if_fail(priv->images.current != NULL);
|
||||||
|
|
||||||
cairo_surface_t* surface = zathura_page_image_get_cairo(priv->page, priv->images.current, NULL);
|
cairo_surface_t* surface = zathura_page_image_get_cairo(priv->page, priv->images.current, NULL);
|
||||||
|
@ -1169,7 +1168,7 @@ cb_menu_image_save(GtkMenuItem* item, ZathuraPage* page)
|
||||||
{
|
{
|
||||||
g_return_if_fail(item != NULL);
|
g_return_if_fail(item != NULL);
|
||||||
g_return_if_fail(page != NULL);
|
g_return_if_fail(page != NULL);
|
||||||
zathura_page_widget_private_t* priv = ZATHURA_PAGE_GET_PRIVATE(page);
|
ZathuraPagePrivate* priv = zathura_page_widget_get_instance_private(page);
|
||||||
g_return_if_fail(priv->images.current != NULL);
|
g_return_if_fail(priv->images.current != NULL);
|
||||||
g_return_if_fail(priv->images.list != NULL);
|
g_return_if_fail(priv->images.list != NULL);
|
||||||
|
|
||||||
|
@ -1199,7 +1198,7 @@ void
|
||||||
zathura_page_widget_update_view_time(ZathuraPage* widget)
|
zathura_page_widget_update_view_time(ZathuraPage* widget)
|
||||||
{
|
{
|
||||||
g_return_if_fail(ZATHURA_IS_PAGE(widget));
|
g_return_if_fail(ZATHURA_IS_PAGE(widget));
|
||||||
zathura_page_widget_private_t* priv = ZATHURA_PAGE_GET_PRIVATE(widget);
|
ZathuraPagePrivate* priv = zathura_page_widget_get_instance_private(widget);
|
||||||
|
|
||||||
if (zathura_page_get_visibility(priv->page) == true) {
|
if (zathura_page_get_visibility(priv->page) == true) {
|
||||||
zathura_render_request_update_view_time(priv->render_request);
|
zathura_render_request_update_view_time(priv->render_request);
|
||||||
|
@ -1210,7 +1209,7 @@ bool
|
||||||
zathura_page_widget_have_surface(ZathuraPage* widget)
|
zathura_page_widget_have_surface(ZathuraPage* widget)
|
||||||
{
|
{
|
||||||
g_return_val_if_fail(ZATHURA_IS_PAGE(widget), false);
|
g_return_val_if_fail(ZATHURA_IS_PAGE(widget), false);
|
||||||
zathura_page_widget_private_t* priv = ZATHURA_PAGE_GET_PRIVATE(widget);
|
ZathuraPagePrivate* priv = zathura_page_widget_get_instance_private(widget);
|
||||||
return priv->surface != NULL;
|
return priv->surface != NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1218,7 +1217,7 @@ void
|
||||||
zathura_page_widget_abort_render_request(ZathuraPage* widget)
|
zathura_page_widget_abort_render_request(ZathuraPage* widget)
|
||||||
{
|
{
|
||||||
g_return_if_fail(ZATHURA_IS_PAGE(widget));
|
g_return_if_fail(ZATHURA_IS_PAGE(widget));
|
||||||
zathura_page_widget_private_t* priv = ZATHURA_PAGE_GET_PRIVATE(widget);
|
ZathuraPagePrivate* priv = zathura_page_widget_get_instance_private(widget);
|
||||||
zathura_render_request_abort(priv->render_request);
|
zathura_render_request_abort(priv->render_request);
|
||||||
|
|
||||||
/* Make sure that if we are not cached and invisible, that there is no
|
/* Make sure that if we are not cached and invisible, that there is no
|
||||||
|
@ -1234,7 +1233,7 @@ zathura_page_widget_abort_render_request(ZathuraPage* widget)
|
||||||
zathura_page_t*
|
zathura_page_t*
|
||||||
zathura_page_widget_get_page(ZathuraPage* widget) {
|
zathura_page_widget_get_page(ZathuraPage* widget) {
|
||||||
g_return_val_if_fail(ZATHURA_IS_PAGE(widget), NULL);
|
g_return_val_if_fail(ZATHURA_IS_PAGE(widget), NULL);
|
||||||
zathura_page_widget_private_t* priv = ZATHURA_PAGE_GET_PRIVATE(widget);
|
ZathuraPagePrivate* priv = zathura_page_widget_get_instance_private(widget);
|
||||||
|
|
||||||
return priv->page;
|
return priv->page;
|
||||||
}
|
}
|
||||||
|
|
140
zathura/render.c
140
zathura/render.c
|
@ -13,23 +13,6 @@
|
||||||
#include "page-widget.h"
|
#include "page-widget.h"
|
||||||
#include "utils.h"
|
#include "utils.h"
|
||||||
|
|
||||||
/* define the two types */
|
|
||||||
G_DEFINE_TYPE(ZathuraRenderer, zathura_renderer, G_TYPE_OBJECT)
|
|
||||||
G_DEFINE_TYPE(ZathuraRenderRequest, zathura_render_request, G_TYPE_OBJECT)
|
|
||||||
|
|
||||||
/* private methods for ZathuraRenderer */
|
|
||||||
static void renderer_finalize(GObject* object);
|
|
||||||
/* private methods for ZathuraRenderRequest */
|
|
||||||
static void render_request_dispose(GObject* object);
|
|
||||||
static void render_request_finalize(GObject* object);
|
|
||||||
|
|
||||||
static void render_job(void* data, void* user_data);
|
|
||||||
static gint render_thread_sort(gconstpointer a, gconstpointer b, gpointer data);
|
|
||||||
static ssize_t page_cache_lru_invalidate(ZathuraRenderer* renderer);
|
|
||||||
static void page_cache_invalidate_all(ZathuraRenderer* renderer);
|
|
||||||
static bool page_cache_is_full(ZathuraRenderer* renderer, bool* result);
|
|
||||||
|
|
||||||
|
|
||||||
/* private data for ZathuraRenderer */
|
/* private data for ZathuraRenderer */
|
||||||
typedef struct private_s {
|
typedef struct private_s {
|
||||||
GThreadPool* pool; /**< Pool of threads */
|
GThreadPool* pool; /**< Pool of threads */
|
||||||
|
@ -59,7 +42,7 @@ typedef struct private_s {
|
||||||
|
|
||||||
/* render requests */
|
/* render requests */
|
||||||
girara_list_t* requests;
|
girara_list_t* requests;
|
||||||
} private_t;
|
} ZathuraRendererPrivate;
|
||||||
|
|
||||||
/* private data for ZathuraRenderRequest */
|
/* private data for ZathuraRenderRequest */
|
||||||
typedef struct request_private_s {
|
typedef struct request_private_s {
|
||||||
|
@ -68,13 +51,23 @@ typedef struct request_private_s {
|
||||||
gint64 last_view_time;
|
gint64 last_view_time;
|
||||||
girara_list_t* active_jobs;
|
girara_list_t* active_jobs;
|
||||||
GMutex jobs_mutex;
|
GMutex jobs_mutex;
|
||||||
} request_private_t;
|
} ZathuraRenderRequestPrivate;
|
||||||
|
|
||||||
#define GET_PRIVATE(obj) \
|
/* define the two types */
|
||||||
(G_TYPE_INSTANCE_GET_PRIVATE((obj), ZATHURA_TYPE_RENDERER, private_t))
|
G_DEFINE_TYPE_WITH_CODE(ZathuraRenderer, zathura_renderer, G_TYPE_OBJECT, G_ADD_PRIVATE(ZathuraRenderer))
|
||||||
#define REQUEST_GET_PRIVATE(obj) \
|
G_DEFINE_TYPE_WITH_CODE(ZathuraRenderRequest, zathura_render_request, G_TYPE_OBJECT, G_ADD_PRIVATE(ZathuraRenderRequest))
|
||||||
(G_TYPE_INSTANCE_GET_PRIVATE((obj), ZATHURA_TYPE_RENDER_REQUEST, \
|
|
||||||
request_private_t))
|
/* private methods for ZathuraRenderer */
|
||||||
|
static void renderer_finalize(GObject* object);
|
||||||
|
/* private methods for ZathuraRenderRequest */
|
||||||
|
static void render_request_dispose(GObject* object);
|
||||||
|
static void render_request_finalize(GObject* object);
|
||||||
|
|
||||||
|
static void render_job(void* data, void* user_data);
|
||||||
|
static gint render_thread_sort(gconstpointer a, gconstpointer b, gpointer data);
|
||||||
|
static ssize_t page_cache_lru_invalidate(ZathuraRenderer* renderer);
|
||||||
|
static void page_cache_invalidate_all(ZathuraRenderer* renderer);
|
||||||
|
static bool page_cache_is_full(ZathuraRenderer* renderer, bool* result);
|
||||||
|
|
||||||
/* job descritption for render thread */
|
/* job descritption for render thread */
|
||||||
typedef struct render_job_s {
|
typedef struct render_job_s {
|
||||||
|
@ -87,9 +80,6 @@ typedef struct render_job_s {
|
||||||
static void
|
static void
|
||||||
zathura_renderer_class_init(ZathuraRendererClass* class)
|
zathura_renderer_class_init(ZathuraRendererClass* class)
|
||||||
{
|
{
|
||||||
/* add private members */
|
|
||||||
g_type_class_add_private(class, sizeof(private_t));
|
|
||||||
|
|
||||||
/* overwrite methods */
|
/* overwrite methods */
|
||||||
GObjectClass* object_class = G_OBJECT_CLASS(class);
|
GObjectClass* object_class = G_OBJECT_CLASS(class);
|
||||||
object_class->finalize = renderer_finalize;
|
object_class->finalize = renderer_finalize;
|
||||||
|
@ -98,7 +88,7 @@ zathura_renderer_class_init(ZathuraRendererClass* class)
|
||||||
static void
|
static void
|
||||||
zathura_renderer_init(ZathuraRenderer* renderer)
|
zathura_renderer_init(ZathuraRenderer* renderer)
|
||||||
{
|
{
|
||||||
private_t* priv = GET_PRIVATE(renderer);
|
ZathuraRendererPrivate* priv = zathura_renderer_get_instance_private(renderer);
|
||||||
priv->pool = g_thread_pool_new(render_job, renderer, 1, TRUE, NULL);
|
priv->pool = g_thread_pool_new(render_job, renderer, 1, TRUE, NULL);
|
||||||
priv->about_to_close = false;
|
priv->about_to_close = false;
|
||||||
g_thread_pool_set_sort_function(priv->pool, render_thread_sort, NULL);
|
g_thread_pool_set_sort_function(priv->pool, render_thread_sort, NULL);
|
||||||
|
@ -122,7 +112,7 @@ zathura_renderer_init(ZathuraRenderer* renderer)
|
||||||
static bool
|
static bool
|
||||||
page_cache_init(ZathuraRenderer* renderer, size_t cache_size)
|
page_cache_init(ZathuraRenderer* renderer, size_t cache_size)
|
||||||
{
|
{
|
||||||
private_t* priv = GET_PRIVATE(renderer);
|
ZathuraRendererPrivate* priv = zathura_renderer_get_instance_private(renderer);
|
||||||
|
|
||||||
priv->page_cache.size = cache_size;
|
priv->page_cache.size = cache_size;
|
||||||
priv->page_cache.cache = g_try_malloc0(cache_size * sizeof(int));
|
priv->page_cache.cache = g_try_malloc0(cache_size * sizeof(int));
|
||||||
|
@ -154,7 +144,7 @@ static void
|
||||||
renderer_finalize(GObject* object)
|
renderer_finalize(GObject* object)
|
||||||
{
|
{
|
||||||
ZathuraRenderer* renderer = ZATHURA_RENDERER(object);
|
ZathuraRenderer* renderer = ZATHURA_RENDERER(object);
|
||||||
private_t* priv = GET_PRIVATE(renderer);
|
ZathuraRendererPrivate* priv = zathura_renderer_get_instance_private(renderer);
|
||||||
|
|
||||||
zathura_renderer_stop(renderer);
|
zathura_renderer_stop(renderer);
|
||||||
if (priv->pool != NULL) {
|
if (priv->pool != NULL) {
|
||||||
|
@ -172,7 +162,7 @@ static void
|
||||||
renderer_unregister_request(ZathuraRenderer* renderer,
|
renderer_unregister_request(ZathuraRenderer* renderer,
|
||||||
ZathuraRenderRequest* request)
|
ZathuraRenderRequest* request)
|
||||||
{
|
{
|
||||||
private_t* priv = GET_PRIVATE(renderer);
|
ZathuraRendererPrivate* priv = zathura_renderer_get_instance_private(renderer);
|
||||||
girara_list_remove(priv->requests, request);
|
girara_list_remove(priv->requests, request);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -180,7 +170,7 @@ static void
|
||||||
renderer_register_request(ZathuraRenderer* renderer,
|
renderer_register_request(ZathuraRenderer* renderer,
|
||||||
ZathuraRenderRequest* request)
|
ZathuraRenderRequest* request)
|
||||||
{
|
{
|
||||||
private_t* priv = GET_PRIVATE(renderer);
|
ZathuraRendererPrivate* priv = zathura_renderer_get_instance_private(renderer);
|
||||||
if (girara_list_contains(priv->requests, request) == false) {
|
if (girara_list_contains(priv->requests, request) == false) {
|
||||||
girara_list_append(priv->requests, request);
|
girara_list_append(priv->requests, request);
|
||||||
}
|
}
|
||||||
|
@ -200,9 +190,6 @@ static guint request_signals[REQUEST_LAST_SIGNAL] = { 0 };
|
||||||
static void
|
static void
|
||||||
zathura_render_request_class_init(ZathuraRenderRequestClass* class)
|
zathura_render_request_class_init(ZathuraRenderRequestClass* class)
|
||||||
{
|
{
|
||||||
/* add private members */
|
|
||||||
g_type_class_add_private(class, sizeof(request_private_t));
|
|
||||||
|
|
||||||
/* overwrite methods */
|
/* overwrite methods */
|
||||||
GObjectClass* object_class = G_OBJECT_CLASS(class);
|
GObjectClass* object_class = G_OBJECT_CLASS(class);
|
||||||
object_class->dispose = render_request_dispose;
|
object_class->dispose = render_request_dispose;
|
||||||
|
@ -243,7 +230,7 @@ zathura_render_request_class_init(ZathuraRenderRequestClass* class)
|
||||||
static void
|
static void
|
||||||
zathura_render_request_init(ZathuraRenderRequest* request)
|
zathura_render_request_init(ZathuraRenderRequest* request)
|
||||||
{
|
{
|
||||||
request_private_t* priv = REQUEST_GET_PRIVATE(request);
|
ZathuraRenderRequestPrivate* priv = zathura_render_request_get_instance_private(request);
|
||||||
priv->renderer = NULL;
|
priv->renderer = NULL;
|
||||||
priv->page = NULL;
|
priv->page = NULL;
|
||||||
}
|
}
|
||||||
|
@ -259,7 +246,7 @@ zathura_render_request_new(ZathuraRenderer* renderer, zathura_page_t* page)
|
||||||
}
|
}
|
||||||
|
|
||||||
ZathuraRenderRequest* request = ZATHURA_RENDER_REQUEST(obj);
|
ZathuraRenderRequest* request = ZATHURA_RENDER_REQUEST(obj);
|
||||||
request_private_t* priv = REQUEST_GET_PRIVATE(request);
|
ZathuraRenderRequestPrivate* priv = zathura_render_request_get_instance_private(request);
|
||||||
/* we want to make sure that renderer lives long enough */
|
/* we want to make sure that renderer lives long enough */
|
||||||
priv->renderer = g_object_ref(renderer);
|
priv->renderer = g_object_ref(renderer);
|
||||||
priv->page = page;
|
priv->page = page;
|
||||||
|
@ -276,7 +263,7 @@ static void
|
||||||
render_request_dispose(GObject* object)
|
render_request_dispose(GObject* object)
|
||||||
{
|
{
|
||||||
ZathuraRenderRequest* request = ZATHURA_RENDER_REQUEST(object);
|
ZathuraRenderRequest* request = ZATHURA_RENDER_REQUEST(object);
|
||||||
request_private_t* priv = REQUEST_GET_PRIVATE(request);
|
ZathuraRenderRequestPrivate* priv = zathura_render_request_get_instance_private(request);
|
||||||
|
|
||||||
if (priv->renderer != NULL) {
|
if (priv->renderer != NULL) {
|
||||||
/* unregister the request */
|
/* unregister the request */
|
||||||
|
@ -292,7 +279,7 @@ static void
|
||||||
render_request_finalize(GObject* object)
|
render_request_finalize(GObject* object)
|
||||||
{
|
{
|
||||||
ZathuraRenderRequest* request = ZATHURA_RENDER_REQUEST(object);
|
ZathuraRenderRequest* request = ZATHURA_RENDER_REQUEST(object);
|
||||||
request_private_t* priv = REQUEST_GET_PRIVATE(request);
|
ZathuraRenderRequestPrivate* priv = zathura_render_request_get_instance_private(request);
|
||||||
|
|
||||||
if (girara_list_size(priv->active_jobs) != 0) {
|
if (girara_list_size(priv->active_jobs) != 0) {
|
||||||
girara_error("This should not happen!");
|
girara_error("This should not happen!");
|
||||||
|
@ -310,7 +297,8 @@ zathura_renderer_recolor_enabled(ZathuraRenderer* renderer)
|
||||||
{
|
{
|
||||||
g_return_val_if_fail(ZATHURA_IS_RENDERER(renderer), false);
|
g_return_val_if_fail(ZATHURA_IS_RENDERER(renderer), false);
|
||||||
|
|
||||||
return GET_PRIVATE(renderer)->recolor.enabled;
|
ZathuraRendererPrivate* priv = zathura_renderer_get_instance_private(renderer);
|
||||||
|
return priv->recolor.enabled;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
@ -318,7 +306,8 @@ zathura_renderer_enable_recolor(ZathuraRenderer* renderer, bool enable)
|
||||||
{
|
{
|
||||||
g_return_if_fail(ZATHURA_IS_RENDERER(renderer));
|
g_return_if_fail(ZATHURA_IS_RENDERER(renderer));
|
||||||
|
|
||||||
GET_PRIVATE(renderer)->recolor.enabled = enable;
|
ZathuraRendererPrivate* priv = zathura_renderer_get_instance_private(renderer);
|
||||||
|
priv->recolor.enabled = enable;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
|
@ -326,7 +315,8 @@ zathura_renderer_recolor_hue_enabled(ZathuraRenderer* renderer)
|
||||||
{
|
{
|
||||||
g_return_val_if_fail(ZATHURA_IS_RENDERER(renderer), false);
|
g_return_val_if_fail(ZATHURA_IS_RENDERER(renderer), false);
|
||||||
|
|
||||||
return GET_PRIVATE(renderer)->recolor.hue;
|
ZathuraRendererPrivate* priv = zathura_renderer_get_instance_private(renderer);
|
||||||
|
return priv->recolor.hue;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
@ -334,7 +324,8 @@ zathura_renderer_enable_recolor_hue(ZathuraRenderer* renderer, bool enable)
|
||||||
{
|
{
|
||||||
g_return_if_fail(ZATHURA_IS_RENDERER(renderer));
|
g_return_if_fail(ZATHURA_IS_RENDERER(renderer));
|
||||||
|
|
||||||
GET_PRIVATE(renderer)->recolor.hue = enable;
|
ZathuraRendererPrivate* priv = zathura_renderer_get_instance_private(renderer);
|
||||||
|
priv->recolor.hue = enable;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
|
@ -342,7 +333,8 @@ zathura_renderer_recolor_reverse_video_enabled(ZathuraRenderer* renderer)
|
||||||
{
|
{
|
||||||
g_return_val_if_fail(ZATHURA_IS_RENDERER(renderer), false);
|
g_return_val_if_fail(ZATHURA_IS_RENDERER(renderer), false);
|
||||||
|
|
||||||
return GET_PRIVATE(renderer)->recolor.reverse_video;
|
ZathuraRendererPrivate* priv = zathura_renderer_get_instance_private(renderer);
|
||||||
|
return priv->recolor.reverse_video;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
@ -350,7 +342,8 @@ zathura_renderer_enable_recolor_reverse_video(ZathuraRenderer* renderer, bool en
|
||||||
{
|
{
|
||||||
g_return_if_fail(ZATHURA_IS_RENDERER(renderer));
|
g_return_if_fail(ZATHURA_IS_RENDERER(renderer));
|
||||||
|
|
||||||
GET_PRIVATE(renderer)->recolor.reverse_video = enable;
|
ZathuraRendererPrivate* priv = zathura_renderer_get_instance_private(renderer);
|
||||||
|
priv->recolor.reverse_video = enable;
|
||||||
}
|
}
|
||||||
void
|
void
|
||||||
zathura_renderer_set_recolor_colors(ZathuraRenderer* renderer,
|
zathura_renderer_set_recolor_colors(ZathuraRenderer* renderer,
|
||||||
|
@ -358,7 +351,7 @@ zathura_renderer_set_recolor_colors(ZathuraRenderer* renderer,
|
||||||
{
|
{
|
||||||
g_return_if_fail(ZATHURA_IS_RENDERER(renderer));
|
g_return_if_fail(ZATHURA_IS_RENDERER(renderer));
|
||||||
|
|
||||||
private_t* priv = GET_PRIVATE(renderer);
|
ZathuraRendererPrivate* priv = zathura_renderer_get_instance_private(renderer);
|
||||||
if (light != NULL) {
|
if (light != NULL) {
|
||||||
memcpy(&priv->recolor.light, light, sizeof(GdkRGBA));
|
memcpy(&priv->recolor.light, light, sizeof(GdkRGBA));
|
||||||
}
|
}
|
||||||
|
@ -393,7 +386,7 @@ zathura_renderer_get_recolor_colors(ZathuraRenderer* renderer,
|
||||||
{
|
{
|
||||||
g_return_if_fail(ZATHURA_IS_RENDERER(renderer));
|
g_return_if_fail(ZATHURA_IS_RENDERER(renderer));
|
||||||
|
|
||||||
private_t* priv = GET_PRIVATE(renderer);
|
ZathuraRendererPrivate* priv = zathura_renderer_get_instance_private(renderer);
|
||||||
if (light != NULL) {
|
if (light != NULL) {
|
||||||
memcpy(light, &priv->recolor.light, sizeof(GdkRGBA));
|
memcpy(light, &priv->recolor.light, sizeof(GdkRGBA));
|
||||||
}
|
}
|
||||||
|
@ -407,7 +400,7 @@ zathura_renderer_lock(ZathuraRenderer* renderer)
|
||||||
{
|
{
|
||||||
g_return_if_fail(ZATHURA_IS_RENDERER(renderer));
|
g_return_if_fail(ZATHURA_IS_RENDERER(renderer));
|
||||||
|
|
||||||
private_t* priv = GET_PRIVATE(renderer);
|
ZathuraRendererPrivate* priv = zathura_renderer_get_instance_private(renderer);
|
||||||
g_mutex_lock(&priv->mutex);
|
g_mutex_lock(&priv->mutex);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -416,7 +409,7 @@ zathura_renderer_unlock(ZathuraRenderer* renderer)
|
||||||
{
|
{
|
||||||
g_return_if_fail(ZATHURA_IS_RENDERER(renderer));
|
g_return_if_fail(ZATHURA_IS_RENDERER(renderer));
|
||||||
|
|
||||||
private_t* priv = GET_PRIVATE(renderer);
|
ZathuraRendererPrivate* priv = zathura_renderer_get_instance_private(renderer);
|
||||||
g_mutex_unlock(&priv->mutex);
|
g_mutex_unlock(&priv->mutex);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -424,7 +417,8 @@ void
|
||||||
zathura_renderer_stop(ZathuraRenderer* renderer)
|
zathura_renderer_stop(ZathuraRenderer* renderer)
|
||||||
{
|
{
|
||||||
g_return_if_fail(ZATHURA_IS_RENDERER(renderer));
|
g_return_if_fail(ZATHURA_IS_RENDERER(renderer));
|
||||||
GET_PRIVATE(renderer)->about_to_close = true;
|
ZathuraRendererPrivate* priv = zathura_renderer_get_instance_private(renderer);
|
||||||
|
priv->about_to_close = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -435,7 +429,7 @@ zathura_render_request(ZathuraRenderRequest* request, gint64 last_view_time)
|
||||||
{
|
{
|
||||||
g_return_if_fail(ZATHURA_IS_RENDER_REQUEST(request));
|
g_return_if_fail(ZATHURA_IS_RENDER_REQUEST(request));
|
||||||
|
|
||||||
request_private_t* request_priv = REQUEST_GET_PRIVATE(request);
|
ZathuraRenderRequestPrivate* request_priv = zathura_render_request_get_instance_private(request);
|
||||||
g_mutex_lock(&request_priv->jobs_mutex);
|
g_mutex_lock(&request_priv->jobs_mutex);
|
||||||
|
|
||||||
bool unfinished_jobs = false;
|
bool unfinished_jobs = false;
|
||||||
|
@ -460,7 +454,7 @@ zathura_render_request(ZathuraRenderRequest* request, gint64 last_view_time)
|
||||||
job->aborted = false;
|
job->aborted = false;
|
||||||
girara_list_append(request_priv->active_jobs, job);
|
girara_list_append(request_priv->active_jobs, job);
|
||||||
|
|
||||||
private_t* priv = GET_PRIVATE(request_priv->renderer);
|
ZathuraRendererPrivate* priv = zathura_renderer_get_instance_private(request_priv->renderer);
|
||||||
g_thread_pool_push(priv->pool, job, NULL);
|
g_thread_pool_push(priv->pool, job, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -472,7 +466,7 @@ zathura_render_request_abort(ZathuraRenderRequest* request)
|
||||||
{
|
{
|
||||||
g_return_if_fail(ZATHURA_IS_RENDER_REQUEST(request));
|
g_return_if_fail(ZATHURA_IS_RENDER_REQUEST(request));
|
||||||
|
|
||||||
request_private_t* request_priv = REQUEST_GET_PRIVATE(request);
|
ZathuraRenderRequestPrivate* request_priv = zathura_render_request_get_instance_private(request);
|
||||||
g_mutex_lock(&request_priv->jobs_mutex);
|
g_mutex_lock(&request_priv->jobs_mutex);
|
||||||
GIRARA_LIST_FOREACH_BODY(request_priv->active_jobs, render_job_t*, job,
|
GIRARA_LIST_FOREACH_BODY(request_priv->active_jobs, render_job_t*, job,
|
||||||
job->aborted = true;
|
job->aborted = true;
|
||||||
|
@ -485,7 +479,7 @@ zathura_render_request_update_view_time(ZathuraRenderRequest* request)
|
||||||
{
|
{
|
||||||
g_return_if_fail(ZATHURA_IS_RENDER_REQUEST(request));
|
g_return_if_fail(ZATHURA_IS_RENDER_REQUEST(request));
|
||||||
|
|
||||||
request_private_t* request_priv = REQUEST_GET_PRIVATE(request);
|
ZathuraRenderRequestPrivate* request_priv = zathura_render_request_get_instance_private(request);
|
||||||
request_priv->last_view_time = g_get_real_time();
|
request_priv->last_view_time = g_get_real_time();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -494,7 +488,7 @@ zathura_render_request_update_view_time(ZathuraRenderRequest* request)
|
||||||
static void
|
static void
|
||||||
remove_job_and_free(render_job_t* job)
|
remove_job_and_free(render_job_t* job)
|
||||||
{
|
{
|
||||||
request_private_t* request_priv = REQUEST_GET_PRIVATE(job->request);
|
ZathuraRenderRequestPrivate* request_priv = zathura_render_request_get_instance_private(job->request);
|
||||||
|
|
||||||
g_mutex_lock(&request_priv->jobs_mutex);
|
g_mutex_lock(&request_priv->jobs_mutex);
|
||||||
girara_list_remove(request_priv->active_jobs, job);
|
girara_list_remove(request_priv->active_jobs, job);
|
||||||
|
@ -515,8 +509,8 @@ emit_completed_signal(void* data)
|
||||||
{
|
{
|
||||||
emit_completed_signal_t* ecs = data;
|
emit_completed_signal_t* ecs = data;
|
||||||
render_job_t* job = ecs->job;
|
render_job_t* job = ecs->job;
|
||||||
request_private_t* request_priv = REQUEST_GET_PRIVATE(job->request);
|
ZathuraRenderRequestPrivate* request_priv = zathura_render_request_get_instance_private(job->request);
|
||||||
private_t* priv = GET_PRIVATE(request_priv->renderer);
|
ZathuraRendererPrivate* priv = zathura_renderer_get_instance_private(request_priv->renderer);
|
||||||
|
|
||||||
if (priv->about_to_close == false && job->aborted == false) {
|
if (priv->about_to_close == false && job->aborted == false) {
|
||||||
/* emit the signal */
|
/* emit the signal */
|
||||||
|
@ -568,7 +562,7 @@ colorumax(const double h[3], double l, double l1, double l2)
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
recolor(private_t* priv, zathura_page_t* page, unsigned int page_width,
|
recolor(ZathuraRendererPrivate* priv, zathura_page_t* page, unsigned int page_width,
|
||||||
unsigned int page_height, cairo_surface_t* surface)
|
unsigned int page_height, cairo_surface_t* surface)
|
||||||
{
|
{
|
||||||
/* uses a representation of a rgb color as follows:
|
/* uses a representation of a rgb color as follows:
|
||||||
|
@ -708,8 +702,8 @@ recolor(private_t* priv, zathura_page_t* page, unsigned int page_width,
|
||||||
static bool
|
static bool
|
||||||
render(render_job_t* job, ZathuraRenderRequest* request, ZathuraRenderer* renderer)
|
render(render_job_t* job, ZathuraRenderRequest* request, ZathuraRenderer* renderer)
|
||||||
{
|
{
|
||||||
private_t* priv = GET_PRIVATE(renderer);
|
ZathuraRendererPrivate* priv = zathura_renderer_get_instance_private(renderer);
|
||||||
request_private_t* request_priv = REQUEST_GET_PRIVATE(request);
|
ZathuraRenderRequestPrivate* request_priv = zathura_render_request_get_instance_private(request);
|
||||||
zathura_page_t* page = request_priv->page;
|
zathura_page_t* page = request_priv->page;
|
||||||
|
|
||||||
/* create cairo surface */
|
/* create cairo surface */
|
||||||
|
@ -812,14 +806,14 @@ render_job(void* data, void* user_data)
|
||||||
g_return_if_fail(ZATHURA_IS_RENDER_REQUEST(request));
|
g_return_if_fail(ZATHURA_IS_RENDER_REQUEST(request));
|
||||||
g_return_if_fail(ZATHURA_IS_RENDERER(renderer));
|
g_return_if_fail(ZATHURA_IS_RENDERER(renderer));
|
||||||
|
|
||||||
private_t* priv = GET_PRIVATE(renderer);
|
ZathuraRendererPrivate* priv = zathura_renderer_get_instance_private(renderer);
|
||||||
if (priv->about_to_close == true || job->aborted == true) {
|
if (priv->about_to_close == true || job->aborted == true) {
|
||||||
/* back out early */
|
/* back out early */
|
||||||
remove_job_and_free(job);
|
remove_job_and_free(job);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
request_private_t* request_priv = REQUEST_GET_PRIVATE(request);
|
ZathuraRenderRequestPrivate* request_priv = zathura_render_request_get_instance_private(request);
|
||||||
girara_debug("Rendering page %d ...",
|
girara_debug("Rendering page %d ...",
|
||||||
zathura_page_get_index(request_priv->page) + 1);
|
zathura_page_get_index(request_priv->page) + 1);
|
||||||
if (render(job, request, renderer) != true) {
|
if (render(job, request, renderer) != true) {
|
||||||
|
@ -866,8 +860,8 @@ render_thread_sort(gconstpointer a, gconstpointer b, gpointer UNUSED(data))
|
||||||
const render_job_t* job_a = a;
|
const render_job_t* job_a = a;
|
||||||
const render_job_t* job_b = b;
|
const render_job_t* job_b = b;
|
||||||
if (job_a->aborted == job_b->aborted) {
|
if (job_a->aborted == job_b->aborted) {
|
||||||
request_private_t* priv_a = REQUEST_GET_PRIVATE(job_a->request);
|
ZathuraRenderRequestPrivate* priv_a = zathura_render_request_get_instance_private(job_a->request);
|
||||||
request_private_t* priv_b = REQUEST_GET_PRIVATE(job_b->request);
|
ZathuraRenderRequestPrivate* priv_b = zathura_render_request_get_instance_private(job_b->request);
|
||||||
|
|
||||||
return priv_a->last_view_time < priv_b->last_view_time ? -1 :
|
return priv_a->last_view_time < priv_b->last_view_time ? -1 :
|
||||||
(priv_a->last_view_time > priv_b->last_view_time ? 1 : 0);
|
(priv_a->last_view_time > priv_b->last_view_time ? 1 : 0);
|
||||||
|
@ -883,7 +877,7 @@ static bool
|
||||||
page_cache_is_cached(ZathuraRenderer* renderer, unsigned int page_index)
|
page_cache_is_cached(ZathuraRenderer* renderer, unsigned int page_index)
|
||||||
{
|
{
|
||||||
g_return_val_if_fail(renderer != NULL, false);
|
g_return_val_if_fail(renderer != NULL, false);
|
||||||
private_t* priv = GET_PRIVATE(renderer);
|
ZathuraRendererPrivate* priv = zathura_renderer_get_instance_private(renderer);
|
||||||
|
|
||||||
if (priv->page_cache.num_cached_pages != 0) {
|
if (priv->page_cache.num_cached_pages != 0) {
|
||||||
for (size_t i = 0; i < priv->page_cache.size; ++i) {
|
for (size_t i = 0; i < priv->page_cache.size; ++i) {
|
||||||
|
@ -902,10 +896,10 @@ page_cache_is_cached(ZathuraRenderer* renderer, unsigned int page_index)
|
||||||
static int
|
static int
|
||||||
find_request_by_page_index(const void* req, const void* data)
|
find_request_by_page_index(const void* req, const void* data)
|
||||||
{
|
{
|
||||||
const ZathuraRenderRequest* request = req;
|
ZathuraRenderRequest* request = (void*) req;
|
||||||
const unsigned int page_index = *((const int*)data);
|
const unsigned int page_index = *((const int*)data);
|
||||||
|
|
||||||
request_private_t* priv = REQUEST_GET_PRIVATE(request);
|
ZathuraRenderRequestPrivate* priv = zathura_render_request_get_instance_private(request);
|
||||||
if (zathura_page_get_index(priv->page) == page_index) {
|
if (zathura_page_get_index(priv->page) == page_index) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -916,7 +910,7 @@ static ssize_t
|
||||||
page_cache_lru_invalidate(ZathuraRenderer* renderer)
|
page_cache_lru_invalidate(ZathuraRenderer* renderer)
|
||||||
{
|
{
|
||||||
g_return_val_if_fail(renderer != NULL, -1);
|
g_return_val_if_fail(renderer != NULL, -1);
|
||||||
private_t* priv = GET_PRIVATE(renderer);
|
ZathuraRendererPrivate* priv = zathura_renderer_get_instance_private(renderer);
|
||||||
g_return_val_if_fail(priv->page_cache.size != 0, -1);
|
g_return_val_if_fail(priv->page_cache.size != 0, -1);
|
||||||
|
|
||||||
ssize_t lru_index = 0;
|
ssize_t lru_index = 0;
|
||||||
|
@ -926,7 +920,7 @@ page_cache_lru_invalidate(ZathuraRenderer* renderer)
|
||||||
ZathuraRenderRequest* tmp_request = girara_list_find(priv->requests,
|
ZathuraRenderRequest* tmp_request = girara_list_find(priv->requests,
|
||||||
find_request_by_page_index, &priv->page_cache.cache[i]);
|
find_request_by_page_index, &priv->page_cache.cache[i]);
|
||||||
g_return_val_if_fail(tmp_request != NULL, -1);
|
g_return_val_if_fail(tmp_request != NULL, -1);
|
||||||
request_private_t* request_priv = REQUEST_GET_PRIVATE(tmp_request);
|
ZathuraRenderRequestPrivate* request_priv = zathura_render_request_get_instance_private(tmp_request);
|
||||||
|
|
||||||
if (request_priv->last_view_time < lru_view_time) {
|
if (request_priv->last_view_time < lru_view_time) {
|
||||||
lru_view_time = request_priv->last_view_time;
|
lru_view_time = request_priv->last_view_time;
|
||||||
|
@ -935,7 +929,7 @@ page_cache_lru_invalidate(ZathuraRenderer* renderer)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
request_private_t* request_priv = REQUEST_GET_PRIVATE(request);
|
ZathuraRenderRequestPrivate* request_priv = zathura_render_request_get_instance_private(request);
|
||||||
|
|
||||||
/* emit the signal */
|
/* emit the signal */
|
||||||
g_signal_emit(request, request_signals[REQUEST_CACHE_INVALIDATED], 0);
|
g_signal_emit(request, request_signals[REQUEST_CACHE_INVALIDATED], 0);
|
||||||
|
@ -952,7 +946,7 @@ page_cache_is_full(ZathuraRenderer* renderer, bool* result)
|
||||||
{
|
{
|
||||||
g_return_val_if_fail(ZATHURA_IS_RENDERER(renderer) && result != NULL, false);
|
g_return_val_if_fail(ZATHURA_IS_RENDERER(renderer) && result != NULL, false);
|
||||||
|
|
||||||
private_t* priv = GET_PRIVATE(renderer);
|
ZathuraRendererPrivate* priv = zathura_renderer_get_instance_private(renderer);
|
||||||
*result = priv->page_cache.num_cached_pages == priv->page_cache.size;
|
*result = priv->page_cache.num_cached_pages == priv->page_cache.size;
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
@ -963,7 +957,7 @@ page_cache_invalidate_all(ZathuraRenderer* renderer)
|
||||||
{
|
{
|
||||||
g_return_if_fail(ZATHURA_IS_RENDERER(renderer));
|
g_return_if_fail(ZATHURA_IS_RENDERER(renderer));
|
||||||
|
|
||||||
private_t* priv = GET_PRIVATE(renderer);
|
ZathuraRendererPrivate* priv = zathura_renderer_get_instance_private(renderer);
|
||||||
for (size_t i = 0; i < priv->page_cache.size; ++i) {
|
for (size_t i = 0; i < priv->page_cache.size; ++i) {
|
||||||
priv->page_cache.cache[i] = -1;
|
priv->page_cache.cache[i] = -1;
|
||||||
}
|
}
|
||||||
|
@ -979,7 +973,7 @@ zathura_renderer_page_cache_add(ZathuraRenderer* renderer,
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
private_t* priv = GET_PRIVATE(renderer);
|
ZathuraRendererPrivate* priv = zathura_renderer_get_instance_private(renderer);
|
||||||
bool full = false;
|
bool full = false;
|
||||||
if (page_cache_is_full(renderer, &full) == false) {
|
if (page_cache_is_full(renderer, &full) == false) {
|
||||||
return;
|
return;
|
||||||
|
|
Loading…
Reference in a new issue