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

Use signals as final methods in interfaces #321

Open
Rogni opened this issue Feb 26, 2021 · 2 comments
Open

Use signals as final methods in interfaces #321

Rogni opened this issue Feb 26, 2021 · 2 comments

Comments

@Rogni
Copy link

Rogni commented Feb 26, 2021

Currently signals in ListModelIF are generated as virtual methods

connect:

gulong addOnItemsChanged(void delegate(uint, uint, uint, ListModelIF) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0);

emit:
public void itemsChanged(uint position, uint removed, uint added);

and implementation of signals defined in mixin template ListModelT. It is required to implement signal methods in the derived classes.

        void itemsChanged(uint position, uint removed, uint added) {
            g_list_model_items_changed(getListModelStruct(), position, removed, added);
        }

        gulong addOnItemsChanged(void delegate(uint, uint, uint, ListModelIF) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0)
        {
            return Signals.connect(this, "items-changed", dlg, connectFlags ^ ConnectFlags.SWAPPED);
        }

https://github.com/Rogni/ExampleContactsBook/blob/8ed1193ba5a5048b0a6a71cdef42ff10f7034aea/src/controllers/ContactListController.d#L84-L91

I suggest to move implementation of signal methods from mixin template to interface as final methods

@Rogni
Copy link
Author

Rogni commented Feb 28, 2021

also maybe need generate

GListModel* getListModelStruct(bool transferOwnership = false) {
            return cast(GListModel*) getStruct;
}

as final method

@MikeWey
Copy link
Member

MikeWey commented Mar 1, 2021

Probably all functions that are not part of the GTK interface should be final functions in the D interface.

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