[gnome-shell/wip/carlosg/sound-abstraction: 9/10] global: Drop API to play sounds



commit 78986b7ad9b89b7e8056a77ea06d3d60d9fd7709
Author: Carlos Garnacho <carlosg gnome org>
Date:   Thu Dec 13 20:37:24 2018 +0100

    global: Drop API to play sounds
    
    All callers have been updated to use MetaSoundPlayer. This drops direct
    usage of libcanberra-gtk, and the X11 connection indirectly.

 src/shell-global.c | 174 -----------------------------------------------------
 src/shell-global.h |  28 ---------
 2 files changed, 202 deletions(-)
---
diff --git a/src/shell-global.c b/src/shell-global.c
index dbd3bbe95..e02c5982d 100644
--- a/src/shell-global.c
+++ b/src/shell-global.c
@@ -16,8 +16,6 @@
 #include <locale.h>
 
 #include <X11/extensions/Xfixes.h>
-#include <canberra.h>
-#include <canberra-gtk.h>
 #include <clutter/x11/clutter-x11.h>
 #include <gdk/gdkx.h>
 #include <gio/gio.h>
@@ -1546,178 +1544,6 @@ shell_global_run_at_leisure (ShellGlobal         *global,
     schedule_leisure_functions (global);
 }
 
-static void
-build_ca_proplist_for_event (ca_proplist  *props,
-                             const char   *event_property,
-                             const char   *event_id,
-                             const char   *event_description,
-                             ClutterEvent *for_event)
-{
-  ca_proplist_sets (props, event_property, event_id);
-  ca_proplist_sets (props, CA_PROP_EVENT_DESCRIPTION, event_description);
-  ca_proplist_sets (props, CA_PROP_CANBERRA_CACHE_CONTROL, "volatile");
-
-  if (for_event)
-    {
-      if (clutter_event_type (for_event) != CLUTTER_KEY_PRESS &&
-          clutter_event_type (for_event) != CLUTTER_KEY_RELEASE)
-        {
-          ClutterPoint point;
-
-          clutter_event_get_position (for_event, &point);
-
-          ca_proplist_setf (props, CA_PROP_EVENT_MOUSE_X, "%d", (int)point.x);
-          ca_proplist_setf (props, CA_PROP_EVENT_MOUSE_Y, "%d", (int)point.y);
-        }
-
-      if (clutter_event_type (for_event) == CLUTTER_BUTTON_PRESS ||
-          clutter_event_type (for_event) == CLUTTER_BUTTON_RELEASE)
-        {
-          gint button;
-
-          button = clutter_event_get_button (for_event);
-          ca_proplist_setf (props, CA_PROP_EVENT_MOUSE_BUTTON, "%d", button);
-        }
-    }
-}
-
-/**
- * shell_global_play_theme_sound:
- * @global: the #ShellGlobal
- * @id: an id, used to cancel later (0 if not needed)
- * @name: the sound name
- * @for_event: (nullable): a #ClutterEvent in response to which the sound is played
- *
- * Plays a simple sound picked according to Freedesktop sound theme.
- * Really just a workaround for libcanberra not being introspected.
- */
-void
-shell_global_play_theme_sound (ShellGlobal  *global,
-                               guint         id,
-                               const char   *name,
-                               const char   *description,
-                               ClutterEvent *for_event)
-{
-  ca_proplist *props;
-
-  ca_proplist_create (&props);
-  build_ca_proplist_for_event (props, CA_PROP_EVENT_ID, name, description, for_event);
-
-  ca_context_play_full (global->sound_context, id, props, NULL, NULL);
-
-  ca_proplist_destroy (props);
-}
-
-/**
- * shell_global_play_theme_sound_full:
- * @global: the #ShellGlobal
- * @id: an id, used to cancel later (0 if not needed)
- * @name: the sound name
- * @description: the localized description of the event that triggered this alert
- * @for_event: (nullable): a #ClutterEvent in response to which the sound is played
- * @application_id: application on behalf of which the sound is played
- * @application_name:
- *
- * Plays a simple sound picked according to Freedesktop sound theme.
- * Really just a workaround for libcanberra not being introspected.
- */
-void
-shell_global_play_theme_sound_full (ShellGlobal  *global,
-                                    guint         id,
-                                    const char   *name,
-                                    const char   *description,
-                                    ClutterEvent *for_event,
-                                    const char   *application_id,
-                                    const char   *application_name)
-{
-  ca_proplist *props;
-
-  ca_proplist_create (&props);
-  build_ca_proplist_for_event (props, CA_PROP_EVENT_ID, name, description, for_event);
-  ca_proplist_sets (props, CA_PROP_APPLICATION_ID, application_id);
-  ca_proplist_sets (props, CA_PROP_APPLICATION_NAME, application_name);
-
-  ca_context_play_full (global->sound_context, id, props, NULL, NULL);
-
-  ca_proplist_destroy (props);
-}
-
-/**
- * shell_global_play_sound_file_full:
- * @global: the #ShellGlobal
- * @id: an id, used to cancel later (0 if not needed)
- * @file_name: the file name to play
- * @description: the localized description of the event that triggered this alert
- * @for_event: (nullable): a #ClutterEvent in response to which the sound is played
- * @application_id: application on behalf of which the sound is played
- * @application_name:
- *
- * Like shell_global_play_theme_sound_full(), but with an explicit path
- * instead of a themed sound.
- */
-void
-shell_global_play_sound_file_full  (ShellGlobal  *global,
-                                    guint         id,
-                                    const char   *file_name,
-                                    const char   *description,
-                                    ClutterEvent *for_event,
-                                    const char   *application_id,
-                                    const char   *application_name)
-{
-  ca_proplist *props;
-
-  ca_proplist_create (&props);
-  build_ca_proplist_for_event (props, CA_PROP_MEDIA_FILENAME, file_name, description, for_event);
-  ca_proplist_sets (props, CA_PROP_APPLICATION_ID, application_id);
-  ca_proplist_sets (props, CA_PROP_APPLICATION_NAME, application_name);
-
-  ca_context_play_full (global->sound_context, id, props, NULL, NULL);
-
-  ca_proplist_destroy (props);
-}
-
-/**
- * shell_global_play_sound_file:
- * @global: the #ShellGlobal
- * @id: an id, used to cancel later (0 if not needed)
- * @file_name: the file name to play
- * @description: the localized description of the event that triggered this alert
- * @for_event: (nullable): a #ClutterEvent in response to which the sound is played
- *
- * Like shell_global_play_theme_sound(), but with an explicit path
- * instead of a themed sound.
- */
-void
-shell_global_play_sound_file (ShellGlobal  *global,
-                              guint         id,
-                              const char   *file_name,
-                              const char   *description,
-                              ClutterEvent *for_event)
-{
-  ca_proplist *props;
-
-  ca_proplist_create (&props);
-  build_ca_proplist_for_event (props, CA_PROP_MEDIA_FILENAME, file_name, description, for_event);
-
-  ca_context_play_full (global->sound_context, id, props, NULL, NULL);
-
-  ca_proplist_destroy (props);
-}
-
-/**
- * shell_global_cancel_theme_sound:
- * @global: the #ShellGlobal
- * @id: the id previously passed to shell_global_play_theme_sound()
- *
- * Cancels a sound notification.
- */
-void
-shell_global_cancel_theme_sound (ShellGlobal *global,
-                                 guint id)
-{
-  ca_context_cancel (global->sound_context, id);
-}
-
 const char *
 shell_global_get_session_mode (ShellGlobal *global)
 {
diff --git a/src/shell-global.h b/src/shell-global.h
index c8cddf883..9d9bc19fd 100644
--- a/src/shell-global.h
+++ b/src/shell-global.h
@@ -71,34 +71,6 @@ GAppLaunchContext *
                                                  guint32       timestamp,
                                                  int           workspace);
 
-void     shell_global_play_theme_sound          (ShellGlobal *global,
-                                                 guint        id,
-                                                 const char   *name,
-                                                 const char   *description,
-                                                 ClutterEvent *for_event);
-void     shell_global_play_theme_sound_full     (ShellGlobal  *global,
-                                                 guint         id,
-                                                 const char   *name,
-                                                 const char   *description,
-                                                 ClutterEvent *for_event,
-                                                 const char   *application_id,
-                                                 const char   *application_name);
-void     shell_global_play_sound_file           (ShellGlobal  *global,
-                                                 guint         id,
-                                                 const char   *file_name,
-                                                 const char   *description,
-                                                 ClutterEvent *for_event);
-void     shell_global_play_sound_file_full      (ShellGlobal  *global,
-                                                 guint         id,
-                                                 const char   *file_name,
-                                                 const char   *description,
-                                                 ClutterEvent *for_event,
-                                                 const char   *application_id,
-                                                 const char   *application_name);
-
-void     shell_global_cancel_theme_sound        (ShellGlobal  *global,
-                                                 guint         id);
-
 void     shell_global_notify_error              (ShellGlobal  *global,
                                                  const char   *msg,
                                                  const char   *details);


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]