chiark / gitweb /
choose_populate() always raise choose-more-tracks rather than only
[disorder] / disobedience / choose.c
index c30d7128d47b368d817542acee95d0021a868b50..44096d5eb28d609560e6467192680255ba9b1771 100644 (file)
@@ -52,9 +52,6 @@ GtkTreeSelection *choose_selection;
 /** @brief Count of file listing operations in flight */
 static int choose_list_in_flight;
 
-/** @brief Count of files inserted in current batch of listing operations */
-static int choose_inserted;
-
 static char *choose_get_string(GtkTreeIter *iter, int column) {
   gchar *gs;
   gtk_tree_model_get(GTK_TREE_MODEL(choose_store), iter,
@@ -171,9 +168,10 @@ static void choose_set_state(const char attribute((unused)) *event,
 static void choose_populate(GtkTreeRowReference *parent_ref,
                             int nvec, char **vec,
                             int isfile) {
-  if(!nvec)
-    return;
   const char *type = isfile ? "track" : "dir";
+  //fprintf(stderr, "%d new children of type %s\n", nvec, type);
+  if(!nvec)
+    goto skip;
   /* Compute parent_* */
   GtkTreeIter pit[1], *parent_it;
   GtkTreePath *parent_path;
@@ -309,18 +307,17 @@ static void choose_populate(GtkTreeRowReference *parent_ref,
     gtk_tree_row_reference_free(parent_ref);
     gtk_tree_path_free(parent_path);
   }
+skip:
   /* We only notify others that we've inserted tracks when there are no more
    * insertions pending, so that they don't have to keep track of how many
    * requests they've made.  */
-  choose_inserted += inserted;
   if(--choose_list_in_flight == 0) {
     /* Notify interested parties that we inserted some tracks, AFTER making
      * sure that the row is properly expanded */
-    if(choose_inserted) {
-      event_raise("choose-inserted-tracks", parent_it);
-      choose_inserted = 0;
-    }
+    //fprintf(stderr, "raising choose-more-tracks\n");
+    event_raise("choose-more-tracks", 0);
   }
+  //fprintf(stderr, "choose_list_in_flight -> %d-\n", choose_list_in_flight);
 }
 
 static void choose_dirs_completed(void *v,
@@ -392,6 +389,7 @@ static void choose_row_expanded(GtkTreeView attribute((unused)) *treeview,
                                                    path));
   /* The row references are destroyed in the _completed handlers. */
   choose_list_in_flight += 2;
+  //fprintf(stderr, "choose_list_in_flight -> %d+\n", choose_list_in_flight);
 }
 
 /** @brief Create the choose tab */
@@ -476,6 +474,8 @@ GtkWidget *choose_widget(void) {
   /* Fill the root */
   disorder_eclient_files(client, choose_files_completed, "", NULL, NULL); 
   disorder_eclient_dirs(client, choose_dirs_completed, "", NULL, NULL); 
+  choose_list_in_flight += 2;
+  //fprintf(stderr, "choose_list_in_flight -> %d+\n", choose_list_in_flight);
 
   /* Make the widget scrollable */
   GtkWidget *scrolled = scroll_widget(choose_view);