converted more modules to the new arch.

2007-06-06  Rodrigo Moya <rodrigo@gnome-db.org>

	* gnome-settings-default-editor.c:
	* gnome-settings-gtk1theme.c:
	* gnome-settings-mouse.c:
	* gnome-settings-sound.c:
	* gnome-settings-xsettings.c: converted more modules to the new arch.

	* gnome-settings-daemon.c (gnome_settings_daemon_new): now this is much
	cleaner.

svn path=/trunk/; revision=7697
This commit is contained in:
Rodrigo Moya 2007-06-06 11:51:40 +00:00 committed by Rodrigo Moya
parent 6bfc75101d
commit ff9f268fff
13 changed files with 1032 additions and 865 deletions

View file

@ -1,3 +1,14 @@
2007-06-06 Rodrigo Moya <rodrigo@gnome-db.org>
* gnome-settings-default-editor.c:
* gnome-settings-gtk1theme.c:
* gnome-settings-mouse.c:
* gnome-settings-sound.c:
* gnome-settings-xsettings.c: converted more modules to the new arch.
* gnome-settings-daemon.c (gnome_settings_daemon_new): now this is much
cleaner.
2007-06-05 Rodrigo Moya <rodrigo@gnome-db.org>
* gnome-settings-font.c:

View file

@ -29,10 +29,8 @@ gnome_settings_daemon_SOURCES = \
gnome-settings-dbus.c \
gnome-settings-dbus.h \
gnome-settings-default-editor.c \
gnome-settings-default-editor.h \
gnome-settings-font.c \
gnome-settings-gtk1theme.c \
gnome-settings-gtk1theme.h \
gnome-settings-keybindings.c \
gnome-settings-keybindings.h \
gnome-settings-keyboard-xkb.h \
@ -43,14 +41,12 @@ gnome_settings_daemon_SOURCES = \
gnome-settings-locate-pointer.h \
gnome-settings-module.c \
gnome-settings-module.h \
gnome-settings-mouse.h \
gnome-settings-mouse.c \
gnome-settings-multimedia-keys.h \
gnome-settings-multimedia-keys.c \
gnome-settings-screensaver.c \
gnome-settings-server.h \
gnome-settings-sound.c \
gnome-settings-sound.h \
gnome-settings-typing-break.c \
gnome-settings-typing-break.h \
gnome-settings-xmodmap.c \

View file

@ -36,16 +36,11 @@
#include "gnome-settings-xmodmap.h"
/*#include "gnome-settings-disk.h"*/
#include "gnome-settings-xsettings.h"
#include "gnome-settings-mouse.h"
#include "gnome-settings-keyboard-xkb.h"
#include "gnome-settings-keyboard.h"
#include "gnome-settings-sound.h"
#include "gnome-settings-accessibility-keyboard.h"
#include "gnome-settings-default-editor.h"
#include "gnome-settings-keybindings.h"
#include "gnome-settings-multimedia-keys.h"
#include "gnome-settings-gtk1theme.h"
#include "gnome-settings-xrdb.h"
#include "gnome-settings-typing-break.h"
@ -55,8 +50,13 @@ struct _GnomeSettingsDaemonPrivate {
GType gnome_settings_module_background_get_type (void);
GType gnome_settings_module_clipboard_get_type (void);
GType gnome_settings_module_default_editor_get_type (void);
GType gnome_settings_module_font_get_type (void);
GType gnome_settings_module_gtk1_get_type (void);
GType gnome_settings_module_mouse_get_type (void);
GType gnome_settings_module_screensaver_get_type (void);
GType gnome_settings_module_sound_get_type (void);
GType gnome_settings_module_xsettings_get_type (void);
static GObjectClass *parent_class = NULL;
XSettingsManager **managers = NULL;
@ -186,8 +186,13 @@ gnome_settings_daemon_init (GnomeSettingsDaemon *settings)
/* register all internal modules types */
if (!gnome_settings_module_background_get_type ()
|| !gnome_settings_module_clipboard_get_type ()
|| !gnome_settings_module_default_editor_get_type ()
|| !gnome_settings_module_font_get_type ()
|| !gnome_settings_module_screensaver_get_type ())
|| !gnome_settings_module_gtk1_get_type ()
|| !gnome_settings_module_mouse_get_type ()
|| !gnome_settings_module_screensaver_get_type ()
|| !gnome_settings_module_sound_get_type ()
|| !gnome_settings_module_xsettings_get_type ())
return;
/* create hash table for loaded modules */
@ -271,19 +276,14 @@ gnome_settings_daemon_new (void)
client = gnome_settings_get_config_client ();
/* gnome_settings_disk_init (client);*/
gnome_settings_xsettings_init (client);
gnome_settings_mouse_init (client);
/* Essential - xkb initialization should happen before */
gnome_settings_keyboard_xkb_set_post_activation_callback ((PostActivationCallback) gnome_settings_load_modmap_files, NULL);
gnome_settings_keyboard_xkb_init (client);
gnome_settings_keyboard_init (client);
gnome_settings_multimedia_keys_init (client);
/* */
gnome_settings_sound_init (client);
gnome_settings_accessibility_keyboard_init (client);
gnome_settings_default_editor_init (client);
gnome_settings_keybindings_init (client);
gnome_settings_gtk1_theme_init (client);
gnome_settings_xrdb_init (client);
gnome_settings_typing_break_init (client);
@ -303,18 +303,13 @@ gnome_settings_daemon_new (void)
}
/* gnome_settings_disk_load (client);*/
gnome_settings_xsettings_load (client);
gnome_settings_mouse_load (client);
/* Essential - xkb initialization should happen before */
gnome_settings_keyboard_xkb_load (client);
gnome_settings_keyboard_load (client);
gnome_settings_multimedia_keys_load (client);
/* */
gnome_settings_sound_load (client);
gnome_settings_accessibility_keyboard_load (client);
gnome_settings_default_editor_load (client);
gnome_settings_keybindings_load (client);
gnome_settings_gtk1_theme_load (client);
gnome_settings_xrdb_load (client);
gnome_settings_typing_break_load (client);

View file

@ -18,20 +18,83 @@
#include <config.h>
#include "gnome-settings-daemon.h"
#include "gnome-settings-default-editor.h"
#include "gnome-settings-module.h"
#include "utils.h"
#include <libgnomevfs/gnome-vfs-mime-handlers.h>
#include <libgnomevfs/gnome-vfs-mime-monitor.h>
#include <string.h>
typedef struct {
GnomeSettingsModule parent;
} GnomeSettingsModuleDefaultEditor;
typedef struct {
GnomeSettingsModuleClass parent_class;
} GnomeSettingsModuleDefaultEditorClass;
static GnomeSettingsModuleRunlevel gnome_settings_module_default_editor_get_runlevel (GnomeSettingsModule *module);
static gboolean gnome_settings_module_default_editor_initialize (GnomeSettingsModule *module,
GConfClient *config_client);
static gboolean gnome_settings_module_default_editor_start (GnomeSettingsModule *module);
static gboolean gnome_settings_module_default_editor_stop (GnomeSettingsModule *module);
/* #define DE_DEBUG */
#define SYNC_CHANGES_KEY "/apps/gnome_settings_daemon/default_editor/sync_text_types"
static gboolean sync_changes;
static void
gnome_settings_module_default_editor_class_init (GnomeSettingsModuleDefaultEditorClass *klass)
{
GnomeSettingsModuleClass *module_class;
module_class = (GnomeSettingsModuleClass *) klass;
module_class->get_runlevel = gnome_settings_module_default_editor_get_runlevel;
module_class->initialize = gnome_settings_module_default_editor_initialize;
module_class->start = gnome_settings_module_default_editor_start;
module_class->stop = gnome_settings_module_default_editor_stop;
}
static void
gnome_settings_module_default_editor_init (GnomeSettingsModuleDefaultEditor *module)
{
}
GType
gnome_settings_module_default_editor_get_type (void)
{
static GType module_type = 0;
if (!module_type) {
static const GTypeInfo module_info = {
sizeof (GnomeSettingsModuleDefaultEditorClass),
NULL, /* base_init */
NULL, /* base_finalize */
(GClassInitFunc) gnome_settings_module_default_editor_class_init,
NULL, /* class_finalize */
NULL, /* class_data */
sizeof (GnomeSettingsModuleDefaultEditor),
0, /* n_preallocs */
(GInstanceInitFunc) gnome_settings_module_default_editor_init,
};
module_type = g_type_register_static (GNOME_SETTINGS_TYPE_MODULE,
"GnomeSettingsModuleDefaultEditor",
&module_info, 0);
}
return module_type;
}
static GnomeSettingsModuleRunlevel
gnome_settings_module_default_editor_get_runlevel (GnomeSettingsModule *module)
{
return GNOME_SETTINGS_MODULE_RUNLEVEL_GNOME_SETTINGS;
}
#ifdef DE_DEBUG
static void
print_mime_app (const char *mime_type)
@ -120,19 +183,29 @@ vfs_change_cb (GnomeVFSMIMEMonitor *monitor, GConfClient *client)
PRINT_STATE;
}
void
gnome_settings_default_editor_init (GConfClient *client)
static gboolean
gnome_settings_module_default_editor_initialize (GnomeSettingsModule *module, GConfClient *config_client)
{
sync_changes = gconf_client_get_bool (client, SYNC_CHANGES_KEY, NULL);
sync_changes = gconf_client_get_bool (config_client, SYNC_CHANGES_KEY, NULL);
gnome_settings_register_config_callback (SYNC_CHANGES_KEY, sync_changes_cb);
g_signal_connect (gnome_vfs_mime_monitor_get (), "data_changed",
G_CALLBACK (vfs_change_cb), client);
G_CALLBACK (vfs_change_cb), config_client);
return TRUE;
}
void
gnome_settings_default_editor_load (GConfClient *client)
static gboolean
gnome_settings_module_default_editor_start (GnomeSettingsModule *module)
{
vfs_change_cb (NULL, client);
vfs_change_cb (NULL, gnome_settings_module_get_config_client (module));
return TRUE;
}
static gboolean
gnome_settings_module_default_editor_stop (GnomeSettingsModule *module)
{
return TRUE;
}

