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:
authorTon Roosendaal <ton@blender.org>2009-02-14 17:25:48 +0300
committerTon Roosendaal <ton@blender.org>2009-02-14 17:25:48 +0300
commit05cdff9bf1687a6998e8bd13b21003e97e98c81d (patch)
treeee64b1bb5bd24119bd405def6a3e114c73db2aea /source/blender/editors/space_file
parent3f425dfc715d846fe9127eaed1a398c747b41f01 (diff)
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.
Diffstat (limited to 'source/blender/editors/space_file')
-rw-r--r--source/blender/editors/space_file/file_draw.c8
-rw-r--r--source/blender/editors/space_file/file_intern.h20
-rw-r--r--source/blender/editors/space_file/file_ops.c56
-rw-r--r--source/blender/editors/space_file/space_file.c32
4 files changed, 62 insertions, 54 deletions
diff --git a/source/blender/editors/space_file/file_draw.c b/source/blender/editors/space_file/file_draw.c
index 2c839adc451..4cd511082c0 100644
--- a/source/blender/editors/space_file/file_draw.c
+++ b/source/blender/editors/space_file/file_draw.c
@@ -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, "");
}
diff --git a/source/blender/editors/space_file/file_intern.h b/source/blender/editors/space_file/file_intern.h
index d4cb80c1b39..e47387a2d22 100644
--- a/source/blender/editors/space_file/file_intern.h
+++ b/source/blender/editors/space_file/file_intern.h
@@ -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);
diff --git a/source/blender/editors/space_file/file_ops.c b/source/blender/editors/space_file/file_ops.c
index b584524e396..1d1f31c4221 100644
--- a/source/blender/editors/space_file/file_ops.c
+++ b/source/blender/editors/space_file/file_ops.c
@@ -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;
diff --git a/source/blender/editors/space_file/space_file.c b/source/blender/editors/space_file/space_file.c
index fe681e246ce..f8557a2b573 100644
--- a/source/blender/editors/space_file/space_file.c
+++ b/source/blender/editors/space_file/space_file.c
@@ -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);
}