2011-09-28 13:16:26 +00:00
|
|
|
// -*- mode: js; js-indent-level: 4; indent-tabs-mode: nil -*-
|
2010-10-31 20:02:24 +00:00
|
|
|
|
|
|
|
const Clutter = imports.gi.Clutter;
|
|
|
|
const St = imports.gi.St;
|
|
|
|
|
|
|
|
const UI = imports.testcommon.ui;
|
|
|
|
|
|
|
|
UI.init();
|
|
|
|
let stage = Clutter.Stage.get_default();
|
|
|
|
|
2010-11-02 20:15:53 +00:00
|
|
|
stage.width = 400;
|
|
|
|
stage.height = 700;
|
|
|
|
|
2010-10-31 20:02:24 +00:00
|
|
|
let b = new St.BoxLayout({ vertical: true,
|
|
|
|
width: stage.width,
|
|
|
|
height: stage.height });
|
|
|
|
stage.add_actor(b);
|
|
|
|
|
|
|
|
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-11-05 14:04:10 +00:00
|
|
|
let hb = new St.BoxLayout({ vertical: false,
|
|
|
|
style: 'spacing: 10px;' });
|
2010-10-31 20:02:24 +00:00
|
|
|
|
2010-11-05 14:04:10 +00:00
|
|
|
hb.add(new St.Label({ text: label }), { y_fill: false });
|
2010-10-31 20:02:24 +00:00
|
|
|
hb.add(new St.Icon(icon_props));
|
|
|
|
|
|
|
|
b.add(hb);
|
|
|
|
}
|
|
|
|
|
|
|
|
addTest("Symbolic",
|
2010-11-02 20:15:53 +00:00
|
|
|
{ icon_name: 'battery-full',
|
2010-10-31 20:02:24 +00:00
|
|
|
icon_type: St.IconType.SYMBOLIC,
|
|
|
|
icon_size: 48 });
|
|
|
|
addTest("Full color",
|
2010-11-02 20:15:53 +00:00
|
|
|
{ icon_name: 'battery-full',
|
2010-10-31 20:02:24 +00:00
|
|
|
icon_type: St.IconType.FULLCOLOR,
|
|
|
|
icon_size: 48 });
|
|
|
|
addTest("Default size",
|
2010-11-02 20:15:53 +00:00
|
|
|
{ icon_name: 'battery-full',
|
2010-10-31 20:02:24 +00:00
|
|
|
icon_type: St.IconType.SYMBOLIC });
|
|
|
|
addTest("Size set by property",
|
2010-11-02 20:15:53 +00:00
|
|
|
{ icon_name: 'battery-full',
|
2010-10-31 20:02:24 +00:00
|
|
|
icon_type: St.IconType.SYMBOLIC,
|
|
|
|
icon_size: 32 });
|
|
|
|
addTest("Size set by style",
|
2010-11-02 20:15:53 +00:00
|
|
|
{ icon_name: 'battery-full',
|
2010-10-31 20:02:24 +00:00
|
|
|
icon_type: St.IconType.SYMBOLIC,
|
|
|
|
style: 'icon-size: 1em;' });
|
|
|
|
addTest("16px icon in 48px icon widget",
|
2010-11-02 20:15:53 +00:00
|
|
|
{ icon_name: 'battery-full',
|
2010-10-31 20:02:24 +00:00
|
|
|
icon_type: St.IconType.SYMBOLIC,
|
2010-11-05 14:04:10 +00:00
|
|
|
style: 'icon-size: 16px; width: 48px; height: 48px; border: 1px solid black;' });
|
2010-10-31 20:02:24 +00:00
|
|
|
|
2010-11-02 20:15:53 +00:00
|
|
|
function iconRow(icons, box_style) {
|
|
|
|
let hb = new St.BoxLayout({ vertical: false, style: box_style });
|
|
|
|
|
|
|
|
for each (let iconName in icons) {
|
|
|
|
hb.add(new St.Icon({ icon_name: iconName,
|
|
|
|
icon_type: St.IconType.SYMBOLIC,
|
|
|
|
icon_size: 48 }));
|
|
|
|
}
|
|
|
|
|
|
|
|
b.add(hb);
|
|
|
|
}
|
|
|
|
|
|
|
|
let normalCss = 'background: white; color: black; padding: 10px 10px;';
|
|
|
|
let reversedCss = 'background: black; color: white; warning-color: #ffcc00; error-color: #ff0000; padding: 10px 10px;';
|
|
|
|
|
|
|
|
let batteryIcons = ['battery-full-charging',
|
|
|
|
'battery-full',
|
|
|
|
'battery-good',
|
|
|
|
'battery-low',
|
|
|
|
'battery-caution' ];
|
|
|
|
|
|
|
|
let volumeIcons = ['audio-volume-high',
|
|
|
|
'audio-volume-medium',
|
|
|
|
'audio-volume-low',
|
|
|
|
'audio-volume-muted' ];
|
|
|
|
|
|
|
|
iconRow(batteryIcons, normalCss);
|
|
|
|
iconRow(batteryIcons, reversedCss);
|
|
|
|
iconRow(volumeIcons, normalCss);
|
|
|
|
iconRow(volumeIcons, reversedCss);
|
|
|
|
|
2010-10-31 20:02:24 +00:00
|
|
|
stage.show();
|
|
|
|
Clutter.main();
|