web-greeter icon indicating copy to clipboard operation
web-greeter copied to clipboard

List files synchronously

Open JezerM opened this issue 4 years ago • 2 comments

Environment

  • OS: Ubuntu 21.04
  • web-greeter version: 3.1.0

Description of feature

Currently, the only way to list files is with theme_utils.dirlist, which works asynchronously: it's needed to pass a function that resolves the list of files. This is sometimes frustrating, as you would need to make things asynchronous when working on backgrounds.

So, a funnction like theme_utils.dirlist_sync would be helpful to block all the webpage and wait for the result.

Possible solutions

nody-greeter has actually solved this problem, thanks to Electron's IPC capacity to send messages both sync and async. QtWebEngine and QtWebChannel works only in an asynchronous way, so based on some research, there's no know method to make a synchronous call between the webpage and web-greeter.

I'll need to make a further research.

JezerM avatar Oct 13 '21 19:10 JezerM

After a long research, it seems impossible :c

Thought about modifying qwebchannel.js to send a "block" message to web-greeter and block the webpage thread after calling a QObject method in the javascript side. Then, do all related to the called function in python, update the properties (each method could have a "private" like property) and unblock the webpage thread. Finally, in the javascript side, qwebchannel.js could return the updated property without needing callbacks...

However, javascript is single threaded, so this solution would only work until the last step, because the properties update are needed to be handled by javascript itself. Therefore, qwebchannel.js would return an outdated value and then update the properties... it's not useful. Doing twice could create issues.

JezerM avatar Dec 27 '21 04:12 JezerM

I'm hating Qt5 xd

Considering to move to another framework.

JezerM avatar Oct 17 '22 06:10 JezerM