+/* NOTE:
+ * This is one of the 'simpler new-style' Insert Keyframe operators which relies on Keying Sets.
+ * For now, these are absolute Keying Sets only, so there is very little context info involved.
+ *
+ * -- Joshua Leung, Feb 2009
+ */
+
+static int insert_key_exec (bContext *C, wmOperator *op)
+{
+ ListBase dsources = {NULL, NULL};
+ Scene *scene= CTX_data_scene(C);
+ KeyingSet *ks= NULL;
+ float cfra= (float)CFRA; // XXX for now, don't bother about all the yucky offset crap
+ short success;
+
+ /* try to get KeyingSet */
+ if (scene->active_keyingset > 0)
+ ks= BLI_findlink(&scene->keyingsets, scene->active_keyingset-1);
+ /* report failure */
+ if (ks == NULL) {
+ BKE_report(op->reports, RPT_ERROR, "No active Keying Set");
+ return OPERATOR_CANCELLED;
+ }
+
+ /* try to insert keyframes for the channels specified by KeyingSet */
+ success= commonkey_modifykey(&dsources, ks, COMMONKEY_MODE_INSERT, cfra);
+ printf("KeyingSet '%s' - Successfully added %d Keyframes \n", ks->name, success);
+
+ /* report failure? */
+ if (success == 0)
+ BKE_report(op->reports, RPT_WARNING, "Keying Set failed to insert any keyframes");
+
+ /* send updates */
+ ED_anim_dag_flush_update(C);
+
+ /* for now, only send ND_KEYS for KeyingSets */
+ WM_event_add_notifier(C, ND_KEYS, NULL);
+
+ return OPERATOR_FINISHED;
+}
+
+void ANIM_OT_insert_keyframe (wmOperatorType *ot)
+{
+ /* identifiers */
+ ot->name= "Insert Keyframe";
+ ot->idname= "ANIM_OT_insert_keyframe";
+
+ /* callbacks */
+ ot->exec= insert_key_exec;
+ ot->poll= ED_operator_areaactive;
+
+ /* flags */
+ ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
+}
+
+/* Delete Key Operator ------------------------ */
+
+/* NOTE:
+ * This is one of the 'simpler new-style' Insert Keyframe operators which relies on Keying Sets.
+ * For now, these are absolute Keying Sets only, so there is very little context info involved.
+ *
+ * -- Joshua Leung, Feb 2009
+ */
+
+static int delete_key_exec (bContext *C, wmOperator *op)
+{
+ ListBase dsources = {NULL, NULL};
+ Scene *scene= CTX_data_scene(C);
+ KeyingSet *ks= NULL;
+ float cfra= (float)CFRA; // XXX for now, don't bother about all the yucky offset crap
+ short success;
+
+ /* try to get KeyingSet */
+ if (scene->active_keyingset > 0)
+ ks= BLI_findlink(&scene->keyingsets, scene->active_keyingset-1);
+ /* report failure */
+ if (ks == NULL) {
+ BKE_report(op->reports, RPT_ERROR, "No active Keying Set");
+ return OPERATOR_CANCELLED;
+ }
+
+ /* try to insert keyframes for the channels specified by KeyingSet */
+ success= commonkey_modifykey(&dsources, ks, COMMONKEY_MODE_DELETE, cfra);
+ printf("KeyingSet '%s' - Successfully removed %d Keyframes \n", ks->name, success);
+
+ /* report failure? */
+ if (success == 0)
+ BKE_report(op->reports, RPT_WARNING, "Keying Set failed to remove any keyframes");
+
+ /* send updates */
+ ED_anim_dag_flush_update(C);
+
+ /* for now, only send ND_KEYS for KeyingSets */
+ WM_event_add_notifier(C, ND_KEYS, NULL);
+
+ return OPERATOR_FINISHED;
+}
+
+void ANIM_OT_delete_keyframe (wmOperatorType *ot)
+{
+ /* identifiers */
+ ot->name= "Delete Keyframe";
+ ot->idname= "ANIM_OT_delete_keyframe";
+
+ /* callbacks */
+ ot->exec= delete_key_exec;
+
+ ot->poll= ED_operator_areaactive;
+
+ /* flags */
+ ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
+}
+
+/* Insert Key Operator ------------------------ */
+