gnome-shell/tests/interactive/icons.js
Owen W. Taylor 439d7f036f Port StIcon from MX framework to St framework
Make StIcon compile and work in St.

Changes:

 * ::icon-type and st_icon_set_icon_type are added to allow
   specifying SYMBOLIC/FULLCOLOR for an icon.
 * Ability to set the icon name from the theme is removed; it
   wouldn't easily fit into our framework and two levels of
   abstraction between code and image doesn't seem that useful.
 * size CSS property is renamed from x-st-icon-size to icon-size
   to correspond to what we are doing elsewhere.
 * CSS and property based icon sizing are cleanly layered - if
   you set the icon-size property, the CSS size is ignored.
 * Add a simple JS test of StIcon.

https://bugzilla.gnome.org/show_bug.cgi?id=633865
2010-11-12 17:36:25 -05:00

54 lines
1.5 KiB
JavaScript

/* -*- mode: js2; js2-basic-offset: 4; indent-tabs-mode: nil -*- */
const Clutter = imports.gi.Clutter;
const St = imports.gi.St;
const UI = imports.testcommon.ui;
UI.init();
let stage = Clutter.Stage.get_default();
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; ' }));
let hb = new St.BoxLayout({ vertical: false });
hb.add(new St.Label({ text: label }));
hb.add(new St.Icon(icon_props));
b.add(hb);
}
addTest("Symbolic",
{ icon_name: 'zoom-in',
icon_type: St.IconType.SYMBOLIC,
icon_size: 48 });
addTest("Full color",
{ icon_name: 'zoom-in',
icon_type: St.IconType.FULLCOLOR,
icon_size: 48 });
addTest("Default size",
{ icon_name: 'zoom-in',
icon_type: St.IconType.SYMBOLIC });
addTest("Size set by property",
{ icon_name: 'zoom-in',
icon_type: St.IconType.SYMBOLIC,
icon_size: 32 });
addTest("Size set by style",
{ icon_name: 'zoom-in',
icon_type: St.IconType.SYMBOLIC,
style: 'icon-size: 1em;' });
addTest("16px icon in 48px icon widget",
{ icon_name: 'zoom-in',
icon_type: St.IconType.SYMBOLIC,
style: 'icon-size: 16px; width: 48px; height: 48px;' });
stage.show();
Clutter.main();