Skip to content

Commit 5d0040b

Browse files
authored
Don't depend on libnotify (#310)
* Don't depend on `libnotify` * CI: Update dependencies
1 parent afee7a1 commit 5d0040b

3 files changed

Lines changed: 10 additions & 32 deletions

File tree

‎.github/workflows/main.yml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ jobs:
2323
- name: Install Dependencies
2424
run: |
2525
apt update
26-
apt install -y libgranite-7-dev libgtop2-dev libudev-dev libwingpanel-9-dev libnotify-dev meson valac
26+
apt install -y libgranite-7-dev libgtop2-dev libudev-dev libwingpanel-9-dev meson valac
2727
- name: Build
2828
env:
2929
DESTDIR: out

‎src/Indicator.vala‎

Lines changed: 9 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -218,44 +218,23 @@ public class Power.Indicator : Wingpanel.Indicator {
218218
}
219219
}
220220

221-
private bool show_notification () {
222-
if (is_in_session) {
223-
var notification = new Notify.Notification ("indicator-power", "", "display-brightness-symbolic");
224-
notification.set_hint ("x-canonical-private-synchronous", new Variant.string ("indicator-power"));
225-
notification.set_hint ("value", new Variant.int32 ((int) (brightness_manager.get_global_brightness () * 100)));
226-
try {
227-
notification.show ();
228-
return true;
229-
} catch (Error e) {
230-
warning ("Unable to show notification: %s", e.message);
231-
}
232-
233-
}
234-
235-
return false;
236-
}
237-
238221
private void setup_scroll_controller () {
239222
if (brightness_manager.present) {
240223
var scroll_controller = new Gtk.EventControllerScroll (BOTH_AXES);
241-
scroll_controller.scroll.connect ((controller, dx, dy) => {
242-
if (Utils.handle_global_scroll_event (
243-
(Gdk.ScrollEvent) controller.get_current_event ())
244-
) {
245-
if (popover_widget == null || !popover_widget.is_visible ()) {
246-
show_notification ();
247-
}
248-
249-
return true;
250-
}
251-
252-
return false;
253-
});
224+
scroll_controller.scroll.connect (on_scroll);
254225
display_widget.add_controller (scroll_controller);
255226

256227
brightness_manager.monitor_brightness_changed.connect (update_tooltip);
257228
}
258229
}
230+
231+
private bool on_scroll (Gtk.EventControllerScroll controller, double dx, double dy) {
232+
if (Utils.handle_global_scroll_event ((Gdk.ScrollEvent) controller.get_current_event ())) {
233+
maybe_show_brightness_osd (brightness_manager.get_global_brightness ());
234+
return true;
235+
}
236+
return false;
237+
}
259238
}
260239

261240
public Wingpanel.Indicator get_indicator (Module module, Wingpanel.ServerType server_type) {

‎src/meson.build‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,6 @@ dependencies = [
3838
dependency('gtk4'),
3939
dependency('libgtop-2.0'),
4040
dependency('libudev'),
41-
dependency('libnotify'),
4241
meson.get_compiler('vala').find_library('posix'),
4342
wingpanel_dep
4443
]

0 commit comments

Comments
 (0)