Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrea Weikert <elubie@gmx.net>2009-07-10 21:05:04 +0400
committerAndrea Weikert <elubie@gmx.net>2009-07-10 21:05:04 +0400
commit66ca86b40b7f4f66f46572ca218e522d5bbf7919 (patch)
tree89df818c6c0e74c702ca14d29d7df19e870e3b99 /source/blender/editors/space_file/file_ops.c
parent8f602277503361c1f0e0f53f3c99fdc3fa8b2d1c (diff)
2.5 file browser
* directory button enabled again, c code for now, can later become nicer operator * filename button enabled (pattern match for selection) * RNA completed (title, file and directory) * some unused code removal.
Diffstat (limited to 'source/blender/editors/space_file/file_ops.c')
-rw-r--r--source/blender/editors/space_file/file_ops.c135
1 files changed, 135 insertions, 0 deletions
diff --git a/source/blender/editors/space_file/file_ops.c b/source/blender/editors/space_file/file_ops.c
index c4435e85749..ef15586bba9 100644
--- a/source/blender/editors/space_file/file_ops.c
+++ b/source/blender/editors/space_file/file_ops.c
@@ -652,6 +652,96 @@ int file_next_exec(bContext *C, wmOperator *unused)
return OPERATOR_FINISHED;
}
+int file_directory_new_exec(bContext *C, wmOperator *unused)
+{
+ char tmpstr[FILE_MAX];
+ char tmpdir[FILE_MAXFILE];
+ int i = 1;
+
+ SpaceFile *sfile= (SpaceFile*)CTX_wm_space_data(C);
+
+ if(sfile->params) {
+
+ BLI_strncpy(tmpstr, sfile->params->dir, FILE_MAX);
+ BLI_join_dirfile(tmpstr, tmpstr, "New Folder");
+ while (BLI_exists(tmpstr)) {
+ BLI_snprintf(tmpdir, FILE_MAXFILE, "New Folder(%d)", i++);
+ BLI_strncpy(tmpstr, sfile->params->dir, FILE_MAX);
+ BLI_join_dirfile(tmpstr, tmpstr, tmpdir);
+ }
+ BLI_recurdir_fileops(tmpstr);
+ if (!BLI_exists(tmpstr)) {
+ filelist_free(sfile->files);
+ filelist_parent(sfile->files);
+ BLI_strncpy(sfile->params->dir, filelist_dir(sfile->files), FILE_MAX);
+ }
+ }
+ WM_event_add_notifier(C, NC_FILE|ND_FILELIST, NULL);
+
+ return OPERATOR_FINISHED;
+}
+
+
+void FILE_OT_directory_new(struct wmOperatorType *ot)
+{
+ /* identifiers */
+ ot->name= "Create New Directory";
+ ot->idname= "FILE_OT_directory_new";
+
+ /* api callbacks */
+ ot->invoke= WM_operator_confirm;
+ ot->exec= file_directory_new_exec;
+ ot->poll= ED_operator_file_active; /* <- important, handler is on window level */
+}
+
+int file_directory_exec(bContext *C, wmOperator *unused)
+{
+ char tmpstr[FILE_MAX];
+
+ SpaceFile *sfile= (SpaceFile*)CTX_wm_space_data(C);
+
+ if(sfile->params) {
+
+ if ( sfile->params->dir[0] == '~' ) {
+ if (sfile->params->dir[1] == '\0') {
+ BLI_strncpy(sfile->params->dir, BLI_gethome(), sizeof(sfile->params->dir) );
+ } else {
+ /* replace ~ with home */
+ char homestr[FILE_MAX];
+ char *d = &sfile->params->dir[1];
+
+ while ( (*d == '\\') || (*d == '/') )
+ d++;
+ BLI_strncpy(homestr, BLI_gethome(), FILE_MAX);
+ BLI_add_slash(homestr);
+ BLI_join_dirfile(tmpstr, homestr, d);
+ BLI_strncpy(sfile->params->dir, tmpstr, sizeof(sfile->params->dir));
+ }
+ }
+
+ file_change_dir(sfile);
+ }
+ WM_event_add_notifier(C, NC_FILE|ND_FILELIST, NULL);
+
+ return OPERATOR_FINISHED;
+}
+
+int file_filename_exec(bContext *C, wmOperator *unused)
+{
+ SpaceFile *sfile= (SpaceFile*)CTX_wm_space_data(C);
+
+ if(sfile->params) {
+ if (file_select_match(sfile, sfile->params->file))
+ {
+ sfile->params->file[0] = '\0';
+ WM_event_add_notifier(C, NC_FILE|ND_PARAMS, NULL);
+ }
+ }
+
+ return OPERATOR_FINISHED;
+}
+
+
void FILE_OT_refresh(struct wmOperatorType *ot)
{
/* identifiers */
@@ -772,3 +862,48 @@ void FILE_OT_filenum(struct wmOperatorType *ot)
RNA_def_int(ot->srna, "increment", 1, 0, 100, "Increment", "", 0,100);
}
+int file_delete_poll(bContext *C)
+{
+ int poll = ED_operator_file_active(C);
+ SpaceFile *sfile= (SpaceFile*)CTX_wm_space_data(C);
+ struct direntry* file;
+
+ if(!sfile->params ) poll= 0;
+
+ if (sfile->params->active_file < 0) {
+ poll= 0;
+ } else {
+ file = filelist_file(sfile->files, sfile->params->active_file);
+ if (file && S_ISDIR(file->type)) poll= 0;
+ }
+ return poll;
+}
+
+int file_delete_exec(bContext *C, wmOperator *op)
+{
+ char str[FILE_MAX];
+ SpaceFile *sfile= (SpaceFile*)CTX_wm_space_data(C);
+ struct direntry* file;
+
+
+ file = filelist_file(sfile->files, sfile->params->active_file);
+ BLI_make_file_string(G.sce, str, sfile->params->dir, file->relname);
+ BLI_delete(str, 0, 0);
+ WM_event_add_notifier(C, NC_FILE | ND_FILELIST, NULL);
+
+ return OPERATOR_FINISHED;
+
+}
+
+void FILE_OT_delete(struct wmOperatorType *ot)
+{
+ /* identifiers */
+ ot->name= "Delete File";
+ ot->idname= "FILE_OT_delete";
+
+ /* api callbacks */
+ ot->invoke= WM_operator_confirm;
+ ot->exec= file_delete_exec;
+ ot->poll= file_delete_poll; /* <- important, handler is on window level */
+}
+