aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordec05eba <dec05eba@protonmail.com>2024-07-21 23:43:25 +0200
committerdec05eba <dec05eba@protonmail.com>2024-07-21 23:43:25 +0200
commit6121a88c6738a667e1a8466706a7caccacb07256 (patch)
tree63b0b3fe76f950b6e488a70714212d616814b7e4
parent7183f6d98e7180b1f242143b9977debf803e66e7 (diff)
Test libnotify
-rw-r--r--meson.build1
-rw-r--r--project.conf3
-rw-r--r--src/main.cpp21
3 files changed, 19 insertions, 6 deletions
diff --git a/meson.build b/meson.build
index 5851485..8ec9220 100644
--- a/meson.build
+++ b/meson.build
@@ -14,6 +14,7 @@ src = [
dep = [
dependency('gtk+-3.0'),
+ dependency('libnotify'),
dependency('x11'),
dependency('libpulse'),
dependency('ayatana-appindicator3-0.1'),
diff --git a/project.conf b/project.conf
index 9792588..8b41f0d 100644
--- a/project.conf
+++ b/project.conf
@@ -10,6 +10,7 @@ error_on_warning = "true"
[dependencies]
gtk+-3.0 = "3"
+libnotify = ">=0"
x11 = "1"
libpulse = ">=13"
-ayatana-appindicator3-0.1 = ">=0"
+ayatana-appindicator3-0.1 = ">=0" \ No newline at end of file
diff --git a/src/main.cpp b/src/main.cpp
index a86f254..f2ded20 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -5,6 +5,7 @@ extern "C" {
#include <gtk/gtk.h>
#include <gdk/gdkx.h>
#include <gdk/gdkwayland.h>
+#include <libnotify/notify.h>
#include <X11/Xlib.h>
#include <X11/Xatom.h>
#include <X11/cursorfont.h>
@@ -983,11 +984,18 @@ static void save_configs() {
}
static void show_notification(GtkApplication *app, const char *title, const char *body, GNotificationPriority priority) {
+ (void)app;
fprintf(stderr, "Notification: title: %s, body: %s\n", title, body);
- GNotification *notification = g_notification_new(title);
- g_notification_set_body(notification, body);
- g_notification_set_priority(notification, priority);
- g_application_send_notification(&app->parent, "gpu-screen-recorder", notification);
+ NotifyNotification *notification = notify_notification_new(title, body, "com.dec05eba.gpu_screen_recorder");
+ if(notification) {
+ notify_notification_set_category(notification, "normal");
+ notify_notification_set_timeout(notification, 2000);
+ notify_notification_show(notification, NULL);
+ }
+ // GNotification *notification = g_notification_new(title);
+ // g_notification_set_body(notification, body);
+ // g_notification_set_priority(notification, priority);
+ // g_application_send_notification(&app->parent, "gpu-screen-recorder", notification);
showing_notification = true;
if(priority < G_NOTIFICATION_PRIORITY_URGENT) {
@@ -3766,12 +3774,13 @@ static void handle_record_timer() {
}
static void handle_notification_timer(GtkApplication *app) {
+ (void)app;
if(!showing_notification)
return;
const double now = clock_get_monotonic_seconds();
if(now - notification_start_seconds >= notification_timeout_seconds) {
- g_application_withdraw_notification(&app->parent, "gpu-screen-recorder");
+ //g_application_withdraw_notification(&app->parent, "gpu-screen-recorder");
showing_notification = false;
}
}
@@ -4174,9 +4183,11 @@ int main(int argc, char **argv) {
}
}
+ notify_init("com.dec05eba.gpu_screen_recorder");
GtkApplication *app = gtk_application_new("com.dec05eba.gpu_screen_recorder", G_APPLICATION_NON_UNIQUE);
g_signal_connect(app, "activate", G_CALLBACK(activate), NULL);
int status = g_application_run(G_APPLICATION(app), argc, argv);
g_object_unref(app);
+ notify_uninit();
return status;
}