gnome-settings-daemon r298 - in trunk: . plugins/xrandr plugins/xrdb plugins/xsettings
- From: jensg svn gnome org
- To: svn-commits-list gnome org
- Subject: gnome-settings-daemon r298 - in trunk: . plugins/xrandr plugins/xrdb plugins/xsettings
- Date: Fri, 11 Apr 2008 21:22:50 +0100 (BST)
Author: jensg
Date: Fri Apr 11 21:22:50 2008
New Revision: 298
URL: http://svn.gnome.org/viewvc/gnome-settings-daemon?rev=298&view=rev
Log:
2008-04-11 Jens Granseuer <jensgr gmx net>
Make xrandr, xrdb, and xsettings plugin deactivation work
* plugins/xrandr/gsd-xrandr-manager.c: (apply_settings): cleanup
* plugins/xrandr/gsd-xrandr-plugin.c: (impl_deactivate):
* plugins/xrdb/gsd-xrdb-plugin.c: (impl_deactivate):
* plugins/xsettings/gsd-xsettings-plugin.c: (impl_deactivate):
stop manager on deactivation
* plugins/xrdb/gsd-xrdb-manager.c: (gsd_xrdb_manager_start),
(gsd_xrdb_manager_stop):
* plugins/xsettings/gsd-xsettings-manager.c:
(gsd_xsettings_error_quark), (find_translation_entry),
(xsettings_callback), (register_config_callback), (terminate_cb),
(setup_xsettings_managers), (gnome_xsettings_manager_start),
(gnome_xsettings_manager_stop), (gnome_xsettings_manager_init):
clean up properly on stop
Modified:
trunk/ChangeLog
trunk/plugins/xrandr/gsd-xrandr-manager.c
trunk/plugins/xrandr/gsd-xrandr-plugin.c
trunk/plugins/xrdb/gsd-xrdb-manager.c
trunk/plugins/xrdb/gsd-xrdb-plugin.c
trunk/plugins/xsettings/gsd-xsettings-manager.c
trunk/plugins/xsettings/gsd-xsettings-plugin.c
Modified: trunk/plugins/xrandr/gsd-xrandr-manager.c
==============================================================================
--- trunk/plugins/xrandr/gsd-xrandr-manager.c (original)
+++ trunk/plugins/xrandr/gsd-xrandr-manager.c Fri Apr 11 21:22:50 2008
@@ -44,6 +44,10 @@
#include "gnome-settings-profile.h"
#include "gsd-xrandr-manager.h"
+#ifndef HOST_NAME_MAX
+#define HOST_NAME_MAX 255
+#endif
+
static void gsd_xrandr_manager_class_init (GsdXrandrManagerClass *klass);
static void gsd_xrandr_manager_init (GsdXrandrManager *xrandr_manager);
static void gsd_xrandr_manager_finalize (GObject *object);
@@ -186,11 +190,7 @@
int height;
int rate;
int rotation;
-#ifdef HOST_NAME_MAX
char hostname[HOST_NAME_MAX + 1];
-#else
- char hostname[256];
-#endif
char *specific_path;
char *keys[3];
int i;
@@ -381,7 +381,7 @@
static void
gsd_xrandr_manager_class_init (GsdXrandrManagerClass *klass)
{
- GObjectClass *object_class = G_OBJECT_CLASS (klass);
+ GObjectClass *object_class = G_OBJECT_CLASS (klass);
object_class->get_property = gsd_xrandr_manager_get_property;
object_class->set_property = gsd_xrandr_manager_set_property;
Modified: trunk/plugins/xrandr/gsd-xrandr-plugin.c
==============================================================================
--- trunk/plugins/xrandr/gsd-xrandr-plugin.c (original)
+++ trunk/plugins/xrandr/gsd-xrandr-plugin.c Fri Apr 11 21:22:50 2008
@@ -86,6 +86,7 @@
impl_deactivate (GnomeSettingsPlugin *plugin)
{
g_debug ("Deactivating xrandr plugin");
+ gsd_xrandr_manager_stop (GSD_XRANDR_PLUGIN (plugin)->priv->manager);
}
static void
Modified: trunk/plugins/xrdb/gsd-xrdb-manager.c
==============================================================================
--- trunk/plugins/xrdb/gsd-xrdb-manager.c (original)
+++ trunk/plugins/xrdb/gsd-xrdb-manager.c Fri Apr 11 21:22:50 2008
@@ -55,10 +55,6 @@
GtkWidget *widget;
};
-enum {
- PROP_0,
-};
-
static void gsd_xrdb_manager_class_init (GsdXrdbManagerClass *klass);
static void gsd_xrdb_manager_init (GsdXrdbManager *xrdb_manager);
static void gsd_xrdb_manager_finalize (GObject *object);
@@ -494,25 +490,19 @@
gsd_xrdb_manager_start (GsdXrdbManager *manager,
GError **error)
{
- static gboolean initialized = FALSE;
-
gnome_settings_profile_start (NULL);
- if (! initialized) {
- GtkSettings *settings;
- /* the initialization is done here otherwise
- gnome_settings_xsettings_load would generate
- false hit as gtk-theme-name is set to Default in
- gnome_settings_xsettings_init */
- settings = gtk_settings_get_default ();
- manager->priv->widget = gtk_window_new (GTK_WINDOW_TOPLEVEL);
- g_signal_connect (settings,
- "notify::gtk-theme-name",
- G_CALLBACK (theme_changed),
- manager);
- gtk_widget_ensure_style (manager->priv->widget);
- initialized = TRUE;
- }
+ /* the initialization is done here otherwise
+ gnome_settings_xsettings_load would generate
+ false hit as gtk-theme-name is set to Default in
+ gnome_settings_xsettings_init */
+ g_signal_connect (gtk_settings_get_default (),
+ "notify::gtk-theme-name",
+ G_CALLBACK (theme_changed),
+ manager);
+
+ manager->priv->widget = gtk_window_new (GTK_WINDOW_TOPLEVEL);
+ gtk_widget_ensure_style (manager->priv->widget);
gnome_settings_profile_end (NULL);
@@ -522,7 +512,18 @@
void
gsd_xrdb_manager_stop (GsdXrdbManager *manager)
{
+ GsdXrdbManagerPrivate *p = manager->priv;
+
g_debug ("Stopping xrdb manager");
+
+ g_signal_handlers_disconnect_by_func (gtk_settings_get_default (),
+ theme_changed,
+ manager);
+
+ if (p->widget != NULL) {
+ gtk_widget_destroy (p->widget);
+ p->widget = NULL;
+ }
}
static void
@@ -589,7 +590,7 @@
static void
gsd_xrdb_manager_class_init (GsdXrdbManagerClass *klass)
{
- GObjectClass *object_class = G_OBJECT_CLASS (klass);
+ GObjectClass *object_class = G_OBJECT_CLASS (klass);
object_class->get_property = gsd_xrdb_manager_get_property;
object_class->set_property = gsd_xrdb_manager_set_property;
Modified: trunk/plugins/xrdb/gsd-xrdb-plugin.c
==============================================================================
--- trunk/plugins/xrdb/gsd-xrdb-plugin.c (original)
+++ trunk/plugins/xrdb/gsd-xrdb-plugin.c Fri Apr 11 21:22:50 2008
@@ -86,6 +86,7 @@
impl_deactivate (GnomeSettingsPlugin *plugin)
{
g_debug ("Deactivating xrdb plugin");
+ gsd_xrdb_manager_stop (GSD_XRDB_PLUGIN (plugin)->priv->manager);
}
static void
Modified: trunk/plugins/xsettings/gsd-xsettings-manager.c
==============================================================================
--- trunk/plugins/xsettings/gsd-xsettings-manager.c (original)
+++ trunk/plugins/xsettings/gsd-xsettings-manager.c Fri Apr 11 21:22:50 2008
@@ -43,6 +43,10 @@
#define GNOME_XSETTINGS_MANAGER_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), GNOME_TYPE_XSETTINGS_MANAGER, GnomeXSettingsManagerPrivate))
+#define MOUSE_SETTINGS_DIR "/desktop/gnome/peripherals/mouse"
+#define GTK_SETTINGS_DIR "/desktop/gtk"
+#define INTERFACE_SETTINGS_DIR "/desktop/gnome/interface"
+
#ifdef HAVE_XFT2
#define FONT_RENDER_DIR "/desktop/gnome/font_rendering"
#define FONT_ANTIALIASING_KEY FONT_RENDER_DIR "/antialiasing"
@@ -82,6 +86,13 @@
struct GnomeXSettingsManagerPrivate
{
XSettingsManager **managers;
+ guint notify[4];
+};
+
+#define GSD_XSETTINGS_ERROR gsd_xsettings_error_quark ()
+
+enum {
+ GSD_XSETTINGS_ERROR_INIT
};
static void gnome_xsettings_manager_class_init (GnomeXSettingsManagerClass *klass);
@@ -92,6 +103,12 @@
static gpointer manager_object = NULL;
+static GQuark
+gsd_xsettings_error_quark (void)
+{
+ return g_quark_from_static_string ("gsd-xsettings-error-quark");
+}
+
static void
translate_bool_int (GnomeXSettingsManager *manager,
TranslationEntry *trans,
@@ -570,6 +587,111 @@
}
}
+static TranslationEntry *
+find_translation_entry (const char *gconf_key)
+{
+ int i;
+
+ for (i = 0; i < G_N_ELEMENTS (translations); ++i) {
+ if (strcmp (translations[i].gconf_key, gconf_key) == 0) {
+ return &translations[i];
+ }
+ }
+
+ return NULL;
+}
+
+static void
+xsettings_callback (GConfClient *client,
+ guint cnxn_id,
+ GConfEntry *entry,
+ GnomeXSettingsManager *manager)
+{
+ TranslationEntry *trans;
+ int i;
+
+ trans = find_translation_entry (entry->key);
+ if (trans == NULL) {
+ return;
+ }
+
+ process_value (manager, trans, entry->value);
+
+ for (i = 0; manager->priv->managers [i]; i++) {
+ xsettings_manager_set_string (manager->priv->managers [i],
+ "Net/FallbackIconTheme",
+ "gnome");
+ }
+
+ for (i = 0; manager->priv->managers [i]; i++) {
+ xsettings_manager_notify (manager->priv->managers [i]);
+ }
+}
+
+static guint
+register_config_callback (GnomeXSettingsManager *manager,
+ GConfClient *client,
+ const char *path,
+ GConfClientNotifyFunc func)
+{
+ gconf_client_add_dir (client, path, GCONF_CLIENT_PRELOAD_NONE, NULL);
+ return gconf_client_notify_add (client, path, func, manager, NULL, NULL);
+}
+
+static void
+terminate_cb (void *data)
+{
+ gboolean *terminated = data;
+
+ if (*terminated) {
+ return;
+ }
+
+ *terminated = TRUE;
+
+ gtk_main_quit ();
+}
+
+static gboolean
+setup_xsettings_managers (GnomeXSettingsManager *manager)
+{
+ GdkDisplay *display;
+ int i;
+ int n_screens;
+ gboolean res;
+ gboolean terminated;
+
+ display = gdk_display_get_default ();
+ n_screens = gdk_display_get_n_screens (display);
+
+ res = xsettings_manager_check_running (gdk_x11_display_get_xdisplay (display),
+ gdk_screen_get_number (gdk_screen_get_default ()));
+ if (res) {
+ g_error ("You can only run one xsettings manager at a time; exiting");
+ return FALSE;
+ }
+
+ manager->priv->managers = g_new0 (XSettingsManager *, n_screens + 1);
+
+ terminated = FALSE;
+ for (i = 0; i < n_screens; i++) {
+ GdkScreen *screen;
+
+ screen = gdk_display_get_screen (display, i);
+
+ manager->priv->managers [i] = xsettings_manager_new (gdk_x11_display_get_xdisplay (display),
+ gdk_screen_get_number (screen),
+ terminate_cb,
+ &terminated);
+ if (! manager->priv->managers [i]) {
+ g_error ("Could not create xsettings manager for screen %d!", i);
+ return FALSE;
+ }
+ }
+
+ return TRUE;
+}
+
gboolean
gnome_xsettings_manager_start (GnomeXSettingsManager *manager,
GError **error)
@@ -580,6 +702,13 @@
g_debug ("Starting xsettings manager");
gnome_settings_profile_start (NULL);
+ if (!setup_xsettings_managers (manager)) {
+ g_set_error (error, GSD_XSETTINGS_ERROR,
+ GSD_XSETTINGS_ERROR_INIT,
+ "Could not initialize xsettings manager.");
+ return FALSE;
+ }
+
client = gconf_client_get_default ();
for (i = 0; i < G_N_ELEMENTS (translations); i++) {
@@ -604,7 +733,24 @@
}
}
+ manager->priv->notify[0] =
+ register_config_callback (manager, client,
+ MOUSE_SETTINGS_DIR,
+ (GConfClientNotifyFunc) xsettings_callback);
+ manager->priv->notify[1] =
+ register_config_callback (manager, client,
+ GTK_SETTINGS_DIR,
+ (GConfClientNotifyFunc) xsettings_callback);
+ manager->priv->notify[2] =
+ register_config_callback (manager, client,
+ INTERFACE_SETTINGS_DIR,
+ (GConfClientNotifyFunc) xsettings_callback);
+
#ifdef HAVE_XFT2
+ manager->priv->notify[3] =
+ register_config_callback (manager, client,
+ FONT_RENDER_DIR,
+ (GConfClientNotifyFunc) xft_callback);
update_xft_settings (manager, client);
#endif /* HAVE_XFT */
@@ -619,6 +765,7 @@
xsettings_manager_notify (manager->priv->managers [i]);
}
+
gnome_settings_profile_end (NULL);
return TRUE;
@@ -627,7 +774,37 @@
void
gnome_xsettings_manager_stop (GnomeXSettingsManager *manager)
{
+ GnomeXSettingsManagerPrivate *p = manager->priv;
+ GConfClient *client;
+ int i;
+
g_debug ("Stopping xsettings manager");
+
+ if (p->managers != NULL) {
+ for (i = 0; p->managers [i]; ++i)
+ xsettings_manager_destroy (p->managers [i]);
+
+ g_free (p->managers);
+ p->managers = NULL;
+ }
+
+ client = gconf_client_get_default ();
+
+ gconf_client_remove_dir (client, MOUSE_SETTINGS_DIR, NULL);
+ gconf_client_remove_dir (client, GTK_SETTINGS_DIR, NULL);
+ gconf_client_remove_dir (client, INTERFACE_SETTINGS_DIR, NULL);
+#ifdef HAVE_XFT2
+ gconf_client_remove_dir (client, FONT_RENDER_DIR, NULL);
+#endif
+
+ for (i = 0; i < G_N_ELEMENTS (p->notify); ++i) {
+ if (p->notify[i] != 0) {
+ gconf_client_notify_remove (client, p->notify[i]);
+ p->notify[i] = 0;
+ }
+ }
+
+ g_object_unref (client);
}
static void
@@ -694,7 +871,7 @@
static void
gnome_xsettings_manager_class_init (GnomeXSettingsManagerClass *klass)
{
- GObjectClass *object_class = G_OBJECT_CLASS (klass);
+ GObjectClass *object_class = G_OBJECT_CLASS (klass);
object_class->get_property = gnome_xsettings_manager_get_property;
object_class->set_property = gnome_xsettings_manager_set_property;
@@ -705,125 +882,10 @@
g_type_class_add_private (klass, sizeof (GnomeXSettingsManagerPrivate));
}
-static TranslationEntry *
-find_translation_entry (const char *gconf_key)
-{
- int i;
-
- for (i =0; i < G_N_ELEMENTS (translations); i++) {
- if (strcmp (translations[i].gconf_key, gconf_key) == 0) {
- return &translations[i];
- }
- }
-
- return NULL;
-}
-
-static void
-xsettings_callback (GConfClient *client,
- guint cnxn_id,
- GConfEntry *entry,
- GnomeXSettingsManager *manager)
-{
- TranslationEntry *trans;
- int i;
-
- trans = find_translation_entry (entry->key);
- if (trans == NULL) {
- return;
- }
-
- process_value (manager, trans, entry->value);
-
- for (i = 0; manager->priv->managers [i]; i++) {
- xsettings_manager_set_string (manager->priv->managers [i],
- "Net/FallbackIconTheme",
- "gnome");
- }
-
- for (i = 0; manager->priv->managers [i]; i++) {
- xsettings_manager_notify (manager->priv->managers [i]);
- }
-}
-
-static void
-register_config_callback (GnomeXSettingsManager *manager,
- const char *path,
- GConfClientNotifyFunc func)
-{
- GConfClient *client;
-
- client = gconf_client_get_default ();
-
- gconf_client_add_dir (client, path, GCONF_CLIENT_PRELOAD_NONE, NULL);
- gconf_client_notify_add (client, path, func, manager, NULL, NULL);
-
- g_object_unref (client);
-}
-
-static void
-terminate_cb (void *data)
-{
- gboolean *terminated = data;
-
- if (*terminated) {
- return;
- }
-
- *terminated = TRUE;
-
- gtk_main_quit ();
-}
-
static void
gnome_xsettings_manager_init (GnomeXSettingsManager *manager)
{
- GdkDisplay *display;
- int i;
- int n_screens;
- gboolean res;
- gboolean terminated;
-
manager->priv = GNOME_XSETTINGS_MANAGER_GET_PRIVATE (manager);
-
- display = gdk_display_get_default ();
- n_screens = gdk_display_get_n_screens (display);
-
- res = xsettings_manager_check_running (gdk_x11_display_get_xdisplay (display),
- gdk_screen_get_number (gdk_screen_get_default ()));
- if (res) {
- g_error ("You can only run one xsettings manager at a time; exiting\n");
- exit (1);
- }
-
- manager->priv->managers = g_new (XSettingsManager *, n_screens + 1);
-
- terminated = FALSE;
- for (i = 0; i < n_screens; i++) {
- GdkScreen *screen;
-
- screen = gdk_display_get_screen (display, i);
-
- manager->priv->managers [i] = xsettings_manager_new (gdk_x11_display_get_xdisplay (display),
- gdk_screen_get_number (screen),
- terminate_cb,
- &terminated);
- if (! manager->priv->managers [i]) {
- g_error ("Could not create xsettings manager for screen %d!\n", i);
- exit (1);
- }
- }
-
- manager->priv->managers [i] = NULL;
-
- register_config_callback (manager, "/desktop/gnome/peripherals/mouse", (GConfClientNotifyFunc)xsettings_callback);
- register_config_callback (manager, "/desktop/gtk", (GConfClientNotifyFunc)xsettings_callback);
- register_config_callback (manager, "/desktop/gnome/interface", (GConfClientNotifyFunc)xsettings_callback);
-
-#ifdef HAVE_XFT2
- register_config_callback (manager, FONT_RENDER_DIR, (GConfClientNotifyFunc)xft_callback);
-#endif /* HAVE_XFT2 */
-
}
static void
Modified: trunk/plugins/xsettings/gsd-xsettings-plugin.c
==============================================================================
--- trunk/plugins/xsettings/gsd-xsettings-plugin.c (original)
+++ trunk/plugins/xsettings/gsd-xsettings-plugin.c Fri Apr 11 21:22:50 2008
@@ -86,6 +86,7 @@
impl_deactivate (GnomeSettingsPlugin *plugin)
{
g_debug ("Deactivating xsettings plugin");
+ gnome_xsettings_manager_stop (GNOME_XSETTINGS_PLUGIN (plugin)->priv->manager);
}
static void
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]