[gtk/soundcheck] Add a quick sound test
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk/soundcheck] Add a quick sound test
- Date: Wed, 29 Apr 2020 14:56:19 +0000 (UTC)
commit f8ef15b555fc3d21ede2e3f8d01c068cbe5c7e03
Author: Matthias Clasen <mclasen redhat com>
Date: Wed Apr 29 10:54:40 2020 -0400
Add a quick sound test
Just to show that our media infrastructure is up
to playing little beeps and bings.
tests/meson.build | 1 +
tests/service-login.oga | Bin 0 -> 17274 bytes
tests/service-logout.oga | Bin 0 -> 14573 bytes
tests/testsounds.c | 68 +++++++++++++++++++++++++++++++++++++++++++++++
4 files changed, 69 insertions(+)
---
diff --git a/tests/meson.build b/tests/meson.build
index 45014aca7b..a6a386ef4b 100644
--- a/tests/meson.build
+++ b/tests/meson.build
@@ -73,6 +73,7 @@ gtk_tests = [
['testprint', ['testprintfileoperation.c']],
['testscale'],
['testselectionmode'],
+ ['testsounds'],
['testspinbutton'],
['testtoolbar2'],
['testtreechanging'],
diff --git a/tests/service-login.oga b/tests/service-login.oga
new file mode 100644
index 0000000000..7d931b736c
Binary files /dev/null and b/tests/service-login.oga differ
diff --git a/tests/service-logout.oga b/tests/service-logout.oga
new file mode 100644
index 0000000000..c5b6f314e4
Binary files /dev/null and b/tests/service-logout.oga differ
diff --git a/tests/testsounds.c b/tests/testsounds.c
new file mode 100644
index 0000000000..169120eb71
--- /dev/null
+++ b/tests/testsounds.c
@@ -0,0 +1,68 @@
+#include <gtk/gtk.h>
+
+static void
+ended (GObject *object)
+{
+ g_object_unref (object);
+}
+
+static void
+play (const char *name)
+{
+ char *path;
+ GtkMediaStream *stream;
+
+ path = g_build_filename ("tests", name, NULL);
+
+ stream = gtk_media_file_new_for_filename (path);
+ gtk_media_stream_set_volume (stream, 1.0);
+
+ gtk_media_stream_play (stream);
+
+ g_signal_connect (stream, "notify::ended", G_CALLBACK (ended), NULL);
+
+ g_free (path);
+}
+
+static void
+enter (GtkButton *button)
+{
+ play ("service-login.oga");
+}
+
+static void
+leave (GtkButton *button)
+{
+ play ("service-logout.oga");
+}
+
+int main (int argc, char *argv[])
+{
+ GtkWidget *window;
+ GtkWidget *box;
+ GtkWidget *button;
+
+ gtk_init ();
+
+ window = gtk_window_new ();
+
+ box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 10);
+ gtk_widget_set_halign (box, GTK_ALIGN_CENTER);
+ gtk_widget_set_valign (box, GTK_ALIGN_CENTER);
+ gtk_container_add (GTK_CONTAINER (window), box);
+
+ button = gtk_button_new_with_label ("Α");
+ g_signal_connect (button, "clicked", G_CALLBACK (enter), NULL);
+ gtk_container_add (GTK_CONTAINER (box), button);
+
+ button = gtk_button_new_with_label ("Ω");
+ g_signal_connect (button, "clicked", G_CALLBACK (leave), NULL);
+ gtk_container_add (GTK_CONTAINER (box), button);
+
+ gtk_window_present (GTK_WINDOW (window));
+
+ while (1)
+ g_main_context_iteration (NULL, FALSE);
+
+ return 0;
+}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]