[Thunar-dev] Select all files from select_path

Benedikt Meurer benedikt.meurer at unix-ag.uni-siegen.de
Fri Oct 26 09:36:19 CEST 2007


Fernando Maróstica wrote:
> Hello,
> 
> I want select all files using the standard_view->select_path. But I
> don't want using the standart_view->selec_all.
> 
> 'Cause I want compare all select files with a criteria. The Firt thing
> is get all files from current directory (List of ThunarFiles). So, The
> second thing is compare every item with every selected items (List of
> GtkTreePath) and select only unselect item yet. 
> 
> 
> Bellow follow the code:
> 
> static void
> thunar_standard_view_action_foo (GtkAction          *action,
>                                  ThunarStandardView *standard_view)
> {
>   ThunarFolder *folder;
>   GList        *files;
>   GList        *lp;
> 
>   _thunar_return_if_fail (GTK_IS_ACTION (action));
>   _thunar_return_if_fail (THUNAR_IS_STANDARD_VIEW (standard_view));
> 
>   folder = thunar_list_model_get_folder (standard_view->model);
> 
>   if (G_LIKELY(folder != NULL)) {
>       files = g_list_copy (thunar_folder_get_files (folder));
>       selected_files = THUNAR_STANDARD_VIEW_GET_CLASS (standard_view)->get_selected_items (standard_view);
> 
>       THUNAR_STANDARD_VIEW_GET_CLASS (standard_view)->unselect_all
> (standard_view);
> 
>       for (lp = files; lp != NULL; lp = lp->next) {
>  
>           /* files is a list of ThunarFiles */
>           /* I need convert files in a list of GtkTreePath */
>           /* ??????? */
> 
>           GtkTreePath *path;
>           path = gtk_tree_path_new();
>           
>           /* file doesn't work, 'cause is ThunarFile I need GtkTreePath */
>           THUNAR_STANDARD_VIEW_GET_CLASS (standard_view)->select_path (standard_view, path);
>       }
> 
>       g_list_free (files);
>       g_list_free (lp);
>   }
> }
> 
> Is there any way or sample to convert ThunarFile into GtkTreePath?

get_selected_items() returns a GList of GtkTreePaths. If you want to
query a subset of the files in a ThunarListModel, see the
thunar_list_model_get_paths_for_pattern() method for an example.

> Best Regards.
> Fernando Maróstica.

HTH,
Benedikt



More information about the Thunar-dev mailing list