commit 3c8f1115e02a01e035fecc118b9dae05f977b0b5
parent 157b21157fa1e4536073054b910a742b5a1579d0
Author: Jacki <jacki@thejackimonster.de>
Date: Fri, 27 Sep 2024 21:40:25 +0200
Implement setting to play notification sounds
Signed-off-by: Jacki <jacki@thejackimonster.de>
Diffstat:
5 files changed, 26 insertions(+), 2 deletions(-)
diff --git a/resources/ui/settings.ui b/resources/ui/settings.ui
@@ -243,9 +243,8 @@ Author: Tobias Frisch
</packing>
</child>
<child>
- <object class="GtkSwitch">
+ <object class="GtkSwitch" id="notification_sounds_switch">
<property name="visible">True</property>
- <property name="sensitive">False</property>
<property name="can-focus">True</property>
</object>
<packing>
diff --git a/src/application.h b/src/application.h
@@ -160,6 +160,7 @@ typedef struct MESSENGER_Application
gboolean background_task;
gboolean disable_notifications;
+ gboolean play_notification_sounds;
gboolean send_read_receipts;
diff --git a/src/event.c b/src/event.c
@@ -37,6 +37,7 @@
#include <gnunet/gnunet_chat_lib.h>
#include <gnunet/gnunet_common.h>
+#include <stdio.h>
static void
_close_notification(NotifyNotification* notification,
@@ -93,6 +94,12 @@ _show_notification(MESSENGER_Application *app,
);
notify_notification_show(notification, NULL);
+
+ if (app->settings.play_notification_sounds)
+ {
+ fprintf(stdout, "\a");
+ fflush(stdout);
+ }
}
void
diff --git a/src/ui/settings.c b/src/ui/settings.c
@@ -368,11 +368,20 @@ ui_settings_dialog_init(MESSENGER_Application *app,
gtk_builder_get_object(handle->builder, "enable_notifications_switch")
);
+ handle->notification_sounds_switch = GTK_SWITCH(
+ gtk_builder_get_object(handle->builder, "notification_sounds_switch")
+ );
+
gtk_switch_set_active(
handle->enable_notifications_switch,
!(app->settings.disable_notifications)
);
+ gtk_switch_set_active(
+ handle->notification_sounds_switch,
+ app->settings.play_notification_sounds
+ );
+
g_signal_connect(
handle->enable_notifications_switch,
"state-set",
@@ -380,6 +389,13 @@ ui_settings_dialog_init(MESSENGER_Application *app,
&(app->settings.disable_notifications)
);
+ g_signal_connect(
+ handle->notification_sounds_switch,
+ "state-set",
+ G_CALLBACK(handle_general_switch_state),
+ &(app->settings.play_notification_sounds)
+ );
+
handle->blocked_label = GTK_LABEL(
gtk_builder_get_object(handle->builder, "blocked_label")
);
diff --git a/src/ui/settings.h b/src/ui/settings.h
@@ -36,6 +36,7 @@ typedef struct UI_SETTINGS_Handle
GtkSwitch *run_in_background_switch;
GtkSwitch *enable_notifications_switch;
+ GtkSwitch *notification_sounds_switch;
GtkLabel *blocked_label;
GtkWidget *blocked_scrolled_window;