[Bf-blender-cvs] [7266285] master: WM: expose file loading operator property init functions
Campbell Barton
noreply at git.blender.org
Thu Apr 3 02:33:27 CEST 2014
Commit: 726628518d9c7d30cf5b367992395d74c5cc65af
Author: Campbell Barton
Date: Thu Apr 3 11:04:02 2014 +1100
https://developer.blender.org/rB726628518d9c7d30cf5b367992395d74c5cc65af
WM: expose file loading operator property init functions
===================================================================
M source/blender/windowmanager/intern/wm_files.c
M source/blender/windowmanager/intern/wm_operators.c
M source/blender/windowmanager/wm.h
===================================================================
diff --git a/source/blender/windowmanager/intern/wm_files.c b/source/blender/windowmanager/intern/wm_files.c
index a3aa76d..0d481bd 100644
--- a/source/blender/windowmanager/intern/wm_files.c
+++ b/source/blender/windowmanager/intern/wm_files.c
@@ -1151,3 +1151,39 @@ void wm_autosave_read(bContext *C, ReportList *reports)
WM_file_read(C, filename, reports);
}
+
+/** \name Initialize WM_OT_open_xxx properties
+ *
+ * Check if load_ui was set by the caller.
+ * Fall back to user preference when file flags not specified.
+ *
+ * \{ */
+
+void wm_open_init_load_ui(wmOperator *op, bool use_prefs)
+{
+ PropertyRNA *prop = RNA_struct_find_property(op->ptr, "load_ui");
+ if (!RNA_property_is_set(op->ptr, prop)) {
+ bool value = use_prefs ?
+ ((U.flag & USER_FILENOUI) == 0) :
+ ((G.fileflags & G_FILE_NO_UI) == 0);
+
+ RNA_property_boolean_set(op->ptr, prop, value);
+ }
+}
+
+void wm_open_init_use_scripts(wmOperator *op, bool use_prefs)
+{
+ PropertyRNA *prop = RNA_struct_find_property(op->ptr, "use_scripts");
+ if (!RNA_property_is_set(op->ptr, prop)) {
+ /* use G_SCRIPT_AUTOEXEC rather than the userpref because this means if
+ * the flag has been disabled from the command line, then opening
+ * from the menu wont enable this setting. */
+ bool value = use_prefs ?
+ ((U.flag & USER_SCRIPT_AUTOEXEC_DISABLE) == 0) :
+ ((G.f & G_SCRIPT_AUTOEXEC) != 0);
+
+ RNA_property_boolean_set(op->ptr, prop, value);
+ }
+}
+
+/** \} */
diff --git a/source/blender/windowmanager/intern/wm_operators.c b/source/blender/windowmanager/intern/wm_operators.c
index 747366b..50b0fa2 100644
--- a/source/blender/windowmanager/intern/wm_operators.c
+++ b/source/blender/windowmanager/intern/wm_operators.c
@@ -2188,30 +2188,6 @@ struct FileRuntime {
bool is_untrusted;
};
-
-static void open_set_load_ui(wmOperator *op, bool use_prefs)
-{
- PropertyRNA *prop = RNA_struct_find_property(op->ptr, "load_ui");
- if (!RNA_property_is_set(op->ptr, prop)) {
- RNA_property_boolean_set(op->ptr, prop, use_prefs ?
- (U.flag & USER_FILENOUI) == 0 :
- (G.fileflags & G_FILE_NO_UI) == 0);
- }
-}
-
-static void open_set_use_scripts(wmOperator *op, bool use_prefs)
-{
- PropertyRNA *prop = RNA_struct_find_property(op->ptr, "use_scripts");
- if (!RNA_property_is_set(op->ptr, prop)) {
- /* use G_SCRIPT_AUTOEXEC rather than the userpref because this means if
- * the flag has been disabled from the command line, then opening
- * from the menu wont enable this setting. */
- RNA_property_boolean_set(op->ptr, prop, use_prefs ?
- (U.flag & USER_SCRIPT_AUTOEXEC_DISABLE) == 0 :
- (G.f & G_SCRIPT_AUTOEXEC) != 0);
- }
-}
-
static int wm_open_mainfile_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(event))
{
const char *openname = G.main->name;
@@ -2231,8 +2207,8 @@ static int wm_open_mainfile_invoke(bContext *C, wmOperator *op, const wmEvent *U
}
RNA_string_set(op->ptr, "filepath", openname);
- open_set_load_ui(op, true);
- open_set_use_scripts(op, true);
+ wm_open_init_load_ui(op, true);
+ wm_open_init_use_scripts(op, true);
op->customdata = NULL;
WM_event_add_fileselect(C, op);
@@ -2248,8 +2224,8 @@ static int wm_open_mainfile_exec(bContext *C, wmOperator *op)
RNA_string_get(op->ptr, "filepath", filepath);
/* re-use last loaded setting so we can reload a file without changing */
- open_set_load_ui(op, false);
- open_set_use_scripts(op, false);
+ wm_open_init_load_ui(op, false);
+ wm_open_init_use_scripts(op, false);
if (RNA_boolean_get(op->ptr, "load_ui"))
G.fileflags &= ~G_FILE_NO_UI;
diff --git a/source/blender/windowmanager/wm.h b/source/blender/windowmanager/wm.h
index aa246c9..de04129 100644
--- a/source/blender/windowmanager/wm.h
+++ b/source/blender/windowmanager/wm.h
@@ -76,6 +76,10 @@ void wm_autosave_delete(void);
void wm_autosave_read(bContext *C, struct ReportList *reports);
void wm_autosave_location(char *filepath);
+/* init operator properties */
+void wm_open_init_load_ui(wmOperator *op, bool use_prefs);
+void wm_open_init_use_scripts(wmOperator *op, bool use_prefs);
+
/* hack to store circle select size - campbell, must replace with nice operator memory */
#define GESTURE_MEMORY
More information about the Bf-blender-cvs
mailing list