2011-09-28 09:16:26 -04:00
|
|
|
// -*- mode: js; js-indent-level: 4; indent-tabs-mode: nil -*-
|
2010-10-31 16:02:24 -04:00
|
|
|
|
2017-02-14 19:43:09 -05:00
|
|
|
const UI = imports.testcommon.ui;
|
|
|
|
|
2019-02-08 22:21:36 -05:00
|
|
|
const { Clutter, St } = imports.gi;
|
2010-10-31 16:02:24 -04:00
|
|
|
|
2012-06-24 15:11:41 -04:00
|
|
|
function test() {
|
|
|
|
let stage = new Clutter.Stage();
|
|
|
|
UI.init(stage);
|
2010-11-02 16:15:53 -04:00
|
|
|
|
2012-06-24 15:11:41 -04:00
|
|
|
let b = new St.BoxLayout({ vertical: true,
|
|
|
|
width: stage.width,
|
|
|
|
height: stage.height });
|
|
|
|
stage.add_actor(b);
|
2010-10-31 16:02:24 -04:00
|
|
|
|
2012-06-24 15:11:41 -04:00
|
|
|
function addTest(label, icon_props) {
|
|
|
|
if (b.get_children().length > 0)
|
|
|
|
b.add (new St.BoxLayout({ style: 'background: #cccccc; border: 10px transparent white; height: 1px; ' }));
|
2010-10-31 16:02:24 -04:00
|
|
|
|
2012-06-24 15:11:41 -04:00
|
|
|
let hb = new St.BoxLayout({ vertical: false,
|
|
|
|
style: 'spacing: 10px;' });
|
2010-10-31 16:02:24 -04:00
|
|
|
|
2012-06-24 15:11:41 -04:00
|
|
|
hb.add(new St.Label({ text: label }), { y_fill: false });
|
|
|
|
hb.add(new St.Icon(icon_props));
|
2010-10-31 16:02:24 -04:00
|
|
|
|
2012-06-24 15:11:41 -04:00
|
|
|
b.add(hb);
|
2010-11-02 16:15:53 -04:00
|
|
|
}
|
|
|
|
|
2012-06-24 15:11:41 -04:00
|
|
|
addTest("Symbolic",
|
2012-05-30 09:58:37 -04:00
|
|
|
{ icon_name: 'battery-full-symbolic',
|
2012-06-24 15:11:41 -04:00
|
|
|
icon_size: 48 });
|
|
|
|
addTest("Full color",
|
|
|
|
{ icon_name: 'battery-full',
|
|
|
|
icon_size: 48 });
|
|
|
|
addTest("Default size",
|
2012-05-30 09:58:37 -04:00
|
|
|
{ icon_name: 'battery-full-symbolic' });
|
2012-06-24 15:11:41 -04:00
|
|
|
addTest("Size set by property",
|
2012-05-30 09:58:37 -04:00
|
|
|
{ icon_name: 'battery-full-symbolic',
|
2012-06-24 15:11:41 -04:00
|
|
|
icon_size: 32 });
|
|
|
|
addTest("Size set by style",
|
2012-05-30 09:58:37 -04:00
|
|
|
{ icon_name: 'battery-full-symbolic',
|
2012-06-24 15:11:41 -04:00
|
|
|
style: 'icon-size: 1em;' });
|
|
|
|
addTest("16px icon in 48px icon widget",
|
2012-05-30 09:58:37 -04:00
|
|
|
{ icon_name: 'battery-full-symbolic',
|
2012-06-24 15:11:41 -04:00
|
|
|
style: 'icon-size: 16px; width: 48px; height: 48px; border: 1px solid black;' });
|
|
|
|
|
|
|
|
function iconRow(icons, box_style) {
|
|
|
|
let hb = new St.BoxLayout({ vertical: false, style: box_style });
|
|
|
|
|
2018-02-06 17:25:29 -05:00
|
|
|
for (let iconName of icons) {
|
2012-06-24 15:11:41 -04:00
|
|
|
hb.add(new St.Icon({ icon_name: iconName,
|
|
|
|
icon_size: 48 }));
|
|
|
|
}
|
|
|
|
|
|
|
|
b.add(hb);
|
|
|
|
}
|
2010-11-02 16:15:53 -04:00
|
|
|
|
2012-06-24 15:11:41 -04:00
|
|
|
let normalCss = 'background: white; color: black; padding: 10px 10px;';
|
|
|
|
let reversedCss = 'background: black; color: white; warning-color: #ffcc00; error-color: #ff0000; padding: 10px 10px;';
|
2010-11-02 16:15:53 -04:00
|
|
|
|
2012-05-30 09:58:37 -04:00
|
|
|
let batteryIcons = ['battery-full-charging-symbolic',
|
|
|
|
'battery-full-symbolic',
|
|
|
|
'battery-good-symbolic',
|
|
|
|
'battery-low-symbolic',
|
|
|
|
'battery-caution-symbolic' ];
|
2010-11-02 16:15:53 -04:00
|
|
|
|
2012-05-30 09:58:37 -04:00
|
|
|
let volumeIcons = ['audio-volume-high-symbolic',
|
|
|
|
'audio-volume-medium-symbolic',
|
|
|
|
'audio-volume-low-symbolic',
|
|
|
|
'audio-volume-muted-symbolic' ];
|
2010-11-02 16:15:53 -04:00
|
|
|
|
2012-06-24 15:11:41 -04:00
|
|
|
iconRow(batteryIcons, normalCss);
|
|
|
|
iconRow(batteryIcons, reversedCss);
|
|
|
|
iconRow(volumeIcons, normalCss);
|
|
|
|
iconRow(volumeIcons, reversedCss);
|
2010-11-02 16:15:53 -04:00
|
|
|
|
2012-06-24 15:11:41 -04:00
|
|
|
UI.main(stage);
|
|
|
|
}
|
|
|
|
test();
|