Skip to content

How to create a new G Signal ? #10

@SVGAnimate

Description

@SVGAnimate

Hello,

My attempt to answer the question :

define("g_signal_id", 0);// hack to assign dynamic value to invariant const ZOOMED

class MyObject extends GObject {
	/**
	 * @g_signal_new("zoomed",
	 *               self,
	 *               G_SIGNAL_RUN_LAST,
	 *               NULL, NULL, NULL,
	 *               G_TYPE_INT, 1, G_TYPE_INT)
	 */
	const ZOOMED = g_signal_id;// internal hack : change constant ZOOMED value
	protected $zoom = 100;

	function setZoom($value) {
		$this->zoom = $value;
		g_signal_emit($this, self::ZOOMED, 0, $ret);
	}
}

$object = new MyObject();
g_object_connect($object, "signal::zoomed", function(int):int{ echo "callback"; return 0;}, NULL, NULL);
//g_signal_connect($object, "zoomed", function(int):int{ echo "callback"; return 0;}, NULL);
$object->setZoom(51);

Output:
callback

What do you think ?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions