2015-08-28 14:20:07 +02:00
|
|
|
var React = require('react');
|
|
|
|
var Util = require('../util');
|
|
|
|
var DesktopAppItem = require('./desktop-app-item.jsx');
|
2015-08-30 21:29:19 +02:00
|
|
|
var path = require('path');
|
2015-08-28 14:20:07 +02:00
|
|
|
|
|
|
|
module.exports = React.createClass({
|
|
|
|
|
|
|
|
getInitialState: function() {
|
|
|
|
return {
|
|
|
|
desktopFiles: []
|
|
|
|
};
|
|
|
|
},
|
|
|
|
|
|
|
|
componentDidMount: function() {
|
|
|
|
// Load system desktop apps
|
2015-08-30 21:29:19 +02:00
|
|
|
var baseDirs = global.process.env.XDG_DATA_DIRS.split(':').map(function(baseDir){
|
|
|
|
return path.join(baseDir, 'applications');
|
|
|
|
});
|
|
|
|
|
2015-08-28 14:20:07 +02:00
|
|
|
Util.DesktopApps.loadAllDesktopFiles('/usr/share/applications')
|
|
|
|
.then(function(desktopFiles) {
|
|
|
|
this.setState({ desktopFiles: desktopFiles });
|
|
|
|
}.bind(this))
|
|
|
|
;
|
|
|
|
},
|
|
|
|
|
|
|
|
render: function() {
|
|
|
|
|
|
|
|
var items = this.state.desktopFiles.map(function(desktopFile, i) {
|
|
|
|
var desktopEntry = desktopFile.content['Desktop Entry'];
|
|
|
|
return <DesktopAppItem key={desktopFile.path} desktopEntry={desktopEntry} />;
|
|
|
|
});
|
|
|
|
|
|
|
|
return (
|
|
|
|
<ul className="desktop-apps">
|
|
|
|
{items}
|
|
|
|
</ul>
|
|
|
|
);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
});
|