summaryrefslogtreecommitdiff
path: root/window_main.c
diff options
context:
space:
mode:
Diffstat (limited to 'window_main.c')
-rw-r--r--window_main.c35
1 files changed, 19 insertions, 16 deletions
diff --git a/window_main.c b/window_main.c
index 5183c57..7a95761 100644
--- a/window_main.c
+++ b/window_main.c
@@ -26,8 +26,7 @@ GtkStatusbar *statusbar;
GtkIconView *thumbview;
GtkWidget *window_hpane, *window_vpane, *foldtree, *tagview;
-GThread *add_thread = NULL,
- *thumb_thread = NULL;
+GThread *add_thread = NULL;
gchar *cur_wall_msg = NULL;
@@ -269,13 +268,28 @@ static void fill_wall_list(GtkListStore *liststore, GArray *array) {
g_array_free(array, TRUE);
}
+static void start_thumb_thread(GtkListStore *liststore) {
+ GError *error = NULL;
+
+ if(thumb_thread) {
+ thumb_thread_exit = TRUE;
+ g_thread_join(thumb_thread);
+ }
+
+ thumb_thread = g_thread_create(add_thumbs_thread, liststore, TRUE, &error);
+
+ if(!thumb_thread) {
+ g_warning("Failed to start the thumbnail thread: %s", error->message);
+ g_error_free(error);
+ }
+}
+
static void display_from_foldtree(GtkTreeSelection *treeselection) {
GtkTreeModel *model;
GtkTreeIter iter;
struct directory_t *dir;
GArray *array;
GtkListStore *liststore;
- GError *error = NULL;
if(treeselection == NULL)
treeselection = gtk_tree_view_get_selection(GTK_TREE_VIEW(foldtree));
@@ -290,12 +304,7 @@ static void display_from_foldtree(GtkTreeSelection *treeselection) {
fill_wall_list(liststore, array);
gtk_icon_view_set_model(thumbview, GTK_TREE_MODEL(liststore));
- thumb_thread = g_thread_create(add_thumbs_thread, liststore, FALSE, &error);
-
- if(!thumb_thread) {
- g_warning("%s", error->message);
- g_error_free(error);
- }
+ start_thumb_thread(liststore);
}
}
@@ -339,7 +348,6 @@ void display_from_tagview() {
gboolean active;
GArray *tagarray, *wallarray;
guint64 id;
- GError *error = NULL;
model = gtk_tree_view_get_model(GTK_TREE_VIEW(tagview));
@@ -373,12 +381,7 @@ void display_from_tagview() {
fill_wall_list(liststore, wallarray);
gtk_icon_view_set_model(thumbview, GTK_TREE_MODEL(liststore));
- thumb_thread = g_thread_create(add_thumbs_thread, liststore, FALSE, &error);
-
- if(!thumb_thread) {
- g_warning("%s\n", error->message);
- g_error_free(error);
- }
+ start_thumb_thread(liststore);
}
void on_main_tagview_cell_toggled(GtkCellRendererToggle *cell_renderer, gchar *path_string, gpointer user_data) {