Debian Codegraph @

src/preferences-widgets.vala

raw
1 /* preferences-widgets.vala
2 *
3 * Copyright (C) Red Hat, Inc
4 *
5 * This program is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation, either version 3 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program. If not, see <http://www.gnu.org/licenses/>.
17 *
18 * Author: Felipe Borges <[email protected]>
19 *
20 */
21
22 namespace Connections {
23 private class PreferencesWindow: Hdy.PreferencesWindow {
24 protected weak Connection connection;
25
26 construct {
27 set_transient_for (Application.application.main_window);
28 }
29
30 protected void bind_widget_property (Gtk.Widget widget, string widget_property, string connection_property) {
31 connection.bind_property (connection_property, widget, widget_property, BindingFlags.BIDIRECTIONAL);
32
33 var value = GLib.Value (connection.get_class ().find_property (connection_property).value_type);
34 connection.get_property (connection_property, ref value);
35 widget.set_property (widget_property, value);
36 }
37 }
38
39 private class BooleanProperty: Hdy.ActionRow {
40 public bool active { get; set; }
41
42 construct {
43 var widget = new Gtk.Switch () {
44 visible = true,
45 valign = Gtk.Align.CENTER
46 };
47
48 bind_property ("active", widget, "active", BindingFlags.BIDIRECTIONAL);
49
50 add (widget);
51 set_activatable_widget (widget);
52 }
53 }
54 }