Add Clutter canvas for UI elements

This commit is contained in:
Raymundo Cassani 2020-05-23 11:19:25 -04:00
parent acc52e3c37
commit 8ed3f0215e

View File

@ -2,6 +2,8 @@ const Desklet = imports.ui.desklet;
const Settings = imports.ui.settings; const Settings = imports.ui.settings;
const Mainloop = imports.mainloop; const Mainloop = imports.mainloop;
const Lang = imports.lang; const Lang = imports.lang;
const Clutter = imports.gi.Clutter;
@ -33,18 +35,24 @@ MyDesklet.prototype = {
// initialize size // initialize size
// create the clutter elements // create the clutter elements
// type of system variable to graph
var type = this.type;
// creates container for one child // creates container for one child
this.window = new St.Bin(); // this.window = new St.Bin();
// creates a label to present text // creates a label to present text
this.text = new St.Label(); // this.text = new St.Label();
// adds label to container // adds label to container
this.window.add_actor(this.text); // this.window.add_actor(this.text);
// Sets the container as content actor of the desklet // Sets the container as content actor of the desklet
this.setContent(this.window); // this.setContent(this.window);
this.canvas = new Clutter.Actor();
this.canvas.remove_all_children();
this.text1 = new St.Label();
this.text2 = new St.Label();
this.canvas.add_actor(this.text1);
this.canvas.add_actor(this.text2);
this.setContent(this.canvas);
// set decoration settings // set decoration settings
@ -56,9 +64,15 @@ MyDesklet.prototype = {
// console log // console log
global.log("update SMG"); global.log("update SMG");
// do the graph // do the graph
// type of system variable to graph
var type = this.type; var type = this.type;
// add text to label // add text to label
this.text.set_text("Hello Desktop2 ".concat(type)); this.text1.set_text("Hello Desktop2 ".concat(type));
this.text2.set_text(type);
// positions text
this.text1.set_position(null, null);
this.text2.set_position(null, 50);
// call this.update() in 5 seconds // call this.update() in 5 seconds
this.timeout = Mainloop.timeout_add_seconds(5, Lang.bind(this, this.update)); this.timeout = Mainloop.timeout_add_seconds(5, Lang.bind(this, this.update));
}, },