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:
authorCampbell Barton <ideasman42@gmail.com>2014-04-03 04:04:02 +0400
committerCampbell Barton <ideasman42@gmail.com>2014-04-03 04:04:02 +0400
commit726628518d9c7d30cf5b367992395d74c5cc65af (patch)
tree2a347b2e7a9823383c0b93b09457b7266a3e00f9 /source/blender/windowmanager
parentb2b4f2c033c9e1df15aae6265390d519f55375d2 (diff)
WM: expose file loading operator property init functions
Diffstat (limited to 'source/blender/windowmanager')
-rw-r--r--source/blender/windowmanager/intern/wm_files.c36
-rw-r--r--source/blender/windowmanager/intern/wm_operators.c32
-rw-r--r--source/blender/windowmanager/wm.h4
3 files changed, 44 insertions, 28 deletions
diff --git a/source/blender/windowmanager/intern/wm_files.c b/source/blender/windowmanager/intern/wm_files.c
index a3aa76dfd3a..0d481bd49dc 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 747366b6e8e..50b0fa2fa79 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 aa246c9e402..de04129a0ef 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