Rebase for new release

This commit is contained in:
Ray Strode 2008-12-18 18:28:11 +00:00
parent c8fb60d3ee
commit 84be546c9d
6 changed files with 0 additions and 1732 deletions

View File

@ -1,95 +0,0 @@
diff -up gnome-settings-daemon-2.24.0/plugins/keyboard/gsd-keyboard-xkb.c.fix-gdm-layout gnome-settings-daemon-2.24.0/plugins/keyboard/gsd-keyboard-xkb.c
--- gnome-settings-daemon-2.24.0/plugins/keyboard/gsd-keyboard-xkb.c.fix-gdm-layout 2008-10-14 09:26:57.000000000 -0400
+++ gnome-settings-daemon-2.24.0/plugins/keyboard/gsd-keyboard-xkb.c 2008-10-14 09:27:09.000000000 -0400
@@ -142,12 +142,39 @@ apply_xkb_settings (void)
{
GConfClient *conf_client;
GkbdKeyboardConfig current_sys_kbd_config;
+ int group_to_activate = -1;
+ const char *gdm_layout;
if (!inited_ok)
return;
conf_client = gconf_client_get_default ();
+ /* With GDM the user can already set a layout from the login
+ * screen. Try to keep that setting.
+ * We clear gdm_keyboard_layout early, so we don't risk
+ * recursion from gconf notification.
+ */
+ gdm_layout = gdm_keyboard_layout;
+ gdm_keyboard_layout = NULL;
+ if (gdm_layout != NULL) {
+ GSList *layouts;
+ layouts = gconf_client_get_list (conf_client,
+ GKBD_KEYBOARD_CONFIG_KEY_LAYOUTS,
+ GCONF_VALUE_STRING,
+ NULL);
+ if (layouts == NULL) {
+ layouts = g_slist_append (layouts, g_strdup (gdm_layout));
+ gconf_client_set_list (conf_client,
+ GKBD_KEYBOARD_CONFIG_KEY_LAYOUTS,
+ GCONF_VALUE_STRING,
+ layouts,
+ NULL);
+ }
+ g_slist_foreach (layouts, (GFunc)g_free, NULL);
+ g_slist_free (layouts);
+ }
+
gkbd_keyboard_config_init (&current_sys_kbd_config,
conf_client,
xkl_engine);
@@ -158,29 +185,20 @@ apply_xkb_settings (void)
gkbd_keyboard_config_load_from_x_current (&current_sys_kbd_config,
NULL);
- /* With GDM the user can already set a layout from the login
- * screen. Try to keep that setting */
- if (gdm_keyboard_layout != NULL) {
- if (current_kbd_config.layouts_variants == NULL) {
- current_kbd_config.layouts_variants = g_slist_append (NULL, (char *) gdm_keyboard_layout);
- gconf_client_set_list (conf_client,
- GKBD_KEYBOARD_CONFIG_KEY_LAYOUTS,
- GCONF_VALUE_STRING,
- current_kbd_config.layouts_variants,
- NULL);
- } else {
- GSList *l;
- int i;
- size_t len = strlen (gdm_keyboard_layout);
- for (i = 0, l = current_kbd_config.layouts_variants; l; i++, l = l->next) {
- char *lv = l->data;
- if (strncmp (lv, gdm_keyboard_layout, len) == 0 && (lv[len] == '\0' || lv[len] == '\t')) {
- xkl_engine_lock_group (current_config.engine, i);
- break;
- }
- }
+ if (gdm_layout != NULL) {
+ /* If there are multiple layouts,
+ * try to find the one closest to the gdm layout
+ */
+ GSList *l;
+ int i;
+ size_t len = strlen (gdm_layout);
+ for (i = 0, l = current_kbd_config.layouts_variants; l; i++, l = l->next) {
+ char *lv = l->data;
+ if (strncmp (lv, gdm_layout, len) == 0 && (lv[len] == '\0' || lv[len] == '\t')) {
+ group_to_activate = i;
+ break;
+ }
}
- gdm_keyboard_layout = NULL;
}
/* Activate - only if different! */
@@ -199,6 +217,8 @@ apply_xkb_settings (void)
xkl_debug (100,
"Actual KBD configuration was not changed: redundant notification\n");
+ if (group_to_activate != -1)
+ xkl_engine_lock_group (current_config.engine, group_to_activate);
gkbd_keyboard_config_term (&current_sys_kbd_config);
}

View File

@ -1,896 +0,0 @@
From 0c3624c240d78fc3a677d8d0286b3e0b5f6ae281 Mon Sep 17 00:00:00 2001
From: Lennart Poettering <lennart@poettering.net>
Date: Tue, 29 Jul 2008 22:33:12 +0200
Subject: [PATCH] add sound sample cache plugin that drops cached samples from pulseaudio
Signed-off-by: Lennart Poettering <lennart@poettering.net>
---
configure.ac | 26 ++
data/gnome-settings-daemon.schemas.in | 23 +
plugins/Makefile.am | 1 +
plugins/sound-sample-cache/Makefile.am | 42 ++
.../gsd-sound-sample-cache-manager.c | 471 ++++++++++++++++++++
.../gsd-sound-sample-cache-manager.h | 57 +++
.../gsd-sound-sample-cache-plugin.c | 100 +++++
.../gsd-sound-sample-cache-plugin.h | 59 +++
.../sound-sample-cache.gnome-settings-plugin.in | 8 +
9 files changed, 787 insertions(+), 0 deletions(-)
create mode 100644 plugins/sound-sample-cache/Makefile.am
create mode 100644 plugins/sound-sample-cache/gsd-sound-sample-cache-manager.c
create mode 100644 plugins/sound-sample-cache/gsd-sound-sample-cache-manager.h
create mode 100644 plugins/sound-sample-cache/gsd-sound-sample-cache-plugin.c
create mode 100644 plugins/sound-sample-cache/gsd-sound-sample-cache-plugin.h
create mode 100644 plugins/sound-sample-cache/sound-sample-cache.gnome-settings-plugin.in
diff --git a/configure.ac b/configure.ac
index 1dbd3d9..c921f66 100644
--- a/configure.ac
+++ b/configure.ac
@@ -236,6 +236,30 @@ AC_SUBST(ESD_LIBS)
AC_SUBST(ESD_LOCATION)
dnl ==============================================
+dnl PulseAudio section
+dnl ==============================================
+
+AC_ARG_ENABLE(pulse,
+ AC_HELP_STRING([--disable-pulse],
+ [turn off PulseAudio support]),
+ [case "${enableval}" in
+ yes) WANT_PULSE=yes ;;
+ no) WANT_PULSE=no ;;
+ *) AC_MSG_ERROR(bad value ${enableval} for --disable-pulse) ;;
+ esac],
+ [WANT_PULSE=yes]) dnl Default value
+
+if test x$WANT_PULSE = xyes ; then
+ PKG_CHECK_MODULES(PULSE, libpulse >= 0.9.11,
+ AC_DEFINE(HAVE_PULSE, 1, [Define if PULSE sound server should be used]),
+ AC_MSG_RESULT([disabled]))
+fi
+
+AC_SUBST(PULSE_CFLAGS)
+AC_SUBST(PULSE_LIBS)
+AC_SUBST(PULSE_LOCATION)
+
+dnl ==============================================
dnl GStreamer section
dnl ==============================================
GST_MAJORMINOR=auto
@@ -444,6 +468,7 @@ plugins/mouse/Makefile
plugins/screensaver/Makefile
plugins/sound/Makefile
plugins/sound/libsounds/Makefile
+plugins/sound-sample-cache/Makefile
plugins/typing-break/Makefile
plugins/xrandr/Makefile
plugins/xrdb/Makefile
@@ -485,6 +510,7 @@ echo "
ALSA support: ${have_alsa}
GStreamer support: ${have_gstreamer}
ESD support: ${WANT_ESD}
+ PulseAudio support: ${WANT_PULSE}
Profiling support: ${enable_profiling}
"
diff --git a/data/gnome-settings-daemon.schemas.in b/data/gnome-settings-daemon.schemas.in
index 3f6a426..6efb1f0 100644
--- a/data/gnome-settings-daemon.schemas.in
+++ b/data/gnome-settings-daemon.schemas.in
@@ -233,6 +233,29 @@
</schema>
<schema>
+ <key>/schemas/apps/gnome_settings_daemon/plugins/sound-sample-cache/active</key>
+ <applyto>/apps/gnome_settings_daemon/plugins/sound-sample-cache/active</applyto>
+ <owner>gnome-settings-daemon</owner>
+ <type>bool</type>
+ <default>TRUE</default>
+ <locale name="C">
+ <short>Enable sound sample cache plugin</short>
+ <long>Set to True to enable the plugin to manage sound sample caches.</long>
+ </locale>
+ </schema>
+ <schema>
+ <key>/schemas/apps/gnome_settings_daemon/plugins/sound-sample-cache/priority</key>
+ <applyto>/apps/gnome_settings_daemon/plugins/sound-sample-cache/priority</applyto>
+ <owner>gnome-settings-daemon</owner>
+ <type>int</type>
+ <default>5</default>
+ <locale name="C">
+ <short></short>
+ <long></long>
+ </locale>
+ </schema>
+
+ <schema>
<key>/schemas/apps/gnome_settings_daemon/plugins/sound/active</key>
<applyto>/apps/gnome_settings_daemon/plugins/sound/active</applyto>
<owner>gnome-settings-daemon</owner>
diff --git a/plugins/Makefile.am b/plugins/Makefile.am
index 2d33061..9275969 100644
--- a/plugins/Makefile.am
+++ b/plugins/Makefile.am
@@ -18,4 +18,5 @@ SUBDIRS = \
xrandr \
xrdb \
xsettings \
+ sound-sample-cache \
$(NULL)
diff --git a/plugins/sound-sample-cache/Makefile.am b/plugins/sound-sample-cache/Makefile.am
new file mode 100644
index 0000000..844829c
--- /dev/null
+++ b/plugins/sound-sample-cache/Makefile.am
@@ -0,0 +1,42 @@
+plugin_LTLIBRARIES = \
+ libsound-sample-cache.la
+
+libsound_sample_cache_la_SOURCES = \
+ gsd-sound-sample-cache-plugin.h \
+ gsd-sound-sample-cache-plugin.c \
+ gsd-sound-sample-cache-manager.h \
+ gsd-sound-sample-cache-manager.c
+
+libsound_sample_cache_la_CPPFLAGS = \
+ -I$(top_srcdir)/gnome-settings-daemon \
+ -DGNOME_SETTINGS_LOCALEDIR=\""$(datadir)/locale"\" \
+ $(AM_CPPFLAGS)
+
+libsound_sample_cache_la_CFLAGS = \
+ $(SETTINGS_PLUGIN_CFLAGS) \
+ $(GNOME_CFLAGS) \
+ $(PULSE_CFLAGS) \
+ $(AM_CFLAGS)
+
+libsound_sample_cache_la_LDFLAGS = \
+ $(GSD_PLUGIN_LDFLAGS)
+
+libsound_sample_cache_la_LIBADD = \
+ $(SETTINGS_PLUGIN_LIBS) \
+ $(PULSE_LIBS)
+
+plugin_in_files = \
+ sound-sample-cache.gnome-settings-plugin.in
+
+plugin_DATA = $(plugin_in_files:.gnome-settings-plugin.in=.gnome-settings-plugin)
+
+EXTRA_DIST = \
+ $(plugin_in_files)
+
+CLEANFILES = \
+ $(plugin_DATA)
+
+DISTCLEANFILES = \
+ $(plugin_DATA)
+
+@GSD_INTLTOOL_PLUGIN_RULE@
diff --git a/plugins/sound-sample-cache/gsd-sound-sample-cache-manager.c b/plugins/sound-sample-cache/gsd-sound-sample-cache-manager.c
new file mode 100644
index 0000000..5acf1e2
--- /dev/null
+++ b/plugins/sound-sample-cache/gsd-sound-sample-cache-manager.c
@@ -0,0 +1,471 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*-
+ *
+ * Copyright (C) 2008 Lennart Poettering <lennart@poettering.net>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *
+ */
+
+#include "config.h"
+
+#include <sys/types.h>
+#include <sys/wait.h>
+#include <stdlib.h>
+#include <stdio.h>
+#include <unistd.h>
+#include <string.h>
+#include <errno.h>
+
+#include <locale.h>
+
+#include <glib.h>
+#include <glib/gi18n.h>
+#include <gconf/gconf-client.h>
+#include <gtk/gtk.h>
+
+#ifdef HAVE_PULSE
+#include <pulse/pulseaudio.h>
+#endif
+
+#include "gsd-sound-sample-cache-manager.h"
+#include "gnome-settings-profile.h"
+
+#define GSD_SOUND_SAMPLE_CACHE_MANAGER_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE((o), GSD_TYPE_SOUND_SAMPLE_CACHE_MANAGER, GsdSoundSampleCacheManagerPrivate))
+
+struct GsdSoundSampleCacheManagerPrivate
+{
+ guint gconf_notify;
+ GList* monitors;
+ guint timeout;
+};
+
+#define GCONF_SOUND_DIR "/desktop/gnome/sound"
+
+static void gsd_sound_sample_cache_manager_class_init(GsdSoundSampleCacheManagerClass *klass);
+static void gsd_sound_sample_cache_manager_init(GsdSoundSampleCacheManager *sound_manager);
+static void gsd_sound_sample_cache_manager_finalize(GObject *object);
+
+G_DEFINE_TYPE(GsdSoundSampleCacheManager, gsd_sound_sample_cache_manager, G_TYPE_OBJECT)
+
+static gpointer manager_object = NULL;
+
+#ifdef HAVE_PULSE
+
+static void
+sample_info_cb(pa_context *c, const pa_sample_info *i, int eol, void *userdata)
+{
+ pa_operation *o;
+
+ if (!i)
+ return;
+
+ g_debug("Found sample %s.", i->name);
+
+ /* We only flush those samples which have an XDG sound name
+ * attached, because only those originate from themeing */
+ if (!(pa_proplist_gets(i->proplist, PA_PROP_EVENT_ID)))
+ return;
+
+ g_debug("Dropping sample %s from cache.", i->name);
+
+ if (!(o = pa_context_remove_sample(c, i->name, NULL, NULL))) {
+ g_debug("pa_context_remove_sample(): %s", pa_strerror(pa_context_errno(c)));
+ return;
+ }
+
+ pa_operation_unref(o);
+
+ /* We won't wait until the operation is actually executed to
+ * speed things up a bit.*/
+}
+
+static void
+flush_cache(void)
+{
+ pa_mainloop *ml = NULL;
+ pa_context *c = NULL;
+ pa_proplist *pl = NULL;
+ pa_operation *o = NULL;
+
+ g_debug("Flushing sample cache.");
+
+ if (!(ml = pa_mainloop_new())) {
+ g_debug("Failed to allocate pa_mainloop.");
+ goto fail;
+ }
+
+ if (!(pl = pa_proplist_new())) {
+ g_debug("Failed to allocate pa_proplist.");
+ goto fail;
+ }
+
+ pa_proplist_sets(pl, PA_PROP_APPLICATION_NAME, PACKAGE_NAME);
+ pa_proplist_sets(pl, PA_PROP_APPLICATION_VERSION, PACKAGE_VERSION);
+ pa_proplist_sets(pl, PA_PROP_APPLICATION_ID, "org.gnome.SettingsDaemon");
+
+ if (!(c = pa_context_new_with_proplist(pa_mainloop_get_api(ml), PACKAGE_NAME, pl))) {
+ g_debug("Failed to allocate pa_context.");
+ goto fail;
+ }
+
+ pa_proplist_free(pl);
+ pl = NULL;
+
+ if (pa_context_connect(c, NULL, PA_CONTEXT_NOAUTOSPAWN, NULL) < 0) {
+ g_debug("pa_context_connect(): %s", pa_strerror(pa_context_errno(c)));
+ goto fail;
+ }
+
+ /* Wait until the connection is established */
+ while (pa_context_get_state(c) != PA_CONTEXT_READY) {
+
+ if (!PA_CONTEXT_IS_GOOD(pa_context_get_state(c))) {
+ g_debug("Connection failed: %s", pa_strerror(pa_context_errno(c)));
+ goto fail;
+ }
+
+ if (pa_mainloop_iterate(ml, TRUE, NULL) < 0) {
+ g_debug("pa_mainloop_iterate() failed.");
+ goto fail;
+ }
+ }
+
+ /* Enumerate all cached samples */
+ if (!(o = pa_context_get_sample_info_list(c, sample_info_cb, NULL))) {
+ g_debug("pa_context_get_sample_info_list(): %s", pa_strerror(pa_context_errno(c)));
+ goto fail;
+ }
+
+ /* Wait until our operation is finished and there's nothing
+ * more queued to send to the server */
+ while (pa_operation_get_state(o) == PA_OPERATION_RUNNING || pa_context_is_pending(c)) {
+
+ if (!PA_CONTEXT_IS_GOOD(pa_context_get_state(c))) {
+ g_debug("Connection failed: %s", pa_strerror(pa_context_errno(c)));
+ goto fail;
+ }
+
+ if (pa_mainloop_iterate(ml, TRUE, NULL) < 0) {
+ g_debug("pa_mainloop_iterate() failed.");
+ goto fail;
+ }
+ }
+
+ g_debug("Sample cache flushed.");
+
+fail:
+ if (o) {
+ pa_operation_cancel(o);
+ pa_operation_unref(o);
+ }
+
+ if (c) {
+ pa_context_disconnect(c);
+ pa_context_unref(c);
+ }
+
+ if (pl)
+ pa_proplist_free(pl);
+
+ if (ml)
+ pa_mainloop_free(ml);
+}
+
+static gboolean
+flush_cb(GsdSoundSampleCacheManager *manager)
+{
+ flush_cache();
+ manager->priv->timeout = 0;
+ return FALSE;
+}
+
+static void
+trigger_flush(GsdSoundSampleCacheManager *manager)
+{
+
+ if (manager->priv->timeout)
+ g_source_remove(manager->priv->timeout);
+
+ /* We delay the flushing a bit so that we can coalesce
+ * multiple changes into a single cache flush */
+ manager->priv->timeout = g_timeout_add(500, (GSourceFunc) flush_cb, manager);
+}
+
+static void
+gconf_client_notify_cb(
+ GConfClient *client,
+ guint cnxn_id,
+ GConfEntry *entry,
+ GsdSoundSampleCacheManager *manager)
+{
+ g_debug("GConf dir changed");
+ trigger_flush(manager);
+}
+
+static gboolean
+register_config_callback(
+ GsdSoundSampleCacheManager *manager,
+ GError **error)
+{
+ GConfClient *client;
+
+ client = gconf_client_get_default();
+
+ gconf_client_add_dir(client, GCONF_SOUND_DIR, GCONF_CLIENT_PRELOAD_NONE, error);
+ g_return_val_if_fail(!error || !*error, FALSE);
+
+ manager->priv->gconf_notify = gconf_client_notify_add(client, GCONF_SOUND_DIR, (GConfClientNotifyFunc) gconf_client_notify_cb, manager, NULL, error);
+ g_return_val_if_fail(!error || !*error, FALSE);
+
+ g_object_unref(client);
+
+ return TRUE;
+}
+
+static void
+file_monitor_changed_cb(
+ GFileMonitor *monitor,
+ GFile *file,
+ GFile *other_file,
+ GFileMonitorEvent event,
+ GsdSoundSampleCacheManager *manager)
+{
+ g_debug("Theme dir changed");
+ trigger_flush(manager);
+}
+
+static gboolean
+register_directory_callback(
+ GsdSoundSampleCacheManager *manager,
+ const char *path,
+ GError **error)
+{
+
+ GFile *f;
+ GFileMonitor *m;
+
+ g_debug("registering directory monitor for %s", path);
+
+ f = g_file_new_for_path(path);
+ g_return_val_if_fail(f, FALSE);
+
+ m = g_file_monitor_directory(f, 0, NULL, error);
+ g_return_val_if_fail(m, FALSE);
+
+ g_signal_connect(m, "changed", G_CALLBACK(file_monitor_changed_cb), manager);
+
+ manager->priv->monitors = g_list_prepend(manager->priv->monitors, m);
+
+ g_object_unref(G_OBJECT(f));
+
+ return TRUE;
+}
+
+#endif
+
+gboolean
+gsd_sound_sample_cache_manager_start(
+ GsdSoundSampleCacheManager *manager,
+ GError **error)
+{
+
+#ifdef HAVE_PULSE
+ char *p, **ps, **k;
+ const char *env, *dd;
+#endif
+
+ g_debug("Starting sound sample cache manager");
+ gnome_settings_profile_start(NULL);
+
+#ifdef HAVE_PULSE
+
+ /* We listen for change of the selected theme ... */
+ register_config_callback(manager, NULL);
+
+ /* ... and we listen to changes of the theme base directories
+ * in $HOME ...*/
+
+ if ((env = g_getenv("XDG_DATA_HOME")) && *env == '/')
+ p = g_build_filename(env, "sounds", NULL);
+ else if (((env = g_getenv("HOME")) && *env == '/') || (env = g_get_home_dir()))
+ p = g_build_filename(env, ".local", "share", "sounds", NULL);
+ else
+ p = NULL;
+
+ if (p) {
+ register_directory_callback(manager, p, NULL);
+ g_free(p);
+ }
+
+ /* ... and globally. */
+ if (!(dd = g_getenv("XDG_DATA_DIRS")) || *dd == 0)
+ dd = "/usr/local/share:/usr/share";
+
+ ps = g_strsplit(dd, ":", 0);
+
+ for (k = ps; *k; k++)
+ register_directory_callback(manager, *k, NULL);
+
+ g_strfreev(ps);
+#endif
+
+ return TRUE;
+}
+
+void
+gsd_sound_sample_cache_manager_stop(
+ GsdSoundSampleCacheManager *manager)
+{
+ g_debug("Stopping sound sample cache manager");
+
+#ifdef HAVE_PULSE
+ if (manager->priv->gconf_notify != 0) {
+ GConfClient *client = gconf_client_get_default();
+
+ gconf_client_remove_dir(client, GCONF_SOUND_DIR, NULL);
+
+ gconf_client_notify_remove(client, manager->priv->gconf_notify);
+ manager->priv->gconf_notify = 0;
+
+ g_object_unref(client);
+ }
+
+ if (manager->priv->timeout) {
+ g_source_remove(manager->priv->timeout);
+ manager->priv->timeout = 0;
+ }
+
+ while (manager->priv->monitors) {
+ g_file_monitor_cancel(G_FILE_MONITOR(manager->priv->monitors->data));
+ g_object_unref(G_OBJECT(manager->priv->monitors->data));
+ manager->priv->monitors = g_list_delete_link(manager->priv->monitors, manager->priv->monitors);
+ }
+#endif
+}
+
+static void
+gsd_sound_sample_cache_manager_set_property(
+ GObject *object,
+ guint prop_id,
+ const GValue *value,
+ GParamSpec *pspec)
+{
+ GsdSoundSampleCacheManager *self;
+
+ self = GSD_SOUND_SAMPLE_CACHE_MANAGER(object);
+
+ switch (prop_id) {
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec);
+ break;
+ }
+}
+
+static void
+gsd_sound_sample_cache_manager_get_property(
+ GObject *object,
+ guint prop_id,
+ GValue *value,
+ GParamSpec *pspec)
+{
+ GsdSoundSampleCacheManager *self;
+
+ self = GSD_SOUND_SAMPLE_CACHE_MANAGER(object);
+
+ switch (prop_id) {
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec);
+ break;
+ }
+}
+
+static GObject *
+gsd_sound_sample_cache_manager_constructor(
+ GType type,
+ guint n_construct_properties,
+ GObjectConstructParam *construct_properties)
+{
+ GsdSoundSampleCacheManager *m;
+ GsdSoundSampleCacheManagerClass *klass;
+
+ klass = GSD_SOUND_SAMPLE_CACHE_MANAGER_CLASS(g_type_class_peek(GSD_TYPE_SOUND_SAMPLE_CACHE_MANAGER));
+
+ m = GSD_SOUND_SAMPLE_CACHE_MANAGER(G_OBJECT_CLASS(gsd_sound_sample_cache_manager_parent_class)->constructor(
+ type,
+ n_construct_properties,
+ construct_properties));
+
+ return G_OBJECT(m);
+}
+
+static void
+gsd_sound_sample_cache_manager_dispose(GObject *object)
+{
+ GsdSoundSampleCacheManager *manager;
+
+ manager = GSD_SOUND_SAMPLE_CACHE_MANAGER(object);
+
+ gsd_sound_sample_cache_manager_stop(manager);
+
+ G_OBJECT_CLASS(gsd_sound_sample_cache_manager_parent_class)->dispose(object);
+}
+
+static void
+gsd_sound_sample_cache_manager_class_init(GsdSoundSampleCacheManagerClass *klass)
+{
+ GObjectClass *object_class = G_OBJECT_CLASS(klass);
+
+ object_class->get_property = gsd_sound_sample_cache_manager_get_property;
+ object_class->set_property = gsd_sound_sample_cache_manager_set_property;
+ object_class->constructor = gsd_sound_sample_cache_manager_constructor;
+ object_class->dispose = gsd_sound_sample_cache_manager_dispose;
+ object_class->finalize = gsd_sound_sample_cache_manager_finalize;
+
+ g_type_class_add_private(klass, sizeof(GsdSoundSampleCacheManagerPrivate));
+}
+
+static void
+gsd_sound_sample_cache_manager_init(GsdSoundSampleCacheManager *manager)
+{
+ manager->priv = GSD_SOUND_SAMPLE_CACHE_MANAGER_GET_PRIVATE(manager);
+}
+
+static void
+gsd_sound_sample_cache_manager_finalize(GObject *object)
+{
+ GsdSoundSampleCacheManager *sound_sample_cache_manager;
+
+ g_return_if_fail(object != NULL);
+ g_return_if_fail(GSD_IS_SOUND_SAMPLE_CACHE_MANAGER(object));
+
+ sound_sample_cache_manager = GSD_SOUND_SAMPLE_CACHE_MANAGER(object);
+
+ g_return_if_fail(sound_sample_cache_manager->priv);
+
+ G_OBJECT_CLASS(gsd_sound_sample_cache_manager_parent_class)->finalize(object);
+}
+
+GsdSoundSampleCacheManager *
+gsd_sound_sample_cache_manager_new(void)
+{
+ if (manager_object) {
+ g_object_ref(manager_object);
+ } else {
+ manager_object = g_object_new(GSD_TYPE_SOUND_SAMPLE_CACHE_MANAGER, NULL);
+ g_object_add_weak_pointer(manager_object, (gpointer *) &manager_object);
+ }
+
+ return GSD_SOUND_SAMPLE_CACHE_MANAGER(manager_object);
+}
diff --git a/plugins/sound-sample-cache/gsd-sound-sample-cache-manager.h b/plugins/sound-sample-cache/gsd-sound-sample-cache-manager.h
new file mode 100644
index 0000000..7be3e96
--- /dev/null
+++ b/plugins/sound-sample-cache/gsd-sound-sample-cache-manager.h
@@ -0,0 +1,57 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*-
+ *
+ * Copyright (C) 2008 Lennart Poettering <lennart@poettering.net>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *
+ */
+
+#ifndef __GSD_SOUND_SAMPLE_CACHE_MANAGER_H
+#define __GSD_SOUND_SAMPLE_CACHE_MANAGER_H
+
+#include <glib.h>
+#include <glib-object.h>
+
+G_BEGIN_DECLS
+
+#define GSD_TYPE_SOUND_SAMPLE_CACHE_MANAGER (gsd_sound_sample_cache_manager_get_type())
+#define GSD_SOUND_SAMPLE_CACHE_MANAGER(o) (G_TYPE_CHECK_INSTANCE_CAST((o), GSD_TYPE_SOUND_SAMPLE_CACHE_MANAGER, GsdSoundSampleCacheManager))
+#define GSD_SOUND_SAMPLE_CACHE_MANAGER_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), GSD_TYPE_SOUND_SAMPLE_CACHE_MANAGER, GsdSoundSampleCacheManagerClass))
+#define GSD_IS_SOUND_SAMPLE_CACHE_MANAGER(o) (G_TYPE_CHECK_INSTANCE_TYPE((o), GSD_TYPE_SOUND_SAMPLE_CACHE_MANAGER))
+#define GSD_IS_SOUND_SAMPLE_CACHE_MANAGER_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE((k), GSD_TYPE_SOUND_SAMPLE_CACHE_MANAGER))
+#define GSD_SOUND_SAMPLE_CACHE_MANAGER_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS((o), GSD_TYPE_SOUND_SAMPLE_CACHE_MANAGER, GsdSoundSampleCacheManagerClass))
+
+typedef struct GsdSoundSampleCacheManagerPrivate GsdSoundSampleCacheManagerPrivate;
+
+typedef struct
+{
+ GObject parent;
+ GsdSoundSampleCacheManagerPrivate *priv;
+} GsdSoundSampleCacheManager;
+
+typedef struct
+{
+ GObjectClass parent_class;
+} GsdSoundSampleCacheManagerClass;
+
+GType gsd_sound_sample_cache_manager_get_type(void) G_GNUC_CONST;
+
+GsdSoundSampleCacheManager *gsd_sound_sample_cache_manager_new(void);
+gboolean gsd_sound_sample_cache_manager_start(GsdSoundSampleCacheManager *manager, GError **error);
+void gsd_sound_sample_cache_manager_stop(GsdSoundSampleCacheManager *manager);
+
+G_END_DECLS
+
+#endif /* __GSD_SOUND_SAMPLE_CACHE_MANAGER_H */
diff --git a/plugins/sound-sample-cache/gsd-sound-sample-cache-plugin.c b/plugins/sound-sample-cache/gsd-sound-sample-cache-plugin.c
new file mode 100644
index 0000000..9d9ab47
--- /dev/null
+++ b/plugins/sound-sample-cache/gsd-sound-sample-cache-plugin.c
@@ -0,0 +1,100 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*-
+ *
+ * Copyright (C) 2008 Lennart Poettering <lennart@poettering.net>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2, or (at your option)
+ * any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *
+ */
+
+#include "config.h"
+
+#include <glib/gi18n-lib.h>
+#include <gmodule.h>
+
+#include "gnome-settings-plugin.h"
+#include "gsd-sound-sample-cache-plugin.h"
+#include "gsd-sound-sample-cache-manager.h"
+
+struct GsdSoundSampleCachePluginPrivate {
+ GsdSoundSampleCacheManager *manager;
+};
+
+#define GSD_SOUND_SAMPLE_CACHE_PLUGIN_GET_PRIVATE(object) (G_TYPE_INSTANCE_GET_PRIVATE((object), GSD_TYPE_SOUND_SAMPLE_CACHE_PLUGIN, GsdSoundSampleCachePluginPrivate))
+
+GNOME_SETTINGS_PLUGIN_REGISTER(GsdSoundSampleCachePlugin, gsd_sound_sample_cache_plugin)
+
+static void
+gsd_sound_sample_cache_plugin_init(GsdSoundSampleCachePlugin *plugin)
+{
+ plugin->priv = GSD_SOUND_SAMPLE_CACHE_PLUGIN_GET_PRIVATE(plugin);
+
+ g_debug("GsdSoundSampleCachePlugin initializing");
+
+ plugin->priv->manager = gsd_sound_sample_cache_manager_new();
+}
+
+static void
+gsd_sound_sample_cache_plugin_finalize(GObject *object)
+{
+ GsdSoundSampleCachePlugin *plugin;
+
+ g_return_if_fail(object != NULL);
+ g_return_if_fail(GSD_IS_SOUND_SAMPLE_CACHE_PLUGIN(object));
+
+ g_debug("GsdSoundSampleCachePlugin finalizing");
+
+ plugin = GSD_SOUND_SAMPLE_CACHE_PLUGIN(object);
+
+ g_return_if_fail(plugin->priv != NULL);
+
+ if (plugin->priv->manager != NULL)
+ g_object_unref(plugin->priv->manager);
+
+ G_OBJECT_CLASS(gsd_sound_sample_cache_plugin_parent_class)->finalize(object);
+}
+
+static void
+impl_activate(GnomeSettingsPlugin *plugin)
+{
+ GError *error = NULL;
+
+ g_debug("Activating sound_sample_cache plugin");
+
+ if (!gsd_sound_sample_cache_manager_start(GSD_SOUND_SAMPLE_CACHE_PLUGIN(plugin)->priv->manager, &error)) {
+ g_warning("Unable to start sound sample cache manager: %s", error->message);
+ g_error_free(error);
+ }
+}
+
+static void
+impl_deactivate(GnomeSettingsPlugin *plugin)
+{
+ g_debug("Deactivating sound sample cache plugin");
+ gsd_sound_sample_cache_manager_stop(GSD_SOUND_SAMPLE_CACHE_PLUGIN(plugin)->priv->manager);
+}
+
+static void
+gsd_sound_sample_cache_plugin_class_init(GsdSoundSampleCachePluginClass *klass)
+{
+ GObjectClass *object_class = G_OBJECT_CLASS(klass);
+ GnomeSettingsPluginClass *plugin_class = GNOME_SETTINGS_PLUGIN_CLASS(klass);
+
+ object_class->finalize = gsd_sound_sample_cache_plugin_finalize;
+
+ plugin_class->activate = impl_activate;
+ plugin_class->deactivate = impl_deactivate;
+
+ g_type_class_add_private(klass, sizeof(GsdSoundSampleCachePluginPrivate));
+}
diff --git a/plugins/sound-sample-cache/gsd-sound-sample-cache-plugin.h b/plugins/sound-sample-cache/gsd-sound-sample-cache-plugin.h
new file mode 100644
index 0000000..3aa3f49
--- /dev/null
+++ b/plugins/sound-sample-cache/gsd-sound-sample-cache-plugin.h
@@ -0,0 +1,59 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*-
+ *
+ * Copyright (C) 2008 Lennart Poettering <lennart@poettering.net>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2, or (at your option)
+ * any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *
+ */
+
+#ifndef __GSD_SOUND_SAMPLE_CACHE_PLUGIN_H__
+#define __GSD_SOUND_SAMPLE_CACHE_PLUGIN_H__
+
+#include <glib.h>
+#include <glib-object.h>
+#include <gmodule.h>
+
+#include "gnome-settings-plugin.h"
+
+G_BEGIN_DECLS
+
+#define GSD_TYPE_SOUND_SAMPLE_CACHE_PLUGIN (gsd_sound_sample_cache_plugin_get_type())
+#define GSD_SOUND_SAMPLE_CACHE_PLUGIN(o) (G_TYPE_CHECK_INSTANCE_CAST((o), GSD_TYPE_SOUND_SAMPLE_CACHE_PLUGIN, GsdSoundSampleCachePlugin))
+#define GSD_SOUND_SAMPLE_CACHE_PLUGIN_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), GSD_TYPE_SOUND_SAMPLE_CACHE_PLUGIN, GsdSoundSampleCachePluginClass))
+#define GSD_IS_SOUND_SAMPLE_CACHE_PLUGIN(o) (G_TYPE_CHECK_INSTANCE_TYPE((o), GSD_TYPE_SOUND_SAMPLE_CACHE_PLUGIN))
+#define GSD_IS_SOUND_SAMPLE_CACHE_PLUGIN_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE((k), GSD_TYPE_SOUND_SAMPLE_CACHE_PLUGIN))
+#define GSD_SOUND_SAMPLE_CACHE_PLUGIN_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS((o), GSD_TYPE_SOUND_SAMPLE_CACHE_PLUGIN, GsdSoundSampleCachePluginClass))
+
+typedef struct GsdSoundSampleCachePluginPrivate GsdSoundSampleCachePluginPrivate;
+
+typedef struct
+{
+ GnomeSettingsPlugin parent;
+ GsdSoundSampleCachePluginPrivate *priv;
+} GsdSoundSampleCachePlugin;
+
+typedef struct
+{
+ GnomeSettingsPluginClass parent_class;
+} GsdSoundSampleCachePluginClass;
+
+GType gsd_sound_sample_cache_plugin_get_type(void) G_GNUC_CONST;
+
+/* All the plugins must implement this function */
+G_MODULE_EXPORT GType register_gnome_settings_plugin(GTypeModule *module);
+
+G_END_DECLS
+
+#endif /* __GSD_SOUND_SAMPLE_CACHE_PLUGIN_H__ */
diff --git a/plugins/sound-sample-cache/sound-sample-cache.gnome-settings-plugin.in b/plugins/sound-sample-cache/sound-sample-cache.gnome-settings-plugin.in
new file mode 100644
index 0000000..f31e6b7
--- /dev/null
+++ b/plugins/sound-sample-cache/sound-sample-cache.gnome-settings-plugin.in
@@ -0,0 +1,8 @@
+[GNOME Settings Plugin]
+Module=sound-sample-cache
+IAge=0
+_Name=Sound Sample Cache
+_Description=Sound Sample Cache plugin
+Authors=Lennart Poettering
+Copyright=Copyright © 2008
+Website=
--
1.5.6.4

