diff --git a/src/Widgets/AppSettingsView.vala b/src/Widgets/AppSettingsView.vala index afe70203..0df5e6b4 100644 --- a/src/Widgets/AppSettingsView.vala +++ b/src/Widgets/AppSettingsView.vala @@ -24,6 +24,7 @@ public class Widgets.AppSettingsView : Gtk.Grid { private SettingsOption bubbles_option; private SettingsOption sound_option; private SettingsOption remember_option; + private Gtk.Switch bypass_do_not_disturb_switch; construct { app_image = new Gtk.Image () { @@ -37,11 +38,27 @@ public class Widgets.AppSettingsView : Gtk.Grid { }; app_label.get_style_context ().add_class (Granite.STYLE_CLASS_H2_LABEL); + var bypass_do_not_disturb_label = new Granite.HeaderLabel (_("Bypass Do Not Disturb")) { + margin_start = 3 + }; + + bypass_do_not_disturb_switch = new Gtk.Switch () { + margin = 6, + margin_end = 3 + }; + + var bypass_do_not_disturb_grid = new Gtk.Grid () { + margin_top = 6 + }; + bypass_do_not_disturb_grid.attach (bypass_do_not_disturb_label, 0, 0); + bypass_do_not_disturb_grid.attach (bypass_do_not_disturb_switch, 1, 0); + var header = new Gtk.Grid () { column_spacing = 12 }; header.attach (app_image, 0, 0); header.attach (app_label, 1, 0); + header.attach (bypass_do_not_disturb_grid, 2, 0); bubbles_option = new SettingsOption ( "/io/elementary/switchboard/bubbles.svg", @@ -77,12 +94,16 @@ public class Widgets.AppSettingsView : Gtk.Grid { remove_bindings (); update_selected_app (); }); + + bypass_do_not_disturb_switch.notify["state"].connect (update_view); + NotificationsPlug.notify_settings.changed["do-not-disturb"].connect (update_view); } private void remove_bindings () { Settings.unbind (bubbles_option.widget, "state"); Settings.unbind (sound_option.widget, "state"); Settings.unbind (remember_option.widget, "state"); + Settings.unbind (bypass_do_not_disturb_switch, "state"); } private void update_selected_app () { @@ -93,8 +114,19 @@ public class Widgets.AppSettingsView : Gtk.Grid { selected_app.settings.bind ("bubbles", bubbles_option.widget, "state", GLib.SettingsBindFlags.DEFAULT); selected_app.settings.bind ("sounds", sound_option.widget, "state", GLib.SettingsBindFlags.DEFAULT); selected_app.settings.bind ("remember", remember_option.widget, "state", GLib.SettingsBindFlags.DEFAULT); + selected_app.settings.bind ("bypass-do-not-disturb", bypass_do_not_disturb_switch, "state", GLib.SettingsBindFlags.DEFAULT); app_label.label = selected_app.app_info.get_display_name (); app_image.gicon = selected_app.app_info.get_icon (); + + update_view (); + } + + private void update_view () { + if (NotificationsPlug.notify_settings.get_boolean ("do-not-disturb") && !bypass_do_not_disturb_switch.state) { + bubbles_option.sensitive = sound_option.sensitive = remember_option.sensitive = false; + } else { + bubbles_option.sensitive = sound_option.sensitive = remember_option.sensitive = true; + } } } diff --git a/src/Widgets/MainView.vala b/src/Widgets/MainView.vala index eb2085f5..ef77a437 100644 --- a/src/Widgets/MainView.vala +++ b/src/Widgets/MainView.vala @@ -18,7 +18,7 @@ */ public class Widgets.MainView : Gtk.Paned { - private Gtk.Stack stack; + //private Gtk.Stack stack; construct { var sidebar = new Sidebar (); @@ -26,35 +26,8 @@ public class Widgets.MainView : Gtk.Paned { var app_settings_view = new AppSettingsView (); app_settings_view.show_all (); - 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.Widgets.AlertView ( - _("elementary OS is in Do Not Disturb mode"), - description, - "notification-disabled" - ); - alert_view.show_all (); - - stack = new Gtk.Stack (); - stack.add_named (app_settings_view, "app-settings-view"); - stack.add_named (alert_view, "alert-view"); - pack1 (sidebar, true, false); - pack2 (stack, true, false); + pack2 (app_settings_view, true, false); set_position (240); - - 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"; - } } } diff --git a/src/Widgets/Sidebar.vala b/src/Widgets/Sidebar.vala index 6c67daa3..f7b6979b 100644 --- a/src/Widgets/Sidebar.vala +++ b/src/Widgets/Sidebar.vala @@ -50,13 +50,6 @@ public class Widgets.Sidebar : Gtk.Grid { app_list.row_selected.connect (show_row); - NotificationsPlug.notify_settings.bind ( - "do-not-disturb", - app_list, - "sensitive", - SettingsBindFlags.INVERT_BOOLEAN - ); - NotificationsPlug.notify_settings.bind ( "do-not-disturb", do_not_disturb_switch,