diff options
author | Campbell Barton <ideasman42@gmail.com> | 2009-10-07 17:22:56 +0400 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2009-10-07 17:22:56 +0400 |
commit | 568be173266d42321909b1b9e047d214775c237c (patch) | |
tree | aeb7dbb5d52fca344f41a1ed9287e0983c9553b7 /source/blender/editors/animation/drivers.c | |
parent | 9cf78144f1e6369bc640df783b4ec7b5f2a15235 (diff) |
Option to copy the data path of an RNA button
Diffstat (limited to 'source/blender/editors/animation/drivers.c')
-rw-r--r-- | source/blender/editors/animation/drivers.c | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/source/blender/editors/animation/drivers.c b/source/blender/editors/animation/drivers.c index 363a5a80f00..7a457548623 100644 --- a/source/blender/editors/animation/drivers.c +++ b/source/blender/editors/animation/drivers.c @@ -564,4 +564,48 @@ void ANIM_OT_paste_driver_button (wmOperatorType *ot) ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; } + +/* Paste Driver Button Operator ------------------------ */ + +static int copy_clipboard_button_exec(bContext *C, wmOperator *op) +{ + PointerRNA ptr; + PropertyRNA *prop= NULL; + char *path; + short success= 0; + int index; + + /* try to create driver using property retrieved from UI */ + memset(&ptr, 0, sizeof(PointerRNA)); + uiAnimContextProperty(C, &ptr, &prop, &index); + + if (ptr.data && prop) { // && RNA_property_animateable(ptr.data, prop) + path= RNA_path_from_ID_to_property(&ptr, prop); + + if (path) { + WM_clipboard_text_set(path, FALSE); + MEM_freeN(path); + } + } + + /* since we're just copying, we don't really need to do anything else...*/ + return (success)? OPERATOR_FINISHED: OPERATOR_CANCELLED; +} + +void ANIM_OT_copy_clipboard_button(wmOperatorType *ot) +{ + /* identifiers */ + ot->name= "Copy Data Path"; + ot->idname= "ANIM_OT_copy_clipboard_button"; + ot->description= "Copy the rna data path to the clipboard."; + + /* callbacks */ + ot->exec= copy_clipboard_button_exec; + //op->poll= ??? // TODO: need to have some driver to be able to do this... + + /* flags */ + ot->flag= 0; +} + + /* ************************************************** */ |