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 define signals? #328

Open
tokyob0t opened this issue Dec 4, 2024 · 2 comments
Open

How to define signals? #328

tokyob0t opened this issue Dec 4, 2024 · 2 comments

Comments

@tokyob0t
Copy link

tokyob0t commented Dec 4, 2024

So, im trying to make a custom GObject.Object with custom props/signals but idk how to

atm i know how to define custom props

local MyClass = GObject.Object:derive('MyClass')

MyClass._property.my_property =
    GObject.ParamSpecString('my_property', 'my_property', 'my_property', '', { 'READWRITE' })

MyClass._signal.my_signal = {} -- ????? idk what goes here

local obj = MyClass { my_property = 'Hello, World!' }
obj.my_property = 'New Value'

obj.on_my_signal = function() end -- do something
@oezingle
Copy link

Using LGI internals like _property probably isn’t a good idea, as they’re not likely to apply back to your GObject.

Have a read of https://docs.gtk.org/gobject/tutorial.html. LGI should provide all the functions needed, though they’ll be namespaced per-library, and you may run into some functions that are handled differently for language bindings. the GObject docs will have a line at the bottom of a function or method’s definition that mentions if that function is unavailable to language bindings.

As for signals, apparently they’re defined by GObject.signal_newv

@tokyob0t
Copy link
Author

tokyob0t commented Feb 18, 2025

According to docs/guide.md in 3.8.2 Installing new properties thats how props are defined.

Also, the functions GObject.signal_new/GObject.signal_newv do not exist in lua

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

2 participants