2001-12-09 18:50:32 +00:00
|
|
|
/*
|
|
|
|
* Copyright © 2001 Red Hat, Inc.
|
|
|
|
*
|
|
|
|
* Permission to use, copy, modify, distribute, and sell this software and its
|
|
|
|
* documentation for any purpose is hereby granted without fee, provided that
|
|
|
|
* the above copyright notice appear in all copies and that both that
|
|
|
|
* copyright notice and this permission notice appear in supporting
|
|
|
|
* documentation, and that the name of Red Hat not be used in advertising or
|
|
|
|
* publicity pertaining to distribution of the software without specific,
|
|
|
|
* written prior permission. Red Hat makes no representations about the
|
|
|
|
* suitability of this software for any purpose. It is provided "as is"
|
|
|
|
* without express or implied warranty.
|
|
|
|
*
|
|
|
|
* RED HAT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL
|
|
|
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL RED HAT
|
|
|
|
* BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
|
|
|
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
|
|
|
|
* OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
|
|
|
|
* CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
|
|
|
*
|
|
|
|
* Authors: Owen Taylor, Havoc Pennington
|
|
|
|
*/
|
2005-05-22 15:46:45 +00:00
|
|
|
#include <config.h>
|
2001-12-09 18:50:32 +00:00
|
|
|
#include <stdlib.h>
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <string.h>
|
|
|
|
|
|
|
|
#include <gdk/gdkx.h>
|
2005-05-22 15:46:45 +00:00
|
|
|
#include <gtk/gtk.h>
|
|
|
|
|
2001-12-09 18:50:32 +00:00
|
|
|
|
|
|
|
#include <gconf/gconf.h>
|
2002-01-08 14:54:35 +00:00
|
|
|
#include <libgnome/gnome-init.h>
|
|
|
|
#include <libgnomeui/gnome-ui-init.h>
|
2003-02-06 21:47:00 +00:00
|
|
|
|
|
|
|
#include <errno.h>
|
|
|
|
#include <sys/types.h>
|
|
|
|
#include <sys/wait.h>
|
|
|
|
#include <unistd.h>
|
|
|
|
|
2001-12-09 18:50:32 +00:00
|
|
|
#include "xsettings-manager.h"
|
|
|
|
#include "gnome-settings-daemon.h"
|
2005-01-31 15:31:44 +00:00
|
|
|
#include "gnome-settings-xmodmap.h"
|
2001-12-09 18:50:32 +00:00
|
|
|
|
2002-04-10 06:08:08 +00:00
|
|
|
/*#include "gnome-settings-disk.h"*/
|
2002-03-28 14:27:13 +00:00
|
|
|
#include "gnome-settings-font.h"
|
2001-12-20 20:20:03 +00:00
|
|
|
#include "gnome-settings-xsettings.h"
|
|
|
|
#include "gnome-settings-mouse.h"
|
2003-11-12 21:58:51 +00:00
|
|
|
#include "gnome-settings-keyboard-xkb.h"
|
2001-12-20 20:20:03 +00:00
|
|
|
#include "gnome-settings-keyboard.h"
|
|
|
|
#include "gnome-settings-background.h"
|
2002-01-04 17:50:44 +00:00
|
|
|
#include "gnome-settings-sound.h"
|
2002-03-23 04:39:24 +00:00
|
|
|
#include "gnome-settings-accessibility-keyboard.h"
|
2002-03-26 17:22:02 +00:00
|
|
|
#include "gnome-settings-screensaver.h"
|
2002-05-16 23:09:02 +00:00
|
|
|
#include "gnome-settings-default-editor.h"
|
2002-05-30 00:25:29 +00:00
|
|
|
#include "gnome-settings-keybindings.h"
|
2004-01-13 15:59:09 +00:00
|
|
|
#include "gnome-settings-multimedia-keys.h"
|
2002-08-19 19:14:21 +00:00
|
|
|
#include "gnome-settings-gtk1theme.h"
|
2003-05-01 16:08:26 +00:00
|
|
|
#include "gnome-settings-xrdb.h"
|
2003-06-26 11:40:10 +00:00
|
|
|
#include "gnome-settings-typing-break.h"
|
2001-12-20 20:20:03 +00:00
|
|
|
|
2005-06-03 08:29:45 +00:00
|
|
|
#include "clipboard-manager.h"
|
|
|
|
|
2002-03-11 01:44:03 +00:00
|
|
|
static GObjectClass *parent_class = NULL;
|
|
|
|
|
|
|
|
struct _GnomeSettingsDaemonPrivate {
|
2002-03-13 17:31:20 +00:00
|
|
|
int dummy;
|
2002-03-11 01:44:03 +00:00
|
|
|
};
|
|
|
|
|
2001-12-09 18:50:32 +00:00
|
|
|
static GSList *directories = NULL;
|
2002-11-08 03:26:33 +00:00
|
|
|
XSettingsManager **managers = NULL;
|
2005-06-03 08:29:45 +00:00
|
|
|
static ClipboardManager *clipboard_manager;
|
2001-12-09 18:50:32 +00:00
|
|
|
|
|
|
|
typedef struct DirElement
|
|
|
|
{
|
|
|
|
char *dir;
|
|
|
|
GSList *callbacks;
|
|
|
|
} DirElement;
|
|
|
|
|
|
|
|
void
|
|
|
|
gnome_settings_daemon_register_callback (const char *dir,
|
|
|
|
KeyCallbackFunc func)
|
|
|
|
{
|
|
|
|
GSList *list;
|
|
|
|
gboolean dir_found = FALSE;
|
|
|
|
|
|
|
|
for (list = directories; list; list = list->next)
|
|
|
|
{
|
|
|
|
DirElement *dir_element = list->data;
|
|
|
|
|
|
|
|
if (! strcmp (dir_element->dir, dir))
|
|
|
|
{
|
2002-03-13 17:31:20 +00:00
|
|
|
dir_element->callbacks = g_slist_prepend (dir_element->callbacks, (gpointer)func);
|
2001-12-09 18:50:32 +00:00
|
|
|
dir_found = TRUE;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (! dir_found)
|
|
|
|
{
|
|
|
|
DirElement *dir_element = g_new0 (DirElement, 1);
|
|
|
|
|
|
|
|
dir_element->dir = g_strdup (dir);
|
2002-03-13 17:31:20 +00:00
|
|
|
dir_element->callbacks = g_slist_prepend (dir_element->callbacks, (gpointer)func);
|
2001-12-09 18:50:32 +00:00
|
|
|
directories = g_slist_prepend (directories, dir_element);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2001-12-16 08:24:23 +00:00
|
|
|
GtkWidget *
|
|
|
|
gnome_settings_daemon_get_invisible (void)
|
|
|
|
{
|
|
|
|
static GtkWidget *invisible = NULL;
|
|
|
|
if (invisible == NULL)
|
|
|
|
invisible = gtk_invisible_new ();
|
|
|
|
return invisible;
|
|
|
|
}
|
|
|
|
|
2001-12-09 18:50:32 +00:00
|
|
|
static void
|
2002-01-04 20:48:17 +00:00
|
|
|
config_notify (GConfClient *client,
|
2001-12-09 18:50:32 +00:00
|
|
|
guint cnxn_id,
|
|
|
|
GConfEntry *entry,
|
|
|
|
gpointer user_data)
|
|
|
|
{
|
|
|
|
GSList *list;
|
|
|
|
|
|
|
|
for (list = directories; list; list = list->next)
|
|
|
|
{
|
|
|
|
DirElement *dir_element = list->data;
|
|
|
|
|
|
|
|
if (! strncmp (dir_element->dir, entry->key, strlen (dir_element->dir)))
|
|
|
|
{
|
|
|
|
GSList *func_list;
|
|
|
|
for (func_list = dir_element->callbacks; func_list; func_list = func_list->next)
|
|
|
|
{
|
|
|
|
((KeyCallbackFunc) func_list->data) (entry);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2005-06-03 08:29:45 +00:00
|
|
|
static void
|
|
|
|
clipboard_manager_terminate_cb (void *data)
|
|
|
|
{
|
|
|
|
/* Do nothing */
|
|
|
|
}
|
|
|
|
|
|
|
|
static GdkFilterReturn
|
|
|
|
clipboard_manager_event_filter (GdkXEvent *xevent,
|
|
|
|
GdkEvent *event,
|
|
|
|
gpointer data)
|
|
|
|
{
|
|
|
|
if (clipboard_manager_process_event (clipboard_manager,
|
|
|
|
(XEvent *)xevent))
|
|
|
|
return GDK_FILTER_REMOVE;
|
|
|
|
else
|
|
|
|
return GDK_FILTER_CONTINUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
clipboard_manager_watch_cb (Window window,
|
|
|
|
Bool is_start,
|
|
|
|
long mask,
|
|
|
|
void *cb_data)
|
|
|
|
{
|
|
|
|
GdkWindow *gdkwin;
|
|
|
|
GdkDisplay *display;
|
|
|
|
|
|
|
|
display = gdk_display_get_default ();
|
|
|
|
gdkwin = gdk_window_lookup_for_display (display, window);
|
|
|
|
|
|
|
|
if (is_start)
|
|
|
|
{
|
|
|
|
if (!gdkwin)
|
|
|
|
gdkwin = gdk_window_foreign_new_for_display (display, window);
|
|
|
|
else
|
|
|
|
g_object_ref (gdkwin);
|
|
|
|
|
|
|
|
gdk_window_add_filter (gdkwin, clipboard_manager_event_filter, NULL);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2005-06-12 13:09:44 +00:00
|
|
|
if (!gdkwin)
|
|
|
|
return;
|
2005-06-03 08:29:45 +00:00
|
|
|
gdk_window_remove_filter (gdkwin, clipboard_manager_event_filter, NULL);
|
|
|
|
g_object_unref (gdkwin);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2001-12-09 18:50:32 +00:00
|
|
|
static void
|
|
|
|
terminate_cb (void *data)
|
|
|
|
{
|
|
|
|
gboolean *terminated = data;
|
2002-11-08 03:26:33 +00:00
|
|
|
|
|
|
|
if (*terminated)
|
|
|
|
return;
|
2001-12-09 18:50:32 +00:00
|
|
|
|
|
|
|
*terminated = TRUE;
|
|
|
|
gtk_main_quit ();
|
|
|
|
}
|
|
|
|
|
|
|
|
static GdkFilterReturn
|
|
|
|
manager_event_filter (GdkXEvent *xevent,
|
|
|
|
GdkEvent *event,
|
|
|
|
gpointer data)
|
|
|
|
{
|
2002-11-08 03:26:33 +00:00
|
|
|
int screen_num = GPOINTER_TO_INT (data);
|
|
|
|
|
|
|
|
g_return_val_if_fail (managers != NULL, GDK_FILTER_CONTINUE);
|
|
|
|
|
|
|
|
if (xsettings_manager_process_event (managers [screen_num], (XEvent *)xevent))
|
2001-12-09 18:50:32 +00:00
|
|
|
return GDK_FILTER_REMOVE;
|
|
|
|
else
|
|
|
|
return GDK_FILTER_CONTINUE;
|
|
|
|
}
|
|
|
|
|
2002-03-11 01:44:03 +00:00
|
|
|
static void
|
|
|
|
finalize (GObject *object)
|
|
|
|
{
|
|
|
|
GnomeSettingsDaemon *daemon;
|
2002-11-08 03:26:33 +00:00
|
|
|
int i;
|
2002-03-11 01:44:03 +00:00
|
|
|
|
|
|
|
daemon = GNOME_SETTINGS_DAEMON (object);
|
|
|
|
if (daemon->private == NULL) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2002-11-08 03:26:33 +00:00
|
|
|
for (i = 0; managers && managers [i]; i++)
|
|
|
|
xsettings_manager_destroy (managers [i]);
|
2002-03-11 01:44:03 +00:00
|
|
|
|
2005-06-03 08:29:45 +00:00
|
|
|
clipboard_manager_destroy (clipboard_manager);
|
|
|
|
|
2002-03-11 01:44:03 +00:00
|
|
|
g_free (daemon->private);
|
|
|
|
daemon->private = NULL;
|
|
|
|
|
|
|
|
G_OBJECT_CLASS (parent_class)->finalize (object);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gnome_settings_daemon_class_init (GnomeSettingsDaemonClass *klass)
|
|
|
|
{
|
|
|
|
GObjectClass *object_class;
|
|
|
|
|
|
|
|
object_class = G_OBJECT_CLASS (klass);
|
|
|
|
|
|
|
|
object_class->finalize = finalize;
|
|
|
|
|
|
|
|
parent_class = g_type_class_peek_parent (klass);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gnome_settings_daemon_init (GnomeSettingsDaemon *settings)
|
|
|
|
{
|
|
|
|
settings->private = g_new (GnomeSettingsDaemonPrivate, 1);
|
|
|
|
}
|
|
|
|
|
2006-06-25 02:16:06 +00:00
|
|
|
G_DEFINE_TYPE (GnomeSettingsDaemon, gnome_settings_daemon,
|
|
|
|
G_TYPE_OBJECT)
|
2002-03-11 01:44:03 +00:00
|
|
|
|
|
|
|
GObject *
|
|
|
|
gnome_settings_daemon_new (void)
|
2001-12-09 18:50:32 +00:00
|
|
|
{
|
|
|
|
gboolean terminated = FALSE;
|
2002-01-04 20:48:17 +00:00
|
|
|
GConfClient *client;
|
2001-12-09 18:50:32 +00:00
|
|
|
GSList *list;
|
2002-03-11 01:44:03 +00:00
|
|
|
GnomeSettingsDaemon *daemon;
|
2002-11-08 03:26:33 +00:00
|
|
|
GdkDisplay *display;
|
2006-07-06 19:45:13 +00:00
|
|
|
GObject *dbusServer;
|
2002-11-08 03:26:33 +00:00
|
|
|
int i;
|
|
|
|
int n_screens;
|
|
|
|
|
|
|
|
display = gdk_display_get_default ();
|
|
|
|
n_screens = gdk_display_get_n_screens (display);
|
2002-03-06 18:17:33 +00:00
|
|
|
|
2002-03-11 01:44:03 +00:00
|
|
|
daemon = g_object_new (gnome_settings_daemon_get_type (), NULL);
|
2002-01-08 14:54:35 +00:00
|
|
|
|
2002-11-08 03:26:33 +00:00
|
|
|
if (xsettings_manager_check_running (
|
|
|
|
gdk_x11_display_get_xdisplay (display),
|
|
|
|
gdk_screen_get_number (gdk_screen_get_default ())))
|
2001-12-09 18:50:32 +00:00
|
|
|
{
|
2002-03-04 08:54:36 +00:00
|
|
|
fprintf (stderr, "You can only run one xsettings manager at a time; exiting\n");
|
2001-12-09 18:50:32 +00:00
|
|
|
exit (1);
|
|
|
|
}
|
2005-06-03 08:29:45 +00:00
|
|
|
|
|
|
|
|
2001-12-09 18:50:32 +00:00
|
|
|
if (!terminated)
|
|
|
|
{
|
2002-11-08 03:26:33 +00:00
|
|
|
managers = g_new (XSettingsManager *, n_screens + 1);
|
|
|
|
|
|
|
|
for (i = 0; i < n_screens; i++)
|
|
|
|
{
|
|
|
|
GdkScreen *screen;
|
|
|
|
|
|
|
|
screen = gdk_display_get_screen (display, i);
|
|
|
|
|
|
|
|
managers [i] = xsettings_manager_new (
|
|
|
|
gdk_x11_display_get_xdisplay (display),
|
|
|
|
gdk_screen_get_number (screen),
|
|
|
|
terminate_cb, &terminated);
|
|
|
|
if (!managers [i])
|
|
|
|
{
|
|
|
|
fprintf (stderr, "Could not create xsettings manager for screen %d!\n", i);
|
|
|
|
exit (1);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
g_assert (i == n_screens);
|
|
|
|
managers [i] = NULL;
|
2001-12-09 18:50:32 +00:00
|
|
|
}
|
|
|
|
|
2005-06-03 08:29:45 +00:00
|
|
|
if (!clipboard_manager_check_running (GDK_DISPLAY_XDISPLAY (display)))
|
|
|
|
{
|
|
|
|
clipboard_manager = clipboard_manager_new (GDK_DISPLAY_XDISPLAY (display),
|
|
|
|
gdk_error_trap_push,
|
|
|
|
gdk_error_trap_pop,
|
|
|
|
clipboard_manager_terminate_cb,
|
|
|
|
clipboard_manager_watch_cb,
|
|
|
|
NULL);
|
|
|
|
}
|
|
|
|
|
2002-01-04 20:48:17 +00:00
|
|
|
/* We use GConfClient not GConfClient because a cache isn't useful
|
2001-12-09 18:50:32 +00:00
|
|
|
* for us
|
|
|
|
*/
|
declare a global GConfClient. (main): unref the global GConfClient.
2005-10-16 Rodrigo Moya <rodrigo@novell.com>
* factory.c: declare a global GConfClient.
(main): unref the global GConfClient.
* gnome-settings-daemon.[ch] (gnome_settings_daemon_get_conf_client):
new function to use the same GConfClient everywhere.
(gnome_settings_daemon_new): use the global GConfClient.
* gnome-settings-accessibility-keyboard.c (set_server_from_gconf,
ax_response_callback, set_gconf_from_server):
* gnome-settings-gtk1theme.c (apply_settings):
* gnome-settings-keybindings.c (bindings_get_entry):
* gnome-settings-keyboard.c (numlock_get_gconf_state,
numlock_set_gconf_state, apply_settings):
* gnome-settings-keyboard-xkb.c (apply_xkb_settings,
gnome_settings_keyboard_xkb_sysconfig_changed_response,
gnome_settings_keyboard_xkb_analyze_sysconfig,
gnome_settings_chk_file_list):
* gnome-settings-screensaver.c (key_toggled_cb,
really_start_screensaver):
* gnome-settings-sound.c (apply_settings):
* gnome-settings-xmodmap.c (check_button_callback,
gnome_settings_load_modmap_files, remove_button_clicked_callback,
load_button_clicked_callback, gnome_settings_modmap_dialog_call):
* gnome-settings-xsettings.c (xft_callback):
use the global GConfClient.
* gnome-settings-keyboard-xkb.c (gnome_settings_keyboard_xkb_load):
don't get another GConfClient when we're getting one passed!
2005-10-17 14:53:19 +00:00
|
|
|
client = gnome_settings_daemon_get_conf_client ();
|
2002-03-28 14:27:13 +00:00
|
|
|
|
2002-04-10 06:08:08 +00:00
|
|
|
/* gnome_settings_disk_init (client);*/
|
2002-03-28 14:27:13 +00:00
|
|
|
gnome_settings_font_init (client);
|
2002-01-04 20:48:17 +00:00
|
|
|
gnome_settings_xsettings_init (client);
|
|
|
|
gnome_settings_mouse_init (client);
|
2003-11-12 21:58:51 +00:00
|
|
|
/* Essential - xkb initialization should happen before */
|
2005-05-22 15:46:45 +00:00
|
|
|
gnome_settings_keyboard_xkb_set_post_activation_callback ((PostActivationCallback)gnome_settings_load_modmap_files, NULL);
|
2003-11-12 21:58:51 +00:00
|
|
|
gnome_settings_keyboard_xkb_init (client);
|
2002-01-04 20:48:17 +00:00
|
|
|
gnome_settings_keyboard_init (client);
|
2004-01-13 15:59:09 +00:00
|
|
|
gnome_settings_multimedia_keys_init (client);
|
2003-11-12 21:58:51 +00:00
|
|
|
/* */
|
2002-01-04 20:48:17 +00:00
|
|
|
gnome_settings_sound_init (client);
|
2002-03-23 04:39:24 +00:00
|
|
|
gnome_settings_accessibility_keyboard_init (client);
|
2002-03-26 17:22:02 +00:00
|
|
|
gnome_settings_screensaver_init (client);
|
2002-05-16 23:09:02 +00:00
|
|
|
gnome_settings_default_editor_init (client);
|
2002-05-22 20:58:14 +00:00
|
|
|
gnome_settings_background_init (client);
|
2002-05-30 00:25:29 +00:00
|
|
|
gnome_settings_keybindings_init (client);
|
2002-08-19 19:14:21 +00:00
|
|
|
gnome_settings_gtk1_theme_init (client);
|
2003-05-01 16:08:26 +00:00
|
|
|
gnome_settings_xrdb_init (client);
|
2003-06-26 11:40:10 +00:00
|
|
|
gnome_settings_typing_break_init (client);
|
2002-03-26 17:22:02 +00:00
|
|
|
|
2001-12-09 18:50:32 +00:00
|
|
|
for (list = directories; list; list = list->next)
|
|
|
|
{
|
|
|
|
GError *error = NULL;
|
|
|
|
DirElement *dir_element = list->data;
|
2002-01-09 01:08:50 +00:00
|
|
|
|
|
|
|
gconf_client_add_dir (client,
|
|
|
|
dir_element->dir,
|
|
|
|
GCONF_CLIENT_PRELOAD_ONELEVEL,
|
|
|
|
NULL);
|
2001-12-09 18:50:32 +00:00
|
|
|
|
2002-01-04 20:48:17 +00:00
|
|
|
gconf_client_notify_add (client,
|
2001-12-09 18:50:32 +00:00
|
|
|
dir_element->dir,
|
|
|
|
config_notify,
|
|
|
|
NULL,
|
2002-01-04 20:48:17 +00:00
|
|
|
NULL,
|
2001-12-09 18:50:32 +00:00
|
|
|
&error);
|
|
|
|
|
|
|
|
if (error)
|
|
|
|
{
|
|
|
|
fprintf (stderr, "Could not listen for changes to configuration in '%s': %s\n",
|
|
|
|
dir_element->dir, error->message);
|
|
|
|
g_error_free (error);
|
|
|
|
}
|
|
|
|
}
|
2005-06-03 08:29:45 +00:00
|
|
|
|
2002-11-08 03:26:33 +00:00
|
|
|
for (i = 0; i < n_screens; i++)
|
|
|
|
{
|
|
|
|
GdkScreen *screen;
|
|
|
|
|
|
|
|
screen = gdk_display_get_screen (display, i);
|
|
|
|
gdk_window_add_filter (
|
|
|
|
gdk_screen_get_root_window (screen),
|
|
|
|
manager_event_filter, GINT_TO_POINTER (i));
|
|
|
|
}
|
2002-03-28 14:27:13 +00:00
|
|
|
|
2002-04-10 06:08:08 +00:00
|
|
|
/* gnome_settings_disk_load (client);*/
|
2002-03-28 14:27:13 +00:00
|
|
|
gnome_settings_font_load (client);
|
2002-01-04 20:48:17 +00:00
|
|
|
gnome_settings_xsettings_load (client);
|
|
|
|
gnome_settings_mouse_load (client);
|
2003-11-12 21:58:51 +00:00
|
|
|
/* Essential - xkb initialization should happen before */
|
|
|
|
gnome_settings_keyboard_xkb_load (client);
|
2002-05-16 23:09:02 +00:00
|
|
|
gnome_settings_keyboard_load (client);
|
2004-01-13 15:59:09 +00:00
|
|
|
gnome_settings_multimedia_keys_load (client);
|
2003-11-12 21:58:51 +00:00
|
|
|
/* */
|
2002-01-08 14:54:35 +00:00
|
|
|
gnome_settings_sound_load (client);
|
2002-03-23 04:39:24 +00:00
|
|
|
gnome_settings_accessibility_keyboard_load (client);
|
2002-03-26 17:22:02 +00:00
|
|
|
gnome_settings_screensaver_load (client);
|
2002-05-16 23:09:02 +00:00
|
|
|
gnome_settings_default_editor_load (client);
|
2002-05-22 20:58:14 +00:00
|
|
|
gnome_settings_background_load (client);
|
2002-05-30 00:25:29 +00:00
|
|
|
gnome_settings_keybindings_load (client);
|
2002-08-19 19:14:21 +00:00
|
|
|
gnome_settings_gtk1_theme_load (client);
|
2003-05-01 16:08:26 +00:00
|
|
|
gnome_settings_xrdb_load (client);
|
2003-06-26 11:40:10 +00:00
|
|
|
gnome_settings_typing_break_load (client);
|
2002-05-16 23:09:02 +00:00
|
|
|
|
2006-07-06 19:45:13 +00:00
|
|
|
dbusServer = g_object_new (gnome_settings_server_get_type (), NULL);
|
|
|
|
|
2002-03-11 01:44:03 +00:00
|
|
|
return G_OBJECT (daemon);
|
2001-12-09 18:50:32 +00:00
|
|
|
}
|
2003-02-06 21:47:00 +00:00
|
|
|
|
|
|
|
|
|
|
|
/* Helper functions */
|
|
|
|
|
2005-10-15 21:56:43 +00:00
|
|
|
static void
|
|
|
|
child_watch_cb (GPid pid, gint status, gpointer user_data)
|
|
|
|
{
|
|
|
|
gchar *command = user_data;
|
|
|
|
|
|
|
|
if (!WIFEXITED (status) || WEXITSTATUS (status))
|
|
|
|
{
|
|
|
|
g_warning ("Command %s failed", command);
|
|
|
|
}
|
|
|
|
|
|
|
|
g_free (command);
|
|
|
|
|
|
|
|
}
|
2003-02-06 21:47:00 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Helper function for spawn_with_input() - write an entire
|
|
|
|
* string to a fd.
|
|
|
|
*/
|
|
|
|
static gboolean
|
|
|
|
write_all (int fd,
|
|
|
|
const char *buf,
|
|
|
|
gsize to_write)
|
|
|
|
{
|
|
|
|
while (to_write > 0)
|
|
|
|
{
|
|
|
|
gssize count = write (fd, buf, to_write);
|
|
|
|
if (count < 0)
|
|
|
|
{
|
|
|
|
if (errno != EINTR)
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
to_write -= count;
|
|
|
|
buf += count;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* gnome_settings_daemon-spawn_with_input:
|
|
|
|
* @argv: command line to run
|
|
|
|
* @input: string to write to the child process.
|
|
|
|
*
|
|
|
|
* Spawns a child process specified by @argv, writes the text in
|
|
|
|
* @input to it, then waits for the child to exit. Any failures
|
|
|
|
* are output through g_warning(); if you wanted to use this in
|
|
|
|
* cases where errors need to be presented to the user, some
|
|
|
|
* modification would be needed.
|
|
|
|
**/
|
|
|
|
void
|
|
|
|
gnome_settings_daemon_spawn_with_input (char **argv,
|
|
|
|
const char *input)
|
|
|
|
{
|
|
|
|
int child_pid;
|
|
|
|
int inpipe;
|
|
|
|
GError *err = NULL;
|
2005-10-15 21:56:43 +00:00
|
|
|
gchar *command;
|
2003-02-06 21:47:00 +00:00
|
|
|
|
|
|
|
if (!g_spawn_async_with_pipes (NULL /* working directory */, argv, NULL /* envp */,
|
|
|
|
G_SPAWN_SEARCH_PATH | G_SPAWN_DO_NOT_REAP_CHILD,
|
|
|
|
NULL, NULL, /* child setup and data */
|
|
|
|
&child_pid,
|
|
|
|
&inpipe, NULL, NULL, /* stdin, stdout, stderr */
|
|
|
|
&err))
|
|
|
|
{
|
2005-11-14 15:18:09 +00:00
|
|
|
command = g_strjoinv (" ", argv);
|
2003-02-06 21:47:00 +00:00
|
|
|
g_warning ("Could not execute %s: %s", command, err->message);
|
|
|
|
g_error_free (err);
|
|
|
|
g_free (command);
|
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2005-10-15 21:56:43 +00:00
|
|
|
command = g_strjoinv (" ", argv);
|
2003-02-06 21:47:00 +00:00
|
|
|
if (input)
|
|
|
|
{
|
|
|
|
if (!write_all (inpipe, input, strlen (input)))
|
|
|
|
{
|
|
|
|
g_warning ("Could not write input to %s", command);
|
|
|
|
}
|
|
|
|
|
|
|
|
close (inpipe);
|
|
|
|
}
|
2005-10-15 21:56:43 +00:00
|
|
|
|
|
|
|
g_child_watch_add (child_pid, (GChildWatchFunc) child_watch_cb, command);
|
2003-02-06 21:47:00 +00:00
|
|
|
}
|
declare a global GConfClient. (main): unref the global GConfClient.
2005-10-16 Rodrigo Moya <rodrigo@novell.com>
* factory.c: declare a global GConfClient.
(main): unref the global GConfClient.
* gnome-settings-daemon.[ch] (gnome_settings_daemon_get_conf_client):
new function to use the same GConfClient everywhere.
(gnome_settings_daemon_new): use the global GConfClient.
* gnome-settings-accessibility-keyboard.c (set_server_from_gconf,
ax_response_callback, set_gconf_from_server):
* gnome-settings-gtk1theme.c (apply_settings):
* gnome-settings-keybindings.c (bindings_get_entry):
* gnome-settings-keyboard.c (numlock_get_gconf_state,
numlock_set_gconf_state, apply_settings):
* gnome-settings-keyboard-xkb.c (apply_xkb_settings,
gnome_settings_keyboard_xkb_sysconfig_changed_response,
gnome_settings_keyboard_xkb_analyze_sysconfig,
gnome_settings_chk_file_list):
* gnome-settings-screensaver.c (key_toggled_cb,
really_start_screensaver):
* gnome-settings-sound.c (apply_settings):
* gnome-settings-xmodmap.c (check_button_callback,
gnome_settings_load_modmap_files, remove_button_clicked_callback,
load_button_clicked_callback, gnome_settings_modmap_dialog_call):
* gnome-settings-xsettings.c (xft_callback):
use the global GConfClient.
* gnome-settings-keyboard-xkb.c (gnome_settings_keyboard_xkb_load):
don't get another GConfClient when we're getting one passed!
2005-10-17 14:53:19 +00:00
|
|
|
|
|
|
|
extern GConfClient *conf_client;
|
|
|
|
|
|
|
|
GConfClient *
|
|
|
|
gnome_settings_daemon_get_conf_client (void)
|
|
|
|
{
|
|
|
|
if (!conf_client)
|
|
|
|
conf_client = gconf_client_get_default ();
|
|
|
|
|
|
|
|
return conf_client;
|
|
|
|
}
|