summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJon Bergli Heier <snakebite@jvnv.net>2010-11-05 01:04:22 +0100
committerJon Bergli Heier <snakebite@jvnv.net>2010-11-05 01:04:22 +0100
commita35488f4b8f5c88b5f81f134596929a28dd74b42 (patch)
tree4ae93979fae8e1b850387b2533ef22a6d052c1cb
parentc7536ae1e25670a5c3ebeb824fa2e9ab6d83e2a8 (diff)
List untagged wallpapers from the new 'Other' page.HEADmaster
-rw-r--r--db.c41
-rw-r--r--db.h1
-rw-r--r--walls.ui48
-rw-r--r--window_main.c44
4 files changed, 134 insertions, 0 deletions
diff --git a/db.c b/db.c
index 2e3c5bf..c6e6e93 100644
--- a/db.c
+++ b/db.c
@@ -521,6 +521,47 @@ int db_get_walls_by_tags(GArray *tags, GArray **array) {
return 1;
}
+int db_get_walls_untagged(GArray **array) {
+ sqlite3_stmt *stmt;
+ int rc;
+ struct wallpaper_t temp, *temp2;
+
+ rc = sqlite3_prepare_v2(db, "SELECT w.id, w.filepath, w.date, w.size, w.width, w.height "
+ "FROM wallpaper w WHERE NOT (SELECT COUNT(*) FROM walltags t WHERE t.wallid = w.id)",
+ -1, &stmt, NULL);
+ if(rc != SQLITE_OK) {
+ return 0;
+ }
+
+ *array = g_array_new(FALSE, FALSE, sizeof(struct wallpaper_t));
+ while((rc = sqlite3_step(stmt)) == SQLITE_ROW) {
+ temp.filepath = g_strdup((const gchar*)sqlite3_column_text(stmt, 1));
+ temp.id = sqlite3_column_int64(stmt, 0);
+ if(sizeof(time_t) == 8) {
+ temp.date = sqlite3_column_int64(stmt, 2);
+ } else {
+ temp.date = sqlite3_column_int(stmt, 2);
+ }
+ temp.size = sqlite3_column_int(stmt, 3);
+ temp.width = sqlite3_column_int(stmt, 4);
+ temp.height = sqlite3_column_int(stmt, 5);
+ g_array_append_val(*array, temp);
+ }
+
+ sqlite3_finalize(stmt);
+
+ if(rc != SQLITE_DONE) {
+ for(int i = 0; i < (*array)->len; i++) {
+ temp2 = &g_array_index(*array, struct wallpaper_t, i);
+ g_free(temp2->filepath);
+ }
+ g_array_free(*array, TRUE);
+ return 0;
+ }
+
+ return 1;
+}
+
sqlite_uint64 db_add_tag(const char *name, sqlite_uint64 parent) {
sqlite3_stmt *stmt;
int rc;
diff --git a/db.h b/db.h
index 97a830c..433cfa7 100644
--- a/db.h
+++ b/db.h
@@ -43,6 +43,7 @@ int db_get_wallpaper_data(sqlite_uint64, struct wallpaper_t*);
int db_get_wall_tags(sqlite_uint64, GArray**);
int db_get_wallpapers(sqlite_uint64, GArray**);
int db_get_walls_by_tags(GArray*, GArray**);
+int db_get_walls_untagged(GArray**);
sqlite_uint64 db_add_tag(const char*, sqlite_uint64);
int db_get_tags_all(GArray**);
int db_get_top_level_tags(GArray**);
diff --git a/walls.ui b/walls.ui
index f4aa3c9..083b59f 100644
--- a/walls.ui
+++ b/walls.ui
@@ -241,6 +241,54 @@
<property name="tab_fill">False</property>
</packing>
</child>
+ <child>
+ <object class="GtkVBox" id="vbox2">
+ <property name="visible">True</property>
+ <property name="orientation">vertical</property>
+ <child>
+ <object class="GtkRadioButton" id="other_none_radiobtn">
+ <property name="label" translatable="yes">None</property>
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">False</property>
+ <property name="draw_indicator">True</property>
+ <signal name="toggled" handler="on_other_none_radiobtn_toggled"/>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkRadioButton" id="other_untagged_radiobtn">
+ <property name="label" translatable="yes">Untagged</property>
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">False</property>
+ <property name="draw_indicator">True</property>
+ <property name="group">other_none_radiobtn</property>
+ <signal name="toggled" handler="on_other_untagged_radiobtn_toggled"/>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ </object>
+ <packing>
+ <property name="position">2</property>
+ </packing>
+ </child>
+ <child type="tab">
+ <object class="GtkLabel" id="label3">
+ <property name="visible">True</property>
+ <property name="label" translatable="yes">Other</property>
+ </object>
+ <packing>
+ <property name="position">2</property>
+ <property name="tab_fill">False</property>
+ </packing>
+ </child>
</object>
<packing>
<property name="resize">False</property>
diff --git a/window_main.c b/window_main.c
index 8d756d7..680506b 100644
--- a/window_main.c
+++ b/window_main.c
@@ -921,6 +921,50 @@ gboolean on_thumbview_button_press_event(GtkWidget *widget, GdkEventButton *even
return FALSE;
}
+void on_other_none_radiobtn_toggled(GtkToggleButton *togglebutton, gpointer user_data) {
+ GtkListStore *liststore;
+ GtkTreeModel *old_model;
+
+ if(gtk_toggle_button_get_active(togglebutton) == FALSE) {
+ return;
+ }
+
+ old_model = gtk_icon_view_get_model(thumbview);
+
+ liststore = gtk_list_store_new(4, GDK_TYPE_PIXBUF, G_TYPE_STRING, G_TYPE_UINT64, G_TYPE_STRING);
+ gtk_icon_view_set_model(thumbview, GTK_TREE_MODEL(liststore));
+
+ if(old_model)
+ gtk_list_store_clear(GTK_LIST_STORE(old_model));
+}
+
+void on_other_untagged_radiobtn_toggled(GtkToggleButton *togglebutton, gpointer user_data) {
+ GtkListStore *liststore;
+ GtkTreeModel *old_model;
+ GArray *wallarray;
+
+ if(gtk_toggle_button_get_active(togglebutton) == FALSE) {
+ return;
+ }
+
+ if(!db_get_walls_untagged(&wallarray)) {
+ g_warning("Could not fetch untagged walls\n");
+ return;
+ }
+
+ liststore = gtk_list_store_new(4, GDK_TYPE_PIXBUF, G_TYPE_STRING, G_TYPE_UINT64, G_TYPE_STRING);
+ fill_wall_list(liststore, wallarray);
+
+ old_model = gtk_icon_view_get_model(thumbview);
+
+ gtk_icon_view_set_model(thumbview, GTK_TREE_MODEL(liststore));
+
+ start_thumb_thread(liststore);
+
+ if(old_model)
+ gtk_list_store_clear(GTK_LIST_STORE(old_model));
+}
+
gboolean on_left_pages_switch_page(GtkNotebook *notebook, GtkNotebookTab page, guint page_num, gpointer user_data) {
switch(page_num) {
case 0: