Open ghost opened 9 years ago
Now it worked by the second try. Nice desklet! :+1:
Hope everything works like you want ! Thank you for following!
@fthuin I have drag-drop issues. Sometimes when I want to scroll it starts to drag the whole box. But this is maybe a cinnamon issue, I don't know. Otherwise it works perfectly. I have new feature ideas, some of them will be for private usage, but I'll probably send pull requests about the rest. I have other hobby projects now, so I'll develop it maybe in winter or at weekends. One of the ideas that the stock list should be configurable from the GUI. As far as I understand it is stored in a file currently.
I never had drag&drop issues so I don't know why it happens, maybe you can look at ~/.xsession-errors or with the looking glass tool (right click on the task bar, troubleshoot, looking glass -> log) to get lines of errors (if there are any).
Yes, the stocks list is currently in a file, I don't know if I can make it editable in the GUI, what could be easy to do is to add a "spawn command line" button with "xdg-open" to modify the file but it doesn't really resolve the problem.
@fthuin There is nothing related to this desklet in the log, so it is maybe something general in cinnamon.
There is nothing special about the stock list, it should be a simple table with checkboxes and add/remove buttons. I'll check whether I can do it, I am not familiar with Linux development, I just started using it 3 weeks ago. :-)
Any fast tutorial on how to debug and develop these apps? Something like BDD and selenium? :D Maybe I'm asking too much. :D
I think the only possible way is a huge "entry" type input box. As far as I can tell there is no multi-select combobox in the settings api, but the documentation is very low quality. If there would be, I am not sure it would be possible to change the options. I have the impression you can bind only values by these properties. If there is a low max length limit by this "entry" then you are right, this cannot be done. :S
@fthuin I managed to add the stock list to the options. I'll add further modifications tomorrow, and send a pull request.
There isn't any tutorial I think ; everything I write is inspired from other desklets/applets on cinnamon-spices or from gnome-shell extensions page.
Okay, I'll check it and upload a new release if everything works fine ! :) Thanks for your contribution !
@fthuin Be prepared that the code is oop now, so you maybe you won't like it.
I suspect this is the code of the settings api: https://github.com/lestcape/Cinnamon-Settings-Installer/blob/master/Cinnamon-Settings-Installer/settings-module/XletInstallerSettingsWidgets.py for example the textview is not in the documentation I read. https://github.com/linuxmint/Cinnamon/wiki/Applet,-Desklet-and-Extension-Settings-Reference
I moved the company symbol list from the file to a textview in the settings. That's all you need if you don't want to use the oo code I wrote.
I think the select * is too wide. There are many columns we don't use: http://aadrake.com/downloading-financial-data-from-yahoo-finance-using-ruby-and-yahoo-query-language.html that makes the whole desklet very slow.
If it is possible to add new combobox options somehow to the settings, then Settings.BindingDirection.OUT can help to update it based on a company list, but I think there is no multi select combobox in the settings api. So I suspect the only thing we can do is using the textview and adding something like +TEVA if we want to see the stock info, and -TEVA if we don't want to see the stock info of the company. But I think this does not worth the effort.
I sent the pull request. https://github.com/fthuin/yahoofinance-cinnamon-desklet/pull/2 I think we need a build and testing tool Looking Glass is far from usable. At least a webstorm console reporter or something like that would be nice.
I merged it, everything seems to work.
The select * is not the problem, the problem is that I didn't use the Soup library as I did in my new desklet , so the http session is not async and sometimes it makes the desktop freezes because of that... I'll release a new version in which the desklet never freezes or fails.
@fthuin Use tagging to make releases: https://git-scm.com/book/en/v2/Git-Basics-Tagging
Okay add the async request. I'll optimize the query to make it faster.
Created a deploy bash script. To remove the old version from the desklet directory and copy the new version into there and after that restart cinnamon. Do you have something better for testing? I mean something automated? It is hard to write proper code without automated tests. :S
@fthuin I won't use Cinnamon, because I like XFCE better, so I cannot help in your project. I decided to share the deploy bash and some ideas here, maybe you can use them.
#!/usr/bin/env bash
function main(){
echo "uninstalling old version if necessary";
uninstallPerviousVersion;
echo "installing desklet";
installDesklet;
echo "restarting gui";
restartGUI;
}
function uninstallPerviousVersion(){
rm -r ~/.local/share/cinnamon/desklets/yahoostocks@fthuin;
}
function installDesklet(){
cp -r ./yahoostocks@fthuin/ ~/.local/share/cinnamon/desklets;
}
function restartGUI(){
cinnamon --replace;
}
main
By optimizing the request I had the idea, that it should not immediately ask yahoo by every keystroke. In browser I would do this with the usage of setTimeout and clearTimeout. As far as I can understand this is not available by Cinnamon, so I assume you would use your setUpdateTimer and removeUpdateTimer methods. By any change of the companySymbols in the config you could set a timer with 2-5 secs. This timer calls this.onSettingsChanged, which asks yahoo for the data. If there is already a previous timer set, then it has to be cleared with removeUpdateTimer, so it wouldn't constantly read from yahoo by typing the list of symbols, just 3-5 secs after the user stopped typing.
Another part of the code you can optimize is reading from yahoo. You don't need to read every single column, just a few of them. So instead of select *, you could add a list of column names. You can optimize the query by the symbols too. You don't need to ask every symbol by the change of the config. So if the yahoo request is caused by the config change, then you could query only for the data of the newly added symbols. In order to do this you need a simple symbol repo (or array if you don't know this term), which is in sync with the config and which stores the symbol list, the last update time and the data needed to update the table. So before sending the request you can ask the repo, which symbols are outdated or were never read and ask only their data from yahoo.
Updating the table could be something like d3 js does. You could reuse the view components and change only the text in them. This way it would be much faster to update and would require less resource. By scrolling if it is possible, you could ask the position of the scrollbar and change the top and bottom padding. With this technique you can simulate fixed positioning on a few rows, while you are scrolling the page. By changing the text of these few rows you can simulate scrolling, but it will be much faster by a long list than displaying all of the rows. E.g. if you have 1000 symbols, all you need to display for example 20 rows. Ofc. you have to add more items if the page is resized. This is currently the fastest solution to display grids and tables with a lot of items.
You could use an utf8 symbol instead of image by the triangle icon, so displaying that will be faster too.
If you are right and the current display logic is blocking the desktop, then you should change it to async non-blocking if that is possible.
Good luck!
I have grey fonts, I barely can read them. Is there a way to override the font color? I tried by modifying the stylesheet.css but that had no effect... :S