Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use Granite.SettingsSidebar #165

Merged
merged 3 commits into from
Jan 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions po/POTFILES
Original file line number Diff line number Diff line change
Expand Up @@ -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
12 changes: 2 additions & 10 deletions src/Plug.vala
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down Expand Up @@ -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 () {
Expand All @@ -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", "keyboard<sep>behavior")
Expand Down
34 changes: 16 additions & 18 deletions src/Views/FirewallPanel.vala
Original file line number Diff line number Diff line change
Expand Up @@ -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 ();
Expand All @@ -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 ();
});
}

Expand Down Expand Up @@ -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");
}
}
}
3 changes: 3 additions & 0 deletions src/Views/HouseKeepingPanel.vala
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
95 changes: 0 additions & 95 deletions src/Widgets/ServiceItem.vala

This file was deleted.

96 changes: 0 additions & 96 deletions src/Widgets/ServiceList.vala

This file was deleted.

4 changes: 1 addition & 3 deletions src/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -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 = [
Expand Down