/* * call-seq: * add_action(action, label, user_data) { |action, user_data| ... } * * action = The action id * * label = The action label * * user_data = Custom data to pass into the block (optional) * * Adds an action. When the action is invoked, the specified block will be called * * Examples: * * myinstance.add_action( "MyAction", "MyLabel" ) do |action| * # something to do * end * * Or * * myinstance.add_action( "MyAction", "MyLabel", MyData ) do |action, mydata| * # something to do * end */ static VALUE _wrap_notification_add_action(int argc, VALUE *argv, VALUE self) { NotifyNotification *n = NOTIFY_NOTIFICATION(RVAL2GOBJ(self)); VALUE action, label, data, body; ActionData *actionData = NULL; #ifdef DEBUG if(NOTIFY_IS_NOTIFICATION(n)) rb_warn("add_action, ok"); else rb_warn("add_action, no ok"); #endif if(!rb_block_given_p()) rb_raise(rb_eRuntimeError, "This method requires a block"); rb_scan_args(argc, argv, "21&", &action, &label, &data, &body); actionData = g_new0(ActionData, 1); actionData->callback = body; actionData->action = action; actionData->user_data = data; notify_notification_add_action(n, NIL_P(action) ? NULL : StringValuePtr(action), NIL_P(label) ? NULL : StringValuePtr(label), (NotifyActionCallback) _notification_action_cb, actionData, (GFreeFunc)_notification_action_free); return Qnil; }