changes to relative path option
authorCampbell Barton <ideasman42@gmail.com>
Wed, 12 Oct 2011 00:15:19 +0000 (00:15 +0000)
committerCampbell Barton <ideasman42@gmail.com>
Wed, 12 Oct 2011 00:15:19 +0000 (00:15 +0000)
- initialize the relative_path option in ED_fileselect_get_params(), saves initializing within every operators own init functions, some even trying to initialize a non existing property.
- don't set the operator default from the user preferece, operator property defaults should be static else python scripts for eg can get different defaults depending on user settings, this also wont get updated when user-defaults are edited so generally confusing & not good practice.

source/blender/editors/curve/editfont.c
source/blender/editors/object/object_modifier.c
source/blender/editors/render/render_shading.c
source/blender/editors/sound/sound_ops.c
source/blender/editors/space_buttons/buttons_ops.c
source/blender/editors/space_file/filesel.c
source/blender/editors/space_image/image_ops.c
source/blender/editors/space_sequencer/sequencer_add.c
source/blender/windowmanager/intern/wm_operators.c

index 19892d2c1ee4194ce34b1816754cceb18c1ae038..1f2ef79e091a57337f6b0a1cb73407ec10721b24 100644 (file)
@@ -1707,10 +1707,7 @@ static int open_invoke(bContext *C, wmOperator *op, wmEvent *UNUSED(event))
        }
 
        path = (font && strcmp(font->name, FO_BUILTIN_NAME) != 0)? font->name: U.fontdir;
-       
-       if(!RNA_property_is_set(op->ptr, "relative_path"))
-               RNA_boolean_set(op->ptr, "relative_path", U.flag & USER_RELPATHS);
-               
+
        if(RNA_property_is_set(op->ptr, "filepath"))
                return open_exec(C, op);
 