View file

@ -1,18 +0,0 @@
/*
* gnome-settings-default-editor.h: sync default editor changes to mime database
*
* Copyright 2002 Sun Microsystems, Inc.
*
* Author: jacob berkman <jacob@ximian.com>
*
*/
#ifndef GNOME_SETTINGS_DEFAULT_EDITOR_H
#define GNOME_SETTINGS_DEFAULT_EDITOR_H
#include <gconf/gconf-client.h>
void gnome_settings_default_editor_init (GConfClient *client);
void gnome_settings_default_editor_load (GConfClient *client);
#endif /* GNOME_SETTINGS_DEFAULT_EDITOR_H */

View file

@ -27,11 +27,74 @@
#include <string.h>
#include <unistd.h>
#include "gnome-settings-daemon.h"
#include "gnome-settings-gtk1theme.h"
#include <gdk/gdkx.h>
#include "gnome-settings-module.h"
#include "utils.h"
#define GTK_THEME_KEY "/desktop/gnome/interface/gtk_theme"
typedef struct {
GnomeSettingsModule parent;
} GnomeSettingsModuleGtk1;
typedef struct {
GnomeSettingsModuleClass parent_class;
} GnomeSettingsModuleGtk1Class;
static GnomeSettingsModuleRunlevel gnome_settings_module_gtk1_get_runlevel (GnomeSettingsModule *module);
static gboolean gnome_settings_module_gtk1_initialize (GnomeSettingsModule *module, GConfClient *config_client);
static gboolean gnome_settings_module_gtk1_start (GnomeSettingsModule *module);
static gboolean gnome_settings_module_gtk1_stop (GnomeSettingsModule *module);
static void
gnome_settings_module_gtk1_class_init (GnomeSettingsModuleGtk1Class *klass)
{
GnomeSettingsModuleClass *module_class;
module_class = (GnomeSettingsModuleClass *) klass;
module_class->get_runlevel = gnome_settings_module_gtk1_get_runlevel;
module_class->initialize = gnome_settings_module_gtk1_initialize;
module_class->start = gnome_settings_module_gtk1_start;
module_class->stop = gnome_settings_module_gtk1_stop;
}
static void
gnome_settings_module_gtk1_init (GnomeSettingsModuleGtk1 *module)
{
}
GType
gnome_settings_module_gtk1_get_type (void)
{
static GType module_type = 0;
if (!module_type) {
static const GTypeInfo module_info = {
sizeof (GnomeSettingsModuleGtk1Class),
NULL, /* base_init */
NULL, /* base_finalize */
(GClassInitFunc) gnome_settings_module_gtk1_class_init,
NULL, /* class_finalize */
NULL, /* class_data */
sizeof (GnomeSettingsModuleGtk1),
0, /* n_preallocs */
(GInstanceInitFunc) gnome_settings_module_gtk1_init,
};
module_type = g_type_register_static (GNOME_SETTINGS_TYPE_MODULE,
"GnomeSettingsModuleGtk1",
&module_info, 0);
}
return module_type;
}
static GnomeSettingsModuleRunlevel
gnome_settings_module_gtk1_get_runlevel (GnomeSettingsModule *module)
{
return GNOME_SETTINGS_MODULE_RUNLEVEL_GNOME_SETTINGS;
}
/* Given the theme filename, return the needed contents for the RC file
* in the user's home directory
*/
@ -208,15 +271,25 @@ apply_settings (void)
g_free (rc_filename);
}
void
gnome_settings_gtk1_theme_init (GConfClient *client)
static gboolean
gnome_settings_module_gtk1_initialize (GnomeSettingsModule *module, GConfClient *config_client)
{
gnome_settings_register_config_callback (GTK_THEME_KEY,
(GnomeSettingsConfigCallback) apply_settings);
return TRUE;
}
void
gnome_settings_gtk1_theme_load (GConfClient *client)
static gboolean
gnome_settings_module_gtk1_start (GnomeSettingsModule *module)
{
apply_settings ();
return TRUE;
}
static gboolean
gnome_settings_module_gtk1_stop (GnomeSettingsModule *module)
{
return TRUE;
}

View file

