From d17a46454b3ff886b0a9834d1ee63056e1d007ba Mon Sep 17 00:00:00 2001 From: Jon Bergli Heier Date: Wed, 23 Dec 2009 20:31:11 +0100 Subject: Show file name and image resolution in the status bar. --- db.c | 31 ++++++++++++++++++++++++++++++- 1 file changed, 30 insertions(+), 1 deletion(-) (limited to 'db.c') diff --git a/db.c b/db.c index 931767d..1215430 100644 --- a/db.c +++ b/db.c @@ -298,6 +298,35 @@ sqlite_uint64 db_get_wallpaper(const char *path) { return 0; } +int db_get_wallpaper_data(sqlite_uint64 id, struct wallpaper_t *wall) { + sqlite3_stmt *stmt; + int rc; + sqlite_uint64 dirid; + + rc = sqlite3_prepare_v2(db, "SELECT id, filepath, size, width, height FROM wallpaper WHERE id = ? LIMIT 1", -1, &stmt, NULL); + if(rc != SQLITE_OK) { + return 0; + } + + rc = sqlite3_bind_int64(stmt, 1, id); + if(rc != SQLITE_OK) { + sqlite3_finalize(stmt); + return 0; + } + + rc = sqlite3_step(stmt); + if(rc == SQLITE_ROW) { + wall->filepath = g_strdup(sqlite3_column_text(stmt, 1)); + wall->id = sqlite3_column_int64(stmt, 0); + wall->size = sqlite3_column_int(stmt, 2); + wall->width = sqlite3_column_int(stmt, 3); + wall->height = sqlite3_column_int(stmt, 4); + } + + sqlite3_finalize(stmt); + return 1; +} + int db_get_wallpapers(sqlite_uint64 dirid, GArray **array) { struct wallpaper_t temp, *temp2; sqlite3_stmt *stmt; @@ -318,7 +347,7 @@ int db_get_wallpapers(sqlite_uint64 dirid, GArray **array) { *array = g_array_new(TRUE, FALSE, sizeof(struct wallpaper_t)); while((rc = sqlite3_step(stmt)) == SQLITE_ROW) { temp.filepath = g_strdup(sqlite3_column_text(stmt, 1)); - temp.id = sqlite3_column_int64(stmt, 1); + temp.id = sqlite3_column_int64(stmt, 0); temp.size = sqlite3_column_int(stmt, 2); temp.width = sqlite3_column_int(stmt, 3); temp.height = sqlite3_column_int(stmt, 4); -- cgit v1.2.3