Lanceur d’application pour GNU/Linux
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

43 lines
1012B

  1. var React = require('react');
  2. var Util = require('../util');
  3. var DesktopAppItem = require('./desktop-app-item.jsx');
  4. var path = require('path');
  5. module.exports = React.createClass({
  6. getInitialState: function() {
  7. return {
  8. desktopFiles: []
  9. };
  10. },
  11. componentDidMount: function() {
  12. // Load system desktop apps
  13. var baseDirs = global.process.env.XDG_DATA_DIRS.split(':').map(function(baseDir){
  14. return path.join(baseDir, 'applications');
  15. });
  16. Util.DesktopApps.loadAllDesktopFiles('/usr/share/applications')
  17. .then(function(desktopFiles) {
  18. this.setState({ desktopFiles: desktopFiles });
  19. }.bind(this))
  20. ;
  21. },
  22. render: function() {
  23. var items = this.state.desktopFiles.map(function(desktopFile, i) {
  24. var desktopEntry = desktopFile.content['Desktop Entry'];
  25. return <DesktopAppItem key={desktopFile.path} desktopEntry={desktopEntry} />;
  26. });
  27. return (
  28. <ul className="desktop-apps">
  29. {items}
  30. </ul>
  31. );
  32. }
  33. });