@ -1,34 +0,0 @@
/* -*- mode: c; style: linux -*- */
/* gnome-settings-keyboard.h
*
* Copyright © 2002 Red Hat, Inc.
*
* Written by Owen Taylor <otaylor@redhat.com>
*
* 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 __GNOME_SETTINGS_GTK1THEME_H
#define __GNOME_SETTINGS_GTK1THEME_H
#include <gconf/gconf.h>
#include <gconf/gconf-client.h>
void gnome_settings_gtk1_theme_init (GConfClient *client);
void gnome_settings_gtk1_theme_load (GConfClient *client);
#endif

View file

@ -14,18 +14,79 @@
#include <gconf/gconf.h>
#include "gnome-settings-mouse.h"
#include "gnome-settings-locate-pointer.h"
#include "gnome-settings-daemon.h"
#include "gnome-settings-module.h"
typedef struct {
GnomeSettingsModule parent;
} GnomeSettingsModuleMouse;
typedef struct {
GnomeSettingsModuleClass parent_class;
} GnomeSettingsModuleMouseClass;
static GnomeSettingsModuleRunlevel gnome_settings_module_mouse_get_runlevel (GnomeSettingsModule *module);
static gboolean gnome_settings_module_mouse_initialize (GnomeSettingsModule *module, GConfClient *config_client);
static gboolean gnome_settings_module_mouse_start (GnomeSettingsModule *module);
static gboolean gnome_settings_module_mouse_stop (GnomeSettingsModule *module);
static void
gnome_settings_module_mouse_class_init (GnomeSettingsModuleMouseClass *klass)
{
GnomeSettingsModuleClass *module_class;
module_class = (GnomeSettingsModuleClass *) klass;
module_class->get_runlevel = gnome_settings_module_mouse_get_runlevel;
module_class->initialize = gnome_settings_module_mouse_initialize;
module_class->start = gnome_settings_module_mouse_start;
module_class->stop = gnome_settings_module_mouse_stop;
}
static void
gnome_settings_module_mouse_init (GnomeSettingsModuleMouse *module)
{
}
GType
gnome_settings_module_mouse_get_type (void)
{
static GType module_type = 0;
if (!module_type) {
static const GTypeInfo module_info = {
sizeof (GnomeSettingsModuleMouseClass),
NULL, /* base_init */
NULL, /* base_finalize */
(GClassInitFunc) gnome_settings_module_mouse_class_init,
NULL, /* class_finalize */
NULL, /* class_data */
sizeof (GnomeSettingsModuleMouse),
0, /* n_preallocs */
(GInstanceInitFunc) gnome_settings_module_mouse_init,
};
module_type = g_type_register_static (GNOME_SETTINGS_TYPE_MODULE,
"GnomeSettingsModuleMouse",
&module_info, 0);
}
return module_type;
}
static GnomeSettingsModuleRunlevel
gnome_settings_module_mouse_get_runlevel (GnomeSettingsModule *module)
{
return GNOME_SETTINGS_MODULE_RUNLEVEL_XSETTINGS;
}
#ifdef HAVE_XINPUT
static gboolean
supports_xinput_devices (void)
{
gint op_code, event, error;
gint op_code, event, error;
return XQueryExtension (GDK_DISPLAY (), "XInputExtension",
&op_code, &event, &error);
return XQueryExtension (GDK_DISPLAY (), "XInputExtension",
&op_code, &event, &error);
}
#endif
@ -34,241 +95,217 @@ configure_button_layout (guchar *buttons,
gint n_buttons,
gboolean left_handed)
{
const gint left_button = 1;
gint right_button;
gint i;
const gint left_button = 1;
gint right_button;
gint i;
/* if the button is higher than 2 (3rd button) then it's
* probably one direction of a scroll wheel or something else
* uninteresting
*/
right_button = MIN (n_buttons, 3);
/* if the button is higher than 2 (3rd button) then it's
* probably one direction of a scroll wheel or something else
* uninteresting
*/
right_button = MIN (n_buttons, 3);
/* If we change things we need to make sure we only swap buttons.
* If we end up with multiple physical buttons assigned to the same
* logical button the server will complain. This code assumes physical
* button 0 is the physical left mouse button, and that the physical
* button other than 0 currently assigned left_button or right_button
* is the physical right mouse button.
*/
/* If we change things we need to make sure we only swap buttons.
* If we end up with multiple physical buttons assigned to the same
* logical button the server will complain. This code assumes physical
* button 0 is the physical left mouse button, and that the physical
* button other than 0 currently assigned left_button or right_button
* is the physical right mouse button.
*/
/* check if the current mapping satisfies the above assumptions */
if (buttons[left_button - 1] != left_button &&
buttons[left_button - 1] != right_button)
/* The current mapping is weird. Swapping buttons is probably not a
* good idea.
*/
return;
/* check if the current mapping satisfies the above assumptions */
if (buttons[left_button - 1] != left_button &&
buttons[left_button - 1] != right_button)
/* The current mapping is weird. Swapping buttons is probably not a
* good idea.
*/
return;
/* check if we are left_handed and currently not swapped */
if (left_handed && buttons[left_button - 1] == left_button)
{
/* find the right button */
for (i = 0; i < n_buttons; i++)
{
if (buttons[i] == right_button)
{
buttons[i] = left_button;
break;
}
}
/* swap the buttons */
buttons[left_button - 1] = right_button;
}
/* check if we are not left_handed but are swapped */
else if (!left_handed && buttons[left_button - 1] == right_button)
{
/* find the right button */
for (i = 0; i < n_buttons; i++)
{
if (buttons[i] == left_button)
{
buttons[i] = right_button;
break;
}
}
/* swap the buttons */
buttons[left_button - 1] = left_button;
}
/* check if we are left_handed and currently not swapped */
if (left_handed && buttons[left_button - 1] == left_button) {
/* find the right button */
for (i = 0; i < n_buttons; i++) {
if (buttons[i] == right_button) {
buttons[i] = left_button;
break;
}
}
/* swap the buttons */
buttons[left_button - 1] = right_button;
}
/* check if we are not left_handed but are swapped */
else if (!left_handed && buttons[left_button - 1] == right_button) {
/* find the right button */
for (i = 0; i < n_buttons; i++) {
if (buttons[i] == left_button) {
buttons[i] = right_button;
break;
}
}
/* swap the buttons */
buttons[left_button - 1] = left_button;
}
}
#ifdef HAVE_XINPUT
static gboolean
xinput_device_has_buttons (XDeviceInfo *device_info)
{
int i;
XAnyClassInfo *class_info;
int i;
XAnyClassInfo *class_info;
class_info = device_info->inputclassinfo;
for (i = 0; i < device_info->num_classes; i++)
{
if (class_info->class == ButtonClass)
{
XButtonInfo *button_info;
class_info = device_info->inputclassinfo;
for (i = 0; i < device_info->num_classes; i++) {
if (class_info->class == ButtonClass) {
XButtonInfo *button_info;
button_info = (XButtonInfo *) class_info;
if (button_info->num_buttons > 0)
return TRUE;
}
button_info = (XButtonInfo *) class_info;
if (button_info->num_buttons > 0)
return TRUE;
}
class_info = (XAnyClassInfo *) (((guchar *) class_info) +
class_info->length);
}
return FALSE;
class_info = (XAnyClassInfo *) (((guchar *) class_info) +
class_info->length);
}
return FALSE;
}
static void
set_xinput_devices_left_handed (gboolean left_handed)
{
XDeviceInfo *device_info;
gint n_devices;
guchar *buttons;
gsize buttons_capacity = 16;
gint n_buttons;
gint i;
XDeviceInfo *device_info;
gint n_devices;
guchar *buttons;
gsize buttons_capacity = 16;
gint n_buttons;
gint i;
device_info = XListInputDevices (GDK_DISPLAY (), &n_devices);
device_info = XListInputDevices (GDK_DISPLAY (), &n_devices);
if (n_devices > 0)
buttons = g_new (guchar, buttons_capacity);
else
buttons = NULL;
if (n_devices > 0)
buttons = g_new (guchar, buttons_capacity);
else
buttons = NULL;
for (i = 0; i < n_devices; i++)
{
XDevice *device = NULL;
for (i = 0; i < n_devices; i++) {
XDevice *device = NULL;
if ((device_info[i].use != IsXExtensionDevice) ||
(!xinput_device_has_buttons (&device_info[i])))
continue;
if ((device_info[i].use != IsXExtensionDevice) ||
(!xinput_device_has_buttons (&device_info[i])))
continue;
gdk_error_trap_push ();
gdk_error_trap_push ();
device = XOpenDevice (GDK_DISPLAY (), device_info[i].id);
device = XOpenDevice (GDK_DISPLAY (), device_info[i].id);
if ((gdk_error_trap_pop () != 0) ||
(device == NULL))
continue;
if ((gdk_error_trap_pop () != 0) ||
(device == NULL))
continue;
n_buttons = XGetDeviceButtonMapping (GDK_DISPLAY (), device,
buttons,
buttons_capacity);
n_buttons = XGetDeviceButtonMapping (GDK_DISPLAY (), device,
buttons,
buttons_capacity);
while (n_buttons > buttons_capacity)
{
buttons_capacity = n_buttons;
buttons = (guchar *) g_realloc (buttons,
buttons_capacity * sizeof (guchar));
while (n_buttons > buttons_capacity) {
buttons_capacity = n_buttons;
buttons = (guchar *) g_realloc (buttons,
buttons_capacity * sizeof (guchar));
n_buttons = XGetDeviceButtonMapping (GDK_DISPLAY (), device,
buttons,
buttons_capacity);
}
n_buttons = XGetDeviceButtonMapping (GDK_DISPLAY (), device,
buttons,
buttons_capacity);
}
configure_button_layout (buttons, n_buttons, left_handed);
configure_button_layout (buttons, n_buttons, left_handed);
XSetDeviceButtonMapping (GDK_DISPLAY (), device, buttons, n_buttons);
XCloseDevice (GDK_DISPLAY (), device);
}
g_free (buttons);
XSetDeviceButtonMapping (GDK_DISPLAY (), device, buttons, n_buttons);
XCloseDevice (GDK_DISPLAY (), device);
}
g_free (buttons);
if (device_info != NULL)
XFreeDeviceList (device_info);
if (device_info != NULL)
XFreeDeviceList (device_info);
}
#endif
static void
set_left_handed (gboolean left_handed)
{
guchar *buttons ;
gsize buttons_capacity = 16;
gint n_buttons, i;
guchar *buttons ;
gsize buttons_capacity = 16;
gint n_buttons, i;
#ifdef HAVE_XINPUT
if (supports_xinput_devices ())
set_xinput_devices_left_handed (left_handed);
if (supports_xinput_devices ())
set_xinput_devices_left_handed (left_handed);
#endif
buttons = g_new (guchar, buttons_capacity);
n_buttons = XGetPointerMapping (GDK_DISPLAY (), buttons,
(gint) buttons_capacity);
while (n_buttons > buttons_capacity)
{
buttons_capacity = n_buttons;
buttons = (guchar *) g_realloc (buttons,
buttons_capacity * sizeof (guchar));
buttons = g_new (guchar, buttons_capacity);
n_buttons = XGetPointerMapping (GDK_DISPLAY (), buttons,
(gint) buttons_capacity);
while (n_buttons > buttons_capacity) {
buttons_capacity = n_buttons;
buttons = (guchar *) g_realloc (buttons,
buttons_capacity * sizeof (guchar));
n_buttons = XGetPointerMapping (GDK_DISPLAY (), buttons,
(gint) buttons_capacity);
}
n_buttons = XGetPointerMapping (GDK_DISPLAY (), buttons,
(gint) buttons_capacity);
}
configure_button_layout (buttons, n_buttons, left_handed);
configure_button_layout (buttons, n_buttons, left_handed);
/* X refuses to change the mapping while buttons are engaged,
* so if this is the case we'll retry a few times
*/
for (i = 0; i < 20 &&
XSetPointerMapping (GDK_DISPLAY (), buttons, n_buttons) == MappingBusy;
++i)
{
g_usleep (300);
}
/* X refuses to change the mapping while buttons are engaged,
* so if this is the case we'll retry a few times
*/
for (i = 0;
i < 20 && XSetPointerMapping (GDK_DISPLAY (), buttons, n_buttons) == MappingBusy;
++i) {
g_usleep (300);
}
g_free (buttons);
g_free (buttons);
}
static void
set_motion_acceleration (gfloat motion_acceleration)
{
gint numerator, denominator;
gint numerator, denominator;
if (motion_acceleration >= 1.0)
{
/* we want to get the acceleration, with a resolution of 0.5
*/
if ((motion_acceleration - floor (motion_acceleration)) < 0.25)
{
numerator = floor (motion_acceleration);
denominator = 1;
if (motion_acceleration >= 1.0) {
/* we want to get the acceleration, with a resolution of 0.5
*/
if ((motion_acceleration - floor (motion_acceleration)) < 0.25) {
numerator = floor (motion_acceleration);
denominator = 1;
} else if ((motion_acceleration - floor (motion_acceleration)) < 0.5) {
numerator = ceil (2.0 * motion_acceleration);
denominator = 2;
} else if ((motion_acceleration - floor (motion_acceleration)) < 0.75) {
numerator = floor (2.0 *motion_acceleration);
denominator = 2;
} else {
numerator = ceil (motion_acceleration);
denominator = 1;
}
} else if (motion_acceleration < 1.0 && motion_acceleration > 0) {
/* This we do to 1/10ths */
numerator = floor (motion_acceleration * 10) + 1;
denominator= 10;
} else {
numerator = -1;
denominator = -1;
}
else if ((motion_acceleration - floor (motion_acceleration)) < 0.5)
{
numerator = ceil (2.0 * motion_acceleration);
denominator = 2;
}
else if ((motion_acceleration - floor (motion_acceleration)) < 0.75)
{
numerator = floor (2.0 *motion_acceleration);
denominator = 2;
}
else
{
numerator = ceil (motion_acceleration);
denominator = 1;
}
}
else if (motion_acceleration < 1.0 && motion_acceleration > 0)
{
/* This we do to 1/10ths */
numerator = floor (motion_acceleration * 10) + 1;
denominator= 10;
}
else
{
numerator = -1;
denominator = -1;
}
XChangePointerControl (GDK_DISPLAY (), True, False,
numerator, denominator,
0);
XChangePointerControl (GDK_DISPLAY (), True, False,
numerator, denominator,
0);
}
static void
set_motion_threshold (gint motion_threshold)
{
XChangePointerControl (GDK_DISPLAY (), False, True,
0, 0, motion_threshold);
XChangePointerControl (GDK_DISPLAY (), False, True,
0, 0, motion_threshold);
}
@ -281,199 +318,189 @@ filter (GdkXEvent *xevent,
GdkEvent *event,
gpointer data)
{
XEvent *xev = (XEvent *) xevent;
guint keyval;
gint group;
XEvent *xev = (XEvent *) xevent;
guint keyval;
gint group;
GdkScreen *screen = (GdkScreen *)data;
GdkScreen *screen = (GdkScreen *)data;
if (xev->type == KeyPress ||
xev->type == KeyRelease)
{
/* get the keysym */
group = (xev->xkey.state & KEYBOARD_GROUP_MASK) >> KEYBOARD_GROUP_SHIFT;
gdk_keymap_translate_keyboard_state (gdk_keymap_get_default (),
xev->xkey.keycode,
xev->xkey.state,
group,
&keyval,
NULL, NULL, NULL);
if (keyval == GDK_Control_L || keyval == GDK_Control_R)
{
if (xev->type == KeyPress)
{
XAllowEvents (gdk_x11_get_default_xdisplay (),
SyncKeyboard,
xev->xkey.time);
}
else
{
XAllowEvents (gdk_x11_get_default_xdisplay (),
AsyncKeyboard,
xev->xkey.time);
gnome_settings_locate_pointer (screen);
}
}
else
{
XAllowEvents (gdk_x11_get_default_xdisplay (),
ReplayKeyboard,
xev->xkey.time);
XUngrabKeyboard (gdk_x11_get_default_xdisplay (),
xev->xkey.time);
}
if (xev->type == KeyPress ||
xev->type == KeyRelease) {
/* get the keysym */
group = (xev->xkey.state & KEYBOARD_GROUP_MASK) >> KEYBOARD_GROUP_SHIFT;
gdk_keymap_translate_keyboard_state (gdk_keymap_get_default (),
xev->xkey.keycode,
xev->xkey.state,
group,
&keyval,
NULL, NULL, NULL);
if (keyval == GDK_Control_L || keyval == GDK_Control_R) {
if (xev->type == KeyPress) {
XAllowEvents (gdk_x11_get_default_xdisplay (),
SyncKeyboard,
xev->xkey.time);
} else {
XAllowEvents (gdk_x11_get_default_xdisplay (),
AsyncKeyboard,
xev->xkey.time);
gnome_settings_locate_pointer (screen);
}
} else {
XAllowEvents (gdk_x11_get_default_xdisplay (),
ReplayKeyboard,
xev->xkey.time);
XUngrabKeyboard (gdk_x11_get_default_xdisplay (),
xev->xkey.time);
}
return GDK_FILTER_REMOVE;
}
return GDK_FILTER_CONTINUE;
return GDK_FILTER_REMOVE;
}
return GDK_FILTER_CONTINUE;
}
static void
set_locate_pointer (gboolean locate_pointer)
{
GdkKeymapKey *keys;
GdkDisplay *display;
int n_screens;
int n_keys;
gboolean has_entries;
static const guint keyvals[] = { GDK_Control_L, GDK_Control_R };
unsigned j;
GdkKeymapKey *keys;
GdkDisplay *display;
int n_screens;
int n_keys;
gboolean has_entries;
static const guint keyvals[] = { GDK_Control_L, GDK_Control_R };
unsigned j;
display = gdk_display_get_default ();
n_screens = gdk_display_get_n_screens (display);
display = gdk_display_get_default ();
n_screens = gdk_display_get_n_screens (display);
for (j = 0 ; j < G_N_ELEMENTS (keyvals) ; j++) {
has_entries = gdk_keymap_get_entries_for_keyval (gdk_keymap_get_default (),
keyvals[j],
&keys,
&n_keys);
if (has_entries)
{
gint i, j;
for (j = 0 ; j < G_N_ELEMENTS (keyvals) ; j++) {
has_entries = gdk_keymap_get_entries_for_keyval (gdk_keymap_get_default (),
keyvals[j],
&keys,
&n_keys);
if (has_entries) {
gint i, j;
for (i = 0; i < n_keys; i++)
{
for(j=0; j< n_screens; j++)
{
GdkScreen *screen = gdk_display_get_screen (display, j);
Window xroot = gdk_x11_drawable_get_xid (gdk_screen_get_root_window (screen));
for (i = 0; i < n_keys; i++) {
for(j=0; j< n_screens; j++) {
GdkScreen *screen = gdk_display_get_screen (display, j);
Window xroot = gdk_x11_drawable_get_xid (gdk_screen_get_root_window (screen));
if (locate_pointer)
{
XGrabKey (GDK_DISPLAY_XDISPLAY (display),
keys[i].keycode,
0,
xroot,
False,
GrabModeAsync,
GrabModeSync);
XGrabKey (GDK_DISPLAY_XDISPLAY (display),
keys[i].keycode,
LockMask,
xroot,
False,
GrabModeAsync,
GrabModeSync);
XGrabKey (GDK_DISPLAY_XDISPLAY (display),
keys[i].keycode,
Mod2Mask,
xroot,
False,
GrabModeAsync,
GrabModeSync);
XGrabKey (GDK_DISPLAY_XDISPLAY (display),
keys[i].keycode,
Mod4Mask,
xroot,
False,
GrabModeAsync,
GrabModeSync);
}
else
{
XUngrabKey (GDK_DISPLAY_XDISPLAY (display),
keys[i].keycode,
Mod4Mask,
xroot);
XUngrabKey (GDK_DISPLAY_XDISPLAY (display),
keys[i].keycode,
Mod2Mask,
xroot);
XUngrabKey (GDK_DISPLAY_XDISPLAY (display),
keys[i].keycode,
LockMask,
xroot);
XUngrabKey (GDK_DISPLAY_XDISPLAY (display),
keys[i].keycode,
0,
xroot);
}
}
if (locate_pointer) {
XGrabKey (GDK_DISPLAY_XDISPLAY (display),
keys[i].keycode,
0,
xroot,
False,
GrabModeAsync,
GrabModeSync);
XGrabKey (GDK_DISPLAY_XDISPLAY (display),
keys[i].keycode,
LockMask,
xroot,
False,
GrabModeAsync,
GrabModeSync);
XGrabKey (GDK_DISPLAY_XDISPLAY (display),
keys[i].keycode,
Mod2Mask,
xroot,
False,
GrabModeAsync,
GrabModeSync);
XGrabKey (GDK_DISPLAY_XDISPLAY (display),
keys[i].keycode,
Mod4Mask,
xroot,
False,
GrabModeAsync,
GrabModeSync);
} else {
XUngrabKey (GDK_DISPLAY_XDISPLAY (display),
keys[i].keycode,
Mod4Mask,
xroot);
XUngrabKey (GDK_DISPLAY_XDISPLAY (display),
keys[i].keycode,
Mod2Mask,
xroot);
XUngrabKey (GDK_DISPLAY_XDISPLAY (display),
keys[i].keycode,
LockMask,
xroot);
XUngrabKey (GDK_DISPLAY_XDISPLAY (display),
keys[i].keycode,
0,
xroot);
}
}
}
g_free (keys);
if (locate_pointer) {
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),
filter,
screen);
}
} else {
for (i = 0; i < n_screens; i++) {
GdkScreen *screen;
screen = gdk_display_get_screen (display, i);
gdk_window_remove_filter (gdk_screen_get_root_window (screen),
filter,
screen);
}
}
}
}
g_free (keys);
if (locate_pointer)
{
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),
filter,
screen);
}
}
else
{
for (i = 0; i < n_screens; i++)
{
GdkScreen *screen;
screen = gdk_display_get_screen (display, i);
gdk_window_remove_filter (gdk_screen_get_root_window (screen),
filter,
screen);
}
}
}
}
}
static void
mouse_callback (GConfEntry *entry)
{
if (! strcmp (entry->key, "/desktop/gnome/peripherals/mouse/left_handed"))
{
if (entry->value->type == GCONF_VALUE_BOOL)
set_left_handed (gconf_value_get_bool (entry->value));
}
else if (! strcmp (entry->key, "/desktop/gnome/peripherals/mouse/motion_acceleration"))
{
if (entry->value->type == GCONF_VALUE_FLOAT)
set_motion_acceleration (gconf_value_get_float (entry->value));
}
else if (! strcmp (entry->key, "/desktop/gnome/peripherals/mouse/motion_threshold"))
{
if (entry->value->type == GCONF_VALUE_INT)
set_motion_threshold (gconf_value_get_int (entry->value));
}
else if (! strcmp (entry->key, "/desktop/gnome/peripherals/mouse/locate_pointer"))
{
if (entry->value->type == GCONF_VALUE_BOOL)
set_locate_pointer (gconf_value_get_bool (entry->value));
}
if (! strcmp (entry->key, "/desktop/gnome/peripherals/mouse/left_handed")) {
if (entry->value->type == GCONF_VALUE_BOOL)
set_left_handed (gconf_value_get_bool (entry->value));
} else if (! strcmp (entry->key, "/desktop/gnome/peripherals/mouse/motion_acceleration")) {
if (entry->value->type == GCONF_VALUE_FLOAT)
set_motion_acceleration (gconf_value_get_float (entry->value));
} else if (! strcmp (entry->key, "/desktop/gnome/peripherals/mouse/motion_threshold")) {
if (entry->value->type == GCONF_VALUE_INT)
set_motion_threshold (gconf_value_get_int (entry->value));
} else if (! strcmp (entry->key, "/desktop/gnome/peripherals/mouse/locate_pointer")) {
if (entry->value->type == GCONF_VALUE_BOOL)
set_locate_pointer (gconf_value_get_bool (entry->value));
}
}
void
gnome_settings_mouse_init (GConfClient *client)
static gboolean
gnome_settings_module_mouse_initialize (GnomeSettingsModule *module, GConfClient *config_client)
{
gnome_settings_register_config_callback ("/desktop/gnome/peripherals/mouse", mouse_callback);
gnome_settings_register_config_callback ("/desktop/gnome/peripherals/mouse", mouse_callback);
return TRUE;
}
void
gnome_settings_mouse_load (GConfClient *client)
static gboolean
gnome_settings_module_mouse_start (GnomeSettingsModule *module)
{
set_left_handed (gconf_client_get_bool (client, "/desktop/gnome/peripherals/mouse/left_handed", NULL));
set_motion_acceleration (gconf_client_get_float (client, "/desktop/gnome/peripherals/mouse/motion_acceleration", NULL));
set_motion_threshold (gconf_client_get_int (client, "/desktop/gnome/peripherals/mouse/motion_threshold", NULL));
set_locate_pointer (gconf_client_get_bool (client, "/desktop/gnome/peripherals/mouse/locate_pointer", NULL));
GConfClient *client = gnome_settings_module_get_config_client (module);
set_left_handed (gconf_client_get_bool (client, "/desktop/gnome/peripherals/mouse/left_handed", NULL));
set_motion_acceleration (gconf_client_get_float (client,
"/desktop/gnome/peripherals/mouse/motion_acceleration", NULL));
set_motion_threshold (gconf_client_get_int (client,
"/desktop/gnome/peripherals/mouse/motion_threshold", NULL));
set_locate_pointer (gconf_client_get_bool (client,
"/desktop/gnome/peripherals/mouse/locate_pointer", NULL));
return TRUE;
}
static gboolean
gnome_settings_module_mouse_stop (GnomeSettingsModule *module)
{
return TRUE;
}

