* add exit app with CTRLKEY+QKEY.
[blender-staging.git] / source / blender / windowmanager / intern / wm_operators.c
index 4c26ef4b11579f870a8fcb8b3a9b04091417fdca..05d27c1321abe798f5a39c091544125cd38296d1 100644 (file)
@@ -116,6 +116,16 @@ static void WM_OT_window_fullscreen_toggle(wmOperatorType *ot)
     ot->poll= WM_operator_winactive;
 }
 
+static void WM_OT_exit_blender(wmOperatorType *ot)
+{
+       ot->name= "Exit Blender";
+       ot->idname= "WM_OT_exit_blender";
+
+       ot->invoke= NULL; /* do confirm stuff */
+       ot->exec= wm_exit_blender_op;
+       ot->poll= WM_operator_winactive;
+}
+
 
 #define ADD_OPTYPE(opfunc)     ot= MEM_callocN(sizeof(wmOperatorType), "operatortype"); \
                                                        opfunc(ot);  \
@@ -136,6 +146,7 @@ void wm_operatortype_init(void)
        ADD_OPTYPE(WM_OT_window_duplicate);
        ADD_OPTYPE(WM_OT_save_homefile);
     ADD_OPTYPE(WM_OT_window_fullscreen_toggle);
+       ADD_OPTYPE(WM_OT_exit_blender);
 }
 
 /* wrapped to get property from a operator. */
@@ -158,6 +169,17 @@ void op_init_property(wmOperator *op)
 }
 
 /* ***** Property API, exported ***** */
+void OP_free_property(wmOperator *op)
+{
+       IDP_FreeProperty(op->properties);
+       /*
+        * This need change, when the idprop code only
+        * need call IDP_FreeProperty. (check BKE_idprop.h)
+        */
+       MEM_freeN(op->properties);
+       op->properties= NULL;
+}
+
 void OP_set_int(wmOperator *op, char *name, int value)
 {
        IDPropertyTemplate val;
@@ -171,6 +193,72 @@ void OP_set_int(wmOperator *op, char *name, int value)
        IDP_ReplaceInGroup(op->properties, prop);
 }
 
+void OP_set_float(wmOperator *op, char *name, float value)
+{
+       IDPropertyTemplate val;
+       IDProperty *prop;
+
+       if(!op->properties)
+               op_init_property(op);
+
+       val.f= value;
+       prop= IDP_New(IDP_FLOAT, val, name);
+       IDP_ReplaceInGroup(op->properties, prop);
+}
+
+void OP_set_int_array(wmOperator *op, char *name, int *array, short len)
+{
+       IDPropertyTemplate val;
+       IDProperty *prop;
+       short i;
+       int *pointer;
+
+       if(!op->properties)
+               op_init_property(op);
+
+       val.array.len= len;
+       val.array.type= IDP_INT;
+       prop= IDP_New(IDP_ARRAY, val, name);
+
+       pointer= (int *)prop->data.pointer;
+       for(i= 0; i < len; i++)
+               pointer[i]= array[i];
+       IDP_ReplaceInGroup(op->properties, prop);
+}
+
+void OP_set_float_array(wmOperator *op, char *name, float *array, short len)
+{
+       IDPropertyTemplate val;
+       IDProperty *prop;
+       short i;
+       float *pointer;
+
+       if(!op->properties)
+               op_init_property(op);
+
+       val.array.len= len;
+       val.array.type= IDP_FLOAT;
+       prop= IDP_New(IDP_ARRAY, val, name);
+
+       pointer= (float *) prop->data.pointer;
+       for(i= 0; i < len; i++)
+               pointer[i]= array[i];
+       IDP_ReplaceInGroup(op->properties, prop);
+}
+
+void OP_set_string(wmOperator *op, char *name, char *str)
+{
+       IDPropertyTemplate val;
+       IDProperty *prop;
+
+       if(!op->properties)
+               op_init_property(op);
+
+       val.str= str;
+       prop= IDP_New(IDP_STRING, val, name);
+       IDP_ReplaceInGroup(op->properties, prop);
+}
+
 int OP_get_int(wmOperator *op, char *name, int *value)
 {
        IDProperty *prop= op_get_property(op, name);
@@ -182,3 +270,61 @@ int OP_get_int(wmOperator *op, char *name, int *value)
        }
        return (status);
 }
+
+int OP_get_float(wmOperator *op, char *name, float *value)
+{
+       IDProperty *prop= op_get_property(op, name);
+       int status= 1;
+
+       if ((prop) && (prop->type == IDP_FLOAT)) {
+               (*value)= *(float*)&prop->data.val;
+               status= 0;
+       }
+       return (status);
+}
+
+int OP_get_int_array(wmOperator *op, char *name, int *array, short *len)
+{
+       IDProperty *prop= op_get_property(op, name);
+       short i;
+       int status= 1;
+       int *pointer;
+
+       if ((prop) && (prop->type == IDP_ARRAY)) {
+               pointer= (int *) prop->data.pointer;
+
+               for(i= 0; (i < prop->len) && (i < *len); i++)
+                       array[i]= pointer[i];
+
+               (*len)= i;
+               status= 0;
+       }
+       return (status);
+}
+
+int OP_get_float_array(wmOperator *op, char *name, float *array, short *len)
+{
+       IDProperty *prop= op_get_property(op, name);
+       short i;
+       float *pointer;
+       int status= 1;
+
+       if ((prop) && (prop->type == IDP_ARRAY)) {
+               pointer= (float *) prop->data.pointer;
+
+               for(i= 0; (i < prop->len) && (i < *len); i++)
+                       array[i]= pointer[i];
+
+               (*len)= i;
+               status= 0;
+       }
+       return (status);
+}
+
+char *OP_get_string(wmOperator *op, char *name)
+{
+       IDProperty *prop= op_get_property(op, name);
+       if ((prop) && (prop->type == IDP_STRING))
+               return ((char *) prop->data.pointer);
+       return (NULL);
+}