summaryrefslogtreecommitdiff
path: root/tests/device-view-test.vala
blob: 0bc5ed496f447ca88a1e80e7cdbabb0e0f64c137 (plain)
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
using GLib;
using Gtk;
using GUPnP;

public class Test.DeviceViewTest : Window {

    construct {
        title = "GUPnP DeviceView Test";
        resize (400, 300);
        destroy.connect (Gtk.main_quit);

        /* Init GUPnP stuff */
        Context ctxt;
        try {
            ctxt = new Context (null, null, 0);
        } catch (Error err) {
            critical (err.message);
            Gtk.main_quit ();
        }

        ControlPoint cp = new ControlPoint (ctxt, "upnp:rootdevice");
        cp.active = true;

        /* Create a ScrolledWindow for the UIDeviceView */
        var scroll_win = new ScrolledWindow (null, null);
        scroll_win.set_policy (PolicyType.AUTOMATIC,
                               PolicyType.ALWAYS);
        scroll_win.set_shadow_type (ShadowType.IN);
        add (scroll_win);

        /* Set up store and view */
        UIDeviceStore store = new UIDeviceStore (cp);
        UIDeviceView view = new UIDeviceView (store);
        scroll_win.add (view);
    }

    static int main (string[] args) {
        Gtk.init (ref args);

        var test = new DeviceViewTest ();
        test.show_all ();
        Gtk.main ();

        return 0;
    }
}