2.5 filebrowser
authorAndrea Weikert <elubie@gmx.net>
Thu, 12 Mar 2009 06:40:03 +0000 (06:40 +0000)
committerAndrea Weikert <elubie@gmx.net>
Thu, 12 Mar 2009 06:40:03 +0000 (06:40 +0000)
- add refresh filelist operator and button in header

source/blender/editors/space_file/file_header.c
source/blender/editors/space_file/file_intern.h
source/blender/editors/space_file/file_ops.c
source/blender/editors/space_file/space_file.c

index 2f9d5ed8c7ae04c0d3986621e51d21472e90fb57..b967e21c99cb39c0a8af802e698dc42925659651 100644 (file)
@@ -143,10 +143,13 @@ void file_header_buttons(const bContext *C, ARegion *ar)
        uiBlockSetEmboss(block, UI_EMBOSSX);
        
        xco += 5;
-       
-       uiDefIconButO(block, BUT, "FILE_OT_parent", WM_OP_INVOKE_DEFAULT, ICON_FILE_PARENT, xco, yco, 20, 20, "Navigate to Parent Folder");
-       
-       xco+=XIC;
+
+       uiBlockBeginAlign(block);
+       uiDefIconButO(block, BUT, "FILE_OT_parent", WM_OP_INVOKE_DEFAULT, ICON_FILE_PARENT, xco+=XIC, yco, 20, 20, "Navigate to Parent Folder");
+       uiDefIconButO(block, BUT, "FILE_OT_refresh", WM_OP_INVOKE_DEFAULT, ICON_FILE_REFRESH, xco+=XIC, yco, 20, 20, "Refresh List of Files");
+       uiBlockEndAlign(block);
+
+       xco += 5;
        
        if (sfile->params->type != FILE_MAIN) {
                uiBlockBeginAlign(block);
index 1c39e1d685ef28027941087d878e4a877f3c93cd..6a75303696b077c9cc71bc9edadc53d53732f2e4 100644 (file)
@@ -60,6 +60,7 @@ void FILE_OT_loadimages(struct wmOperatorType *ot);
 void FILE_OT_exec(struct wmOperatorType *ot);
 void FILE_OT_cancel(struct wmOperatorType *ot);
 void FILE_OT_parent(struct wmOperatorType *ot);
+void FILE_OT_refresh(struct wmOperatorType *ot);
 void FILE_OT_bookmark_toggle(struct wmOperatorType *ot);
 
 int file_exec(bContext *C, struct wmOperator *unused);
index bb25fb6270233d31131814343c6c18dadf2c114a..4725014a4b1db55f8eb157b494636d44100c0d3f 100644 (file)
@@ -569,6 +569,34 @@ void FILE_OT_parent(struct wmOperatorType *ot)
        ot->poll= ED_operator_file_active; /* <- important, handler is on window level */
 }
 
+
+int file_refresh_exec(bContext *C, wmOperator *unused)
+{
+       SpaceFile *sfile= (SpaceFile*)CTX_wm_space_data(C);
+       
+       if(sfile->params) {
+               filelist_setdir(sfile->files, sfile->params->dir);
+               filelist_free(sfile->files);
+               sfile->params->active_file = -1;
+       }               
+       ED_area_tag_redraw(CTX_wm_area(C));
+
+       return OPERATOR_FINISHED;
+
+}
+
+
+void FILE_OT_refresh(struct wmOperatorType *ot)
+{
+       /* identifiers */
+       ot->name= "Refresh Filelist";
+       ot->idname= "FILE_OT_refresh";
+       
+       /* api callbacks */
+       ot->exec= file_refresh_exec;
+       ot->poll= ED_operator_file_active; /* <- important, handler is on window level */
+}
+
 struct ARegion *file_buttons_region(struct ScrArea *sa)
 {
        ARegion *ar;
index 50dbaf08c06b9a2901efa6d24341aafda0ec00b0..d68cde85554bcc5637da9546a2f56b359e4c3911 100644 (file)
@@ -270,6 +270,7 @@ void file_operatortypes(void)
        WM_operatortype_append(FILE_OT_exec);
        WM_operatortype_append(FILE_OT_cancel);
        WM_operatortype_append(FILE_OT_parent);
+       WM_operatortype_append(FILE_OT_refresh);
        WM_operatortype_append(FILE_OT_bookmark_toggle);
 }