diff --git a/po/POTFILES b/po/POTFILES index 98da5533..4dc9573b 100644 --- a/po/POTFILES +++ b/po/POTFILES @@ -12,5 +12,3 @@ src/Widgets/AppRow.vala src/Widgets/ClearUsagePopover.vala src/Widgets/ExcludeTreeView.vala src/Widgets/IncludeTreeView.vala -src/Widgets/ServiceItem.vala -src/Widgets/ServiceList.vala diff --git a/src/Plug.vala b/src/Plug.vala index f3a7bf0e..015b8e65 100644 --- a/src/Plug.vala +++ b/src/Plug.vala @@ -31,8 +31,6 @@ namespace SecurityPrivacy { Gtk.Grid main_grid; Gtk.Stack stack; - ServiceList service_list; - private const string FIREWALL = "firewall"; private const string HOUSEKEEPING = "housekeeping"; private const string HISTORY = "tracking"; @@ -132,20 +130,15 @@ namespace SecurityPrivacy { stack.add_titled (housekeeping, HOUSEKEEPING, _("Housekeeping")); stack.add_titled (location, LOCATION, _("Location Services")); - service_list = new ServiceList (); + var settings_sidebar = new Granite.SettingsSidebar (stack); var paned = new Gtk.Paned (Gtk.Orientation.HORIZONTAL); paned.position = 200; - paned.add1 (service_list); + paned.add1 (settings_sidebar); paned.add2 (grid); main_grid.add (paned); main_grid.show_all (); - - service_list.row_selected.connect ((row) => { - var title = ((ServiceItem)row).title; - stack.visible_child_name = title; - }); } public override void hidden () { @@ -158,7 +151,6 @@ namespace SecurityPrivacy { } stack.set_visible_child_name (location); - service_list.select_service_name (location); } // 'search' returns results like ("Keyboard → Behavior → Duration", "keyboardbehavior") diff --git a/src/Views/FirewallPanel.vala b/src/Views/FirewallPanel.vala index dff79c53..a1be668f 100644 --- a/src/Views/FirewallPanel.vala +++ b/src/Views/FirewallPanel.vala @@ -55,20 +55,9 @@ public class SecurityPrivacy.FirewallPanel : Granite.SimpleSettingsPage { status_switch.notify["active"].connect (() => { if (loading == false) { - view.sensitive = status_switch.active; UFWHelpers.set_status (status_switch.active); } - - if (status_switch.active) { - status_type = Granite.SettingsPage.StatusType.SUCCESS; - status = _("Enabled"); - } else { - warning ("Trying to set offline"); - status_type = Granite.SettingsPage.StatusType.OFFLINE; - status = _("Disabled"); - } - - show_rules (); + update_status (); }); create_treeview (); @@ -81,13 +70,9 @@ public class SecurityPrivacy.FirewallPanel : Granite.SimpleSettingsPage { status_switch.active = UFWHelpers.get_status (); list_store.clear (); remove_button.sensitive = false; - if (status_switch.active == true) { - view.sensitive = true; - show_rules (); - } else { - view.sensitive = false; - } + loading = false; + update_status (); }); } @@ -465,4 +450,17 @@ public class SecurityPrivacy.FirewallPanel : Granite.SimpleSettingsPage { content_area.attach (frame, 0, 1, 3, 1); } + + private void update_status () { + view.sensitive = status_switch.active; + + if (status_switch.active) { + status_type = Granite.SettingsPage.StatusType.SUCCESS; + status = _("Enabled"); + show_rules (); + } else { + status_type = Granite.SettingsPage.StatusType.OFFLINE; + status = _("Disabled"); + } + } } diff --git a/src/Views/HouseKeepingPanel.vala b/src/Views/HouseKeepingPanel.vala index 01ab5577..5b836f08 100644 --- a/src/Views/HouseKeepingPanel.vala +++ b/src/Views/HouseKeepingPanel.vala @@ -153,10 +153,13 @@ public class SecurityPrivacy.HouseKeepingPanel : Granite.SimpleSettingsPage { if (all_active) { status_type = Granite.SettingsPage.StatusType.SUCCESS; + status = _("Enabled"); } else if (any_active) { status_type = Granite.SettingsPage.StatusType.WARNING; + status = _("Partially Enabled"); } else { status_type = Granite.SettingsPage.StatusType.OFFLINE; + status = _("Disabled"); } file_age_label.sensitive = any_active; diff --git a/src/Widgets/ServiceItem.vala b/src/Widgets/ServiceItem.vala deleted file mode 100644 index 3419c87a..00000000 --- a/src/Widgets/ServiceItem.vala +++ /dev/null @@ -1,95 +0,0 @@ -// -*- Mode: vala; indent-tabs-mode: nil; tab-width: 4 -*- -/*- - * Copyright (c) 2017 elementary LLC. (http://launchpad.net/switchboard-plug-security-privacy) - * - * This library 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 3 of the License, or (at your option) any later version. - * - * This library 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, write to the - * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - * Boston, MA 02110-1301 USA - */ - -public class ServiceItem: Gtk.ListBoxRow { - public enum Status { - ENABLED, - DISABLED, - PARTIAL - } - - public Status status { - set { - switch (value) { - case Status.ENABLED: - status_icon.icon_name = "user-available"; - status_label.label = _("Enabled"); - break; - case Status.DISABLED: - status_icon.icon_name = "user-offline"; - status_label.label = _("Disabled"); - break; - case Status.PARTIAL: - status_icon.icon_name = "user-away"; - status_label.label = _("Partially Enabled"); - break; - } - status_label.no_show_all = false; - status_label.show (); - status_label.label = "" + status_label.label + ""; - } - } - - private Gtk.Image status_icon; - private Gtk.Label status_label; - - public string icon_name { get; construct; } - public string label { get; construct; } - public string title { get; construct; } - - public ServiceItem (string icon_name, string title, string label) { - Object (icon_name: icon_name, - label: label, - title: title); - } - - construct { - var icon = new Gtk.Image.from_icon_name (icon_name, Gtk.IconSize.DND); - - var title_label = new Gtk.Label (label); - title_label.get_style_context ().add_class ("h3"); - title_label.ellipsize = Pango.EllipsizeMode.END; - title_label.xalign = 0; - - status_icon = new Gtk.Image (); - status_icon.halign = Gtk.Align.END; - status_icon.valign = Gtk.Align.END; - - status_label = new Gtk.Label (null); - status_label.no_show_all = true; - status_label.use_markup = true; - status_label.ellipsize = Pango.EllipsizeMode.END; - status_label.xalign = 0; - - var overlay = new Gtk.Overlay (); - overlay.width_request = 38; - overlay.add (icon); - overlay.add_overlay (status_icon); - - var grid = new Gtk.Grid (); - grid.margin = 6; - grid.column_spacing = 6; - grid.attach (overlay, 0, 0, 1, 2); - grid.attach (title_label, 1, 0, 1, 1); - grid.attach (status_label, 1, 1, 1, 1); - - add (grid); - } -} diff --git a/src/Widgets/ServiceList.vala b/src/Widgets/ServiceList.vala deleted file mode 100644 index 52483e34..00000000 --- a/src/Widgets/ServiceList.vala +++ /dev/null @@ -1,96 +0,0 @@ -// -*- Mode: vala; indent-tabs-mode: nil; tab-width: 4 -*- -/*- - * Copyright (c) 2017 elementary LLC. (http://launchpad.net/switchboard-plug-security-privacy) - * - * This library 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 3 of the License, or (at your option) any later version. - * - * This library 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, write to the - * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - * Boston, MA 02110-1301 USA - */ - -public class ServiceList : Gtk.ListBox { - private ServiceItem housekeeping_item; - Gee.HashMap services = new Gee.HashMap (); - - public ServiceList () { - Object (activate_on_single_click: true, - selection_mode: Gtk.SelectionMode.SINGLE); - } - - construct { - var privacy_item = new ServiceItem ("document-open-recent", "tracking", _("History")); - var lock_item = new ServiceItem ("system-lock-screen", "locking", _("Locking")); - var firewall_item = new ServiceItem ("network-firewall", "firewall", _("Firewall")); - housekeeping_item = new ServiceItem ( - "preferences-system-privacy-housekeeping", - "housekeeping", - _("Housekeeping") - ); - - add_service (privacy_item); - add_service (lock_item); - add_service (firewall_item); - add_service (housekeeping_item); - - SecurityPrivacy.firewall.status_switch.notify["active"].connect (() => { - update_service_status (firewall_item, SecurityPrivacy.firewall.status_switch.active); - }); - - update_service_status (privacy_item, SecurityPrivacy.tracking.status_switch.active); - - SecurityPrivacy.housekeeping.notify["status-type"].connect (() => { - update_housekeeping_status (); - }); - - update_housekeeping_status (); - - SecurityPrivacy.tracking.status_switch.notify["active"].connect (() => { - update_service_status (privacy_item, SecurityPrivacy.tracking.status_switch.active); - }); - - var location_item = new ServiceItem ("preferences-system-privacy-location", "location", _("Location Services")); - add_service (location_item); - update_service_status (location_item, SecurityPrivacy.location.status_switch.active); - - SecurityPrivacy.location.status_switch.notify["active"].connect (() => { - update_service_status (location_item, SecurityPrivacy.location.status_switch.active); - }); - } - - private void update_service_status (ServiceItem service_item, bool service_status) { - if (service_status) { - service_item.status = ServiceItem.Status.ENABLED; - } else { - service_item.status = ServiceItem.Status.DISABLED; - } - } - - private void update_housekeeping_status () { - if (SecurityPrivacy.housekeeping.status_type == Granite.SettingsPage.StatusType.SUCCESS) { - housekeeping_item.status = ServiceItem.Status.ENABLED; - } else if (SecurityPrivacy.housekeeping.status_type == Granite.SettingsPage.StatusType.WARNING) { - housekeeping_item.status = ServiceItem.Status.PARTIAL; - } else if (SecurityPrivacy.housekeeping.status_type == Granite.SettingsPage.StatusType.OFFLINE) { - housekeeping_item.status = ServiceItem.Status.DISABLED; - } - } - - public void add_service (ServiceItem service) { - add (service); - services.set (service.title, service); - } - - public void select_service_name (string name) { - select_row (services[name]); - } -} diff --git a/src/meson.build b/src/meson.build index 08fc5428..15f8d9b5 100644 --- a/src/meson.build +++ b/src/meson.build @@ -19,9 +19,7 @@ plug_files = files( 'Widgets/AppRow.vala', 'Widgets/ClearUsagePopover.vala', 'Widgets/ExcludeTreeView.vala', - 'Widgets/IncludeTreeView.vala', - 'Widgets/ServiceItem.vala', - 'Widgets/ServiceList.vala' + 'Widgets/IncludeTreeView.vala' ) plug_dependencies = [