code cleanup: move file string defines into BLI_path_utils.h, BKE_utildefines is...
[blender.git] / source / blender / editors / animation / drivers.c
index 75b54a7529a5706e0c5bcbb26f566225c5cfe9d6..672e11ac61363e99c34cd893071cdf12c670eb46 100644 (file)
@@ -1,6 +1,4 @@
 /*
- * $Id$
- *
  * ***** BEGIN GPL LICENSE BLOCK *****
  *
  * This program is free software; you can redistribute it and/or
@@ -68,7 +66,7 @@
 #include "anim_intern.h"
 
 /* called by WM */
-void free_anim_drivers_copybuf (void);
+void free_anim_drivers_copybuf(void);
 
 /* ************************************************** */
 /* Animation Data Validation */
@@ -80,19 +78,19 @@ void free_anim_drivers_copybuf (void);
  *                     1 - add new Driver FCurve, 
  *                     -1 - add new Driver FCurve without driver stuff (for pasting)
  */
-static FCurve *verify_driver_fcurve (ID *id, const char rna_path[], const int array_index, short add)
+FCurve *verify_driver_fcurve(ID *id, const char rna_path[], const int array_index, short add)
 {
        AnimData *adt;
        FCurve *fcu;
        
        /* sanity checks */
-       if ELEM(NULL, id, rna_path)
+       if (ELEM(NULL, id, rna_path))
                return NULL;
        
        /* init animdata if none available yet */
-       adt= BKE_animdata_from_id(id);
+       adt = BKE_animdata_from_id(id);
        if ((adt == NULL) && (add))
-               adt= BKE_id_add_animdata(id);
+               adt = BKE_id_add_animdata(id);
        if (adt == NULL) { 
                /* if still none (as not allowed to add, or ID doesn't have animdata for some reason) */
                return NULL;
@@ -102,22 +100,22 @@ static FCurve *verify_driver_fcurve (ID *id, const char rna_path[], const int ar
         *      - add if not found and allowed to add one
         *              TODO: add auto-grouping support? how this works will need to be resolved
         */
-       fcu= list_find_fcurve(&adt->drivers, rna_path, array_index);
+       fcu = list_find_fcurve(&adt->drivers, rna_path, array_index);
        
        if ((fcu == NULL) && (add)) {
                /* use default settings to make a F-Curve */
-               fcu= MEM_callocN(sizeof(FCurve), "FCurve");
+               fcu = MEM_callocN(sizeof(FCurve), "FCurve");
                
-               fcu->flag = (FCURVE_VISIBLE|FCURVE_AUTO_HANDLES|FCURVE_SELECTED);
+               fcu->flag = (FCURVE_VISIBLE | FCURVE_SELECTED);
                
                /* store path - make copy, and store that */
-               fcu->rna_path= BLI_strdupn(rna_path, strlen(rna_path));
-               fcu->array_index= array_index;
+               fcu->rna_path = BLI_strdupn(rna_path, strlen(rna_path));
+               fcu->array_index = array_index;
                
                /* if add is negative, don't init this data yet, since it will be filled in by the pasted driver */
                if (add > 0) {
                        /* add some new driver data */
-                       fcu->driver= MEM_callocN(sizeof(ChannelDriver), "ChannelDriver");
+                       fcu->driver = MEM_callocN(sizeof(ChannelDriver), "ChannelDriver");
                        
                        /* add simple generator modifier for driver so that there is some visible representation */
                        add_fmodifier(&fcu->modifiers, FMODIFIER_TYPE_GENERATOR);
@@ -135,32 +133,32 @@ static FCurve *verify_driver_fcurve (ID *id, const char rna_path[], const int ar
 /* Driver Management API */
 
 /* Main Driver Management API calls:
- *     Add a new driver for the specified property on the given ID block
+ *  Add a new driver for the specified property on the given ID block
  */
-short ANIM_add_driver (ReportList *reports, ID *id, const char rna_path[], int array_index, short flag, int type)
+short ANIM_add_driver(ReportList *reports, ID *id, const char rna_path[], int array_index, short flag, int type)
 {      
        PointerRNA id_ptr, ptr;
        PropertyRNA *prop;
        FCurve *fcu;
        int array_index_max;
-       int done = 0;
+       int done = FALSE;
        
        /* validate pointer first - exit if failure */
        RNA_id_pointer_create(id, &id_ptr);
        if ((RNA_path_resolve(&id_ptr, rna_path, &ptr, &prop) == 0) || (prop == NULL)) {
                BKE_reportf(reports, RPT_ERROR, 
-                       "Could not add Driver, as RNA Path is invalid for the given ID (ID = %s, Path = %s)", 
-                       id->name, rna_path);
+                           "Could not add Driver, as RNA Path is invalid for the given ID (ID = %s, Path = %s)",
+                           id->name, rna_path);
                return 0;
        }
        
        /* key entire array convenience method */
        if (array_index == -1) {
-               array_index_max= RNA_property_array_length(&ptr, prop);
-               array_index= 0;
+               array_index_max = RNA_property_array_length(&ptr, prop);
+               array_index = 0;
        }
        else
-               array_index_max= array_index;
+               array_index_max = array_index;
        
        /* maximum index should be greater than the start index */
        if (array_index == array_index_max)
@@ -169,40 +167,40 @@ short ANIM_add_driver (ReportList *reports, ID *id, const char rna_path[], int a
        /* will only loop once unless the array index was -1 */
        for (; array_index < array_index_max; array_index++) {
                /* create F-Curve with Driver */
-               fcu= verify_driver_fcurve(id, rna_path, array_index, 1);
+               fcu = verify_driver_fcurve(id, rna_path, array_index, 1);
                
                if (fcu && fcu->driver) {
-                       ChannelDriver *driver= fcu->driver;
+                       ChannelDriver *driver = fcu->driver;
                        
                        /* set the type of the driver */
-                       driver->type= type;
+                       driver->type = type;
                        
                        /* creating drivers for buttons will create the driver(s) with type 
                         * "scripted expression" so that their values won't be lost immediately,
                         * so here we copy those values over to the driver's expression
                         */
                        if (type == DRIVER_TYPE_PYTHON) {
-                               PropertyType proptype= RNA_property_type(prop);
-                               int array= RNA_property_array_length(&ptr, prop);
-                               char *expression= driver->expression;
-                               int val, maxlen= sizeof(driver->expression);
+                               PropertyType proptype = RNA_property_type(prop);
+                               int array = RNA_property_array_length(&ptr, prop);
+                               char *expression = driver->expression;
+                               int val, maxlen = sizeof(driver->expression);
                                float fval;
                                
                                if (proptype == PROP_BOOLEAN) {
-                                       if (!array) val= RNA_property_boolean_get(&ptr, prop);
-                                       else val= RNA_property_boolean_get_index(&ptr, prop, array_index);
+                                       if (!array) val = RNA_property_boolean_get(&ptr, prop);
+                                       else val = RNA_property_boolean_get_index(&ptr, prop, array_index);
                                        
-                                       BLI_strncpy(expression, (val)? "True": "False", maxlen);
+                                       BLI_strncpy(expression, (val) ? "True" : "False", maxlen);
                                }
                                else if (proptype == PROP_INT) {
-                                       if (!array) val= RNA_property_int_get(&ptr, prop);
-                                       else val= RNA_property_int_get_index(&ptr, prop, array_index);
+                                       if (!array) val = RNA_property_int_get(&ptr, prop);
+                                       else val = RNA_property_int_get_index(&ptr, prop, array_index);
                                        
                                        BLI_snprintf(expression, maxlen, "%d", val);
                                }
                                else if (proptype == PROP_FLOAT) {
-                                       if (!array) fval= RNA_property_float_get(&ptr, prop);
-                                       else fval= RNA_property_float_get_index(&ptr, prop, array_index);
+                                       if (!array) fval = RNA_property_float_get(&ptr, prop);
+                                       else fval = RNA_property_float_get_index(&ptr, prop, array_index);
                                        
                                        BLI_snprintf(expression, maxlen, "%.3f", fval);
                                }
@@ -229,25 +227,25 @@ short ANIM_add_driver (ReportList *reports, ID *id, const char rna_path[], int a
 }
 
 /* Main Driver Management API calls:
- *     Remove the driver for the specified property on the given ID block (if available)
+ *  Remove the driver for the specified property on the given ID block (if available)
  */
-short ANIM_remove_driver (ReportList *UNUSED(reports), ID *id, const char rna_path[], int array_index, short UNUSED(flag))
+short ANIM_remove_driver(ReportList *UNUSED(reports), ID *id, const char rna_path[], int array_index, short UNUSED(flag))
 {
        AnimData *adt;
        FCurve *fcu;
-       int success= 0;
+       int success = 0;
        
        /* we don't check the validity of the path here yet, but it should be ok... */
-       adt= BKE_animdata_from_id(id);
+       adt = BKE_animdata_from_id(id);
        
        if (adt) {
                if (array_index == -1) {
                        /* step through all drivers, removing all of those with the same base path */
-                       FCurve *fcu_iter= adt->drivers.first;
+                       FCurve *fcu_iter = adt->drivers.first;
                        
                        while ((fcu = iter_step_fcurve(fcu_iter, rna_path)) != NULL) {
                                /* store the next fcurve for looping  */
-                               fcu_iter= fcu->next;
+                               fcu_iter = fcu->next;
                                
                                /* remove F-Curve from driver stack, then free it */
                                BLI_remlink(&adt->drivers, fcu);
@@ -260,9 +258,9 @@ short ANIM_remove_driver (ReportList *UNUSED(reports), ID *id, const char rna_pa
                else {
                        /* find the matching driver and remove it only 
                         * Note: here is one of the places where we don't want new F-Curve + Driver added!
-                        *              so 'add' var must be 0
+                        *      so 'add' var must be 0
                         */
-                       fcu= verify_driver_fcurve(id, rna_path, array_index, 0);
+                       fcu = verify_driver_fcurve(id, rna_path, array_index, 0);
                        if (fcu) {
                                BLI_remlink(&adt->drivers, fcu);
                                free_fcurve(fcu);
@@ -283,16 +281,16 @@ static FCurve *channeldriver_copypaste_buf = NULL;
 
 /* This function frees any MEM_calloc'ed copy/paste buffer data */
 // XXX find some header to put this in!
-void free_anim_drivers_copybuf (void)
+void free_anim_drivers_copybuf(void)
 {
        /* free the buffer F-Curve if it exists, as if it were just another F-Curve */
        if (channeldriver_copypaste_buf)
                free_fcurve(channeldriver_copypaste_buf);
-       channeldriver_copypaste_buf= NULL;
+       channeldriver_copypaste_buf = NULL;
 }
 
 /* Checks if there is a driver in the copy/paste buffer */
-short ANIM_driver_can_paste (void)
+short ANIM_driver_can_paste(void)
 {
        return (channeldriver_copypaste_buf != NULL);
 }
@@ -300,9 +298,9 @@ short ANIM_driver_can_paste (void)
 /* ------------------- */
 
 /* Main Driver Management API calls:
- *     Make a copy of the driver for the specified property on the given ID block
+ *  Make a copy of the driver for the specified property on the given ID block
  */
-short ANIM_copy_driver (ReportList *reports, ID *id, const char rna_path[], int array_index, short UNUSED(flag))
+short ANIM_copy_driver(ReportList *reports, ID *id, const char rna_path[], int array_index, short UNUSED(flag))
 {
        PointerRNA id_ptr, ptr;
        PropertyRNA *prop;
@@ -312,13 +310,13 @@ short ANIM_copy_driver (ReportList *reports, ID *id, const char rna_path[], int
        RNA_id_pointer_create(id, &id_ptr);
        if ((RNA_path_resolve(&id_ptr, rna_path, &ptr, &prop) == 0) || (prop == NULL)) {
                BKE_reportf(reports, RPT_ERROR,
-                       "Could not find Driver to copy, as RNA Path is invalid for the given ID (ID = %s, Path = %s)", 
-                       id->name, rna_path);
+                           "Could not find Driver to copy, as RNA Path is invalid for the given ID (ID = %s, Path = %s)",
+                           id->name, rna_path);
                return 0;
        }
        
        /* try to get F-Curve with Driver */
-       fcu= verify_driver_fcurve(id, rna_path, array_index, 0);
+       fcu = verify_driver_fcurve(id, rna_path, array_index, 0);
        
        /* clear copy/paste buffer first (for consistency with other copy/paste buffers) */
        free_anim_drivers_copybuf();
@@ -329,13 +327,13 @@ short ANIM_copy_driver (ReportList *reports, ID *id, const char rna_path[], int
                 * so that we don't end up wasting memory storing the path which won't get used ever...
                 */
                char *tmp_path = fcu->rna_path;
-               fcu->rna_path= NULL;
+               fcu->rna_path = NULL;
                
                /* make a copy of the F-Curve with */
-               channeldriver_copypaste_buf= copy_fcurve(fcu);
+               channeldriver_copypaste_buf = copy_fcurve(fcu);
                
                /* restore the path */
-               fcu->rna_path= tmp_path;
+               fcu->rna_path = tmp_path;
                
                /* copied... */
                return 1;
@@ -346,10 +344,10 @@ short ANIM_copy_driver (ReportList *reports, ID *id, const char rna_path[], int
 }
 
 /* Main Driver Management API calls:
- *     Add a new driver for the specified property on the given ID block or replace an existing one
+ *  Add a new driver for the specified property on the given ID block or replace an existing one
  *     with the driver + driver-curve data from the buffer 
  */
-short ANIM_paste_driver (ReportList *reports, ID *id, const char rna_path[], int array_index, short UNUSED(flag))
+short ANIM_paste_driver(ReportList *reports, ID *id, const char rna_path[], int array_index, short UNUSED(flag))
 {      
        PointerRNA id_ptr, ptr;
        PropertyRNA *prop;
@@ -359,42 +357,37 @@ short ANIM_paste_driver (ReportList *reports, ID *id, const char rna_path[], int
        RNA_id_pointer_create(id, &id_ptr);
        if ((RNA_path_resolve(&id_ptr, rna_path, &ptr, &prop) == 0) || (prop == NULL)) {
                BKE_reportf(reports, RPT_ERROR,
-                       "Could not paste Driver, as RNA Path is invalid for the given ID (ID = %s, Path = %s)", 
-                       id->name, rna_path);
+                           "Could not paste Driver, as RNA Path is invalid for the given ID (ID = %s, Path = %s)",
+                           id->name, rna_path);
                return 0;
        }
        
        /* if the buffer is empty, cannot paste... */
        if (channeldriver_copypaste_buf == NULL) {
-               BKE_report(reports, RPT_ERROR, "Paste Driver: No Driver to paste.");
+               BKE_report(reports, RPT_ERROR, "Paste Driver: No Driver to paste");
                return 0;
        }
        
        /* create Driver F-Curve, but without data which will be copied across... */
-       fcu= verify_driver_fcurve(id, rna_path, array_index, -1);
+       fcu = verify_driver_fcurve(id, rna_path, array_index, -1);
 
        if (fcu) {
                /* copy across the curve data from the buffer curve 
                 * NOTE: this step needs care to not miss new settings
                 */
-                       /* keyframes/samples */
-               fcu->bezt= MEM_dupallocN(channeldriver_copypaste_buf->bezt);
-               fcu->fpt= MEM_dupallocN(channeldriver_copypaste_buf->fpt);
-               fcu->totvert= channeldriver_copypaste_buf->totvert;
+               /* keyframes/samples */
+               fcu->bezt = MEM_dupallocN(channeldriver_copypaste_buf->bezt);
+               fcu->fpt = MEM_dupallocN(channeldriver_copypaste_buf->fpt);
+               fcu->totvert = channeldriver_copypaste_buf->totvert;
                
-                       /* modifiers */
+               /* modifiers */
                copy_fmodifiers(&fcu->modifiers, &channeldriver_copypaste_buf->modifiers);
                
-                       /* flags - on a per-relevant-flag basis */
-               if (channeldriver_copypaste_buf->flag & FCURVE_AUTO_HANDLES)
-                       fcu->flag |= FCURVE_AUTO_HANDLES;
-               else
-                       fcu->flag &= ~FCURVE_AUTO_HANDLES;
-                       /* extrapolation mode */
-               fcu->extend= channeldriver_copypaste_buf->extend;
+               /* extrapolation mode */
+               fcu->extend = channeldriver_copypaste_buf->extend;
                        
-                       /* the 'juicy' stuff - the driver */
-               fcu->driver= fcurve_copy_driver(channeldriver_copypaste_buf->driver);
+               /* the 'juicy' stuff - the driver */
+               fcu->driver = fcurve_copy_driver(channeldriver_copypaste_buf->driver);
        }
        
        /* done */
@@ -414,7 +407,7 @@ short ANIM_paste_driver (ReportList *reports, ID *id, const char rna_path[], int
  *
  * > returns: MEM_alloc'd string representing the path to the property from the given PointerRNA
  */
-static char *get_driver_path_hack (bContext *C, PointerRNA *ptr, PropertyRNA *prop)
+static char *get_driver_path_hack(bContext *C, PointerRNA *ptr, PropertyRNA *prop)
 {
        ID *id = (ID *)ptr->id.data;
        ScrArea *sa = CTX_wm_area(C);
@@ -423,6 +416,7 @@ static char *get_driver_path_hack (bContext *C, PointerRNA *ptr, PropertyRNA *pr
        char *basepath = RNA_path_from_ID_to_property(ptr, prop);
        char *path = basepath; /* in case no remapping is needed */
        
+       
        /* Remapping will only be performed in the Properties Editor, as only this 
         * restricts the subspace of options to the 'active' data (a manageable state)
         */
@@ -433,40 +427,24 @@ static char *get_driver_path_hack (bContext *C, PointerRNA *ptr, PropertyRNA *pr
                if (ob && id) {
                        /* only id-types which can be remapped to go through objects should be considered */
                        switch (GS(id->name)) {
-                               case ID_MA: /* materials */
-                               {
-                                       Material *ma = give_current_material(ob, ob->actcol);
-                                       
-                                       /* assumes: material will only be shown if it is active objects's active material it's ok */
-                                       if ((ID*)ma == id) {
-                                               /* create new path */
-                                               // TODO: use RNA path functions to construct instead?
-                                               path = BLI_sprintfN("material_slots[\"%s\"].material.%s",
-                                                       ma->id.name+2, basepath);
-                                                       
-                                               /* free old one */
-                                               MEM_freeN(basepath);
-                                       }
-                               }
-                                       break;
-                                       
                                case ID_TE: /* textures */
                                {
                                        Material *ma = give_current_material(ob, ob->actcol);
                                        Tex *tex = give_current_material_texture(ma);
                                        
                                        /* assumes: texture will only be shown if it is active material's active texture it's ok */
-                                       if ((ID*)tex == id) {
+                                       if ((ID *)tex == id) {
                                                /* create new path */
                                                // TODO: use RNA path functions to construct step by step instead?
+                                               // FIXME: maybe this isn't even needed anymore...
                                                path = BLI_sprintfN("material_slots[\"%s\"].material.texture_slots[\"%s\"].texture.%s", 
-                                                       ma->id.name+2, tex->id.name+2, basepath);
+                                                                   ma->id.name + 2, tex->id.name + 2, basepath);
                                                        
                                                /* free old one */
                                                MEM_freeN(basepath);
                                        }
                                }
-                                       break;
+                               break;
                        }
                        
                        /* fix RNA pointer, as we've now changed the ID root by changing the paths */
@@ -483,25 +461,25 @@ static char *get_driver_path_hack (bContext *C, PointerRNA *ptr, PropertyRNA *pr
 
 /* Add Driver Button Operator ------------------------ */
 
-static int add_driver_button_exec (bContext *C, wmOperator *op)
+static int add_driver_button_exec(bContext *C, wmOperator *op)
 {
-       PointerRNA ptr= {{NULL}};
-       PropertyRNA *prop= NULL;
-       short success= 0;
-       int index, all= RNA_boolean_get(op->ptr, "all");
+       PointerRNA ptr = {{NULL}};
+       PropertyRNA *prop = NULL;
+       short success = 0;
+       int index, all = RNA_boolean_get(op->ptr, "all");
        
        /* try to create driver using property retrieved from UI */
        uiContextActiveProperty(C, &ptr, &prop, &index);
        
        if (all)
-               index= -1;
+               index = -1;
        
        if (ptr.id.data && ptr.data && prop && RNA_property_animateable(&ptr, prop)) {
-               char *path= get_driver_path_hack(C, &ptr, prop);
+               char *path = get_driver_path_hack(C, &ptr, prop);
                short flags = CREATEDRIVER_WITH_DEFAULT_DVAR;
                
                if (path) {                     
-                       success+= ANIM_add_driver(op->reports, ptr.id.data, path, index, flags, DRIVER_TYPE_PYTHON);
+                       success += ANIM_add_driver(op->reports, ptr.id.data, path, index, flags, DRIVER_TYPE_PYTHON);
                        
                        MEM_freeN(path);
                }
@@ -513,49 +491,49 @@ static int add_driver_button_exec (bContext *C, wmOperator *op)
                
                DAG_ids_flush_update(CTX_data_main(C), 0);
                
-               WM_event_add_notifier(C, NC_ANIMATION|ND_FCURVES_ORDER, NULL); // XXX
+               WM_event_add_notifier(C, NC_ANIMATION | ND_FCURVES_ORDER, NULL); // XXX
        }
        
-       return (success)? OPERATOR_FINISHED: OPERATOR_CANCELLED;
+       return (success) ? OPERATOR_FINISHED : OPERATOR_CANCELLED;
 }
 
-void ANIM_OT_driver_button_add (wmOperatorType *ot)
+void ANIM_OT_driver_button_add(wmOperatorType *ot)
 {
        /* identifiers */
-       ot->name= "Add Driver";
-       ot->idname= "ANIM_OT_driver_button_add";
-       ot->description= "Add driver(s) for the property(s) connected represented by the highlighted button";
+       ot->name = "Add Driver";
+       ot->idname = "ANIM_OT_driver_button_add";
+       ot->description = "Add driver(s) for the property(s) connected represented by the highlighted button";
        
        /* callbacks */
-       ot->exec= add_driver_button_exec; 
-       //op->poll= ??? // TODO: need to have some animateable property to do this
+       ot->exec = add_driver_button_exec; 
+       //op->poll = ??? // TODO: need to have some animatable property to do this
        
        /* flags */
-       ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
+       ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
 
        /* properties */
-       RNA_def_boolean(ot->srna, "all", 1, "All", "Create drivers for all elements of the array.");
+       RNA_def_boolean(ot->srna, "all", 1, "All", "Create drivers for all elements of the array");
 }
 
 /* Remove Driver Button Operator ------------------------ */
 
-static int remove_driver_button_exec (bContext *C, wmOperator *op)
+static int remove_driver_button_exec(bContext *C, wmOperator *op)
 {
-       PointerRNA ptr= {{NULL}};
-       PropertyRNA *prop= NULL;
-       short success= 0;
-       int index, all= RNA_boolean_get(op->ptr, "all");
+       PointerRNA ptr = {{NULL}};
+       PropertyRNA *prop = NULL;
+       short success = 0;
+       int index, all = RNA_boolean_get(op->ptr, "all");
        
        /* try to find driver using property retrieved from UI */
        uiContextActiveProperty(C, &ptr, &prop, &index);
        
        if (all)
-               index= -1;
+               index = -1;
        
        if (ptr.id.data && ptr.data && prop) {
-               char *path= get_driver_path_hack(C, &ptr, prop);
+               char *path = get_driver_path_hack(C, &ptr, prop);
                
-               success= ANIM_remove_driver(op->reports, ptr.id.data, path, index, 0);
+               success = ANIM_remove_driver(op->reports, ptr.id.data, path, index, 0);
                MEM_freeN(path);
        }
        
@@ -565,48 +543,48 @@ static int remove_driver_button_exec (bContext *C, wmOperator *op)
                
                DAG_ids_flush_update(CTX_data_main(C), 0);
                
-               WM_event_add_notifier(C, NC_ANIMATION|ND_FCURVES_ORDER, NULL);  // XXX
+               WM_event_add_notifier(C, NC_ANIMATION | ND_FCURVES_ORDER, NULL);  // XXX
        }
        
-       return (success)? OPERATOR_FINISHED: OPERATOR_CANCELLED;
+       return (success) ? OPERATOR_FINISHED : OPERATOR_CANCELLED;
 }
 
-void ANIM_OT_driver_button_remove (wmOperatorType *ot)
+void ANIM_OT_driver_button_remove(wmOperatorType *ot)
 {
        /* identifiers */
-       ot->name= "Remove Driver";
-       ot->idname= "ANIM_OT_driver_button_remove";
-       ot->description= "Remove the driver(s) for the property(s) connected represented by the highlighted button";
+       ot->name = "Remove Driver";
+       ot->idname = "ANIM_OT_driver_button_remove";
+       ot->description = "Remove the driver(s) for the property(s) connected represented by the highlighted button";
        
        /* callbacks */
-       ot->exec= remove_driver_button_exec; 
-       //op->poll= ??? // TODO: need to have some driver to be able to do this...
+       ot->exec = remove_driver_button_exec; 
+       //op->poll = ??? // TODO: need to have some driver to be able to do this...
        
        /* flags */
-       ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
+       ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
 
        /* properties */
-       RNA_def_boolean(ot->srna, "all", 1, "All", "Delete drivers for all elements of the array.");
+       RNA_def_boolean(ot->srna, "all", 1, "All", "Delete drivers for all elements of the array");
 }
 
 /* Copy Driver Button Operator ------------------------ */
 
-static int copy_driver_button_exec (bContext *C, wmOperator *op)
+static int copy_driver_button_exec(bContext *C, wmOperator *op)
 {
-       PointerRNA ptr= {{NULL}};
-       PropertyRNA *prop= NULL;
-       short success= 0;
+       PointerRNA ptr = {{NULL}};
+       PropertyRNA *prop = NULL;
+       short success = 0;
        int index;
        
        /* try to create driver using property retrieved from UI */
        uiContextActiveProperty(C, &ptr, &prop, &index);
        
        if (ptr.id.data && ptr.data && prop && RNA_property_animateable(&ptr, prop)) {
-               char *path= get_driver_path_hack(C, &ptr, prop);
+               char *path = get_driver_path_hack(C, &ptr, prop);
                
                if (path) {
                        /* only copy the driver for the button that this was involved for */
-                       success= ANIM_copy_driver(op->reports, ptr.id.data, path, index, 0);
+                       success = ANIM_copy_driver(op->reports, ptr.id.data, path, index, 0);
                        
                        uiContextAnimUpdate(C);
                        
@@ -615,42 +593,42 @@ static int copy_driver_button_exec (bContext *C, wmOperator *op)
        }
        
        /* since we're just copying, we don't really need to do anything else...*/
-       return (success)? OPERATOR_FINISHED: OPERATOR_CANCELLED;
+       return (success) ? OPERATOR_FINISHED : OPERATOR_CANCELLED;
 }
 
-void ANIM_OT_copy_driver_button (wmOperatorType *ot)
+void ANIM_OT_copy_driver_button(wmOperatorType *ot)
 {
        /* identifiers */
-       ot->name= "Copy Driver";
-       ot->idname= "ANIM_OT_copy_driver_button";
-       ot->description= "Copy the driver for the highlighted button";
+       ot->name = "Copy Driver";
+       ot->idname = "ANIM_OT_copy_driver_button";
+       ot->description = "Copy the driver for the highlighted button";
        
        /* callbacks */
-       ot->exec= copy_driver_button_exec; 
-       //op->poll= ??? // TODO: need to have some driver to be able to do this...
+       ot->exec = copy_driver_button_exec; 
+       //op->poll = ??? // TODO: need to have some driver to be able to do this...
        
        /* flags */
-       ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
+       ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
 }
 
 /* Paste Driver Button Operator ------------------------ */
 
-static int paste_driver_button_exec (bContext *C, wmOperator *op)
+static int paste_driver_button_exec(bContext *C, wmOperator *op)
 {
-       PointerRNA ptr= {{NULL}};
-       PropertyRNA *prop= NULL;
-       short success= 0;
+       PointerRNA ptr = {{NULL}};
+       PropertyRNA *prop = NULL;
+       short success = 0;
        int index;
        
        /* try to create driver using property retrieved from UI */
        uiContextActiveProperty(C, &ptr, &prop, &index);
        
        if (ptr.id.data && ptr.data && prop && RNA_property_animateable(&ptr, prop)) {
-               char *path= get_driver_path_hack(C, &ptr, prop);
+               char *path = get_driver_path_hack(C, &ptr, prop);
                
                if (path) {
                        /* only copy the driver for the button that this was involved for */
-                       success= ANIM_paste_driver(op->reports, ptr.id.data, path, index, 0);
+                       success = ANIM_paste_driver(op->reports, ptr.id.data, path, index, 0);
                        
                        uiContextAnimUpdate(C);
                        
@@ -659,22 +637,22 @@ static int paste_driver_button_exec (bContext *C, wmOperator *op)
        }
        
        /* since we're just copying, we don't really need to do anything else...*/
-       return (success)? OPERATOR_FINISHED: OPERATOR_CANCELLED;
+       return (success) ? OPERATOR_FINISHED : OPERATOR_CANCELLED;
 }
 
-void ANIM_OT_paste_driver_button (wmOperatorType *ot)
+void ANIM_OT_paste_driver_button(wmOperatorType *ot)
 {
        /* identifiers */
-       ot->name= "Paste Driver";
-       ot->idname= "ANIM_OT_paste_driver_button";
-       ot->description= "Paste the driver in the copy/paste buffer for the highlighted button";
+       ot->name = "Paste Driver";
+       ot->idname = "ANIM_OT_paste_driver_button";
+       ot->description = "Paste the driver in the copy/paste buffer for the highlighted button";
        
        /* callbacks */
-       ot->exec= paste_driver_button_exec; 
-       //op->poll= ??? // TODO: need to have some driver to be able to do this...
+       ot->exec = paste_driver_button_exec; 
+       //op->poll = ??? // TODO: need to have some driver to be able to do this...
        
        /* flags */
-       ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
+       ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
 }
 
 /* ************************************************** */