-
-
Notifications
You must be signed in to change notification settings - Fork 10
Expand file tree
/
Copy pathPlug.vala
More file actions
92 lines (77 loc) · 3.24 KB
/
Plug.vala
File metadata and controls
92 lines (77 loc) · 3.24 KB
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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
// -*- Mode: vala; indent-tabs-mode: nil; tab-width: 4 -*-
/*-
* Copyright (c) 2016 elementary LLC.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* Authored by: Corentin Noël <corentin@elementary.io>
*/
public class Bluetooth.Plug : Switchboard.Plug {
private Gtk.Box box;
private MainView main_view;
private Services.ObjectManager manager;
public Plug () {
GLib.Intl.bindtextdomain (GETTEXT_PACKAGE, LOCALEDIR);
GLib.Intl.bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
var settings = new Gee.TreeMap<string, string?> (null, null);
settings.set ("network/bluetooth", null);
Object (category: Category.NETWORK,
code_name: "io.elementary.settings.bluetooth",
display_name: _("Bluetooth"),
description: _("Configure Bluetooth Settings"),
icon: "bluetooth",
supported_settings: settings);
manager = new Bluetooth.Services.ObjectManager ();
manager.bind_property ("has-object", this, "can-show", GLib.BindingFlags.SYNC_CREATE);
}
public override Gtk.Widget get_widget () {
if (box == null) {
var headerbar = new Adw.HeaderBar () {
show_title = false
};
headerbar.add_css_class (Granite.STYLE_CLASS_FLAT);
main_view = new MainView (manager) {
vexpand = true
};
box = new Gtk.Box (VERTICAL, 0);
box.append (headerbar);
box.append (main_view);
main_view.quit_plug.connect (() => hidden ());
}
return box;
}
public override void shown () {
manager.set_global_state.begin (true); /* Also sets discoverable true and starts discovery */
}
public override void hidden () {
Application.get_default ().hold ();
manager.discoverable = false; /* Does not change is_powered or connections*/
manager.stop_discovery.begin (() => {
Application.get_default ().release ();
});
}
public override void search_callback (string location) {
}
// 'search' returns results like ("Keyboard → Behavior → Duration", "keyboard<sep>behavior")
public override async Gee.TreeMap<string, string> search (string search) {
var search_results = new Gee.TreeMap<string, string> ((GLib.CompareDataFunc<string>)strcmp, (Gee.EqualDataFunc<string>)str_equal);
/*search_results.set ("%s → %s".printf (display_name, _("General")), "");*/
return search_results;
}
}
public Switchboard.Plug get_plug (Module module) {
debug ("Activating Bluetooth plug");
var plug = new Bluetooth.Plug ();
return plug;
}