gnome-shell/tests/interactive/inline-style.js
Owen W. Taylor 7e678ef0d2 Add support for inline styles
Add support for passing an inline-style string when creating a
StThemeNode.

Hook this up to a new 'style' property of StWidget.

Add a test case that demonstrates using this to update font sizes
on the fly.

https://bugzilla.gnome.org/show_bug.cgi?id=595991
2009-09-29 19:58:29 -04:00

48 lines
1.2 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 vbox = new St.BoxLayout({ vertical: true,
width: stage.width,
height: stage.height });
stage.add_actor(vbox);
let hbox = new St.BoxLayout({ spacing: 12 });
vbox.add(hbox);
let text = new St.Label({ text: "Styled Text" });
vbox.add (text);
let size = 24;
function update_size() {
text.style = 'font-size: ' + size + 'pt';
}
update_size();
let button = new St.Button ({ label: 'Smaller',
style: 'padding: 4px; background: #eeddcc' });
hbox.add (button);
button.connect('clicked', function() {
size /= 1.2;
update_size ();
});
let button = new St.Button ({ label: 'Bigger',
style: 'padding: 4px; background: #eeddcc' });
hbox.add (button);
button.connect('clicked', function() {
size *= 1.2;
update_size ();
});
stage.show();
Clutter.main();
stage.destroy();