File: FormView.vala

package info (click to toggle)
granite 6.2.0-7
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 4,768 kB
  • sloc: python: 10; makefile: 8
file content (37 lines) | stat: -rw-r--r-- 987 bytes parent folder | download | duplicates (2)
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
/*
 * Copyright 2020 elementary, Inc. (https://elementary.io)
 * SPDX-License-Identifier: LGPL-3.0-or-later
 */

public class FormView : Gtk.Grid {
    construct {
        Regex? username_regex = null;
        try {
            username_regex = new Regex ("^[a-z]+[a-z0-9]*$");
        } catch (Error e) {
            critical (e.message);
        }

        var username_label = new Granite.HeaderLabel ("Username");

        var username_entry = new Granite.ValidatedEntry () {
            min_length = 8,
            regex = username_regex
        };

        var button = new Gtk.Button.with_label ("Submit");

        margin = 12;
        orientation = Gtk.Orientation.VERTICAL;
        row_spacing = 3;
        halign = Gtk.Align.CENTER;
        valign = Gtk.Align.CENTER;
        vexpand = true;
        add (username_label);
        add (username_entry);
        add (button);
        show_all ();

        username_entry.bind_property ("is-valid", button, "sensitive");
    }
}