View File

@ -1,463 +0,0 @@
diff --git a/plugins/xrandr/gsd-xrandr-manager.c b/plugins/xrandr/gsd-xrandr-manager.c
index 4d8ce2f..4057962 100644
--- a/plugins/xrandr/gsd-xrandr-manager.c
+++ b/plugins/xrandr/gsd-xrandr-manager.c
@@ -82,6 +82,10 @@ struct GsdXrandrManagerPrivate
GnomeRRLabeler *labeler;
GConfClient *client;
int notify_id;
+
+ /* fn-F7 status */
+ int current_fn_f7_config; /* -1 if no configs */
+ GnomeRRConfig **fn_f7_configs; /* NULL terminated, NULL if there are no configs */
};
static void gsd_xrandr_manager_class_init (GsdXrandrManagerClass *klass);
@@ -127,6 +131,421 @@ on_client_message (GdkXEvent *xevent,
return GDK_FILTER_CONTINUE;
}
+static gboolean
+is_laptop (GnomeOutputInfo *output)
+{
+ const char *output_name = output->name;
+
+ if (output->connected && output_name &&
+ (strstr ("lvds", output_name) ||
+ strstr ("LVDS", output_name) ||
+ strstr ("Lvds", output_name)))
+ {
+ return TRUE;
+ }
+
+ return FALSE;
+}
+
+static gboolean
+get_clone_size (GnomeRRScreen *screen, int *width, int *height)
+{
+ GnomeRRMode **modes = gnome_rr_screen_list_clone_modes (screen);
+ int best_w, best_h;
+ int i;
+
+ best_w = 0;
+ best_h = 0;
+
+ for (i = 0; modes[i] != NULL; ++i) {
+ GnomeRRMode *mode = modes[i];
+ int w, h;
+
+ w = gnome_rr_mode_get_width (mode);
+ h = gnome_rr_mode_get_height (mode);
+
+ if (w * h > best_w * best_h) {
+ best_w = w;
+ best_h = h;
+ }
+ }
+
+ if (best_w > 0 && best_h > 0) {
+ if (width)
+ *width = best_w;
+ if (height)
+ *height = best_h;
+
+ return TRUE;
+ }
+
+ return FALSE;
+}
+
+static void
+print_output (GnomeOutputInfo *info)
+{
+ g_print (" Output: %s attached to %s\n", info->display_name, info->name);
+ g_print (" status: %s\n", info->on ? "on" : "off");
+ g_print (" width: %d\n", info->width);
+ g_print (" height: %d\n", info->height);
+ g_print (" rate: %d\n", info->rate);
+ g_print (" position: %d %d\n", info->x, info->y);
+}
+
+static void
+print_configuration (GnomeRRConfig *config, const char *header)
+{
+ int i;
+
+ g_print ("=== %s Configuration ===\n", header);
+ if (!config) {
+ g_print (" none\n");
+ return;
+ }
+
+ for (i = 0; config->outputs[i] != NULL; ++i)
+ print_output (config->outputs[i]);
+}
+
+static GnomeRRConfig *
+make_clone_setup (GnomeRRScreen *screen)
+{
+ GnomeRRConfig *result;
+ int width, height;
+ int i;
+
+ if (!get_clone_size (screen, &width, &height))
+ return NULL;
+
+ result = gnome_rr_config_new_current (screen);
+
+ for (i = 0; result->outputs[i] != NULL; ++i) {
+ GnomeOutputInfo *info = result->outputs[i];
+
+ info->on = FALSE;
+ if (info->connected) {
+ GnomeRROutput *output =
+ gnome_rr_screen_get_output_by_name (screen, info->name);
+ GnomeRRMode **modes = gnome_rr_output_list_modes (output);
+ int j;
+ int best_rate = 0;
+
+ for (j = 0; modes[j] != NULL; ++j) {
+ GnomeRRMode *mode = modes[j];
+ int w, h;
+
+ w = gnome_rr_mode_get_width (mode);
+ h = gnome_rr_mode_get_height (mode);
+
+ if (w == width && h == height) {
+ int r = gnome_rr_mode_get_freq (mode);
+ if (r > best_rate)
+ best_rate = r;
+ }
+ }
+
+ if (best_rate > 0) {
+ info->on = TRUE;
+ info->width = width;
+ info->height = height;
+ info->rate = best_rate;
+ info->rotation = GNOME_RR_ROTATION_0;
+ info->x = 0;
+ info->y = 0;
+ }
+ }
+ }
+
+ print_configuration (result, "clone setup");
+
+ return result;
+}
+
+static gboolean
+turn_on (GnomeRRScreen *screen,
+ GnomeOutputInfo *info,
+ int x, int y)
+{
+ GnomeRROutput *output =
+ gnome_rr_screen_get_output_by_name (screen, info->name);
+ GnomeRRMode *mode = gnome_rr_output_get_preferred_mode (output);
+
+ if (mode) {
+ info->on = TRUE;
+ info->x = x;
+ info->y = y;
+ info->width = gnome_rr_mode_get_width (mode);
+ info->height = gnome_rr_mode_get_height (mode);
+ info->rotation = GNOME_RR_ROTATION_0;
+ info->rate = gnome_rr_mode_get_freq (mode);
+
+ return TRUE;
+ }
+
+ return FALSE;
+}
+
+static GnomeRRConfig *
+make_laptop_setup (GnomeRRScreen *screen)
+{
+ /* Turn on the laptop, disable everything else */
+ GnomeRRConfig *result = gnome_rr_config_new_current (screen);
+ int i;
+
+ for (i = 0; result->outputs[i] != NULL; ++i) {
+ GnomeOutputInfo *info = result->outputs[i];
+
+ if (is_laptop (info)) {
+ if (!info->on) {
+ if (!turn_on (screen, info, 0, 0)) {
+ gnome_rr_config_free (result);
+ result = NULL;
+ break;
+ }
+ }
+ }
+ else {
+ info->on = FALSE;
+ }
+ }
+
+ print_configuration (result, "Laptop setup");
+
+ /* FIXME - Maybe we should return NULL if there is more than
+ * one connected "laptop" screen?
+ */
+ return result;
+
+}
+
+static GnomeRRConfig *
+make_xinerama_setup (GnomeRRScreen *screen)
+{
+ /* Turn on everything that has a preferred mode, and
+ * position it from left to right
+ */
+ GnomeRRConfig *result = gnome_rr_config_new_current (screen);
+ int i;
+ int x;
+
+ x = 0;
+ for (i = 0; result->outputs[i] != NULL; ++i) {
+ GnomeOutputInfo *info = result->outputs[i];
+
+ if (is_laptop (info)) {
+ if (info->on || turn_on (screen, info, x, 0)) {
+ x += info->width;
+ }
+ }
+ }
+
+ for (i = 0; result->outputs[i] != NULL; ++i) {
+ GnomeOutputInfo *info = result->outputs[i];
+
+ if (info->connected && !is_laptop (info)) {
+ if (info->on || turn_on (screen, info, x, 0)) {
+ x += info->width;
+ }
+ }
+ }
+
+ print_configuration (result, "xinerama setup");
+
+ return result;
+}
+
+static GnomeRRConfig *
+make_other_setup (GnomeRRScreen *screen)
+{
+ /* Turn off all laptops, and make all external monitors clone
+ * from (0, 0)
+ */
+
+ GnomeRRConfig *result = gnome_rr_config_new_current (screen);
+ int i;
+
+ for (i = 0; result->outputs[i] != NULL; ++i) {
+ GnomeOutputInfo *info = result->outputs[i];
+
+ if (is_laptop (info)) {
+ info->on = FALSE;
+ }
+ else {
+ if (info->connected && !info->on) {
+ turn_on (screen, info, 0, 0);
+ }
+ }
+ }
+
+ print_configuration (result, "other setup");
+
+ return result;
+}
+
+static GPtrArray *
+sanitize (GPtrArray *array)
+{
+ int i;
+ GPtrArray *new;
+
+ g_print ("before sanitizing\n");
+
+ for (i = 0; i < array->len; ++i) {
+ if (array->pdata[i]) {
+ print_configuration (array->pdata[i], "before");
+ }
+ }
+
+
+ /* Remove configurations that are duplicates of
+ * configurations earlier in the cycle
+ */
+ for (i = 0; i < array->len; ++i) {
+ int j;
+
+ for (j = 0; j < i; ++j) {
+ GnomeRRConfig *this = array->pdata[j];
+ GnomeRRConfig *other = array->pdata[i];
+
+ if (this && other && gnome_rr_config_equal (this, other)) {
+ g_print ("removing duplicate configuration\n");
+ gnome_rr_config_free (this);
+ array->pdata[j] = NULL;
+ break;
+ }
+ }
+ }
+
+ for (i = 0; i < array->len; ++i) {
+ GnomeRRConfig *config = array->pdata[i];
+
+ if (config) {
+ gboolean all_off = TRUE;
+ int j;
+
+ for (j = 0; config->outputs[j] != NULL; ++j) {
+ if (config->outputs[j]->on)
+ all_off = FALSE;
+ }
+
+ if (all_off) {
+ gnome_rr_config_free (array->pdata[i]);
+ array->pdata[i] = NULL;
+ }
+ }
+ }
+
+ /* Remove NULL configurations */
+ new = g_ptr_array_new ();
+
+ for (i = 0; i < array->len; ++i) {
+ if (array->pdata[i]) {
+ g_ptr_array_add (new, array->pdata[i]);
+ print_configuration (array->pdata[i], "Final");
+ }
+ }
+
+ g_ptr_array_add (new, NULL);
+
+ g_ptr_array_free (array, TRUE);
+
+ return new;
+}
+
+static void
+generate_fn_f7_configs (GsdXrandrManager *mgr)
+{
+ GPtrArray *array = g_ptr_array_new ();
+ GnomeRRScreen *screen = mgr->priv->rw_screen;
+
+ g_print ("Generating configurations\n");
+
+ /* Free any existing list of configurations */
+ if (mgr->priv->fn_f7_configs) {
+ int i;
+
+ for (i = 0; mgr->priv->fn_f7_configs[i] != NULL; ++i)
+ gnome_rr_config_free (mgr->priv->fn_f7_configs[i]);
+ g_free (mgr->priv->fn_f7_configs);
+
+ mgr->priv->fn_f7_configs = NULL;
+ mgr->priv->current_fn_f7_config = -1;
+ }
+
+ g_ptr_array_add (array, gnome_rr_config_new_current (screen));
+ g_ptr_array_add (array, make_xinerama_setup (screen));
+ g_ptr_array_add (array, make_clone_setup (screen));
+ g_ptr_array_add (array, make_laptop_setup (screen));
+ g_ptr_array_add (array, make_other_setup (screen));
+ g_ptr_array_add (array, gnome_rr_config_new_stored (screen));
+ g_ptr_array_add (array, NULL);
+
+ array = sanitize (array);
+
+ mgr->priv->fn_f7_configs = (GnomeRRConfig **)g_ptr_array_free (array, FALSE);
+ mgr->priv->current_fn_f7_config = 0;
+}
+
+static void
+handle_fn_f7 (GsdXrandrManager *mgr)
+{
+ GsdXrandrManagerPrivate *priv = mgr->priv;
+ GnomeRRScreen *screen = priv->rw_screen;
+ GnomeRRConfig *current;
+
+ /* Theory of fn-F7 operation
+ *
+ * We maintain a datastructure "fn_f7_status", that contains
+ * a list of GnomeRRConfig's. Each of the GnomeRRConfigs has a
+ * mode (or "off") for each connected output.
+ *
+ * When the user hits fn-F7, we cycle to the next GnomeRRConfig
+ * in the data structure. If the data structure does not exist, it
+ * is generated. If the configs in the data structure do not match
+ * the current hardware reality, it is regenerated.
+ *
+ */
+ g_print ("Handling fn-f7\n");
+ gnome_rr_screen_refresh (screen);
+
+ if (!priv->fn_f7_configs)
+ generate_fn_f7_configs (mgr);
+
+ current = gnome_rr_config_new_current (screen);
+
+ if (priv->fn_f7_configs &&
+ (!gnome_rr_config_match (current, priv->fn_f7_configs[0]) ||
+ !gnome_rr_config_equal (current, priv->fn_f7_configs[mgr->priv->current_fn_f7_config]))) {
+ /* Our view of the world is incorrect, so regenerate the
+ * configurations
+ */
+ generate_fn_f7_configs (mgr);
+ }
+
+ gnome_rr_config_free (current);
+
+ if (priv->fn_f7_configs) {
+ mgr->priv->current_fn_f7_config++;
+
+ if (priv->fn_f7_configs[mgr->priv->current_fn_f7_config] == NULL)
+ mgr->priv->current_fn_f7_config = 0;
+
+ g_print ("cycling to next configuration (%d)\n", mgr->priv->current_fn_f7_config);
+
+ print_configuration (priv->fn_f7_configs[mgr->priv->current_fn_f7_config], "new config");
+
+ g_print ("applying\n");
+
+ gnome_rr_config_apply (priv->fn_f7_configs[mgr->priv->current_fn_f7_config],
+ screen);
+ }
+ else {
+ g_print ("no configurations generated\n");
+ }
+ g_print ("done handling fn-f7\n");
+}
+
static GdkFilterReturn
event_filter (GdkXEvent *xevent,
GdkEvent *event,
@@ -142,12 +561,9 @@ event_filter (GdkXEvent *xevent,
if (xev->xany.type != KeyPress && xev->xany.type != KeyRelease)
return GDK_FILTER_CONTINUE;
- if (xev->xkey.keycode == manager->priv->keycode) {
- /* FIXME: here we should cycle between valid
- * configurations, and save them
- */
- gnome_rr_config_apply_stored (manager->priv->rw_screen);
-
+ if (xev->xkey.keycode == manager->priv->keycode && xev->xany.type == KeyPress) {
+ handle_fn_f7 (manager);
+
return GDK_FILTER_CONTINUE;
}
@@ -869,6 +1285,9 @@ gsd_xrandr_manager_init (GsdXrandrManager *manager)
manager->priv = GSD_XRANDR_MANAGER_GET_PRIVATE (manager);
manager->priv->keycode = keycode;
+
+ manager->priv->current_fn_f7_config = -1;
+ manager->priv->fn_f7_configs = NULL;
}
static void

View File

@ -1,256 +0,0 @@
============================================================
Rename pipefds to daemon_pipe_fds
This fits the naming style of the surrounding code
better. Also, we're going to need another pipe, so
better to use a specific name here.
diff --git a/gnome-settings-daemon/main.c b/gnome-settings-daemon/main.c
--- a/gnome-settings-daemon/main.c
+++ b/gnome-settings-daemon/main.c
@@ -47,7 +47,7 @@
static char *gconf_prefix = NULL;
static gboolean no_daemon = FALSE;
static gboolean debug = FALSE;
-static int pipefds[2];
+static int daemon_pipe_fds[2];
static GOptionEntry entries[] = {
{"debug", 0, 0, G_OPTION_ARG_NONE, &debug, N_("Enable debugging code"), NULL },
@@ -247,7 +247,7 @@ daemon_start (void)
gnome_settings_profile_msg ("forking daemon");
signal (SIGPIPE, SIG_IGN);
- if (-1 == pipe (pipefds)) {
+ if (-1 == pipe (daemon_pipe_fds)) {
g_error ("Could not create pipe: %s", g_strerror (errno));
exit (EXIT_FAILURE);
}
@@ -262,17 +262,17 @@ daemon_start (void)
case 0:
/* child */
- close (pipefds[0]);
+ close (daemon_pipe_fds[0]);
return;
default:
/* parent */
- close (pipefds[1]);
+ close (daemon_pipe_fds[1]);
/* Wait for child to signal that we are good to go. */
- read (pipefds[0], buf, 1);
+ read (daemon_pipe_fds[0], buf, 1);
exit (EXIT_SUCCESS);
}
@@ -305,8 +305,8 @@ daemon_terminate_parent (void)
gnome_settings_profile_msg ("terminating parent");
- write (pipefds[1], "1", 1);
- close (pipefds[1]);
+ write (daemon_pipe_fds[1], "1", 1);
+ close (daemon_pipe_fds[1]);
}
static void
============================================================
Listen for SIGTERM and shut down properly
diff --git a/gnome-settings-daemon/main.c b/gnome-settings-daemon/main.c
--- a/gnome-settings-daemon/main.c
+++ b/gnome-settings-daemon/main.c
@@ -48,6 +48,7 @@ static char *gconf_prefix = NULL;
static gboolean no_daemon = FALSE;
static gboolean debug = FALSE;
static int daemon_pipe_fds[2];
+static int term_signal_pipe_fds[2];
static GOptionEntry entries[] = {
{"debug", 0, 0, G_OPTION_ARG_NONE, &debug, N_("Enable debugging code"), NULL },
@@ -177,6 +178,54 @@ on_session_over (DBusGProxy *proxy, GnomeSettingsManager *manager)
}
static void
+on_term_signal (int signal)
+{
+ /* Wake up main loop to tell it to shutdown */
+ close (term_signal_pipe_fds[1]);
+ term_signal_pipe_fds[1] = -1;
+}
+
+static gboolean
+on_term_signal_pipe_closed (GIOChannel *source,
+ GIOCondition condition,
+ gpointer data)
+{
+ GnomeSettingsManager *manager;
+
+ manager = GNOME_SETTINGS_MANAGER (data);
+
+ term_signal_pipe_fds[0] = -1;
+
+ /* Got SIGTERM, time to clean up and get out
+ */
+ gtk_main_quit ();
+
+ return FALSE;
+}
+
+static void
+watch_for_term_signal (GnomeSettingsManager *manager)
+{
+ GIOChannel *channel;
+
+ if (-1 == pipe (term_signal_pipe_fds) ||
+ -1 == fcntl (term_signal_pipe_fds[0], F_SETFD, FD_CLOEXEC) ||
+ -1 == fcntl (term_signal_pipe_fds[1], F_SETFD, FD_CLOEXEC)) {
+ g_error ("Could not create pipe: %s", g_strerror (errno));
+ exit (EXIT_FAILURE);
+ }
+
+ channel = g_io_channel_unix_new (term_signal_pipe_fds[0]);
+ g_io_channel_set_encoding (channel, NULL, NULL);
+ g_io_channel_set_buffered (channel, FALSE);
+ g_io_add_watch (channel, G_IO_HUP, on_term_signal_pipe_closed, manager);
+ g_io_channel_unref (channel);
+
+ signal (SIGTERM, on_term_signal);
+
+}
+
+static void
set_session_over_handler (DBusGConnection *bus, GnomeSettingsManager *manager)
{
DBusGProxy *session_proxy;
@@ -206,6 +255,7 @@ set_session_over_handler (DBusGConnection *bus, GnomeSettingsManager *manager)
manager,
NULL);
+ watch_for_term_signal (manager);
gnome_settings_profile_end (NULL);
}
============================================================
Restore AccessX bits to original values on exit
diff --git a/plugins/a11y-keyboard/gsd-a11y-keyboard-manager.c b/plugins/a11y-keyboard/gsd-a11y-keyboard-manager.c
--- a/plugins/a11y-keyboard/gsd-a11y-keyboard-manager.c
+++ b/plugins/a11y-keyboard/gsd-a11y-keyboard-manager.c
@@ -63,6 +63,7 @@ struct GsdA11yKeyboardManagerPrivate
GtkWidget *slowkeys_alert;
GtkWidget *preferences_dialog;
GtkStatusIcon *status_icon;
+ XkbDescRec *original_xkb_desc;
guint gconf_notify;
@@ -1012,6 +1013,10 @@ start_a11y_keyboard_idle_cb (GsdA11yKeyboardManager *manager)
(GConfClientNotifyFunc) keyboard_callback,
&manager->priv->gconf_notify);
+ /* Save current xkb state so we can restore it on exit
+ */
+ manager->priv->original_xkb_desc = get_xkb_desc_rec (manager);
+
event_mask = XkbControlsNotifyMask;
#ifdef DEBUG_ACCESSIBILITY
event_mask |= XkbAccessXNotifyMask; /* make default when AXN_AXKWarning works */
@@ -1052,6 +1057,31 @@ gsd_a11y_keyboard_manager_start (GsdA11yKeyboardManager *manager,
return TRUE;
}
+static void
+restore_server_xkb_config (GsdA11yKeyboardManager *manager)
+{
+ gdk_error_trap_push ();
+ XkbSetControls (GDK_DISPLAY (),
+ XkbSlowKeysMask |
+ XkbBounceKeysMask |
+ XkbStickyKeysMask |
+ XkbMouseKeysMask |
+ XkbMouseKeysAccelMask |
+ XkbAccessXKeysMask |
+ XkbAccessXTimeoutMask |
+ XkbAccessXFeedbackMask |
+ XkbControlsEnabledMask,
+ manager->priv->original_xkb_desc);
+
+ XkbFreeKeyboard (manager->priv->original_xkb_desc,
+ XkbAllComponentsMask, True);
+
+ XSync (GDK_DISPLAY (), FALSE);
+ gdk_error_trap_pop ();
+
+ manager->priv->original_xkb_desc = NULL;
+}
+
void
gsd_a11y_keyboard_manager_stop (GsdA11yKeyboardManager *manager)
{
@@ -1074,6 +1104,10 @@ gsd_a11y_keyboard_manager_stop (GsdA11yKeyboardManager *manager)
(GdkFilterFunc) cb_xkb_event_filter,
manager);
+ /* Disable all the AccessX bits
+ */
+ restore_server_xkb_config (manager);
+
if (p->slowkeys_alert != NULL)
gtk_widget_destroy (p->slowkeys_alert);
============================================================
Shutdown properly when bus goes away
Previously we were just letting libdbus
call exit(1) for us which bypasses the
clean up paths.
diff --git a/gnome-settings-daemon/main.c b/gnome-settings-daemon/main.c
--- a/gnome-settings-daemon/main.c
+++ b/gnome-settings-daemon/main.c
@@ -114,6 +114,21 @@ acquire_name_on_proxy (DBusGProxy *bus_proxy)
return ret;
}
+static DBusHandlerResult
+bus_message_handler (DBusConnection *connection,
+ DBusMessage *message,
+ void *user_data)
+{
+ if (dbus_message_is_signal (message,
+ DBUS_INTERFACE_LOCAL,
+ "Disconnected")) {
+ gtk_main_quit ();
+ return DBUS_HANDLER_RESULT_HANDLED;
+ }
+
+ return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
+}
+
static DBusGConnection *
get_session_bus (void)
{
@@ -131,7 +146,12 @@ get_session_bus (void)
}
connection = dbus_g_connection_get_connection (bus);
- dbus_connection_set_exit_on_disconnect (connection, TRUE);
+ dbus_connection_add_filter (connection,
+ (DBusHandleMessageFunction)
+ bus_message_handler,
+ NULL, NULL);
+
+ dbus_connection_set_exit_on_disconnect (connection, FALSE);
out:
return bus;

