cinnamon applet PopupSliderMenuItem and labels

478 Views Asked by At

tIs there any way to add labels to PopupSliderMenuItem? what i want is to have something like label PopupSliderMenuItem label in one row. Or if it is posible (and how?) to draw sliders vertical then

label
slider
label

a sample of code:

for(f=0;f<this.volumes.length;f++) {
       this.labels[f]=new St.Label({ text: this.freq[f]});

       this.sliders[f]=new PopupMenu.PopupSliderMenuItem(this.volumes[f]/100);
       this.sliders[f].connect('value-changed', Lang.bind(this, this._onSlider));

       this.menu.addMenuItem(this.sliders[f]);
       //how can i add each label of labels[] before and after each slider
     }
1

There are 1 best solutions below

0
On

So i manage to solve(patch it from other scripts) my own dilemma

var mainBox = new St.BoxLayout({ vertical: true, x_align: St.Align.MIDDLE});
this.table=new St.Table({homogeneous: false});
mainBox.add_actor(this.table);

     for(f=0;f<this.volumes.length;f++) {
       this.labels[f]=new St.Label({ text: this.freq[f].split(". ")[1] ,x_align: St.Align.MIDDLE, y_align:St.Align.END});
       this.vals[f]=new St.Label({text: (this.volumes[f]).toString(), x_align: St.Align.END, y_align:St.Align.END});
       this.sliders[f]=new PopupMenu.PopupSliderMenuItem(this.volumes[f]/100);
        this.sliders[f].connect('value-changed', Lang.bind(this, this._onSlider));
        this.table.add(this.labels[f], {
          row: f,
          col: 1,
          expand: true,
          x_fill: true,
          y_fill: false,
          x_align: St.Align.MIDDLE,
          y_align: St.Align.MIDDLE

        });
        this.table.add(this.sliders[f].actor, {
          row: f,
          col: 2,
          expand: true,
          x_fill: true,
          y_fill: false,
          x_align: St.Align.MIDDLE,
          y_align: St.Align.MIDDLE

        });     
        this.table.add(this.vals[f], {
          row: f,
          col: 3,
          expand: true,
          x_fill: true,
          y_fill: false,
          x_align: St.Align.MIDDLE,
          y_align: St.Align.MIDDLE

        });

        }