[gtk+/matthiasc/wayland/beep: 2/3] wayland: Add private api to get a ca_context
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+/matthiasc/wayland/beep: 2/3] wayland: Add private api to get a ca_context
- Date: Wed, 2 Mar 2016 17:53:49 +0000 (UTC)
commit 886f521fb57c466e1a0db71dbd83bbf6ad95c92b
Author: Matthias Clasen <mclasen redhat com>
Date: Wed Mar 2 12:43:30 2016 -0500
wayland: Add private api to get a ca_context
Make GdkWaylandScreen keep a ca_context and make
it available via private API. We also update the
context when sound-related settings change.
https://bugzilla.gnome.org/show_bug.cgi?id=763001
gdk/wayland/gdkprivate-wayland.h | 4 ++
gdk/wayland/gdkscreen-wayland.c | 86 ++++++++++++++++++++++++++++++++++++++
2 files changed, 90 insertions(+), 0 deletions(-)
---
diff --git a/gdk/wayland/gdkprivate-wayland.h b/gdk/wayland/gdkprivate-wayland.h
index a60c4c3..56d4042 100644
--- a/gdk/wayland/gdkprivate-wayland.h
+++ b/gdk/wayland/gdkprivate-wayland.h
@@ -36,6 +36,8 @@
#include <xkbcommon/xkbcommon.h>
+#include <canberra.h>
+
#include "gdkinternals.h"
#include "wayland/gtk-primary-selection-client-protocol.h"
@@ -276,4 +278,6 @@ EGLSurface gdk_wayland_window_get_dummy_egl_surface (GdkWindow *window,
void gdk_wayland_seat_set_global_cursor (GdkSeat *seat,
GdkCursor *cursor);
+ca_context *gdk_wayland_screen_get_ca_context (GdkScreen *screen);
+
#endif /* __GDK_PRIVATE_WAYLAND_H__ */
diff --git a/gdk/wayland/gdkscreen-wayland.c b/gdk/wayland/gdkscreen-wayland.c
index ec0d403..3f1f5f6 100644
--- a/gdk/wayland/gdkscreen-wayland.c
+++ b/gdk/wayland/gdkscreen-wayland.c
@@ -31,6 +31,8 @@
#include "wm-button-layout-translation.h"
+#include "canberra.h"
+
typedef struct _GdkWaylandScreen GdkWaylandScreen;
typedef struct _GdkWaylandScreenClass GdkWaylandScreenClass;
@@ -70,6 +72,7 @@ struct _GdkWaylandScreen
GHashTable *settings;
GsdXftSettings xft_settings;
+ ca_context *ca_context;
guint32 shell_capabilities;
};
@@ -159,6 +162,9 @@ gdk_wayland_screen_finalize (GObject *object)
deinit_multihead (GDK_SCREEN (object));
+ if (screen_wayland->ca_context)
+ ca_context_destroy (screen_wayland->ca_context);
+
g_hash_table_destroy (screen_wayland->settings);
G_OBJECT_CLASS (_gdk_wayland_screen_parent_class)->finalize (object);
@@ -595,6 +601,83 @@ find_translation_entry_by_setting (const gchar *setting)
return NULL;
}
+ca_context *
+gdk_wayland_screen_get_ca_context (GdkScreen *screen)
+{
+ GdkWaylandScreen *screen_wayland = GDK_WAYLAND_SCREEN (screen);
+ ca_context *c;
+ ca_proplist *p;
+ const char *name;
+ GSettings *settings;
+
+ if (screen_wayland->ca_context)
+ goto out;
+
+ if (ca_context_create (&c) != CA_SUCCESS)
+ return NULL;
+
+ if (ca_proplist_create (&p) != CA_SUCCESS)
+ {
+ ca_context_destroy (c);
+ return NULL;
+ }
+
+ name = g_get_application_name ();
+ if (name)
+ ca_proplist_sets (p, CA_PROP_APPLICATION_NAME, name);
+
+ settings = g_hash_table_lookup (screen_wayland->settings, "org.gnome.desktop.sound");
+
+ if (settings)
+ {
+ char *theme_name;
+ gboolean event_sounds;
+
+ theme_name = g_settings_get_string (settings, "theme-name");
+ event_sounds = g_settings_get_boolean (settings, "event-sounds");
+
+ ca_proplist_sets (p, CA_PROP_CANBERRA_XDG_THEME_NAME, theme_name);
+ ca_proplist_sets (p, CA_PROP_CANBERRA_ENABLE, event_sounds ? "1" : "0");
+
+ g_free (theme_name);
+ }
+
+ ca_context_change_props_full (c, p);
+ ca_proplist_destroy (p);
+
+ screen_wayland->ca_context = c;
+
+out:
+ return screen_wayland->ca_context;
+}
+
+static void
+update_sound_settings (GSettings *settings,
+ const char *key,
+ GdkScreen *screen)
+{
+ GdkWaylandScreen *screen_wayland = GDK_WAYLAND_SCREEN (screen);
+
+ if (screen_wayland->ca_context == NULL)
+ return;
+
+ if (strcmp (key, "theme-name") == 0)
+ {
+ gchar *theme_name;
+
+ theme_name = g_settings_get_string (settings, key);
+ ca_context_change_props (screen_wayland->ca_context, CA_PROP_CANBERRA_XDG_THEME_NAME, theme_name,
NULL);
+ g_free (theme_name);
+ }
+ else if (strcmp (key, "event-sounds") == 0)
+ {
+ gboolean event_sounds;
+
+ event_sounds = g_settings_get_boolean (settings, key);
+ ca_context_change_props (screen_wayland->ca_context, CA_PROP_CANBERRA_ENABLE, event_sounds ? "1" :
"0", NULL);
+ }
+}
+
static void
settings_changed (GSettings *settings,
const gchar *key,
@@ -606,6 +689,9 @@ settings_changed (GSettings *settings,
if (entry != NULL)
{
+ if (strcmp (entry->schema, "org.gnome.desktop.sound") == 0)
+ update_sound_settings (settings, key, screen);
+
if (entry->type != G_TYPE_NONE)
notify_setting (screen, entry->setting);
else
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]