diff options
author | Campbell Barton <ideasman42@gmail.com> | 2012-04-24 06:01:23 +0400 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2012-04-24 06:01:23 +0400 |
commit | 4ff038c4119327f3b0c472b71356d5e0cf2e0ed6 (patch) | |
tree | 395b8be489c012d9e2cf55d11a69303544bb6d68 /source/blender/windowmanager | |
parent | b374d9b20fc7b5e320da4c00ba7e21976da6b0d3 (diff) |
screenshot operator now adds file extension in the file selector and has its own save options rather then using the render options (works like image save a copy).
Diffstat (limited to 'source/blender/windowmanager')
-rw-r--r-- | source/blender/windowmanager/WM_api.h | 1 | ||||
-rw-r--r-- | source/blender/windowmanager/intern/wm_operators.c | 17 |
2 files changed, 18 insertions, 0 deletions
diff --git a/source/blender/windowmanager/WM_api.h b/source/blender/windowmanager/WM_api.h index a794cf10a86..4c81a0a8654 100644 --- a/source/blender/windowmanager/WM_api.h +++ b/source/blender/windowmanager/WM_api.h @@ -166,6 +166,7 @@ int WM_enum_search_invoke(struct bContext *C, struct wmOperator *op, struct wm int WM_operator_confirm (struct bContext *C, struct wmOperator *op, struct wmEvent *event); /* invoke callback, file selector "filepath" unset + exec */ int WM_operator_filesel (struct bContext *C, struct wmOperator *op, struct wmEvent *event); +int WM_operator_filesel_ensure_ext_imtype(wmOperator *op, const char imtype); /* poll callback, context checks */ int WM_operator_winactive (struct bContext *C); /* invoke callback, exec + redo popup */ diff --git a/source/blender/windowmanager/intern/wm_operators.c b/source/blender/windowmanager/intern/wm_operators.c index c9306f6dcf7..514c159c87b 100644 --- a/source/blender/windowmanager/intern/wm_operators.c +++ b/source/blender/windowmanager/intern/wm_operators.c @@ -65,6 +65,7 @@ #include "BKE_context.h" #include "BKE_depsgraph.h" #include "BKE_idprop.h" +#include "BKE_image.h" #include "BKE_library.h" #include "BKE_global.h" #include "BKE_main.h" @@ -808,6 +809,22 @@ int WM_operator_filesel(bContext *C, wmOperator *op, wmEvent *UNUSED(event)) } } +int WM_operator_filesel_ensure_ext_imtype(wmOperator *op, const char imtype) +{ + PropertyRNA *prop; + char filepath[FILE_MAX]; + /* dont NULL check prop, this can only run on ops with a 'filepath' */ + prop = RNA_struct_find_property(op->ptr, "filepath"); + RNA_property_string_get(op->ptr, prop, filepath); + if (BKE_add_image_extension(filepath, imtype)) { + RNA_property_string_set(op->ptr, prop, filepath); + /* note, we could check for and update 'filename' here, + * but so far nothing needs this. */ + return TRUE; + } + return FALSE; +} + /* default properties for fileselect */ void WM_operator_properties_filesel(wmOperatorType *ot, int filter, short type, short action, short flag, short display) { |