Skip to content

Commit dc1db3e

Browse files
authored
Launcher: Hide badge if do not disturb is active (#295)
1 parent c06b054 commit dc1db3e

File tree

2 files changed

+18
-7
lines changed

2 files changed

+18
-7
lines changed

data/dock.metainfo.xml.in

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
<issues>
3434
<issue url="https://github.com/elementary/dock/issues/276">Changing Dock size left the dock with extra empty space</issue>
3535
<issue url="https://github.com/elementary/dock/issues/279">Dock using too much CPU/RAM</issue>
36+
<issue url="https://github.com/elementary/dock/issues/284">Hide notification badges when Do Not Disturb is on</issue>
3637
</issues>
3738
</release>
3839

src/Launcher.vala

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,17 @@
44
*/
55

66
public class Dock.Launcher : Gtk.Box {
7+
private static Settings settings;
8+
private static Settings? notify_settings;
9+
10+
static construct {
11+
settings = new Settings ("io.elementary.dock");
12+
13+
if (SettingsSchemaSource.get_default ().lookup ("io.elementary.notifications", true) != null) {
14+
notify_settings = new Settings ("io.elementary.notifications");
15+
}
16+
}
17+
718
public signal void revealed_done ();
819

920
// Matches icon size and padding in Launcher.css
@@ -40,8 +51,6 @@ public class Dock.Launcher : Gtk.Box {
4051
}
4152
}
4253

43-
private static Settings settings;
44-
4554
private Gtk.Image image;
4655
private Gtk.Revealer progress_revealer;
4756
private Gtk.Revealer badge_revealer;
@@ -70,10 +79,6 @@ public class Dock.Launcher : Gtk.Box {
7079
set_css_name ("launcher");
7180
}
7281

73-
static construct {
74-
settings = new Settings ("io.elementary.dock");
75-
}
76-
7782
construct {
7883
popover = new Gtk.PopoverMenu.from_model (app.menu_model) {
7984
autohide = true,
@@ -238,6 +243,10 @@ public class Dock.Launcher : Gtk.Box {
238243
}, null
239244
);
240245

246+
if (notify_settings != null) {
247+
notify_settings.changed["do-not-disturb"].connect (update_badge_revealer);
248+
}
249+
241250
app.notify["progress-visible"].connect (update_progress_revealer);
242251
update_progress_revealer ();
243252

@@ -471,7 +480,8 @@ public class Dock.Launcher : Gtk.Box {
471480
}
472481

473482
private void update_badge_revealer () {
474-
badge_revealer.reveal_child = !moving && app.count_visible;
483+
badge_revealer.reveal_child = !moving && app.count_visible
484+
&& (notify_settings == null || !notify_settings.get_boolean ("do-not-disturb"));
475485
}
476486

477487
private void update_progress_revealer () {

0 commit comments

Comments
 (0)