diff options
-rw-r--r-- | db.c | 41 | ||||
-rw-r--r-- | db.h | 1 | ||||
-rw-r--r-- | walls.ui | 48 | ||||
-rw-r--r-- | window_main.c | 44 |
4 files changed, 134 insertions, 0 deletions
@@ -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; @@ -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**); @@ -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: |