2.5
FileWindow: It appeared all load/save went via 1 call, so the 'OK save over' menu popped up on loading files too. Added check in the function for saving... bit weak, could become an argument for ED_fileselect. Also renamed file operators to conform to others.
This commit is contained in:
@@ -2307,8 +2307,8 @@ void ED_keymap_screen(wmWindowManager *wm)
|
||||
WM_keymap_verify_item(keymap, "SCREEN_OT_redo_last", F6KEY, KM_PRESS, 0, 0);
|
||||
|
||||
/* files */
|
||||
WM_keymap_add_item(keymap, "ED_FILE_OT_load", RETKEY, KM_PRESS, 0, 0);
|
||||
WM_keymap_add_item(keymap, "ED_FILE_OT_cancel", ESCKEY, KM_PRESS, 0, 0);
|
||||
WM_keymap_add_item(keymap, "FILE_OT_exec", RETKEY, KM_PRESS, 0, 0);
|
||||
WM_keymap_add_item(keymap, "FILE_OT_cancel", ESCKEY, KM_PRESS, 0, 0);
|
||||
|
||||
/* undo */
|
||||
WM_keymap_add_item(keymap, "ED_OT_undo", ZKEY, KM_PRESS, KM_CTRL, 0);
|
||||
|
||||
@@ -83,7 +83,7 @@
|
||||
/* button events */
|
||||
enum {
|
||||
B_REDR = 0,
|
||||
B_FS_LOAD,
|
||||
B_FS_EXEC,
|
||||
B_FS_CANCEL,
|
||||
B_FS_PARENT,
|
||||
} eFile_ButEvents;
|
||||
@@ -91,8 +91,8 @@ enum {
|
||||
static void do_file_buttons(bContext *C, void *arg, int event)
|
||||
{
|
||||
switch(event) {
|
||||
case B_FS_LOAD:
|
||||
file_load_exec(C, NULL); /* file_ops.c */
|
||||
case B_FS_EXEC:
|
||||
file_exec(C, NULL); /* file_ops.c */
|
||||
break;
|
||||
case B_FS_CANCEL:
|
||||
file_cancel_exec(C, NULL); /* file_ops.c */
|
||||
@@ -158,7 +158,7 @@ void file_draw_buttons(const bContext *C, ARegion *ar)
|
||||
|
||||
if(loadbutton) {
|
||||
uiSetCurFont(block, UI_HELV);
|
||||
uiDefBut(block, BUT, B_FS_LOAD, params->title, xmax-loadbutton, filebuty2, loadbutton, 21, params->dir, 0.0, (float)FILE_MAXFILE-1, 0, 0, "");
|
||||
uiDefBut(block, BUT, B_FS_EXEC, params->title, xmax-loadbutton, filebuty2, loadbutton, 21, params->dir, 0.0, (float)FILE_MAXFILE-1, 0, 0, "");
|
||||
uiDefBut(block, BUT, B_FS_CANCEL, "Cancel", xmax-loadbutton, filebuty1, loadbutton, 21, params->file, 0.0, (float)FILE_MAXFILE-1, 0, 0, "");
|
||||
}
|
||||
|
||||
|
||||
@@ -49,17 +49,17 @@ void file_draw_fsmenu(const bContext *C, ARegion *ar);
|
||||
struct wmOperatorType;
|
||||
struct wmOperator;
|
||||
struct wmEvent;
|
||||
void ED_FILE_OT_highlight(struct wmOperatorType *ot);
|
||||
void ED_FILE_OT_select(struct wmOperatorType *ot);
|
||||
void ED_FILE_OT_select_all(struct wmOperatorType *ot);
|
||||
void ED_FILE_OT_border_select(struct wmOperatorType *ot);
|
||||
void ED_FILE_OT_select_bookmark(struct wmOperatorType *ot);
|
||||
void ED_FILE_OT_loadimages(struct wmOperatorType *ot);
|
||||
void ED_FILE_OT_load(struct wmOperatorType *ot);
|
||||
void ED_FILE_OT_cancel(struct wmOperatorType *ot);
|
||||
void ED_FILE_OT_parent(struct wmOperatorType *ot);
|
||||
void FILE_OT_highlight(struct wmOperatorType *ot);
|
||||
void FILE_OT_select(struct wmOperatorType *ot);
|
||||
void FILE_OT_select_all(struct wmOperatorType *ot);
|
||||
void FILE_OT_border_select(struct wmOperatorType *ot);
|
||||
void FILE_OT_select_bookmark(struct wmOperatorType *ot);
|
||||
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);
|
||||
|
||||
int file_load_exec(bContext *C, struct wmOperator *unused);
|
||||
int file_exec(bContext *C, struct wmOperator *unused);
|
||||
int file_cancel_exec(bContext *C, struct wmOperator *unused);
|
||||
int file_parent_exec(bContext *C, struct wmOperator *unused);
|
||||
int file_hilight_set(SpaceFile *sfile, ARegion *ar, int mx, int my);
|
||||
|
||||
@@ -220,11 +220,11 @@ static int file_border_select_exec(bContext *C, wmOperator *op)
|
||||
return OPERATOR_FINISHED;
|
||||
}
|
||||
|
||||
void ED_FILE_OT_border_select(wmOperatorType *ot)
|
||||
void FILE_OT_border_select(wmOperatorType *ot)
|
||||
{
|
||||
/* identifiers */
|
||||
ot->name= "Activate/Select File";
|
||||
ot->idname= "ED_FILE_OT_border_select";
|
||||
ot->idname= "FILE_OT_border_select";
|
||||
|
||||
/* api callbacks */
|
||||
ot->invoke= WM_border_select_invoke;
|
||||
@@ -259,11 +259,11 @@ static int file_select_invoke(bContext *C, wmOperator *op, wmEvent *event)
|
||||
return OPERATOR_FINISHED;
|
||||
}
|
||||
|
||||
void ED_FILE_OT_select(wmOperatorType *ot)
|
||||
void FILE_OT_select(wmOperatorType *ot)
|
||||
{
|
||||
/* identifiers */
|
||||
ot->name= "Activate/Select File";
|
||||
ot->idname= "ED_FILE_OT_select";
|
||||
ot->idname= "FILE_OT_select";
|
||||
|
||||
/* api callbacks */
|
||||
ot->invoke= file_select_invoke;
|
||||
@@ -303,11 +303,11 @@ static int file_select_all_invoke(bContext *C, wmOperator *op, wmEvent *event)
|
||||
return OPERATOR_FINISHED;
|
||||
}
|
||||
|
||||
void ED_FILE_OT_select_all(wmOperatorType *ot)
|
||||
void FILE_OT_select_all(wmOperatorType *ot)
|
||||
{
|
||||
/* identifiers */
|
||||
ot->name= "Select/Deselect all files";
|
||||
ot->idname= "ED_FILE_OT_select_all";
|
||||
ot->idname= "FILE_OT_select_all";
|
||||
|
||||
/* api callbacks */
|
||||
ot->invoke= file_select_all_invoke;
|
||||
@@ -369,11 +369,11 @@ static int bookmark_select_invoke(bContext *C, wmOperator *op, wmEvent *event)
|
||||
return OPERATOR_FINISHED;
|
||||
}
|
||||
|
||||
void ED_FILE_OT_select_bookmark(wmOperatorType *ot)
|
||||
void FILE_OT_select_bookmark(wmOperatorType *ot)
|
||||
{
|
||||
/* identifiers */
|
||||
ot->name= "Select Directory";
|
||||
ot->idname= "ED_FILE_OT_select_bookmark";
|
||||
ot->idname= "FILE_OT_select_bookmark";
|
||||
|
||||
/* api callbacks */
|
||||
ot->invoke= bookmark_select_invoke;
|
||||
@@ -394,12 +394,12 @@ static int loadimages_invoke(bContext *C, wmOperator *op, wmEvent *event)
|
||||
return OPERATOR_FINISHED;
|
||||
}
|
||||
|
||||
void ED_FILE_OT_loadimages(wmOperatorType *ot)
|
||||
void FILE_OT_loadimages(wmOperatorType *ot)
|
||||
{
|
||||
|
||||
/* identifiers */
|
||||
ot->name= "Load Images";
|
||||
ot->idname= "ED_FILE_OT_loadimages";
|
||||
ot->idname= "FILE_OT_loadimages";
|
||||
|
||||
/* api callbacks */
|
||||
ot->invoke= loadimages_invoke;
|
||||
@@ -442,11 +442,11 @@ static int file_highlight_invoke(bContext *C, wmOperator *op, wmEvent *event)
|
||||
return OPERATOR_FINISHED;
|
||||
}
|
||||
|
||||
void ED_FILE_OT_highlight(struct wmOperatorType *ot)
|
||||
void FILE_OT_highlight(struct wmOperatorType *ot)
|
||||
{
|
||||
/* identifiers */
|
||||
ot->name= "Highlight File";
|
||||
ot->idname= "ED_FILE_OT_highlight";
|
||||
ot->idname= "FILE_OT_highlight";
|
||||
|
||||
/* api callbacks */
|
||||
ot->invoke= file_highlight_invoke;
|
||||
@@ -466,11 +466,11 @@ int file_cancel_exec(bContext *C, wmOperator *unused)
|
||||
return OPERATOR_FINISHED;
|
||||
}
|
||||
|
||||
void ED_FILE_OT_cancel(struct wmOperatorType *ot)
|
||||
void FILE_OT_cancel(struct wmOperatorType *ot)
|
||||
{
|
||||
/* identifiers */
|
||||
ot->name= "Cancel File Load";
|
||||
ot->idname= "ED_FILE_OT_cancel";
|
||||
ot->idname= "FILE_OT_cancel";
|
||||
|
||||
/* api callbacks */
|
||||
ot->exec= file_cancel_exec;
|
||||
@@ -478,7 +478,7 @@ void ED_FILE_OT_cancel(struct wmOperatorType *ot)
|
||||
}
|
||||
|
||||
|
||||
int file_load_exec(bContext *C, wmOperator *unused)
|
||||
int file_exec(bContext *C, wmOperator *unused)
|
||||
{
|
||||
SpaceFile *sfile= (SpaceFile*)CTX_wm_space_data(C);
|
||||
char name[FILE_MAX];
|
||||
@@ -496,24 +496,32 @@ int file_load_exec(bContext *C, wmOperator *unused)
|
||||
strcat(name, sfile->params->file);
|
||||
RNA_string_set(op->ptr, "filename", name);
|
||||
|
||||
/* this gives ownership to pupmenu */
|
||||
uiPupMenuSaveOver(C, op, name);
|
||||
/* a bit weak, might become arg for ED_fileselect? */
|
||||
if(strncmp(sfile->params->title, "Save", 4)==0) {
|
||||
/* this gives ownership to pupmenu */
|
||||
uiPupMenuSaveOver(C, op, name);
|
||||
}
|
||||
else {
|
||||
op->type->exec(C, op);
|
||||
WM_operator_free(op);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return OPERATOR_FINISHED;
|
||||
}
|
||||
|
||||
void ED_FILE_OT_load(struct wmOperatorType *ot)
|
||||
void FILE_OT_exec(struct wmOperatorType *ot)
|
||||
{
|
||||
/* identifiers */
|
||||
ot->name= "Load File";
|
||||
ot->idname= "ED_FILE_OT_load";
|
||||
ot->name= "Execute File Window";
|
||||
ot->idname= "FILE_OT_exec";
|
||||
|
||||
/* api callbacks */
|
||||
ot->exec= file_load_exec;
|
||||
ot->exec= file_exec;
|
||||
ot->poll= ED_operator_file_active; /* <- important, handler is on window level */
|
||||
}
|
||||
|
||||
|
||||
int file_parent_exec(bContext *C, wmOperator *unused)
|
||||
{
|
||||
SpaceFile *sfile= (SpaceFile*)CTX_wm_space_data(C);
|
||||
@@ -530,11 +538,11 @@ int file_parent_exec(bContext *C, wmOperator *unused)
|
||||
|
||||
}
|
||||
|
||||
void ED_FILE_OT_parent(struct wmOperatorType *ot)
|
||||
void FILE_OT_parent(struct wmOperatorType *ot)
|
||||
{
|
||||
/* identifiers */
|
||||
ot->name= "Parent File";
|
||||
ot->idname= "ED_FILE_OT_parent";
|
||||
ot->idname= "FILE_OT_parent";
|
||||
|
||||
/* api callbacks */
|
||||
ot->exec= file_parent_exec;
|
||||
|
||||
@@ -251,31 +251,31 @@ static void file_main_area_draw(const bContext *C, ARegion *ar)
|
||||
|
||||
void file_operatortypes(void)
|
||||
{
|
||||
WM_operatortype_append(ED_FILE_OT_select);
|
||||
WM_operatortype_append(ED_FILE_OT_select_all);
|
||||
WM_operatortype_append(ED_FILE_OT_border_select);
|
||||
WM_operatortype_append(ED_FILE_OT_select_bookmark);
|
||||
WM_operatortype_append(ED_FILE_OT_loadimages);
|
||||
WM_operatortype_append(ED_FILE_OT_highlight);
|
||||
WM_operatortype_append(ED_FILE_OT_load);
|
||||
WM_operatortype_append(ED_FILE_OT_cancel);
|
||||
WM_operatortype_append(ED_FILE_OT_parent);
|
||||
WM_operatortype_append(FILE_OT_select);
|
||||
WM_operatortype_append(FILE_OT_select_all);
|
||||
WM_operatortype_append(FILE_OT_border_select);
|
||||
WM_operatortype_append(FILE_OT_select_bookmark);
|
||||
WM_operatortype_append(FILE_OT_loadimages);
|
||||
WM_operatortype_append(FILE_OT_highlight);
|
||||
WM_operatortype_append(FILE_OT_exec);
|
||||
WM_operatortype_append(FILE_OT_cancel);
|
||||
WM_operatortype_append(FILE_OT_parent);
|
||||
}
|
||||
|
||||
/* NOTE: do not add .blend file reading on this level */
|
||||
void file_keymap(struct wmWindowManager *wm)
|
||||
{
|
||||
ListBase *keymap= WM_keymap_listbase(wm, "File", SPACE_FILE, 0);
|
||||
WM_keymap_add_item(keymap, "ED_FILE_OT_select", LEFTMOUSE, KM_PRESS, 0, 0);
|
||||
WM_keymap_add_item(keymap, "ED_FILE_OT_select_all", AKEY, KM_PRESS, 0, 0);
|
||||
WM_keymap_add_item(keymap, "ED_FILE_OT_border_select", BKEY, KM_PRESS, 0, 0);
|
||||
WM_keymap_add_item(keymap, "ED_FILE_OT_highlight", MOUSEMOVE, KM_ANY, 0, 0);
|
||||
WM_keymap_add_item(keymap, "ED_FILE_OT_parent", PKEY, KM_PRESS, 0, 0);
|
||||
WM_keymap_add_item(keymap, "FILE_OT_select", LEFTMOUSE, KM_PRESS, 0, 0);
|
||||
WM_keymap_add_item(keymap, "FILE_OT_select_all", AKEY, KM_PRESS, 0, 0);
|
||||
WM_keymap_add_item(keymap, "FILE_OT_border_select", BKEY, KM_PRESS, 0, 0);
|
||||
WM_keymap_add_item(keymap, "FILE_OT_highlight", MOUSEMOVE, KM_ANY, 0, 0);
|
||||
WM_keymap_add_item(keymap, "FILE_OT_parent", PKEY, KM_PRESS, 0, 0);
|
||||
|
||||
WM_keymap_add_item(keymap, "ED_FILE_OT_loadimages", TIMER1, KM_ANY, KM_ANY, 0);
|
||||
WM_keymap_add_item(keymap, "FILE_OT_loadimages", TIMER1, KM_ANY, KM_ANY, 0);
|
||||
|
||||
keymap= WM_keymap_listbase(wm, "FileBookmark", SPACE_FILE, 0);
|
||||
WM_keymap_add_item(keymap, "ED_FILE_OT_select_bookmark", LEFTMOUSE, KM_PRESS, 0, 0);
|
||||
WM_keymap_add_item(keymap, "FILE_OT_select_bookmark", LEFTMOUSE, KM_PRESS, 0, 0);
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user