Revision: 48009
          
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=48009
Author:   elubie
Date:     2012-06-17 14:16:26 +0000 (Sun, 17 Jun 2012)
Log Message:
-----------
== filebrowser ==
fixes:
* Sequence editor not loading file typed in filebrowser file button (reported 
by Sergey on IRC)
* filename button doesn't match exactly typed in filename

notes:
* file specified in the filename button now gets added to 'files' list, even if 
not selected
* after matching filename (either by typing in exact match or using wildcards) 
the first match is assigned to the filename button.

Modified Paths:
--------------
    trunk/blender/source/blender/editors/space_file/file_intern.h
    trunk/blender/source/blender/editors/space_file/file_ops.c
    trunk/blender/source/blender/editors/space_file/filesel.c

Modified: trunk/blender/source/blender/editors/space_file/file_intern.h
===================================================================
--- trunk/blender/source/blender/editors/space_file/file_intern.h       
2012-06-17 11:36:28 UTC (rev 48008)
+++ trunk/blender/source/blender/editors/space_file/file_intern.h       
2012-06-17 14:16:26 UTC (rev 48009)
@@ -103,7 +103,7 @@
 
 float file_font_pointsize(void);
 void file_change_dir(bContext *C, int checkdir);
-int file_select_match(struct SpaceFile *sfile, const char *pattern);
+int file_select_match(struct SpaceFile *sfile, const char *pattern, char 
*matched_file);
 void autocomplete_directory(struct bContext *C, char *str, void *arg_v);
 void autocomplete_file(struct bContext *C, char *str, void *arg_v);
 

Modified: trunk/blender/source/blender/editors/space_file/file_ops.c
===================================================================
--- trunk/blender/source/blender/editors/space_file/file_ops.c  2012-06-17 
11:36:28 UTC (rev 48008)
+++ trunk/blender/source/blender/editors/space_file/file_ops.c  2012-06-17 
14:16:26 UTC (rev 48009)
@@ -639,25 +639,40 @@
                int i, numfiles = filelist_numfiles(sfile->files);
 
                if (prop_files) {
+                       int num_files = 0;
                        RNA_property_collection_clear(op->ptr, prop_files);
                        for (i=0; i<numfiles; i++) {
                                if (filelist_is_selected(sfile->files, i, 
CHECK_FILES)) {
                                        struct direntry *file= 
filelist_file(sfile->files, i);
                                        RNA_property_collection_add(op->ptr, 
prop_files, &itemptr);
                                        RNA_string_set(&itemptr, "name", 
file->relname);
+                                       num_files++;
                                }
                        }
+                       /* make sure the file specified in the filename button 
is added even if no files selected */
+                       if (0 == num_files) {
+                               RNA_property_collection_add(op->ptr, 
prop_files, &itemptr);
+                               RNA_string_set(&itemptr, "name", 
sfile->params->file);
+                       }
                }
 
                if (prop_dirs) {
+                       int num_dirs = 0;
                        RNA_property_collection_clear(op->ptr, prop_dirs);
                        for (i=0; i<numfiles; i++) {
                                if (filelist_is_selected(sfile->files, i, 
CHECK_DIRS)) {
                                        struct direntry *file= 
filelist_file(sfile->files, i);
                                        RNA_property_collection_add(op->ptr, 
prop_dirs, &itemptr);
                                        RNA_string_set(&itemptr, "name", 
file->relname);
+                                       num_dirs++;
                                }
                        }
+                       
+                       /* make sure the directory specified in the button is 
added even if no directory selected */
+                       if (0 == num_dirs) {
+                               RNA_property_collection_add(op->ptr, prop_dirs, 
&itemptr);
+                               RNA_string_set(&itemptr, "name", 
sfile->params->dir);
+                       }
                }
 
 
@@ -1187,10 +1202,15 @@
 int file_filename_exec(bContext *C, wmOperator *UNUSED(unused))
 {
        SpaceFile *sfile= CTX_wm_space_file(C);
-       
+       char matched_file[FILE_MAX];
        if (sfile->params) {
-               if (file_select_match(sfile, sfile->params->file)) {
+               matched_file[0] = '\0';
+               if (file_select_match(sfile, sfile->params->file, 
matched_file)) {
+                       int i, numfiles= filelist_numfiles(sfile->files);
                        sfile->params->file[0] = '\0';
+                       /* replace the pattern (or filename that the user typed 
in, with the first selected file of the match */
+                       BLI_strncpy(sfile->params->file, matched_file, 
sizeof(sfile->params->file));
+                       
                        WM_event_add_notifier(C, NC_SPACE|ND_SPACE_FILE_PARAMS, 
NULL);
                }
        }               

Modified: trunk/blender/source/blender/editors/space_file/filesel.c
===================================================================
--- trunk/blender/source/blender/editors/space_file/filesel.c   2012-06-17 
11:36:28 UTC (rev 48008)
+++ trunk/blender/source/blender/editors/space_file/filesel.c   2012-06-17 
14:16:26 UTC (rev 48009)
@@ -589,22 +589,28 @@
        }
 }
 
-int file_select_match(struct SpaceFile *sfile, const char *pattern)
+int file_select_match(struct SpaceFile *sfile, const char *pattern, char 
*matched_file)
 {
        int match = 0;
-       if (strchr(pattern, '*') || strchr(pattern, '?') || strchr(pattern, 
'[')) {
-               int i;
-               struct direntry *file;
-               int n = filelist_numfiles(sfile->files);
+       
+       int i;
+       struct direntry *file;
+       int n = filelist_numfiles(sfile->files);
 
-               for (i = 0; i < n; i++) {
-                       file = filelist_file(sfile->files, i);
-                       if (fnmatch(pattern, file->relname, 0) == 0) {
-                               file->selflag |= SELECTED_FILE;
-                               match = 1;
+       /* select any file that matches the pattern, this includes exact match 
+        * if the user selects a single file by entering the filename
+        */
+       for (i = 0; i < n; i++) {
+               file = filelist_file(sfile->files, i);
+               if (fnmatch(pattern, file->relname, 0) == 0) {
+                       file->selflag |= SELECTED_FILE;
+                       if (!match) {
+                               BLI_strncpy(matched_file, file->relname, 
FILE_MAX );
                        }
+                       match = 1;
                }
        }
+
        return match;
 }
 

_______________________________________________
Bf-blender-cvs mailing list
[email protected]
http://lists.blender.org/mailman/listinfo/bf-blender-cvs

Reply via email to