I'm trying to create a simple Cinnamon panel applet that shows the current process of my Octoprint jobs. I tried the tutorial from http://projects.linuxmint.com/referenc ... pplet.html and modified it but I just can't get it work.
There is always this error message in ~/.xsession-errors when I add the applet to a panel:
Code: Select all
[progress@octoprint]: Failed to evaluate 'main' function on applet: progress@octoprint/100
Cjs-Message: 23:36:55.289: JS LOG: [LookingGlass/trace]
<----------------
_getPanelInfo@/usr/share/cinnamon/js/ui/applet.js:219:19
_init@/usr/share/cinnamon/js/ui/applet.js:197:13
_init@/usr/share/cinnamon/js/ui/applet.js:659:9
anonymous/MyApplet.prototype._init@/home/kolbe/.local/share/cinnamon/applets/progress@octoprint/applet.js:18:9
MyApplet@/home/kolbe/.local/share/cinnamon/applets/progress@octoprint/applet.js:11:5
main@/home/kolbe/.local/share/cinnamon/applets/progress@octoprint/applet.js:53:12
createApplet@/usr/share/cinnamon/js/ui/appletManager.js:581:18
addAppletToPanels@/usr/share/cinnamon/js/ui/appletManager.js:356:22
onEnabledAppletsChanged@/usr/share/cinnamon/js/ui/appletManager.js:296:9
---------------->
Cjs-Message: 23:36:55.296: JS LOG: [LookingGlass/error]
[progress@octoprinte]: [Applet] Unable to find definition for applet 30
[progress@octoprinte]: Failed to evaluate 'main' function on applet: progress@octoprinte/106
Cjs-Message: 23:36:55.296: JS LOG: [LookingGlass/trace]
<----------------
_getPanelInfo@/usr/share/cinnamon/js/ui/applet.js:219:19
_init@/usr/share/cinnamon/js/ui/applet.js:197:13
_init@/usr/share/cinnamon/js/ui/applet.js:789:9
anonymous/MyApplet.prototype._init@/home/kolbe/.local/share/cinnamon/applets/progress@octoprinte/applet.js:68:9
MyApplet@/home/kolbe/.local/share/cinnamon/applets/progress@octoprinte/applet.js:61:5
main@/home/kolbe/.local/share/cinnamon/applets/progress@octoprinte/applet.js:104:20
createApplet@/usr/share/cinnamon/js/ui/appletManager.js:581:18
addAppletToPanels@/usr/share/cinnamon/js/ui/appletManager.js:356:22
onEnabledAppletsChanged@/usr/share/cinnamon/js/ui/appletManager.js:296:9
---------------->
Cjs-Message: 23:36:55.828: JS LOG: Unknown network device type, is 14
Cjs-Message: 23:36:55.843: JS LOG: Unknown network device type, is 13
applet.js:
Code: Select all
const Applet = imports.ui.applet;
const GLib = imports.gi.GLib;
const Mainloop = imports.mainloop;
const PopupMenu = imports.ui.popupMenu;
const Settings = imports.ui.settings;
const UUID = "progress@octoprinte";
const Util = imports.misc.util;
function MyApplet(metadata, orientation, panelHeight, instance_id) {
this._init(metadata, orientation, panelHeight, instance_id);
}
MyApplet.prototype = {
__proto__: Applet.TextApplet.prototype,
_init: function (metadata, orientation, panelHeight, instance_id) {
Applet.TextApplet.prototype._init.call(this, metadata, orientation, panelHeight, instance_id);
// settings
try {
this.settings = new Settings.AppletSettings(this, UUID, instance_id);
this.settings.bindProperty(Settings.BindingDirection.IN,
"server",
"server",
this.on_settings_changed,
null);
this.settings.bindProperty(Settings.BindingDirection.IN,
"basic_auth",
"basic_auth",
this.on_settings_changed,
null);
} catch (e) {
global.logError("Cannot load settings");
}
this.set_applet_tooltip(("Progress"));
},
on_applet_clicked: function() {
Util.spawn('nemo');
},
on_settings_changed: function () {
global.logError("Settings changed");
},
};
function main(metadata, orientation, panelHeight, instance_id) {
let myApplet = new MyApplet(metadata, orientation, panelHeight, instance_id);
return myApplet;
}
Code: Select all
{
"uuid": "progress@octoprinte",
"name": "Octoprint Progress",
"version": "0.1",
"description": "OctoPrint progress",
"icon": "force-exit",
"max-instances": "-1",
"multiversion": true
}
Code: Select all
{
"server": {
"type" : "entry",
"default" : "http://141.56.7.88",
"description" : "Server"
},
"api_key": {
"type" : "entry",
"default" : "XXXXXXXXXXXXXXXXXX",
"description" : "API key"
},
"basic_auth": {
"type" : "entry",
"default" : "xxx:xxx",
"description": "Credentials for basic authentication"
}
}
Any idea what's wrong with my code?