View file

@ -1,25 +0,0 @@
/*
* Copyright © 2001 Jonathan Blandford <jrb@gnome.org>
*
* 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.
*
* Authors: Jonathan Blandford
*/
#ifndef MOUSE_SETTINGS_H
#define MOUSE_SETTINGS_H
#include <gconf/gconf-client.h>
void gnome_settings_mouse_init (GConfClient *client);
void gnome_settings_mouse_load (GConfClient *client);
#endif

View file

@ -42,8 +42,70 @@
#include <libgnome/gnome-exec.h>
#include <libgnomeui/gnome-client.h>
#include "libsounds/sound-properties.h"
#include "gnome-settings-sound.h"
#include "gnome-settings-daemon.h"
#include "gnome-settings-module.h"
#include "utils.h"
typedef struct {
GnomeSettingsModule parent;
} GnomeSettingsModuleSound;
typedef struct {
GnomeSettingsModuleClass parent_class;
} GnomeSettingsModuleSoundClass;
static GnomeSettingsModuleRunlevel gnome_settings_module_sound_get_runlevel (GnomeSettingsModule *module);
static gboolean gnome_settings_module_sound_initialize (GnomeSettingsModule *module, GConfClient *config_client);
static gboolean gnome_settings_module_sound_start (GnomeSettingsModule *module);
static gboolean gnome_settings_module_sound_stop (GnomeSettingsModule *module);
static void
gnome_settings_module_sound_class_init (GnomeSettingsModuleSoundClass *klass)
{
GnomeSettingsModuleClass *module_class;
module_class = (GnomeSettingsModuleClass *) klass;
module_class->get_runlevel = gnome_settings_module_sound_get_runlevel;
module_class->initialize = gnome_settings_module_sound_initialize;
module_class->start = gnome_settings_module_sound_start;
module_class->stop = gnome_settings_module_sound_stop;
}
static void
gnome_settings_module_sound_init (GnomeSettingsModuleSound *module)
{
}
GType
gnome_settings_module_sound_get_type (void)
{
static GType module_type = 0;
if (!module_type) {
static const GTypeInfo module_info = {
sizeof (GnomeSettingsModuleSoundClass),
NULL, /* base_init */
NULL, /* base_finalize */
(GClassInitFunc) gnome_settings_module_sound_class_init,
NULL, /* class_finalize */
NULL, /* class_data */
sizeof (GnomeSettingsModuleSound),
0, /* n_preallocs */
(GInstanceInitFunc) gnome_settings_module_sound_init,
};
module_type = g_type_register_static (GNOME_SETTINGS_TYPE_MODULE,
"GnomeSettingsModuleSound",
&module_info, 0);
}
return module_type;
}
static GnomeSettingsModuleRunlevel
gnome_settings_module_sound_get_runlevel (GnomeSettingsModule *module)
{
return GNOME_SETTINGS_MODULE_RUNLEVEL_GNOME_SETTINGS;
}
/* start_gnome_sound
*
@ -179,14 +241,13 @@ apply_settings (void)
#endif
} else {
#ifdef HAVE_ESD
if (!set_esd_standby)
if (!set_esd_standby)
#endif
stop_gnome_sound ();
stop_gnome_sound ();
}
if (enable_sound &&
(!inited || event_changed_old != event_changed_new))
{
(!inited || event_changed_old != event_changed_new)) {
SoundProperties *props;
inited = TRUE;
@ -200,15 +261,27 @@ apply_settings (void)
}
}
void
gnome_settings_sound_init (GConfClient *client)
static gboolean
gnome_settings_module_sound_initialize (GnomeSettingsModule *module, GConfClient *config_client)
{
gnome_settings_register_config_callback ("/desktop/gnome/sound",
(GnomeSettingsConfigCallback) apply_settings);
return TRUE;
}
void
gnome_settings_sound_load (GConfClient *client)
static gboolean
gnome_settings_module_sound_start (GnomeSettingsModule *module)
{
apply_settings ();
return TRUE;
}
static gboolean
gnome_settings_module_sound_stop (GnomeSettingsModule *module)
{
stop_gnome_sound ();
return TRUE;
}

View file

@ -1,33 +0,0 @@
/* -*- mode: c; style: linux -*- */
/* gnome-settings-sound.h
*
* Copyright © 2001 Ximian, Inc.
*
* Written by Rachel Hestilow <hestilow@ximian.com>
*
* 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 __GNOME_SETTINGS_SOUND_H__
#define __GNOME_SETTINGS_SOUND_H__
#include <gconf/gconf.h>
void gnome_settings_sound_init (GConfClient *client);
void gnome_settings_sound_load (GConfClient *client);
#endif /* __GNOME_SETTINGS_SOUND_H__ */

