~ubuntu-branches/ubuntu/natty/libqtbamf/natty

« back to all changes in this revision

Viewing changes to test.qml

  • Committer: Bazaar Package Importer
  • Author(s): Michael Casadevall
  • Date: 2011-01-14 08:52:53 UTC
  • Revision ID: james.westby@ubuntu.com-20110114085253-urfo7ud83hx69926
Tags: upstream-0.1
Import upstream version 0.1

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * Copyright (C) 2010 Canonical, Ltd.
 
3
 *
 
4
 * Authors:
 
5
 *  Olivier Tilloy <olivier.tilloy@canonical.com>
 
6
 *
 
7
 * This program is free software; you can redistribute it and/or modify
 
8
 * it under the terms of the GNU General Public License as published by
 
9
 * the Free Software Foundation; version 3.
 
10
 *
 
11
 * This program is distributed in the hope that it will be useful,
 
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
14
 * GNU General Public License for more details.
 
15
 *
 
16
 * You should have received a copy of the GNU General Public License
 
17
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
18
 */
 
19
 
 
20
import Qt 4.7
 
21
 
 
22
Rectangle {
 
23
 
 
24
    function info() {
 
25
        var aa = BamfMatcher.active_application()
 
26
        console.log("active application: " + aa.name)
 
27
        var aw = BamfMatcher.active_window()
 
28
        console.log("active window: " + aw.name)
 
29
        var running = BamfMatcher.running_applications()
 
30
        console.log("running applications:")
 
31
        for (var i = 0; i < running.size(); ++i) {
 
32
            var app = running.at(i)
 
33
            console.log("   » " + app.name)
 
34
            var windows = app.windows()
 
35
            for (var j = 0; j < windows.size(); ++j) {
 
36
                var window = windows.at(j)
 
37
                console.log("      » " + window.name)
 
38
            }
 
39
        }
 
40
    }
 
41
 
 
42
    // slots
 
43
    function onActiveWindowChanged() {
 
44
        var aw = BamfMatcher.active_window()
 
45
        if (aw != null)
 
46
            console.log("active window changed to: " + aw.name)
 
47
    }
 
48
 
 
49
    Component.onCompleted: info()
 
50
}
 
51