index ebbc4137628dc6150be9bd9a181c8d486005a743..20ca50581bf465cb7b6ae089f3fc233a7cacbfaf 100644 (file)
@@ -1163,9 +1163,6 @@ static int multires_external_save_invoke(bContext *C, wmOperator *op, wmEvent *U
        if(CustomData_external_test(&me->fdata, CD_MDISPS))
                return OPERATOR_CANCELLED;
 
-       if(!RNA_property_is_set(op->ptr, "relative_path"))
-               RNA_boolean_set(op->ptr, "relative_path", U.flag & USER_RELPATHS);
-
        if(RNA_property_is_set(op->ptr, "filepath"))
                return multires_external_save_exec(C, op);
        
index 72cc4ec2afa5328168fde46e5518ae39fbdb417e..faf0baa1aca1b56c67ec56d2122bcf1c2ebb0c15 100644 (file)
@@ -712,9 +712,6 @@ static int envmap_save_invoke(bContext *C, wmOperator *op, wmEvent *UNUSED(event
 {
        //Scene *scene= CTX_data_scene(C);
        
-       if(!RNA_property_is_set(op->ptr, "relative_path"))
-               RNA_boolean_set(op->ptr, "relative_path", U.flag & USER_RELPATHS);
-       
        if(RNA_property_is_set(op->ptr, "filepath"))
                return envmap_save_exec(C, op);
 
index d03c2b1930004e9359aa05cb4617edd18402afa0..50dda49beadb014638e77d10ed5ae3f26aadf9a8 100644 (file)
@@ -164,9 +164,6 @@ static int open_exec(bContext *UNUSED(C), wmOperator *op)
 
 static int open_invoke(bContext *C, wmOperator *op, wmEvent *event)
 {
-       if(!RNA_property_is_set(op->ptr, "relative_path"))
-               RNA_boolean_set(op->ptr, "relative_path", U.flag & USER_RELPATHS);
-
        if(RNA_property_is_set(op->ptr, "filepath"))
                return open_exec(C, op);
 
@@ -264,9 +261,6 @@ static int mixdown_exec(bContext *C, wmOperator *op)
 
 static int mixdown_invoke(bContext *C, wmOperator *op, wmEvent *event)
 {
-       if(!RNA_property_is_set(op->ptr, "relative_path"))
-               RNA_boolean_set(op->ptr, "relative_path", U.flag & USER_RELPATHS);
-
        if(RNA_property_is_set(op->ptr, "filepath"))
                return mixdown_exec(C, op);
 
index 99e5c6d693ee978d3d9dbd070605bf739a8b078a..75b3eb950a5926ce6c9d5dcedbc70bed649ed88b 100644 (file)
@@ -201,6 +201,8 @@ static int file_browse_invoke(bContext *C, wmOperator *op, wmEvent *event)
                RNA_string_set(op->ptr, path_prop, str);
                MEM_freeN(str);
 
+               /* normally ED_fileselect_get_params would handle this but we need to because of stupid
+                * user-prefs exception - campbell */
                if(RNA_struct_find_property(op->ptr, "relative_path")) {
                        if(!RNA_property_is_set(op->ptr, "relative_path")) {
                                /* annoying exception!, if were dealign with the user prefs, default relative to be off */
index e3571886cf45a468162b67efd7b98f37150e117a..6cc42b2a75193ad1be918f48da4d4eb3ab08f10f 100644 (file)
@@ -125,6 +125,7 @@ short ED_fileselect_set_params(SpaceFile *sfile)
                const short is_filepath= (RNA_struct_find_property(op->ptr, "filepath") != NULL);
                const short is_filename= (RNA_struct_find_property(op->ptr, "filename") != NULL);
                const short is_directory= (RNA_struct_find_property(op->ptr, "directory") != NULL);
+               const short is_relative_path= (RNA_struct_find_property(op->ptr, "relative_path") != NULL);
 
                BLI_strncpy(params->title, op->type->name, sizeof(params->title));
 
@@ -228,6 +229,11 @@ short ED_fileselect_set_params(SpaceFile *sfile)
                        params->display= FILE_SHORTDISPLAY;
                }
 
+               if (is_relative_path) {
+                       if (!RNA_property_is_set(op->ptr, "relative_path")) {
+                               RNA_boolean_set(op->ptr, "relative_path", U.flag & USER_RELPATHS);
+                       }
+               }
        }
        else {
                /* default values, if no operator */
index 33c3ae45a58684b3463c2fa71ba01751e641e9a1..725b5f5c02d372c90957d23b44dc45eafa3ccd3b 100644 (file)
@@ -843,10 +843,6 @@ static int open_invoke(bContext *C, wmOperator *op, wmEvent *UNUSED(event))
 
        if(ima)
                path= ima->name;
-       
-
-       if(!RNA_property_is_set(op->ptr, "relative_path"))
-               RNA_boolean_set(op->ptr, "relative_path", U.flag & USER_RELPATHS);
 
        if(RNA_property_is_set(op->ptr, "filepath"))
                return open_exec(C, op);
@@ -1167,9 +1163,6 @@ static int save_as_invoke(bContext *C, wmOperator *op, wmEvent *UNUSED(event))
        Scene *scene= CTX_data_scene(C);
        SaveImageOptions simopts;
 
-       if(!RNA_property_is_set(op->ptr, "relative_path"))
-               RNA_boolean_set(op->ptr, "relative_path", U.flag & USER_RELPATHS);
-
        if(RNA_property_is_set(op->ptr, "filepath"))
                return save_as_exec(C, op);
 
index b390b7dbdb57cc290f15426be72798c7740843a4..1c4b01308979686f9ce5a702c2c2915c224e0506 100644 (file)
@@ -380,9 +380,6 @@ static int sequencer_add_movie_strip_invoke(bContext *C, wmOperator *op, wmEvent
        
        sequencer_generic_invoke_xy__internal(C, op, event, 0);
        
-       if(!RNA_property_is_set(op->ptr, "relative_path"))
-               RNA_boolean_set(op->ptr, "relative_path", U.flag & USER_RELPATHS);
-       
        WM_event_add_fileselect(C, op);
        return OPERATOR_RUNNING_MODAL;
 
@@ -434,10 +431,7 @@ static int sequencer_add_sound_strip_invoke(bContext *C, wmOperator *op, wmEvent
        }
        
        sequencer_generic_invoke_xy__internal(C, op, event, 0);
-       
-       if(!RNA_property_is_set(op->ptr, "relative_path"))
-               RNA_boolean_set(op->ptr, "relative_path", U.flag & USER_RELPATHS);
-       
+
        WM_event_add_fileselect(C, op);
        return OPERATOR_RUNNING_MODAL;
 
@@ -543,9 +537,6 @@ static int sequencer_add_image_strip_invoke(bContext *C, wmOperator *op, wmEvent
        }
        
        sequencer_generic_invoke_xy__internal(C, op, event, SEQPROP_ENDFRAME);
-       
-       if(!RNA_property_is_set(op->ptr, "relative_path"))
-               RNA_boolean_set(op->ptr, "relative_path", U.flag & USER_RELPATHS);
 
        WM_event_add_fileselect(C, op);
        return OPERATOR_RUNNING_MODAL;
@@ -721,10 +712,6 @@ static int sequencer_add_effect_strip_invoke(bContext *C, wmOperator *op, wmEven
        sequencer_generic_invoke_xy__internal(C, op, event, prop_flag);
 
        if (is_type_set && type==SEQ_PLUGIN) {
-
-               if(!RNA_property_is_set(op->ptr, "relative_path"))
-                       RNA_boolean_set(op->ptr, "relative_path", U.flag & USER_RELPATHS);
-
                /* only plugins need the file selector */
                return WM_operator_filesel(C, op, event);
        }
index eda85f112dfe8b57602566c058e1f77de2805a64..07bab06e52fff1e10eef15a88f73f0a56ad2b919 100644 (file)
@@ -860,7 +860,7 @@ void WM_operator_properties_filesel(wmOperatorType *ot, int filter, short type,
        RNA_def_property_flag(prop, PROP_HIDDEN);
 
        if(flag & WM_FILESEL_RELPATH)
-               RNA_def_boolean(ot->srna, "relative_path", (U.flag & USER_RELPATHS) ? 1:0, "Relative Path", "Select the file relative to the blend file");
+               RNA_def_boolean(ot->srna, "relative_path", TRUE, "Relative Path", "Select the file relative to the blend file");
 }
 
 void WM_operator_properties_select_all(wmOperatorType *ot)
@@ -1618,9 +1618,6 @@ static void WM_OT_open_mainfile(wmOperatorType *ot)
 
 static int wm_link_append_invoke(bContext *C, wmOperator *op, wmEvent *UNUSED(event))
 {
-       if(!RNA_property_is_set(op->ptr, "relative_path"))
-               RNA_boolean_set(op->ptr, "relative_path", U.flag & USER_RELPATHS);
-
        if(RNA_property_is_set(op->ptr, "filepath")) {
                return WM_operator_call(C, op);
        }