View file

@ -1,14 +1,35 @@
/*
* Copyright (C) 2007 The GNOME Foundation
*
* Authors: Rodrigo Moya
*
* 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 <string.h>
#include <stdio.h>
#include <locale.h>
#include <glib.h>
#include <glib/gi18n.h>
#include <gdk/gdkx.h>
#include <gconf/gconf-client.h>
#include "gnome-settings-daemon.h"
#include "gnome-settings-xsettings.h"
#include "gnome-settings-module.h"
#include "xsettings-manager.h"
#include "utils.h"
extern XSettingsManager **managers;
@ -23,15 +44,28 @@ extern XSettingsManager **managers;
typedef struct _TranslationEntry TranslationEntry;
typedef void (* TranslationFunc) (TranslationEntry *trans,
GConfValue *value);
struct _TranslationEntry
{
const char *gconf_key;
const char *xsetting_name;
struct _TranslationEntry {
const char *gconf_key;
const char *xsetting_name;
GConfValueType gconf_type;
TranslationFunc translate;
GConfValueType gconf_type;
TranslationFunc translate;
};
typedef struct {
GnomeSettingsModule parent;
} GnomeSettingsModuleXSettings;
typedef struct {
GnomeSettingsModuleClass parent_class;
} GnomeSettingsModuleXSettingsClass;
static GnomeSettingsModuleRunlevel gnome_settings_module_xsettings_get_runlevel (GnomeSettingsModule *module);
static gboolean gnome_settings_module_xsettings_initialize (GnomeSettingsModule *module, GConfClient *config_client);
static gboolean gnome_settings_module_xsettings_start (GnomeSettingsModule *module);
static gboolean gnome_settings_module_xsettings_stop (GnomeSettingsModule *module);
#ifdef HAVE_XFT2
/* X servers sometimes lie about the screen's physical dimensions, so we cannot
* compute an accurate DPI value. When this happens, the user gets fonts that
@ -51,215 +85,258 @@ static void gnome_settings_update_xft (GConfClient *client);
static void xft_callback (GConfEntry *entry);
#endif /* HAVE_XFT2 */
static void
gnome_settings_module_xsettings_class_init (GnomeSettingsModuleXSettingsClass *klass)
{
GnomeSettingsModuleClass *module_class;
module_class = (GnomeSettingsModuleClass *) klass;
module_class->get_runlevel = gnome_settings_module_xsettings_get_runlevel;
module_class->initialize = gnome_settings_module_xsettings_initialize;
module_class->start = gnome_settings_module_xsettings_start;
module_class->stop = gnome_settings_module_xsettings_stop;
}
static void
gnome_settings_module_xsettings_init (GnomeSettingsModuleXSettings *module)
{
}
GType
gnome_settings_module_xsettings_get_type (void)
{
static GType module_type = 0;
if (!module_type) {
static const GTypeInfo module_info = {
sizeof (GnomeSettingsModuleXSettingsClass),
NULL, /* base_init */
NULL, /* base_finalize */
(GClassInitFunc) gnome_settings_module_xsettings_class_init,
NULL, /* class_finalize */
NULL, /* class_data */
sizeof (GnomeSettingsModuleXSettings),
0, /* n_preallocs */
(GInstanceInitFunc) gnome_settings_module_xsettings_init,
};
module_type = g_type_register_static (GNOME_SETTINGS_TYPE_MODULE,
"GnomeSettingsModuleXSettings",
&module_info, 0);
}
return module_type;
}
static GnomeSettingsModuleRunlevel
gnome_settings_module_xsettings_get_runlevel (GnomeSettingsModule *module)
{
return GNOME_SETTINGS_MODULE_RUNLEVEL_SERVICES;
}
static void
translate_bool_int (TranslationEntry *trans,
GConfValue *value)
{
int i;
int i;
g_assert (value->type == trans->gconf_type);
g_assert (value->type == trans->gconf_type);
for (i = 0; managers [i]; i++)
xsettings_manager_set_int (managers [i], trans->xsetting_name,
gconf_value_get_bool (value));
for (i = 0; managers [i]; i++)
xsettings_manager_set_int (managers [i], trans->xsetting_name,
gconf_value_get_bool (value));
}
static void
translate_int_int (TranslationEntry *trans,
GConfValue *value)
{
int i;
int i;
g_assert (value->type == trans->gconf_type);
g_assert (value->type == trans->gconf_type);
for (i = 0; managers [i]; i++)
xsettings_manager_set_int (managers [i], trans->xsetting_name,
gconf_value_get_int (value));
for (i = 0; managers [i]; i++)
xsettings_manager_set_int (managers [i], trans->xsetting_name,
gconf_value_get_int (value));
}
static void
translate_string_string (TranslationEntry *trans,
GConfValue *value)
{
int i;
int i;
g_assert (value->type == trans->gconf_type);
g_assert (value->type == trans->gconf_type);
for (i = 0; managers [i]; i++)
xsettings_manager_set_string (managers [i],
trans->xsetting_name,
gconf_value_get_string (value));
for (i = 0; managers [i]; i++)
xsettings_manager_set_string (managers [i],
trans->xsetting_name,
gconf_value_get_string (value));
}
static void
translate_string_string_toolbar (TranslationEntry *trans,
GConfValue *value)
{
int i;
const char *tmp;
int i;
const char *tmp;
g_assert (value->type == trans->gconf_type);
g_assert (value->type == trans->gconf_type);
/* This is kind of a workaround since GNOME expects the key value to be
* "both_horiz" and gtk+ wants the XSetting to be "both-horiz".
*/
tmp = gconf_value_get_string (value);
if (tmp && strcmp (tmp, "both_horiz") == 0)
tmp = "both-horiz";
/* This is kind of a workaround since GNOME expects the key value to be
* "both_horiz" and gtk+ wants the XSetting to be "both-horiz".
*/
tmp = gconf_value_get_string (value);
if (tmp && strcmp (tmp, "both_horiz") == 0)
tmp = "both-horiz";
for (i = 0; managers [i]; i++)
xsettings_manager_set_string (managers [i],
for (i = 0; managers [i]; i++)
xsettings_manager_set_string (managers [i],
trans->xsetting_name,
tmp);
}
static TranslationEntry translations [] = {
{ "/desktop/gnome/peripherals/mouse/double_click", "Net/DoubleClickTime",
GCONF_VALUE_INT, translate_int_int },
{ "/desktop/gnome/peripherals/mouse/drag_threshold", "Net/DndDragThreshold",
GCONF_VALUE_INT, translate_int_int },
{ "/desktop/gnome/gtk-color-palette", "Gtk/ColorPalette",
GCONF_VALUE_STRING, translate_string_string },
{ "/desktop/gnome/interface/font_name", "Gtk/FontName",
GCONF_VALUE_STRING, translate_string_string },
{ "/desktop/gnome/interface/gtk_key_theme", "Gtk/KeyThemeName",
GCONF_VALUE_STRING, translate_string_string },
{ "/desktop/gnome/interface/toolbar_style", "Gtk/ToolbarStyle",
GCONF_VALUE_STRING, translate_string_string_toolbar },
{ "/desktop/gnome/interface/toolbar_icon_size", "Gtk/ToolbarIconSize",
GCONF_VALUE_STRING, translate_string_string },
{ "/desktop/gnome/interface/can_change_accels", "Gtk/CanChangeAccels",
GCONF_VALUE_BOOL, translate_bool_int },
{ "/desktop/gnome/interface/cursor_blink", "Net/CursorBlink",
GCONF_VALUE_BOOL, translate_bool_int },
{ "/desktop/gnome/interface/cursor_blink_time", "Net/CursorBlinkTime",
GCONF_VALUE_INT, translate_int_int },
{ "/desktop/gnome/interface/gtk_theme", "Net/ThemeName",
GCONF_VALUE_STRING, translate_string_string },
{ "/desktop/gnome/interface/gtk_color_scheme", "Gtk/ColorScheme",
GCONF_VALUE_STRING, translate_string_string },
{ "/desktop/gnome/interface/gtk-im-preedit-style", "Gtk/IMPreeditStyle",
GCONF_VALUE_STRING, translate_string_string },
{ "/desktop/gnome/interface/gtk-im-status-style", "Gtk/IMStatusStyle",
GCONF_VALUE_STRING, translate_string_string },
{ "/desktop/gnome/interface/icon_theme", "Net/IconThemeName",
GCONF_VALUE_STRING, translate_string_string },
{ "/desktop/gnome/interface/file_chooser_backend", "Gtk/FileChooserBackend",
GCONF_VALUE_STRING, translate_string_string },
{ "/desktop/gnome/interface/menus_have_icons", "Gtk/MenuImages",
GCONF_VALUE_BOOL, translate_bool_int },
{ "/desktop/gnome/interface/menubar_accel", "Gtk/MenuBarAccel",
GCONF_VALUE_STRING, translate_string_string },
{ "/desktop/gnome/peripherals/mouse/cursor_theme", "Gtk/CursorThemeName",
GCONF_VALUE_STRING, translate_string_string },
{ "/desktop/gnome/peripherals/mouse/cursor_size", "Gtk/CursorThemeSize",
GCONF_VALUE_INT, translate_int_int },
{ "/desktop/gnome/interface/show_input_method_menu", "Gtk/ShowInputMethodMenu",
GCONF_VALUE_BOOL, translate_bool_int },
{ "/desktop/gnome/interface/show_unicode_menu", "Gtk/ShowUnicodeMenu",
GCONF_VALUE_BOOL, translate_bool_int },
{ "/desktop/gnome/peripherals/mouse/double_click", "Net/DoubleClickTime",
GCONF_VALUE_INT, translate_int_int },
{ "/desktop/gnome/peripherals/mouse/drag_threshold", "Net/DndDragThreshold",
GCONF_VALUE_INT, translate_int_int },
{ "/desktop/gnome/gtk-color-palette", "Gtk/ColorPalette",
GCONF_VALUE_STRING, translate_string_string },
{ "/desktop/gnome/interface/font_name", "Gtk/FontName",
GCONF_VALUE_STRING, translate_string_string },
{ "/desktop/gnome/interface/gtk_key_theme", "Gtk/KeyThemeName",
GCONF_VALUE_STRING, translate_string_string },
{ "/desktop/gnome/interface/toolbar_style", "Gtk/ToolbarStyle",
GCONF_VALUE_STRING, translate_string_string_toolbar },
{ "/desktop/gnome/interface/toolbar_icon_size", "Gtk/ToolbarIconSize",
GCONF_VALUE_STRING, translate_string_string },
{ "/desktop/gnome/interface/can_change_accels", "Gtk/CanChangeAccels",
GCONF_VALUE_BOOL, translate_bool_int },
{ "/desktop/gnome/interface/cursor_blink", "Net/CursorBlink",
GCONF_VALUE_BOOL, translate_bool_int },
{ "/desktop/gnome/interface/cursor_blink_time", "Net/CursorBlinkTime",
GCONF_VALUE_INT, translate_int_int },
{ "/desktop/gnome/interface/gtk_theme", "Net/ThemeName",
GCONF_VALUE_STRING, translate_string_string },
{ "/desktop/gnome/interface/gtk_color_scheme", "Gtk/ColorScheme",
GCONF_VALUE_STRING, translate_string_string },
{ "/desktop/gnome/interface/gtk-im-preedit-style", "Gtk/IMPreeditStyle",
GCONF_VALUE_STRING, translate_string_string },
{ "/desktop/gnome/interface/gtk-im-status-style", "Gtk/IMStatusStyle",
GCONF_VALUE_STRING, translate_string_string },
{ "/desktop/gnome/interface/icon_theme", "Net/IconThemeName",
GCONF_VALUE_STRING, translate_string_string },
{ "/desktop/gnome/interface/file_chooser_backend", "Gtk/FileChooserBackend",
GCONF_VALUE_STRING, translate_string_string },
{ "/desktop/gnome/interface/menus_have_icons", "Gtk/MenuImages",
GCONF_VALUE_BOOL, translate_bool_int },
{ "/desktop/gnome/interface/menubar_accel", "Gtk/MenuBarAccel",
GCONF_VALUE_STRING, translate_string_string },
{ "/desktop/gnome/peripherals/mouse/cursor_theme", "Gtk/CursorThemeName",
GCONF_VALUE_STRING, translate_string_string },
{ "/desktop/gnome/peripherals/mouse/cursor_size", "Gtk/CursorThemeSize",
GCONF_VALUE_INT, translate_int_int },
{ "/desktop/gnome/interface/show_input_method_menu", "Gtk/ShowInputMethodMenu",
GCONF_VALUE_BOOL, translate_bool_int },
{ "/desktop/gnome/interface/show_unicode_menu", "Gtk/ShowUnicodeMenu",
GCONF_VALUE_BOOL, translate_bool_int },
};
static TranslationEntry*
find_translation_entry (const char *gconf_key)
{
int i;
int i;
i = 0;
while (i < G_N_ELEMENTS (translations))
{
if (strcmp (translations[i].gconf_key, gconf_key) == 0)
return &translations[i];
i = 0;
while (i < G_N_ELEMENTS (translations)) {
if (strcmp (translations[i].gconf_key, gconf_key) == 0)
return &translations[i];
++i;
}
++i;
}
return NULL;
return NULL;
}
static const gchar*
type_to_string (GConfValueType type)
{
switch (type)
{
case GCONF_VALUE_INT:
return "int";
case GCONF_VALUE_STRING:
return "string";
case GCONF_VALUE_FLOAT:
return "float";
case GCONF_VALUE_BOOL:
return "bool";
case GCONF_VALUE_SCHEMA:
return "schema";
case GCONF_VALUE_LIST:
return "list";
case GCONF_VALUE_PAIR:
return "pair";
case GCONF_VALUE_INVALID:
return "*invalid*";
default:
g_assert_not_reached();
return NULL; /* for warnings */
}
switch (type) {
case GCONF_VALUE_INT:
return "int";
case GCONF_VALUE_STRING:
return "string";
case GCONF_VALUE_FLOAT:
return "float";
case GCONF_VALUE_BOOL:
return "bool";
case GCONF_VALUE_SCHEMA:
return "schema";
case GCONF_VALUE_LIST:
return "list";
case GCONF_VALUE_PAIR:
return "pair";
case GCONF_VALUE_INVALID:
return "*invalid*";
default:
g_assert_not_reached();
return NULL; /* for warnings */
}
}
static void
process_value (TranslationEntry *trans,
GConfValue *val)
{
if (val == NULL)
{
int i;
if (val == NULL) {
int i;
for (i = 0; managers [i]; i++)
xsettings_manager_delete_setting (managers [i], trans->xsetting_name);
}
else
{
if (val->type == trans->gconf_type)
{
(* trans->translate) (trans, val);
}
else
{
g_warning (_("GConf key %s set to type %s but its expected type was %s\n"),
trans->gconf_key,
type_to_string (val->type),
type_to_string (trans->gconf_type));
}
}
for (i = 0; managers [i]; i++)
xsettings_manager_delete_setting (managers [i], trans->xsetting_name);
} else {
if (val->type == trans->gconf_type)
(* trans->translate) (trans, val);
else {
g_warning (_("GConf key %s set to type %s but its expected type was %s\n"),
trans->gconf_key,
type_to_string (val->type),
type_to_string (trans->gconf_type));
}
}
}
static void
xsettings_callback (GConfEntry *entry)
{
TranslationEntry *trans;
int i;
TranslationEntry *trans;
int i;
trans = find_translation_entry (entry->key);
if (trans == NULL)
return;
trans = find_translation_entry (entry->key);
if (trans == NULL)
return;
process_value (trans, entry->value);
process_value (trans, entry->value);
for (i = 0; managers [i]; i++)
xsettings_manager_set_string (managers [i], "Net/FallbackIconTheme",
"gnome");
for (i = 0; managers [i]; i++)
xsettings_manager_set_string (managers [i], "Net/FallbackIconTheme",
"gnome");
for (i = 0; managers [i]; i++)
xsettings_manager_notify (managers [i]);
for (i = 0; managers [i]; i++)
xsettings_manager_notify (managers [i]);
}
void
gnome_settings_xsettings_init (GConfClient *client)
static gboolean
gnome_settings_module_xsettings_initialize (GnomeSettingsModule *module, GConfClient *config_client)
{
gnome_settings_register_config_callback ("/desktop/gnome/peripherals/mouse", xsettings_callback);
gnome_settings_register_config_callback ("/desktop/gtk", xsettings_callback);
gnome_settings_register_config_callback ("/desktop/gnome/interface", xsettings_callback);
gnome_settings_register_config_callback ("/desktop/gnome/peripherals/mouse", xsettings_callback);
gnome_settings_register_config_callback ("/desktop/gtk", xsettings_callback);
gnome_settings_register_config_callback ("/desktop/gnome/interface", xsettings_callback);
return TRUE;
#ifdef HAVE_XFT2
gnome_settings_register_config_callback (FONT_RENDER_DIR, xft_callback);
gnome_settings_register_config_callback (FONT_RENDER_DIR, xft_callback);
#endif /* HAVE_XFT2 */
}
@ -267,15 +344,15 @@ gnome_settings_xsettings_init (GConfClient *client)
static void
xft_callback (GConfEntry *entry)
{
GConfClient *client;
int i;
GConfClient *client;
int i;
client = gnome_settings_get_config_client ();
client = gnome_settings_get_config_client ();
gnome_settings_update_xft (client);
gnome_settings_update_xft (client);
for (i = 0; managers [i]; i++)
xsettings_manager_notify (managers [i]);
for (i = 0; managers [i]; i++)
xsettings_manager_notify (managers [i]);
}
static double
@ -294,65 +371,60 @@ dpi_from_pixels_and_mm (int pixels, int mm)
static double
get_dpi_from_x_server (void)
{
GdkScreen *screen;
double dpi;
GdkScreen *screen;
double dpi;
screen = gdk_screen_get_default ();
if (screen)
{
double width_dpi, height_dpi;
screen = gdk_screen_get_default ();
if (screen) {
double width_dpi, height_dpi;
width_dpi = dpi_from_pixels_and_mm (gdk_screen_get_width (screen), gdk_screen_get_width_mm (screen));
height_dpi = dpi_from_pixels_and_mm (gdk_screen_get_height (screen), gdk_screen_get_height_mm (screen));
width_dpi = dpi_from_pixels_and_mm (gdk_screen_get_width (screen), gdk_screen_get_width_mm (screen));
height_dpi = dpi_from_pixels_and_mm (gdk_screen_get_height (screen), gdk_screen_get_height_mm (screen));
if (width_dpi < DPI_LOW_REASONABLE_VALUE || width_dpi > DPI_HIGH_REASONABLE_VALUE
|| height_dpi < DPI_LOW_REASONABLE_VALUE || height_dpi > DPI_HIGH_REASONABLE_VALUE)
dpi = DPI_FALLBACK;
else
dpi = (width_dpi + height_dpi) / 2.0;
}
else
{
/* Huh!? No screen? */
if (width_dpi < DPI_LOW_REASONABLE_VALUE || width_dpi > DPI_HIGH_REASONABLE_VALUE
|| height_dpi < DPI_LOW_REASONABLE_VALUE || height_dpi > DPI_HIGH_REASONABLE_VALUE)
dpi = DPI_FALLBACK;
else
dpi = (width_dpi + height_dpi) / 2.0;
} else {
/* Huh!? No screen? */
dpi = DPI_FALLBACK;
}
dpi = DPI_FALLBACK;
}
return dpi;
return dpi;
}
static double
get_dpi_from_gconf_or_x_server (GConfClient *client)
{
GConfValue *value;
double dpi;
GConfValue *value;
double dpi;
value = gconf_client_get_without_default (client, FONT_DPI_KEY, NULL);
value = gconf_client_get_without_default (client, FONT_DPI_KEY, NULL);
/* If the user has ever set the DPI preference in GConf, we use that.
* Otherwise, we see if the X server reports a reasonable DPI value: some X
* servers report completely bogus values, and the user gets huge or tiny
* fonts which are unusable.
*/
/* If the user has ever set the DPI preference in GConf, we use that.
* Otherwise, we see if the X server reports a reasonable DPI value: some X
* servers report completely bogus values, and the user gets huge or tiny
* fonts which are unusable.
*/
if (value)
{
dpi = gconf_value_get_float (value);
gconf_value_free (value);
}
else
dpi = get_dpi_from_x_server ();
if (value) {
dpi = gconf_value_get_float (value);
gconf_value_free (value);
} else
dpi = get_dpi_from_x_server ();
return dpi;
return dpi;
}
typedef struct
{
gboolean antialias;
gboolean hinting;
int dpi;
const char *rgba;
const char *hintstyle;
gboolean antialias;
gboolean hinting;
int dpi;
const char *rgba;
const char *hintstyle;
} GnomeXftSettings;
static const char *rgba_types[] = { "rgb", "bgr", "vbgr", "vrgb" };
@ -364,125 +436,110 @@ static void
gnome_xft_settings_get (GConfClient *client,
GnomeXftSettings *settings)
{
char *antialiasing = gconf_client_get_string (client, FONT_ANTIALIASING_KEY, NULL);
char *hinting = gconf_client_get_string (client, FONT_HINTING_KEY, NULL);
char *rgba_order = gconf_client_get_string (client, FONT_RGBA_ORDER_KEY, NULL);
double dpi = get_dpi_from_gconf_or_x_server (client);
char *antialiasing = gconf_client_get_string (client, FONT_ANTIALIASING_KEY, NULL);
char *hinting = gconf_client_get_string (client, FONT_HINTING_KEY, NULL);
char *rgba_order = gconf_client_get_string (client, FONT_RGBA_ORDER_KEY, NULL);
double dpi = get_dpi_from_gconf_or_x_server (client);
settings->antialias = TRUE;
settings->hinting = TRUE;
settings->hintstyle = "hintfull";
settings->dpi = dpi * 1024; /* Xft wants 1/1024ths of an inch */
settings->rgba = "rgb";
settings->antialias = TRUE;
settings->hinting = TRUE;
settings->hintstyle = "hintfull";
settings->dpi = dpi * 1024; /* Xft wants 1/1024ths of an inch */
settings->rgba = "rgb";
if (rgba_order)
{
int i;
gboolean found = FALSE;
if (rgba_order) {
int i;
gboolean found = FALSE;
for (i = 0; i < G_N_ELEMENTS (rgba_types) && !found; i++)
if (strcmp (rgba_order, rgba_types[i]) == 0)
{
settings->rgba = rgba_types[i];
found = TRUE;
}
for (i = 0; i < G_N_ELEMENTS (rgba_types) && !found; i++)
if (strcmp (rgba_order, rgba_types[i]) == 0) {
settings->rgba = rgba_types[i];
found = TRUE;
}
if (!found)
g_warning ("Invalid value for " FONT_RGBA_ORDER_KEY ": '%s'",
rgba_order);
}
if (!found)
g_warning ("Invalid value for " FONT_RGBA_ORDER_KEY ": '%s'",
rgba_order);
}
if (hinting)
{
if (strcmp (hinting, "none") == 0)
{
settings->hinting = 0;
settings->hintstyle = "hintnone";
if (hinting) {
if (strcmp (hinting, "none") == 0) {
settings->hinting = 0;
settings->hintstyle = "hintnone";
} else if (strcmp (hinting, "slight") == 0) {
settings->hinting = 1;
settings->hintstyle = "hintslight";
} else if (strcmp (hinting, "medium") == 0) {
settings->hinting = 1;
settings->hintstyle = "hintmedium";
} else if (strcmp (hinting, "full") == 0) {
settings->hinting = 1;
settings->hintstyle = "hintfull";
} else
g_warning ("Invalid value for " FONT_HINTING_KEY ": '%s'",
hinting);
}
else if (strcmp (hinting, "slight") == 0)
{
settings->hinting = 1;
settings->hintstyle = "hintslight";
}
else if (strcmp (hinting, "medium") == 0)
{
settings->hinting = 1;
settings->hintstyle = "hintmedium";
}
else if (strcmp (hinting, "full") == 0)
{
settings->hinting = 1;
settings->hintstyle = "hintfull";
}
else
g_warning ("Invalid value for " FONT_HINTING_KEY ": '%s'",
hinting);
}
if (antialiasing)
{
gboolean use_rgba = FALSE;
if (antialiasing) {
gboolean use_rgba = FALSE;
if (strcmp (antialiasing, "none") == 0)
settings->antialias = 0;
else if (strcmp (antialiasing, "grayscale") == 0)
settings->antialias = 1;
else if (strcmp (antialiasing, "rgba") == 0)
{
settings->antialias = 1;
use_rgba = TRUE;
if (strcmp (antialiasing, "none") == 0)
settings->antialias = 0;
else if (strcmp (antialiasing, "grayscale") == 0)
settings->antialias = 1;
else if (strcmp (antialiasing, "rgba") == 0) {
settings->antialias = 1;
use_rgba = TRUE;
} else
g_warning ("Invalid value for " FONT_ANTIALIASING_KEY " : '%s'",
antialiasing);
if (!use_rgba)
settings->rgba = "none";
}
else
g_warning ("Invalid value for " FONT_ANTIALIASING_KEY " : '%s'",
antialiasing);
if (!use_rgba)
settings->rgba = "none";
}
g_free (rgba_order);
g_free (hinting);
g_free (antialiasing);
g_free (rgba_order);
g_free (hinting);
g_free (antialiasing);
}
static void
gnome_xft_settings_set_xsettings (GnomeXftSettings *settings)
{
int i;
for (i = 0; managers [i]; i++)
{
xsettings_manager_set_int (managers [i], "Xft/Antialias", settings->antialias);
xsettings_manager_set_int (managers [i], "Xft/Hinting", settings->hinting);
xsettings_manager_set_string (managers [i], "Xft/HintStyle", settings->hintstyle);
xsettings_manager_set_int (managers [i], "Xft/DPI", settings->dpi);
xsettings_manager_set_string (managers [i], "Xft/RGBA", settings->rgba);
}
int i;
for (i = 0; managers [i]; i++) {
xsettings_manager_set_int (managers [i], "Xft/Antialias", settings->antialias);
xsettings_manager_set_int (managers [i], "Xft/Hinting", settings->hinting);
xsettings_manager_set_string (managers [i], "Xft/HintStyle", settings->hintstyle);
xsettings_manager_set_int (managers [i], "Xft/DPI", settings->dpi);
xsettings_manager_set_string (managers [i], "Xft/RGBA", settings->rgba);
}
}
static void
gnome_xft_settings_set_xresources (GnomeXftSettings *settings)
{
char *add[] = { "xrdb", "-nocpp", "-merge", NULL };
GString *add_string = g_string_new (NULL);
char *old_locale = g_strdup (setlocale (LC_NUMERIC, NULL));
char *add[] = { "xrdb", "-nocpp", "-merge", NULL };
GString *add_string = g_string_new (NULL);
char *old_locale = g_strdup (setlocale (LC_NUMERIC, NULL));
setlocale (LC_NUMERIC, "C");
g_string_append_printf (add_string,
"Xft.dpi: %f\n", settings->dpi / 1024.);
g_string_append_printf (add_string,
"Xft.antialias: %d\n", settings->antialias);
g_string_append_printf (add_string,
"Xft.hinting: %d\n", settings->hinting);
g_string_append_printf (add_string,
"Xft.hintstyle: %s\n", settings->hintstyle);
g_string_append_printf (add_string,
"Xft.rgba: %s\n", settings->rgba);
setlocale (LC_NUMERIC, "C");
g_string_append_printf (add_string,
"Xft.dpi: %f\n", settings->dpi / 1024.);
g_string_append_printf (add_string,
"Xft.antialias: %d\n", settings->antialias);
g_string_append_printf (add_string,
"Xft.hinting: %d\n", settings->hinting);
g_string_append_printf (add_string,
"Xft.hintstyle: %s\n", settings->hintstyle);
g_string_append_printf (add_string,
"Xft.rgba: %s\n", settings->rgba);
gnome_settings_spawn_with_input (add, add_string->str);
gnome_settings_spawn_with_input (add, add_string->str);
g_string_free (add_string, TRUE);
setlocale (LC_NUMERIC, old_locale);
g_free (old_locale);
g_string_free (add_string, TRUE);
setlocale (LC_NUMERIC, old_locale);
g_free (old_locale);
}
/* We mirror the Xft properties both through XSETTINGS and through
@ -491,54 +548,59 @@ gnome_xft_settings_set_xresources (GnomeXftSettings *settings)
static void
gnome_settings_update_xft (GConfClient *client)
{
GnomeXftSettings settings;
GnomeXftSettings settings;
gnome_xft_settings_get (client, &settings);
gnome_xft_settings_set_xsettings (&settings);
gnome_xft_settings_set_xresources (&settings);
gnome_xft_settings_get (client, &settings);
gnome_xft_settings_set_xsettings (&settings);
gnome_xft_settings_set_xresources (&settings);
}
#endif /* HAVE_XFT2 */
void
gnome_settings_xsettings_load (GConfClient *client)
static gboolean
gnome_settings_module_xsettings_start (GnomeSettingsModule *module)
{
int i;
GConfClient *client = gnome_settings_module_get_config_client (module);
int i;
i = 0;
while (i < G_N_ELEMENTS (translations))
{
GConfValue *val;
GError *err;
i = 0;
while (i < G_N_ELEMENTS (translations)) {
GConfValue *val;
GError *err;
err = NULL;
val = gconf_client_get (client,
err = NULL;
val = gconf_client_get (client,
translations[i].gconf_key,
&err);
if (err != NULL)
{
fprintf (stderr, "Error getting value for %s: %s\n",
translations[i].gconf_key, err->message);
g_error_free (err);
}
else
{
process_value (&translations[i], val);
if (val != NULL)
gconf_value_free (val);
}
if (err != NULL) {
fprintf (stderr, "Error getting value for %s: %s\n",
translations[i].gconf_key, err->message);
g_error_free (err);
} else {
process_value (&translations[i], val);
if (val != NULL)
gconf_value_free (val);
}
++i;
}
++i;
}
#ifdef HAVE_XFT2
gnome_settings_update_xft (client);
gnome_settings_update_xft (client);
#endif /* HAVE_XFT */
for (i = 0; managers [i]; i++)
xsettings_manager_set_string (managers [i], "Net/FallbackIconTheme",
"gnome");
for (i = 0; managers [i]; i++)
xsettings_manager_set_string (managers [i], "Net/FallbackIconTheme",
"gnome");
for (i = 0; managers [i]; i++)
xsettings_manager_notify (managers [i]);
for (i = 0; managers [i]; i++)
xsettings_manager_notify (managers [i]);
return TRUE;
}
static gboolean
gnome_settings_module_xsettings_stop (GnomeSettingsModule *module)
{
return TRUE;
}

View file

@ -1,33 +0,0 @@
/*
* 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: Jonathan Blandford
*/
#ifndef GNOME_SETTINGS_XSETTINGS_H
#define GNOME_SETTINGS_XSETTINGS_H
#include <gconf/gconf.h>
void gnome_settings_xsettings_init (GConfClient *client);
void gnome_settings_xsettings_load (GConfClient *client);
#endif /* GNOME_SETTINGS_XSETTINGS_H */