summaryrefslogtreecommitdiff
path: root/db.c
diff options
context:
space:
mode:
authorJon Bergli Heier <snakebite@jvnv.net>2009-12-23 20:31:11 +0100
committerJon Bergli Heier <snakebite@jvnv.net>2009-12-23 20:31:11 +0100
commitd17a46454b3ff886b0a9834d1ee63056e1d007ba (patch)
tree522d15cd35e6ced82f64c87af1423afe97a3c659 /db.c
parentd7c8c0381462d6f565d0c9eedfd02f61696a2fad (diff)
Show file name and image resolution in the status bar.
Diffstat (limited to 'db.c')
-rw-r--r--db.c31
1 files changed, 30 insertions, 1 deletions
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);