View File

@ -34,23 +34,16 @@ BuildRequires: fontconfig-devel
# http://bugzilla.gnome.org/show_bug.cgi?id=545386 # http://bugzilla.gnome.org/show_bug.cgi?id=545386
Patch6: gnome-settings-daemon-2.25.1-drop-sample-cache.patch Patch6: gnome-settings-daemon-2.25.1-drop-sample-cache.patch
Patch7: gnome-settings-daemon-2.23.91-fnf7-cycle.patch
# http://bugzilla.gnome.org/show_bug.cgi?id=552857 # http://bugzilla.gnome.org/show_bug.cgi?id=552857
Patch8: gnome-settings-daemon-2.25.2-fade.patch Patch8: gnome-settings-daemon-2.25.2-fade.patch
# http://bugzilla.redhat.com/445898
Patch9: gnome-settings-daemon-2.24.0-shutdown-cleanly.patch
# http://bugzilla.redhat.com/474758 # http://bugzilla.redhat.com/474758
Patch10: gnome-settings-daemon-2.24.0-catch-deviceadded.patch Patch10: gnome-settings-daemon-2.24.0-catch-deviceadded.patch
# http://bugzilla.redhat.com/324721 # http://bugzilla.redhat.com/324721
Patch11: gnome-settings-daemon-2.24.0-fix-touchpad.patch Patch11: gnome-settings-daemon-2.24.0-fix-touchpad.patch
# http://bugzilla.gnome.org/show_bug.cgi?id=563543
Patch12: gnome-settings-daemon-2.24.1-umask.patch
%description %description
A daemon to share settings from GNOME to other applications. It also A daemon to share settings from GNOME to other applications. It also
handles global keybindings, as well as a number of desktop-wide settings. handles global keybindings, as well as a number of desktop-wide settings.
@ -70,13 +63,10 @@ developing applications that use %{name}.
%setup -q %setup -q
%patch6 -p1 -b .drop-sample-cache %patch6 -p1 -b .drop-sample-cache
%patch7 -p1 -b .fnf7-cycle
%patch8 -p1 -b .fade %patch8 -p1 -b .fade
%patch9 -p1 -b .shutdown-cleanly
%patch10 -p1 -b .catch-deviceadded %patch10 -p1 -b .catch-deviceadded
# This one is buggy, stop using for now # This one is buggy, stop using for now
#%patch11 -p1 -b .fix-touchpad #%patch11 -p1 -b .fix-touchpad
%patch12 -p1 -b .umask
%build %build
aclocal aclocal

View File

@ -1,12 +0,0 @@
diff -up gnome-settings-daemon-2.24.0/plugins/media-keys/gsd-media-keys-manager.c.power-button gnome-settings-daemon-2.24.0/plugins/media-keys/gsd-media-keys-manager.c
--- gnome-settings-daemon-2.24.0/plugins/media-keys/gsd-media-keys-manager.c.power-button 2008-10-14 14:28:35.000000000 -0400
+++ gnome-settings-daemon-2.24.0/plugins/media-keys/gsd-media-keys-manager.c 2008-10-14 14:29:19.000000000 -0400
@@ -556,7 +556,7 @@ do_www_action (GsdMediaKeysManager *mana
static void
do_exit_action (GsdMediaKeysManager *manager)
{
- execute (manager, "gnome-session-save --kill", FALSE, FALSE);
+ execute (manager, "gnome-session-save --shutdown-dialog", FALSE, FALSE);
}
static void