/** * fm_rename_file * @parent: a window to place dialog over it * @file: the file * * Opens a dialog to choose new name for @file. If it was not cancelled * by user then renames @file. * * Before 0.1.15 this call had different arguments. * * Since: 0.1.0 */ void fm_rename_file(GtkWindow* parent, FmPath* file) { gchar *old_name, *new_name; FmPathList *files; FmFileOpsJob *job; /* NOTE: it's better to use fm_file_info_get_edit_name() to get a name but we cannot get it from FmPath */ old_name = fm_path_display_basename(file); new_name = fm_get_user_input_rename(parent, _("Rename File"), _("Please enter a new name:"), old_name); /* if file name wasn't changed then do nothing */ if (new_name == NULL || strcmp(old_name, new_name) == 0) { g_free(old_name); g_free(new_name); return; } g_free(old_name); files = fm_path_list_new(); fm_path_list_push_tail(files, file); job = fm_file_ops_job_new(FM_FILE_OP_CHANGE_ATTR, files); fm_file_ops_job_set_display_name(job, new_name); g_free(new_name); fm_path_list_unref(files); fm_file_ops_job_run_with_progress(parent, job); /* it eats reference! */ }
/** * fm_empty_trash * @parent: a window to place dialog over it * * Asks user to confirm the emptying trash can and empties it if confirmed. * * Before 0.1.15 this call had different arguments. * * Since: 0.1.0 */ void fm_empty_trash(GtkWindow* parent) { if(fm_yes_no(parent, NULL, _("Are you sure you want to empty the trash can?"), TRUE)) { FmPathList* paths = fm_path_list_new(); fm_path_list_push_tail(paths, fm_path_get_trash()); fm_delete_files_internal(parent, paths); fm_path_list_unref(paths); } }
FmPathList* fm_path_list_new_from_file_info_gslist(GSList* fis) { FmPathList* list = fm_path_list_new(); GSList* l; for(l=fis;l;l=l->next) { FmFileInfo* fi = (FmFileInfo*)l->data; fm_list_push_tail(list, fi->path); } return list; }
FmPathList* fm_path_list_new_from_file_info_list(FmFileInfoList* fis) { FmPathList* list = fm_path_list_new(); GList* l; for(l=fm_list_peek_head_link(fis);l;l=l->next) { FmFileInfo* fi = (FmFileInfo*)l->data; fm_list_push_tail(list, fi->path); } return list; }
static void _fm_set_file_hidden(GtkWindow *parent, FmPath *file, gboolean hidden) { FmPathList *files; FmFileOpsJob *job; files = fm_path_list_new(); fm_path_list_push_tail(files, file); job = fm_file_ops_job_new(FM_FILE_OP_CHANGE_ATTR, files); fm_file_ops_job_set_hidden(job, hidden); fm_path_list_unref(files); fm_file_ops_job_run_with_progress(parent, job); /* it eats reference! */ }
FmPathList* pathListFromQUrls(QList<QUrl> urls) { QList<QUrl>::const_iterator it; FmPathList* pathList = fm_path_list_new(); for(it = urls.begin(); it != urls.end(); ++it) { QUrl url = *it; FmPath* path = fm_path_new_for_uri(url.toString().toUtf8()); fm_path_list_push_tail(pathList, path); fm_path_unref(path); } return pathList; }
FmPathList* FolderView::selectedFilePaths() const { if(model_) { QModelIndexList selIndexes = mode == DetailedListMode ? selectedRows() : selectedIndexes(); if(!selIndexes.isEmpty()) { FmPathList* paths = fm_path_list_new(); QModelIndexList::const_iterator it; for(it = selIndexes.begin(); it != selIndexes.end(); ++it) { FmFileInfo* file = model_->fileInfoFromIndex(*it); fm_path_list_push_tail(paths, fm_file_info_get_path(file)); } return paths; } } return NULL; }
FmPathList* fm_path_list_new_from_uris(const char** uris) { const char** uri; FmPathList* pl = fm_path_list_new(); for(uri = uris; *uri; ++uri) { FmPath* path; char* unescaped; if(g_str_has_prefix(*uri, "file:")) unescaped = g_filename_from_uri(*uri, NULL, NULL); else unescaped = g_uri_unescape_string(*uri, NULL); path = fm_path_new(unescaped); g_free(unescaped); fm_list_push_tail_noref(pl, path); } return pl; }
void PlacesView::onEmptyTrash() { FmPathList* files = fm_path_list_new(); fm_path_list_push_tail(files, fm_path_get_trash()); Fm::FileOperation::deleteFiles(files); fm_path_list_unref(files); }