listbox.c: simplify logic to get selected files
the function used gtk_tree_selection_get_selected_rows()
which is more suitable for a GtkTreeView with GtkTreeStore model I guess..
@@ -594,35 +594,27 @@ GList *
listbox_get_selected_files (gftp_window_data *wdata)
{
GtkTreeView * tree = GTK_TREE_VIEW (wdata->listbox);
-
GtkTreeSelection * tsel = gtk_tree_view_get_selection (tree);
- GList *selrows = gtk_tree_selection_get_selected_rows (tsel, NULL);
- GList *i = selrows;
-
- GtkTreeModel *model = GTK_TREE_MODEL (gtk_tree_view_get_model (tree));
+ GtkTreeModel * model = gtk_tree_view_get_model (tree);
GtkTreeIter iter;
- GtkTreePath *tpath = NULL;
-
- gpointer gftpFile = NULL;
+ gboolean valid;
+ gftp_file * gftpFile = NULL;
GList * out_filelist = NULL;
- while (i)
- {
- tpath = (GtkTreePath *) i->data;
-
- gtk_tree_model_get_iter (model, &iter, tpath);
- gtk_tree_model_get (model, &iter,
- LISTBOX_COL_GFTPFILE, &gftpFile, -1);
- //fprintf(stderr, "list: %s\n", filename);
+ valid = gtk_tree_model_get_iter_first (model, &iter);
+ while (valid)
+ {
+ if (gtk_tree_selection_iter_is_selected (tsel, &iter))
+ {
+ gtk_tree_model_get (model, &iter, LISTBOX_COL_GFTPFILE, &gftpFile, -1);
+ ///fprintf(stderr, "list: %s\n", gftpFile->file);
if (gftpFile) {
out_filelist = g_list_append (out_filelist, gftpFile);
}
-
- i = i->next;
}
-
- g_list_free_full (selrows, (GDestroyNotify) gtk_tree_path_free);
+ valid = gtk_tree_model_iter_next (model, &iter);
+ }
return (out_filelist);
}
