summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--wallpapers.c12
-rw-r--r--wallpapers.h2
-rw-r--r--window_main.c18
3 files changed, 25 insertions, 7 deletions
diff --git a/wallpapers.c b/wallpapers.c
index 67c9cef..86f7318 100644
--- a/wallpapers.c
+++ b/wallpapers.c
@@ -13,7 +13,7 @@
#include "wallpapers.h"
-void wallpapers_add_dir(const gchar *path, sqlite_uint64 parent, GtkStatusbar *statusbar, gboolean recursive ) {
+gboolean wallpapers_add_dir(const gchar *path, sqlite_uint64 parent, GtkStatusbar *statusbar, gboolean recursive ) {
static guint context_id = 0;
GDir *dir;
const gchar *filename;
@@ -23,6 +23,7 @@ void wallpapers_add_dir(const gchar *path, sqlite_uint64 parent, GtkStatusbar *s
struct stat st;
GdkPixbuf *pixbuf;
GError *error;
+ gboolean added = FALSE;
gdk_threads_enter();
@@ -41,12 +42,13 @@ void wallpapers_add_dir(const gchar *path, sqlite_uint64 parent, GtkStatusbar *s
if(dirid == 0) {
dirid = db_add_directory(path, parent);
if(dirid == 0)
- return;
+ return FALSE;
+ added = TRUE;
}
dir = g_dir_open(path, 0, NULL);
if(!dir)
- return;
+ return added;
while((filename = g_dir_read_name(dir)) != NULL) {
filepath = g_strdup_printf("%s/%s", path, filename);
@@ -74,7 +76,7 @@ void wallpapers_add_dir(const gchar *path, sqlite_uint64 parent, GtkStatusbar *s
continue;
}
if(recursive)
- wallpapers_add_dir(filepath, dirid, statusbar, recursive);
+ added |= wallpapers_add_dir(filepath, dirid, statusbar, recursive);
g_free(filepath);
gdk_threads_enter();
gtk_statusbar_pop(statusbar, context_id);
@@ -117,6 +119,8 @@ void wallpapers_add_dir(const gchar *path, sqlite_uint64 parent, GtkStatusbar *s
gtk_statusbar_push(statusbar, context_id, msg);
g_free(msg);
gdk_threads_leave();
+
+ return added;
}
void wallpapers_remove_missing(struct directory_t *dir, GtkStatusbar *statusbar, gboolean recursive) {
diff --git a/wallpapers.h b/wallpapers.h
index 356360d..d8d832e 100644
--- a/wallpapers.h
+++ b/wallpapers.h
@@ -6,7 +6,7 @@
#include "db.h"
-void wallpapers_add_dir(const gchar*, sqlite_uint64, GtkStatusbar*, gboolean);
+gboolean wallpapers_add_dir(const gchar*, sqlite_uint64, GtkStatusbar*, gboolean);
void wallpapers_remove_missing(struct directory_t*, GtkStatusbar*, gboolean);
GdkPixbuf *resize_pixbuf(GdkPixbuf*, gint, gint, gint*, gint*, gdouble*);
diff --git a/window_main.c b/window_main.c
index 2eb8811..8687376 100644
--- a/window_main.c
+++ b/window_main.c
@@ -487,13 +487,20 @@ void on_main_tagview_cell_toggled(GtkCellRendererToggle *cell_renderer, gchar *p
*/
gpointer add_dir_thread(gpointer data) {
gchar *directory;
+ gboolean r = FALSE;
directory = (gchar*)data;
- wallpapers_add_dir(directory, 0, statusbar, FALSE);
+ r = wallpapers_add_dir(directory, 0, statusbar, FALSE);
g_free(directory);
+ if(r) {
+ gdk_threads_enter();
+ foldtree_create_model(GTK_TREE_VIEW(foldtree));
+ gdk_threads_leave();
+ }
+
wallpaper_thread = NULL;
return NULL;
@@ -504,13 +511,20 @@ gpointer add_dir_thread(gpointer data) {
*/
gpointer add_dir_rec_thread(gpointer data) {
gchar *directory;
+ gboolean r = FALSE;
directory = (gchar*)data;
- wallpapers_add_dir(directory, 0, statusbar, TRUE);
+ r = wallpapers_add_dir(directory, 0, statusbar, TRUE);
g_free(directory);
+ if(r) {
+ gdk_threads_enter();
+ foldtree_create_model(GTK_TREE_VIEW(foldtree));
+ gdk_threads_leave();
+ }
+
wallpaper_thread = NULL;
return NULL;