Module dev

9 views
Skip to first unread message

David Rios

unread,
May 12, 2023, 9:30:09 PM5/12/23
to fcitx-dev
Hi,

I'm trying to develop a module and I checked the example code on https://github.com/fcitx/fcitx5-quwei, and I'm wondering if it's possible to populate the candidate list asynchronously, like I make a request in an API for instance, and then after the response I populate the candidate list.

Could you please provide me with a few directions on that? Maybe the source code of a module that does something similar. That would be much appreciated.

All the best,
David

David Rios

unread,
May 13, 2023, 3:10:52 AM5/13/23
to fcitx-dev
Hi,

I'm trying to develop a module and I was wondering if it's possible to load the candidate list asynchronously, like for instance, I show a loading indication, do a request in an API and then after the response I populate the candidate list.

Could you please provide me with a few tips on that? Maybe the source code of a module that does something similar. That would be much appreciated.

Thanks

Weng Xuetian

unread,
May 14, 2023, 2:20:52 PM5/14/23
to fcit...@googlegroups.com
That would mainly depend on how you implement your asynchronous.

While the update to UI needs to happen in the main thread, you can
create the candidate list in another thread and set it to InputPanel
in the main thread.

If you use multi-threading, check EventDispatcher for a helper class
that sends a callback in the main thread. See
https://github.com/fcitx/fcitx5/blob/master/test/testeventdispatcher.cpp

If you have a file descriptor to monitor, you can check and use
addIOEvent https://codedocs.xyz/fcitx/fcitx5/classfcitx_1_1EventLoop.html
.
> --
> You received this message because you are subscribed to the Google Groups "fcitx-dev" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to fcitx-dev+...@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/msgid/fcitx-dev/e3bb5d77-8d96-464a-8bce-6e0a45d53b3en%40googlegroups.com.

David Rios

unread,
May 18, 2023, 6:15:06 PM5/18/23
to fcitx-dev
Thank you. If I create an event loop it just blocks the application, so I can't show a "loading" message and then update with the result. I would need to use the main application event loop, right? I tried using a dispatcher with Instance::eventLoop(), but nothing happens.

To better illustrate what I want using the quwei example:

When the code gets here: https://github.com/fcitx/fcitx5-quwei/blob/master/src/quwei.cpp#L275 , it means the user typed the correct combination, but then I want to show a candidate list that's only a "Loading" message. Meanwhile some processing is done in the background that will take a few seconds, and after finished it updates the candidate list with the computed options.

How do I go about that? Does that make sense?

David Rios

unread,
May 19, 2023, 9:38:34 PM5/19/23
to fcit...@googlegroups.com
Never mind, I managed to to what I wanted with ibus 😂.

You received this message because you are subscribed to a topic in the Google Groups "fcitx-dev" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/fcitx-dev/Jhox9mzmf1k/unsubscribe.
To unsubscribe from this group and all its topics, send an email to fcitx-dev+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/fcitx-dev/8966652d-34f7-4925-a8dc-2be1ef77433en%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages