mirror of
https://git.pwmt.org/pwmt/zathura.git
synced 2024-12-29 10:55:59 +01:00
Update style
This commit is contained in:
parent
b244e016d0
commit
7271166b20
4 changed files with 62 additions and 43 deletions
|
@ -35,15 +35,16 @@ G_DEFINE_TYPE_WITH_CODE(ZathuraPlainDatabase, zathura_plaindatabase, G_TYPE_OBJE
|
||||||
static void plain_finalize(GObject* object);
|
static void plain_finalize(GObject* object);
|
||||||
static bool plain_add_bookmark(zathura_database_t* db, const char* file,
|
static bool plain_add_bookmark(zathura_database_t* db, const char* file,
|
||||||
zathura_bookmark_t* bookmark);
|
zathura_bookmark_t* bookmark);
|
||||||
static bool plain_remove_bookmark(zathura_database_t* db, const char* file, const
|
static bool plain_remove_bookmark(zathura_database_t* db, const char* file,
|
||||||
char* id);
|
const char* id);
|
||||||
static girara_list_t* plain_load_bookmarks(zathura_database_t* db, const char*
|
static girara_list_t* plain_load_bookmarks(zathura_database_t* db,
|
||||||
file);
|
const char* file);
|
||||||
static bool plain_set_fileinfo(zathura_database_t* db, const char* file, unsigned
|
static bool plain_set_fileinfo(zathura_database_t* db, const char* file,
|
||||||
int page, int offset, double scale, int rotation);
|
unsigned int page, int offset, double scale, int rotation);
|
||||||
static bool plain_get_fileinfo(zathura_database_t* db, const char* file, unsigned
|
static bool plain_get_fileinfo(zathura_database_t* db, const char* file,
|
||||||
int* page, int* offset, double* scale, int* rotation);
|
unsigned int* page, int* offset, double* scale, int* rotation);
|
||||||
static void plain_set_property(GObject* object, guint prop_id, const GValue* value, GParamSpec* pspec);
|
static void plain_set_property(GObject* object, guint prop_id,
|
||||||
|
const GValue* value, GParamSpec* pspec);
|
||||||
|
|
||||||
/* forward declaration */
|
/* forward declaration */
|
||||||
static bool zathura_db_check_file(const char* path);
|
static bool zathura_db_check_file(const char* path);
|
||||||
|
@ -102,6 +103,7 @@ static void
|
||||||
zathura_plaindatabase_init(ZathuraPlainDatabase* db)
|
zathura_plaindatabase_init(ZathuraPlainDatabase* db)
|
||||||
{
|
{
|
||||||
zathura_plaindatabase_private_t* priv = ZATHURA_PLAINDATABASE_GET_PRIVATE(db);
|
zathura_plaindatabase_private_t* priv = ZATHURA_PLAINDATABASE_GET_PRIVATE(db);
|
||||||
|
|
||||||
priv->bookmark_path = NULL;
|
priv->bookmark_path = NULL;
|
||||||
priv->bookmark_monitor = NULL;
|
priv->bookmark_monitor = NULL;
|
||||||
priv->bookmarks = NULL;
|
priv->bookmarks = NULL;
|
||||||
|
@ -121,6 +123,7 @@ zathura_plaindatabase_new(const char* path)
|
||||||
g_object_unref(db);
|
g_object_unref(db);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
return db;
|
return db;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -141,6 +144,7 @@ plain_db_init(ZathuraPlainDatabase* db, const char* dir)
|
||||||
} else {
|
} else {
|
||||||
goto error_free;
|
goto error_free;
|
||||||
}
|
}
|
||||||
|
|
||||||
g_object_unref(bookmark_file);
|
g_object_unref(bookmark_file);
|
||||||
|
|
||||||
g_signal_connect(
|
g_signal_connect(
|
||||||
|
@ -167,6 +171,7 @@ plain_db_init(ZathuraPlainDatabase* db, const char* dir)
|
||||||
} else {
|
} else {
|
||||||
goto error_free;
|
goto error_free;
|
||||||
}
|
}
|
||||||
|
|
||||||
g_object_unref(history_file);
|
g_object_unref(history_file);
|
||||||
|
|
||||||
g_signal_connect(
|
g_signal_connect(
|
||||||
|
@ -180,6 +185,7 @@ plain_db_init(ZathuraPlainDatabase* db, const char* dir)
|
||||||
if (priv->history == NULL) {
|
if (priv->history == NULL) {
|
||||||
goto error_free;
|
goto error_free;
|
||||||
}
|
}
|
||||||
|
|
||||||
return;
|
return;
|
||||||
|
|
||||||
error_free:
|
error_free:
|
||||||
|
@ -232,6 +238,7 @@ plain_finalize(GObject* object)
|
||||||
{
|
{
|
||||||
ZathuraPlainDatabase* db = ZATHURA_PLAINDATABASE(object);
|
ZathuraPlainDatabase* db = ZATHURA_PLAINDATABASE(object);
|
||||||
zathura_plaindatabase_private_t* priv = ZATHURA_PLAINDATABASE_GET_PRIVATE(db);
|
zathura_plaindatabase_private_t* priv = ZATHURA_PLAINDATABASE_GET_PRIVATE(db);
|
||||||
|
|
||||||
/* bookmarks */
|
/* bookmarks */
|
||||||
g_free(priv->bookmark_path);
|
g_free(priv->bookmark_path);
|
||||||
|
|
||||||
|
@ -306,8 +313,9 @@ plain_load_bookmarks(zathura_database_t* db, const char* file)
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
girara_list_t* result = girara_sorted_list_new2((girara_compare_function_t) zathura_bookmarks_compare,
|
girara_list_t* result = girara_sorted_list_new2((girara_compare_function_t)
|
||||||
(girara_free_function_t) zathura_bookmark_free);
|
zathura_bookmarks_compare, (girara_free_function_t)
|
||||||
|
zathura_bookmark_free);
|
||||||
|
|
||||||
gsize length;
|
gsize length;
|
||||||
char** keys = g_key_file_get_keys(priv->bookmarks, file, &length, NULL);
|
char** keys = g_key_file_get_keys(priv->bookmarks, file, &length, NULL);
|
||||||
|
@ -506,11 +514,13 @@ cb_zathura_db_watch_file(GFileMonitor* UNUSED(monitor), GFile* file, GFile* UNUS
|
||||||
if (priv->bookmarks != NULL) {
|
if (priv->bookmarks != NULL) {
|
||||||
g_key_file_free(priv->bookmarks);
|
g_key_file_free(priv->bookmarks);
|
||||||
}
|
}
|
||||||
|
|
||||||
priv->bookmarks = zathura_db_read_key_file_from_file(priv->bookmark_path);
|
priv->bookmarks = zathura_db_read_key_file_from_file(priv->bookmark_path);
|
||||||
} else if (priv->history_path && strcmp(priv->history_path, path) == 0) {
|
} else if (priv->history_path && strcmp(priv->history_path, path) == 0) {
|
||||||
if (priv->history != NULL) {
|
if (priv->history != NULL) {
|
||||||
g_key_file_free(priv->history);
|
g_key_file_free(priv->history);
|
||||||
}
|
}
|
||||||
|
|
||||||
priv->history = zathura_db_read_key_file_from_file(priv->history_path);
|
priv->history = zathura_db_read_key_file_from_file(priv->history_path);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,15 +15,16 @@ G_DEFINE_TYPE_WITH_CODE(ZathuraSQLDatabase, zathura_sqldatabase, G_TYPE_OBJECT,
|
||||||
static void sqlite_finalize(GObject* object);
|
static void sqlite_finalize(GObject* object);
|
||||||
static bool sqlite_add_bookmark(zathura_database_t* db, const char* file,
|
static bool sqlite_add_bookmark(zathura_database_t* db, const char* file,
|
||||||
zathura_bookmark_t* bookmark);
|
zathura_bookmark_t* bookmark);
|
||||||
static bool sqlite_remove_bookmark(zathura_database_t* db, const char* file, const
|
static bool sqlite_remove_bookmark(zathura_database_t* db, const char* file,
|
||||||
char* id);
|
const char* id);
|
||||||
static girara_list_t* sqlite_load_bookmarks(zathura_database_t* db, const char*
|
static girara_list_t* sqlite_load_bookmarks(zathura_database_t* db,
|
||||||
file);
|
const char* file);
|
||||||
static bool sqlite_set_fileinfo(zathura_database_t* db, const char* file, unsigned
|
static bool sqlite_set_fileinfo(zathura_database_t* db, const char* file,
|
||||||
int page, int offset, double scale, int rotation);
|
unsigned int page, int offset, double scale, int rotation);
|
||||||
static bool sqlite_get_fileinfo(zathura_database_t* db, const char* file, unsigned
|
static bool sqlite_get_fileinfo(zathura_database_t* db, const char* file,
|
||||||
int* page, int* offset, double* scale, int* rotation);
|
unsigned int* page, int* offset, double* scale, int* rotation);
|
||||||
static void sqlite_set_property(GObject* object, guint prop_id, const GValue* value, GParamSpec* pspec);
|
static void sqlite_set_property(GObject* object, guint prop_id,
|
||||||
|
const GValue* value, GParamSpec* pspec);
|
||||||
|
|
||||||
typedef struct zathura_sqldatabase_private_s {
|
typedef struct zathura_sqldatabase_private_s {
|
||||||
sqlite3* session;
|
sqlite3* session;
|
||||||
|
@ -82,6 +83,7 @@ zathura_sqldatabase_new(const char* path)
|
||||||
g_object_unref(db);
|
g_object_unref(db);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
return db;
|
return db;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -202,7 +204,8 @@ sqlite_add_bookmark(zathura_database_t* db, const char* file,
|
||||||
|
|
||||||
int res = sqlite3_step(stmt);
|
int res = sqlite3_step(stmt);
|
||||||
sqlite3_finalize(stmt);
|
sqlite3_finalize(stmt);
|
||||||
return res == SQLITE_DONE;
|
|
||||||
|
return (res == SQLITE_DONE) ? true : false;
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool
|
static bool
|
||||||
|
@ -228,7 +231,8 @@ sqlite_remove_bookmark(zathura_database_t* db, const char* file, const char*
|
||||||
|
|
||||||
int res = sqlite3_step(stmt);
|
int res = sqlite3_step(stmt);
|
||||||
sqlite3_finalize(stmt);
|
sqlite3_finalize(stmt);
|
||||||
return res == SQLITE_DONE;
|
|
||||||
|
return (res == SQLITE_DONE) ? true : false;
|
||||||
}
|
}
|
||||||
|
|
||||||
static girara_list_t*
|
static girara_list_t*
|
||||||
|
@ -252,6 +256,7 @@ sqlite_load_bookmarks(zathura_database_t* db, const char* file)
|
||||||
|
|
||||||
girara_list_t* result = girara_sorted_list_new2((girara_compare_function_t) zathura_bookmarks_compare,
|
girara_list_t* result = girara_sorted_list_new2((girara_compare_function_t) zathura_bookmarks_compare,
|
||||||
(girara_free_function_t) zathura_bookmark_free);
|
(girara_free_function_t) zathura_bookmark_free);
|
||||||
|
|
||||||
while (sqlite3_step(stmt) == SQLITE_ROW) {
|
while (sqlite3_step(stmt) == SQLITE_ROW) {
|
||||||
zathura_bookmark_t* bookmark = g_malloc0(sizeof(zathura_bookmark_t));
|
zathura_bookmark_t* bookmark = g_malloc0(sizeof(zathura_bookmark_t));
|
||||||
|
|
||||||
|
@ -260,7 +265,9 @@ sqlite_load_bookmarks(zathura_database_t* db, const char* file)
|
||||||
|
|
||||||
girara_list_append(result, bookmark);
|
girara_list_append(result, bookmark);
|
||||||
}
|
}
|
||||||
|
|
||||||
sqlite3_finalize(stmt);
|
sqlite3_finalize(stmt);
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -290,7 +297,8 @@ sqlite_set_fileinfo(zathura_database_t* db, const char* file, unsigned int
|
||||||
|
|
||||||
int res = sqlite3_step(stmt);
|
int res = sqlite3_step(stmt);
|
||||||
sqlite3_finalize(stmt);
|
sqlite3_finalize(stmt);
|
||||||
return res == SQLITE_DONE;
|
|
||||||
|
return (res == SQLITE_DONE) ? true : false;
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool
|
static bool
|
||||||
|
@ -324,5 +332,6 @@ sqlite_get_fileinfo(zathura_database_t* db, const char* file, unsigned int*
|
||||||
*scale = sqlite3_column_double(stmt, 2);
|
*scale = sqlite3_column_double(stmt, 2);
|
||||||
*rotation = sqlite3_column_int(stmt, 3);
|
*rotation = sqlite3_column_int(stmt, 3);
|
||||||
sqlite3_finalize(stmt);
|
sqlite3_finalize(stmt);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue