JezerM / web-greeter

A modern, visually appealing greeter for LightDM.
https://web-greeter-page.vercel.app
GNU General Public License v3.0
211 stars 12 forks source link

List files synchronously #12

Open JezerM opened 2 years ago

JezerM commented 2 years ago

Environment

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 commented 2 years ago

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 commented 1 year ago

I'm hating Qt5 xd

Considering to move to another framework.