/** * fm_trash_or_delete_files * @parent: a window to place progress dialog over it * @files: list of files to delete * * Removes files into trash can if that operation is supported. * Otherwise erases them. If that operation takes some time then progress * dialog will be opened. * * Before 0.1.15 this call had different arguments. * * Since: 0.1.0 */ void fm_trash_or_delete_files(GtkWindow* parent, FmPathList* files) { if( !fm_path_list_is_empty(files) ) { gboolean all_in_trash = TRUE; if(fm_config->use_trash) { GList* l = fm_path_list_peek_head_link(files); for(;l;l=l->next) { FmPath* path = FM_PATH(l->data); if(!fm_path_is_trash(path)) all_in_trash = FALSE; } } /* files already in trash:/// should only be deleted and cannot be trashed again. */ if(fm_config->use_trash && !all_in_trash) fm_trash_files(parent, files); else fm_delete_files(parent, files); } }
gboolean fm_dnd_dest_files_dropped(FmDndDest* dd, GdkDragAction action, int info_type, FmList* files) { FmPath* dest; GtkWidget* parent; dest = fm_dnd_dest_get_dest_path(dd); if(!dest) return FALSE; g_debug("%d files-dropped!, info_type: %d", fm_list_get_length(files), info_type); if(fm_list_is_file_info_list(files)) files = fm_path_list_new_from_file_info_list(files); else fm_list_ref(files); parent = gtk_widget_get_toplevel(dd->widget); switch(action) { case GDK_ACTION_MOVE: if(fm_path_is_trash_root(fm_dnd_dest_get_dest_path(dd))) fm_trash_files(GTK_WINDOW(parent), files); else fm_move_files(GTK_WINDOW(parent), files, fm_dnd_dest_get_dest_path(dd)); break; case GDK_ACTION_COPY: fm_copy_files(GTK_WINDOW(parent), files, fm_dnd_dest_get_dest_path(dd)); break; case GDK_ACTION_LINK: // fm_link_files(parent, files, fm_dnd_dest_get_dest_path(dd)); break; case GDK_ACTION_ASK: g_debug("TODO: GDK_ACTION_ASK"); break; } fm_list_unref(files); return TRUE; }
void on_dnd_dest_files_dropped(FmDndDest* dd, GdkDragAction action, int info_type, FmList* files, FmPlacesView* view) { FmPath* dest; GList* l; dest = fm_dnd_dest_get_dest_path(dd); g_debug("action= %d, %d files-dropped!, info_type: %d", action, fm_list_get_length(files), info_type); if(action != GDK_ACTION_LINK) { if(fm_list_is_file_info_list(files)) files = fm_path_list_new_from_file_info_list(files); else fm_list_ref(files); } switch(action) { case GDK_ACTION_MOVE: if(fm_path_is_trash_root(dest)) fm_trash_files(files); else fm_move_files(files, dest); break; case GDK_ACTION_COPY: fm_copy_files(files, dest); break; case GDK_ACTION_LINK: { GtkTreePath* tp = view->dest_row; if(tp) { GtkTreePath* sep = gtk_tree_model_get_path(GTK_TREE_MODEL(model), &sep_it); int idx = gtk_tree_path_get_indices(tp)[0] - gtk_tree_path_get_indices(sep)[0]; gtk_tree_path_free(sep); if(view->dest_pos == GTK_TREE_VIEW_DROP_BEFORE) --idx; for( l=fm_list_peek_head_link(files); l; l=l->next, ++idx ) { FmBookmarkItem* item; if(fm_list_is_file_info_list(files)) { FmFileInfo* fi = (FmFileInfo*)l->data; item = fm_bookmarks_insert( bookmarks, fi->path, fi->disp_name, idx); } else { FmPath* path = (FmPath*)l->data; char* disp_name = g_filename_display_name(path->name); item = fm_bookmarks_insert( bookmarks, path, disp_name, idx); g_free(disp_name); } /* we don't need to add item to places view. Later the bookmarks will be reloaded. */ } } } break; } fm_list_unref(files); if(view->dest_row) { gtk_tree_path_free(view->dest_row); view->dest_row = NULL; } }