So basically, desktop scripting in Gnome, and therefore Cinnamon, is stuck with a deprecated version of javascript. Since most of my javascript is for the browser, I don't really want to learn how to use it the wrong way. But we know a fix for this - Coffee Script!
Applet = imports.ui.applet
GLib = imports.gi.GLib
Util = imports.misc.util
Gettext = imports.gettext.domain('cinnamon-applets')
_ = Gettext.gettext
class MyApplet
__proto__: base = Applet.IconApplet.prototype
name: 'Gracie'
constructor:(orientation)->
base._init.call(this, orientation);
try
@set_applet_icon_name("gnome-info")
@set_applet_tooltip(_("Say Hello, #{@name}"))
return
catch e
global.logError(e)
return
on_applet_clicked:(evtdata) =>
notification = "notify-send \"Hello #{@name}\" -a TEST -t 10 -u low"
Util.spawnCommandLine(notification)
return
main = (metadata, orientation)-> new MyApplet(orientation)
Note there is now no need for Lang.Class and Lang.Bind. Insted of coffee's extend, I've set the __proto__ property. You can still use extends for your own class hierarchy, but for a GObject based hierarchy, you'll need to use __proto__.
Compile with the bare flag:
And breath some new life into that stale interface!
Compile with the bare flag:
$ coffee -bc applet.coffee
And breath some new life into that stale interface!
No comments:
Post a Comment