File: scrolling.js

package info (click to toggle)
cinnamon 6.4.13-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 13,300 kB
  • sloc: javascript: 54,298; ansic: 51,499; python: 21,971; xml: 2,803; sh: 96; makefile: 27; perl: 13
file content (52 lines) | stat: -rw-r--r-- 1,458 bytes parent folder | download | duplicates (9)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
// -*- mode: js; js-indent-level: 4; indent-tabs-mode: nil -*-

const Clutter = imports.gi.Clutter;
const Gtk = imports.gi.Gtk;
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,
                              style: "padding: 10px;" });
stage.add_actor(vbox);

let toggle = new St.Button({ label: 'Horizontal Scrolling',
                         toggle_mode: true });
vbox.add(toggle);

let v = new St.ScrollView();
vbox.add(v, { expand: true });

toggle.connect('notify::checked', function () {
    v.set_policy(toggle.checked ? Gtk.PolicyType.AUTOMATIC
                                : Gtk.PolicyType.NEVER,
                 Gtk.PolicyType.AUTOMATIC);
});

let b = new St.BoxLayout({ vertical: true,
                           style: "border: 2px solid #880000; border-radius: 10px; padding: 0px 5px;" });
v.add_actor(b);

let cc_a = "a".charCodeAt(0);
let s = "";
for (let i = 0; i < 26 * 3; i++) {
    s += String.fromCharCode(cc_a + i % 26);

    let t = new St.Label({ text: s,
                           reactive: true });
    let line = i + 1;
    t.connect('button-press-event',
              function() {
                  log("Click on line " + line);
              });
    b.add(t);
}

stage.show();
Clutter.main();
stage.destroy();