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

AppSettingsView: don't block settings when DND is active #102

Merged
merged 1 commit into from
Mar 13, 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
8 changes: 8 additions & 0 deletions data/SettingsOption.css
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,21 @@
* Boston, MA 02110-1301 USA.
*/

settingspage.notifications infobar revealer > box {
background-color: mix(@GRAPE_500, @GRAPE_700, 0.5);
background-image: -gtk-icontheme("notification-disabled-symbolic");
color: white;
margin-bottom: 2em;
}

settingspage.notifications .card {
background-position: center;
background-repeat: no-repeat;
background-size: 112px 80px, cover;
min-width: 112px;
min-height: 80px;
margin-top: 1em;
margin-bottom: 2em;
}

settingspage.notifications .card.bubbles {
Expand Down
17 changes: 16 additions & 1 deletion src/Widgets/AppSettingsView.vala
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,18 @@ public class Widgets.AppSettingsView : Switchboard.SettingsPage {
}

construct {
var dnd_header = new Granite.HeaderLabel (_("Do Not Disturb is active")) {
halign = FILL,
hexpand = true,
secondary_text = _("Bubbles will be hidden and sounds will be silenced. System notifications, such as volume and display brightness, will be unaffected.")
};

var dnd_infobar = new Gtk.InfoBar () {
message_type = INFO
};
dnd_infobar.add_child (dnd_header);
dnd_infobar.add_css_class (Granite.STYLE_CLASS_FRAME);

bubbles_option = new SettingsOption (
"bubbles",
_("Bubbles"),
Expand All @@ -48,7 +60,8 @@ public class Widgets.AppSettingsView : Switchboard.SettingsPage {
_("Show missed notifications in Notification Center.")
);

var box = new Gtk.Box (VERTICAL, 24);
var box = new Gtk.Box (VERTICAL, 0);
box.append (dnd_infobar);
box.append (bubbles_option);
box.append (sound_option);
box.append (remember_option);
Expand All @@ -62,6 +75,8 @@ public class Widgets.AppSettingsView : Switchboard.SettingsPage {
remove_bindings ();
update_selected_app ();
});

NotificationsPlug.notify_settings.bind ("do-not-disturb", dnd_infobar, "revealed", GET);
}

private void remove_bindings () {
Expand Down
28 changes: 1 addition & 27 deletions src/Widgets/MainView.vala
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@

public class Widgets.MainView : Gtk.Widget {
private Gtk.Paned main_widget;
private Gtk.Stack stack;

static construct {
set_layout_manager_type (typeof (Gtk.BinLayout));
Expand All @@ -30,40 +29,15 @@ public class Widgets.MainView : Gtk.Widget {

var app_settings_view = new AppSettingsView ();

var description = _("While in Do Not Disturb mode, notifications and alerts will be hidden and notification sounds will be silenced.");
description += "\n\n";
description += _("System notifications, such as volume and display brightness, will be unaffected.");

var alert_view = new Granite.Placeholder (_("Do Not Disturb is active")) {
description = description,
icon = new ThemedIcon ("notification-disabled")
};

stack = new Gtk.Stack ();
stack.add_named (app_settings_view, "app-settings-view");
stack.add_named (alert_view, "alert-view");

main_widget = new Gtk.Paned (Gtk.Orientation.HORIZONTAL) {
start_child = sidebar,
end_child = stack,
end_child = app_settings_view,
resize_start_child = false,
shrink_start_child = false,
shrink_end_child = false,
position = 240
};
main_widget.set_parent (this);

update_view ();

NotificationsPlug.notify_settings.changed["do-not-disturb"].connect (update_view);
}

private void update_view () {
if (NotificationsPlug.notify_settings.get_boolean ("do-not-disturb")) {
stack.visible_child_name = "alert-view";
} else {
stack.visible_child_name = "app-settings-view";
}
}

~MainView () {
Expand Down
9 changes: 1 addition & 8 deletions src/Widgets/Sidebar.vala
Original file line number Diff line number Diff line change
Expand Up @@ -76,17 +76,10 @@ public class Widgets.Sidebar : Gtk.Box {
app_list.invalidate_filter ();
});

NotificationsPlug.notify_settings.bind (
"do-not-disturb",
app_list,
"sensitive",
SettingsBindFlags.INVERT_BOOLEAN
);

NotificationsPlug.notify_settings.bind (
"do-not-disturb",
do_not_disturb_switch,
"state",
"active",
SettingsBindFlags.DEFAULT
);

Expand Down
Loading