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

SignalListItemFactory doesn't provide object argument to handler #161

Closed
Nyeksenn opened this issue Dec 6, 2024 · 4 comments
Closed

SignalListItemFactory doesn't provide object argument to handler #161

Nyeksenn opened this issue Dec 6, 2024 · 4 comments
Labels
bug Something isn't working

Comments

@Nyeksenn
Copy link

Nyeksenn commented Dec 6, 2024

I am trying to bind a callback function to the setup and bind signal emitted by SignalListItemFactory.
I have declared a signal in the ui definition as following:

<object class="GtkSignalListItemFactory">
  <signal name="setup" handler="lstSetupWidget" />
  <signal name="bind" handler="lstBindCategoryName" />
</object>

The corresponding handlers look like this:

    @GtkCallback(name = "lstSetupWidget")
    public void lstSetupWidget(GObject object) {
        var listItem = (ListItem) object;
        var label = new Label("");
        label.setMarginTop(12);
        label.setMarginBottom(12);
        listItem.setChild(label);
    }

    @GtkCallback(name = "lstBindCategoryName")
    public void lstBindCategoryName(GObject object) {
        var listItem = (ListItem) object;
        var label = (Label) listItem.getChild();
        var result = (EvaluationResult) listItem.getItem();
        label.setLabel(result.getCategoryName());
    }

When i run the program I receive the following error:

(java:140426): java-gi-CRITICAL **: 15:42:34.327: Cannot invoke method lstSetupWidget in class MetacheckerWindow: wrong number of arguments: 0 expected: 1
(java:140426): java-gi-CRITICAL **: 15:42:34.327: Cannot invoke method lstBindCategoryName in class MetacheckerWindow: wrong number of arguments: 0 expected: 1

It seems like when the signal is emitted, that the ListItem is not passed as an argument.

I have looked at an example of a Vala app that does it exactly like that, so I don't think this is a GTK issue.

@Nyeksenn Nyeksenn closed this as not planned Won't fix, can't repro, duplicate, stale Dec 6, 2024
@Nyeksenn Nyeksenn reopened this Dec 6, 2024
@jwharm
Copy link
Owner

jwharm commented Dec 7, 2024

This is a bug, thanks for reporting it.
Can you attach a small, easily runnable example that I can test with? I don't know how to work with a ListItemFactory from a ui file.

@jwharm
Copy link
Owner

jwharm commented Dec 7, 2024

Note to self: This needs to be fixed in the BuilderJavaScope class.

@Nyeksenn
Copy link
Author

Nyeksenn commented Dec 7, 2024

This is a bug, thanks for reporting it. Can you attach a small, easily runnable example that I can test with? I don't know how to work with a ListItemFactory from a ui file.

I have created a small PoC that you can run with gradle run.
This project is created with Gradle 8.11
poc.zip

@jwharm jwharm added the bug Something isn't working label Dec 7, 2024
@jwharm jwharm closed this as completed in 310b4b2 Dec 7, 2024
@jwharm
Copy link
Owner

jwharm commented Dec 7, 2024

Thanks a lot for the PoC.
The bug has been fixed in the main branch, and I published a new 0.11.1-SNAPSHOT release.

(To use snapshot releases, add https://s01.oss.sonatype.org/content/repositories/snapshots to the repositories in your build script.)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants