summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--wallpapers.c9
-rw-r--r--window_main.c29
2 files changed, 35 insertions, 3 deletions
diff --git a/wallpapers.c b/wallpapers.c
index 86f7318..a4bfb60 100644
--- a/wallpapers.c
+++ b/wallpapers.c
@@ -168,6 +168,15 @@ void wallpapers_remove_missing(struct directory_t *dir, GtkStatusbar *statusbar,
}
g_array_free(array, TRUE);
+ if(recursive && db_get_directories(dir->dirid, &array)) {
+ for(int i = 0; i < array->len; i++) {
+ struct directory_t *subdir;
+ subdir = &g_array_index(array, struct directory_t, i);
+ wallpapers_remove_missing(subdir, statusbar, recursive);
+ }
+ g_array_free(array, TRUE);
+ }
+
gdk_threads_enter();
gtk_statusbar_pop(statusbar, context_id);
gdk_threads_leave();
diff --git a/window_main.c b/window_main.c
index 8687376..fe2c68d 100644
--- a/window_main.c
+++ b/window_main.c
@@ -548,6 +548,24 @@ gpointer remove_missing_thread(gpointer data) {
return NULL;
}
+/**
+ * Thread function for recursive removal of missing files.
+ */
+gpointer remove_missing_rec_thread(gpointer data) {
+ struct directory_t *dir, temp;
+
+ dir = data;
+
+ temp.dirid = dir->dirid;
+ temp.name = g_strdup(dir->name);
+
+ wallpapers_remove_missing(&temp, statusbar, TRUE);
+
+ wallpaper_thread = NULL;
+
+ return NULL;
+}
+
void on_add_dir_action_activate(GtkAction *action, gpointer user_data) {
GtkWidget *dialog;
GError *error;
@@ -606,7 +624,7 @@ void on_foldtree_remove_missing_activate(GtkMenuItem *menuitem, gpointer user_da
if(gtk_tree_selection_get_selected(treeselection, &model, &iter)) {
browse_model_get_dir_record(model, &iter, &dir);
- wallpaper_thread = g_thread_create(remove_missing_thread, dir, FALSE, &error);
+ wallpaper_thread = g_thread_create(user_data == NULL ? remove_missing_thread : remove_missing_rec_thread, dir, FALSE, &error);
if(!wallpaper_thread) {
g_warning("%s", error->message);
@@ -616,29 +634,34 @@ void on_foldtree_remove_missing_activate(GtkMenuItem *menuitem, gpointer user_da
}
inline static void foldtree_popup_add_items(GtkWidget *menu) {
- GtkWidget *update, *update_rec, *remove_missing;
+ GtkWidget *update, *update_rec, *remove_missing, *remove_missing_rec;
GtkTreeSelection *selection;
update = gtk_menu_item_new_with_label("Update");
update_rec = gtk_menu_item_new_with_label("Update (recursive)");
remove_missing = gtk_menu_item_new_with_label("Remove missing files");
+ remove_missing_rec = gtk_menu_item_new_with_label("Remove missing files (recursive)");
selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(foldtree));
gtk_widget_set_sensitive(update, (gtk_tree_selection_count_selected_rows(selection) == 1 ? TRUE : FALSE));
gtk_widget_set_sensitive(update_rec, (gtk_tree_selection_count_selected_rows(selection) == 1 ? TRUE : FALSE));
gtk_widget_set_sensitive(remove_missing, (gtk_tree_selection_count_selected_rows(selection) == 1 ? TRUE : FALSE));
+ gtk_widget_set_sensitive(remove_missing_rec, (gtk_tree_selection_count_selected_rows(selection) == 1 ? TRUE : FALSE));
gtk_menu_shell_append(GTK_MENU_SHELL(menu), update);
gtk_menu_shell_append(GTK_MENU_SHELL(menu), update_rec);
gtk_menu_shell_append(GTK_MENU_SHELL(menu), remove_missing);
+ gtk_menu_shell_append(GTK_MENU_SHELL(menu), remove_missing_rec);
g_signal_connect(G_OBJECT(update), "activate", G_CALLBACK(on_foldtree_update_activate), (gpointer)FALSE);
g_signal_connect(G_OBJECT(update_rec), "activate", G_CALLBACK(on_foldtree_update_activate), (gpointer)TRUE);
- g_signal_connect(G_OBJECT(remove_missing), "activate", G_CALLBACK(on_foldtree_remove_missing_activate), NULL);
+ g_signal_connect(G_OBJECT(remove_missing), "activate", G_CALLBACK(on_foldtree_remove_missing_activate), (gpointer)FALSE);
+ g_signal_connect(G_OBJECT(remove_missing_rec), "activate", G_CALLBACK(on_foldtree_remove_missing_activate), (gpointer)TRUE);
gtk_widget_show(update);
gtk_widget_show(update_rec);
gtk_widget_show(remove_missing);
+ gtk_widget_show(remove_missing_rec);
}
static void do_foldtree_popup(GtkWidget *widget, GdkEventButton *event) {