Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to create a new G Signal ? #10

Open
SVGAnimate opened this issue Nov 5, 2021 · 0 comments
Open

How to create a new G Signal ? #10

SVGAnimate opened this issue Nov 5, 2021 · 0 comments

Comments

@SVGAnimate
Copy link

SVGAnimate commented Nov 5, 2021

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 ?

@SVGAnimate SVGAnimate changed the title How to create a signal ? How to create a new G Signal ? Nov 6, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant