static int reset_default_button_exec(bContext *C, wmOperator *op)
{
    PointerRNA ptr;
    PropertyRNA *prop;
    int index, all = RNA_boolean_get(op->ptr, "all");

    /* try to reset the nominated setting to its default value */
    uiContextActiveProperty(C, &ptr, &prop, &index);

    /* if there is a valid property that is editable... */
    if (ptr.data && prop && RNA_property_editable(&ptr, prop)) {
        if (RNA_property_reset(&ptr, prop, (all) ? -1 : index))
            return operator_button_property_finish(C, &ptr, prop);
    }

    return OPERATOR_CANCELLED;
}
Exemple #2
0
static int reset_default_button_exec(bContext *C, wmOperator *op)
{
	PointerRNA ptr;
	PropertyRNA *prop;
	int success= 0;
	int index, all = RNA_boolean_get(op->ptr, "all");

	/* try to reset the nominated setting to its default value */
	uiContextActiveProperty(C, &ptr, &prop, &index);
	
	/* if there is a valid property that is editable... */
	if (ptr.data && prop && RNA_property_editable(&ptr, prop)) {
		if(RNA_property_reset(&ptr, prop, (all)? -1: index)) {
			/* perform updates required for this property */
			RNA_property_update(C, &ptr, prop);
			success= 1;
		}
	}
	
	return (success)? OPERATOR_FINISHED: OPERATOR_CANCELLED;
}
Exemple #3
0
static int reset_default_button_exec(bContext *C, wmOperator *op)
{
	PointerRNA ptr;
	PropertyRNA *prop;
	int success= 0;
	int index, all = RNA_boolean_get(op->ptr, "all");

	/* try to reset the nominated setting to its default value */
	uiContextActiveProperty(C, &ptr, &prop, &index);
	
	/* if there is a valid property that is editable... */
	if (ptr.data && prop && RNA_property_editable(&ptr, prop)) {
		if(RNA_property_reset(&ptr, prop, (all)? -1: index)) {
			/* perform updates required for this property */
			RNA_property_update(C, &ptr, prop);

			/* as if we pressed the button */
			uiContextActivePropertyHandle(C);

			success= 1;
		}
	}

	/* Since we dont want to undo _all_ edits to settings, eg window
	 * edits on the screen or on operator settings.
	 * it might be better to move undo's inline - campbell */
	if(success) {
		ID *id= ptr.id.data;
		if(id && ID_CHECK_UNDO(id)) {
			/* do nothing, go ahead with undo */
		}
		else {
			return OPERATOR_CANCELLED;
		}
	}
	/* end hack */

	return (success)? OPERATOR_FINISHED: OPERATOR_CANCELLED;
}