-
-
Notifications
You must be signed in to change notification settings - Fork 24
Expand file tree
/
Copy pathPlug.vala
More file actions
94 lines (77 loc) · 3.63 KB
/
Plug.vala
File metadata and controls
94 lines (77 loc) · 3.63 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
93
94
/*-
* Copyright (c) 2015-2016 elementary LLC.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 2.1 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 Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* Authored by: Adam Bieńkowski <donadigos159@gmail.com>
*/
/* Strings */
const string SUFFIX = " ";
namespace Network {
public class Plug : Switchboard.Plug {
private MainView? main_view = null;
public static GLib.Settings proxy_settings;
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", null);
settings.set ("network/hotspot", "hotspot");
settings.set ("network/proxy", "proxy");
settings.set ("network/vpn", "vpn");
Object (category: Category.NETWORK,
code_name: "io.elementary.settings.network",
display_name: _("Network"),
description: _("Manage network devices and connectivity"),
icon: "preferences-system-network",
supported_settings: settings);
}
static construct {
proxy_settings = new GLib.Settings ("org.gnome.system.proxy");
}
public override Gtk.Widget get_widget () {
if (main_view == null) {
main_view = new MainView ();
}
return main_view;
}
public override void shown () {
}
public override void hidden () {
}
public override void search_callback (string location) {
main_view.push (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, _("Ethernet")), "");
search_results.set ("%s → %s".printf (display_name, _("LAN")), "");
search_results.set ("%s → %s".printf (display_name, _("Wireless")), "");
search_results.set ("%s → %s".printf (display_name, _("Wi-Fi")), "");
search_results.set ("%s → %s".printf (display_name, _("WLAN")), "");
search_results.set ("%s → %s".printf (display_name, _("Proxy")), "proxy");
search_results.set ("%s → %s".printf (display_name, _("Airplane Mode")), "");
search_results.set ("%s → %s".printf (display_name, _("IP Address")), "");
search_results.set ("%s → %s".printf (display_name, _("Hotspot")), "hotspot");
search_results.set ("%s → %s".printf (display_name, _("VPN")), "vpn");
return search_results;
}
}
}
public Switchboard.Plug get_plug (Module module) {
debug ("Activating Network plug");
var plug = new Network.Plug ();
return plug;
}