summaryrefslogtreecommitdiff
path: root/window_main.c
diff options
context:
space:
mode:
Diffstat (limited to 'window_main.c')
-rw-r--r--window_main.c61
1 files changed, 52 insertions, 9 deletions
diff --git a/window_main.c b/window_main.c
index a4e84f1..955c380 100644
--- a/window_main.c
+++ b/window_main.c
@@ -25,7 +25,7 @@ GtkStatusbar *statusbar;
GtkIconView *thumbview;
GtkWidget *window_hpane, *window_vpane, *foldtree, *tagview;
-GThread *add_thread = NULL;
+GThread *wallpaper_thread = NULL;
gchar *cur_wall_msg = NULL;
@@ -437,7 +437,22 @@ gpointer add_dir_thread(gpointer data) {
g_free(directory);
- add_thread = NULL;
+ wallpaper_thread = NULL;
+
+ return NULL;
+}
+
+gpointer remove_missing_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, FALSE);
+
+ wallpaper_thread = NULL;
return NULL;
}
@@ -446,15 +461,15 @@ void on_add_dir_action_activate(GtkAction *action, gpointer user_data) {
GtkWidget *dialog;
GError *error;
- if(add_thread) return;
+ if(wallpaper_thread) return;
dialog = gtk_file_chooser_dialog_new("Choose Directory", NULL, GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER,
GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, GTK_STOCK_OPEN, GTK_RESPONSE_ACCEPT, NULL);
if(gtk_dialog_run(GTK_DIALOG(dialog)) == GTK_RESPONSE_ACCEPT) {
char *directory;
directory = gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(dialog));
- add_thread = g_thread_create(add_dir_thread, directory, FALSE, &error);
- if(!add_thread) {
+ wallpaper_thread = g_thread_create(add_dir_thread, directory, FALSE, &error);
+ if(!wallpaper_thread) {
g_warning("%s", error->message);
g_error_free(error);
}
@@ -469,16 +484,39 @@ void on_foldtree_update_activate(GtkMenuItem *menuitem, gpointer user_data) {
struct directory_t *dir;
GError *error;
- if(add_thread) return;
+ if(wallpaper_thread) return;
+
+ treeselection = gtk_tree_view_get_selection(GTK_TREE_VIEW(foldtree));
+
+ if(gtk_tree_selection_get_selected(treeselection, &model, &iter)) {
+ browse_model_get_dir_record(model, &iter, &dir);
+
+ wallpaper_thread = g_thread_create(add_dir_thread, g_strdup(dir->name), FALSE, &error);
+
+ if(!wallpaper_thread) {
+ g_warning("%s", error->message);
+ g_error_free(error);
+ }
+ }
+}
+
+void on_foldtree_remove_missing_activate(GtkMenuItem *menuitem, gpointer user_data) {
+ GtkTreeSelection *treeselection;
+ GtkTreeModel *model;
+ GtkTreeIter iter;
+ struct directory_t *dir;
+ GError *error;
+
+ if(wallpaper_thread) return;
treeselection = gtk_tree_view_get_selection(GTK_TREE_VIEW(foldtree));
if(gtk_tree_selection_get_selected(treeselection, &model, &iter)) {
browse_model_get_dir_record(model, &iter, &dir);
- add_thread = g_thread_create(add_dir_thread, g_strdup(dir->name), FALSE, &error);
+ wallpaper_thread = g_thread_create(remove_missing_thread, dir, FALSE, &error);
- if(!add_thread) {
+ if(!wallpaper_thread) {
g_warning("%s", error->message);
g_error_free(error);
}
@@ -486,19 +524,24 @@ void on_foldtree_update_activate(GtkMenuItem *menuitem, gpointer user_data) {
}
inline static void foldtree_popup_add_items(GtkWidget *menu) {
- GtkWidget *update;
+ GtkWidget *update, *remove_missing;
GtkTreeSelection *selection;
update = gtk_menu_item_new_with_label("Update");
+ remove_missing = gtk_menu_item_new_with_label("Remove missing files");
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(remove_missing, (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), remove_missing);
g_signal_connect(G_OBJECT(update), "activate", G_CALLBACK(on_foldtree_update_activate), NULL);
+ g_signal_connect(G_OBJECT(remove_missing), "activate", G_CALLBACK(on_foldtree_remove_missing_activate), NULL);
gtk_widget_show(update);
+ gtk_widget_show(remove_missing);
}
static void do_foldtree_popup(GtkWidget *widget, GdkEventButton *event) {