Import from gconf-xsettings module. Cleaned up a bunch, and made to work
Sat Dec 8 21:33:10 2001 Jonathan Blandford <jrb@redhat.com> * gnome-settings-daemon/gnome-settings-daemon.c (main): Import from gconf-xsettings module. Cleaned up a bunch, and made to work with mouse properties too. * schemas/peripherals.schemas: New location for schemas. Need to write many more.
This commit is contained in:
parent
9f8ed1254f
commit
757434ab94
16 changed files with 1585 additions and 2 deletions
|
@ -1,3 +1,12 @@
|
|||
Sat Dec 8 21:33:10 2001 Jonathan Blandford <jrb@redhat.com>
|
||||
|
||||
* gnome-settings-daemon/gnome-settings-daemon.c (main): Import
|
||||
from gconf-xsettings module. Cleaned up a bunch, and made to work
|
||||
with mouse properties too.
|
||||
|
||||
* schemas/peripherals.schemas: New location for schemas. Need to
|
||||
write many more.
|
||||
|
||||
2001-12-09 Gediminas Paulauskas <menesis@delfi.lt>
|
||||
|
||||
* *.c (main): retrieve translation in utf-8 codeset. Do not
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
SUBDIRS = libsounds libbackground capplets control-center idl po
|
||||
SUBDIRS = schemas gnome-settings-daemon libsounds libbackground libsounds capplets control-center idl po
|
||||
|
||||
#I removed the root-manager for now
|
||||
#
|
||||
# it generated this error :
|
||||
|
|
22
configure.in
22
configure.in
|
@ -36,7 +36,9 @@ AC_SUBST(XF86MISC_LIBS)
|
|||
dnl ==============================================
|
||||
dnl Check that we meet the dependencies
|
||||
dnl ==============================================
|
||||
COMMON_MODULES="libgnomeui-2.0 libglade-2.0 libbonobo-2.0 libbonoboui-2.0 libglade-2.0 gconf-2.0"
|
||||
COMMON_MODULES="gtk+-2.0 gconf-2.0 libgnomeui-2.0 libglade-2.0 libbonobo-2.0 libbonoboui-2.0 libglade-2.0 gconf-2.0"
|
||||
PKG_CHECK_MODULES(GCONF, gconf-2.0)
|
||||
PKG_CHECK_MODULES(GTK, gtk+-2.0)
|
||||
PKG_CHECK_MODULES(CAPPLET, $COMMON_MODULES bonobo-config-2.0)
|
||||
PKG_CHECK_MODULES(GNOMECC, $COMMON_MODULES libxml-2.0 gnome-desktop-2.0)
|
||||
PKG_CHECK_MODULES(ARCHIVER, libbonobo-2.0 bonobo-config-2.0 libxml-2.0)
|
||||
|
@ -45,6 +47,11 @@ PKG_CHECK_MODULES(MONIKER, libbonobo-2.0 bonobo-config-2.0 libxml-2.0)
|
|||
PKG_CHECK_MODULES(OLD_CAPPLET, libgnomeui-2.0 libglade-2.0 libcapplet-2.0)
|
||||
PKG_CHECK_MODULES(GNOME, libgnomeui-2.0)
|
||||
|
||||
AC_SUBST(GTK_CFLAGS)
|
||||
AC_SUBST(GCONF_CFLAGS)
|
||||
AC_SUBST(GTK_LIBS)
|
||||
AC_SUBST(GCONF_LIBS)
|
||||
|
||||
SCREENSAVER=screensaver
|
||||
AC_PATH_PROG(XSCREENSAVER, xscreensaver, no)
|
||||
if test "$XSCREENSAVER" = no ; then
|
||||
|
@ -117,6 +124,17 @@ dnl End: Define the main variables
|
|||
dnl ==============================================
|
||||
|
||||
|
||||
GCONF_CONFIG_SOURCE=
|
||||
AC_ARG_ENABLE(gconf-source, [ --enable-gconf-source=sourceaddress Where to install schema files.],GCONF_CONFIG_SOURCE=$enable_gconf_source,)
|
||||
|
||||
if test "x$GCONF_CONFIG_SOURCE" = "x"; then
|
||||
GCONF_CONFIG_SOURCE="xml::\${DESTDIR}\${sysconfdir}/gconf/gconf.xml.defaults"
|
||||
fi
|
||||
|
||||
AC_SUBST(GCONF_CONFIG_SOURCE)
|
||||
AC_SUBST(INSTALL_GCONF_CONFIG_SOURCE)
|
||||
|
||||
|
||||
|
||||
dnl ==============================================
|
||||
dnl Define the directories
|
||||
|
@ -165,6 +183,8 @@ AC_OUTPUT([
|
|||
control-center.spec
|
||||
Makefile
|
||||
po/Makefile.in
|
||||
schemas/Makefile
|
||||
gnome-settings-daemon/Makefile
|
||||
control-center/Makefile
|
||||
libbackground/Makefile
|
||||
capplets/Makefile
|
||||
|
|
17
gnome-settings-daemon/Makefile.am
Normal file
17
gnome-settings-daemon/Makefile.am
Normal file
|
@ -0,0 +1,17 @@
|
|||
INCLUDES=$(GTK_CFLAGS) $(GCONF_CFLAGS)
|
||||
|
||||
gnome_settings_daemon_SOURCES = \
|
||||
gnome-settings-daemon.h \
|
||||
gnome-settings-daemon.c \
|
||||
gnome-settings-mouse.h \
|
||||
gnome-settings-mouse.c \
|
||||
gnome-settings-xsettings.c \
|
||||
gnome-settings-xsettings.h \
|
||||
xsettings-common.c \
|
||||
xsettings-manager.c \
|
||||
xsettings-common.h \
|
||||
xsettings-manager.h
|
||||
|
||||
bin_PROGRAMS=gnome-settings-daemon
|
||||
|
||||
gnome_settings_daemon_LDADD = $(GTK_LIBS) $(GCONF_LIBS)
|
180
gnome-settings-daemon/gnome-settings-daemon.c
Normal file
180
gnome-settings-daemon/gnome-settings-daemon.c
Normal file
|
@ -0,0 +1,180 @@
|
|||
/*
|
||||
* 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
|
||||
*/
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
#include <gtk/gtk.h>
|
||||
#include <gdk/gdkx.h>
|
||||
|
||||
#include <gconf/gconf.h>
|
||||
|
||||
#include "xsettings-manager.h"
|
||||
#include "gnome-settings-daemon.h"
|
||||
|
||||
static GSList *directories = NULL;
|
||||
XSettingsManager *manager;
|
||||
|
||||
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))
|
||||
{
|
||||
dir_element->callbacks = g_slist_prepend (dir_element->callbacks, func);
|
||||
dir_found = TRUE;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (! dir_found)
|
||||
{
|
||||
DirElement *dir_element = g_new0 (DirElement, 1);
|
||||
|
||||
dir_element->dir = g_strdup (dir);
|
||||
dir_element->callbacks = g_slist_prepend (dir_element->callbacks, func);
|
||||
directories = g_slist_prepend (directories, dir_element);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
config_notify (GConfEngine *client,
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
terminate_cb (void *data)
|
||||
{
|
||||
gboolean *terminated = data;
|
||||
|
||||
*terminated = TRUE;
|
||||
gtk_main_quit ();
|
||||
}
|
||||
|
||||
static GdkFilterReturn
|
||||
manager_event_filter (GdkXEvent *xevent,
|
||||
GdkEvent *event,
|
||||
gpointer data)
|
||||
{
|
||||
if (xsettings_manager_process_event (manager, (XEvent *)xevent))
|
||||
return GDK_FILTER_REMOVE;
|
||||
else
|
||||
return GDK_FILTER_CONTINUE;
|
||||
}
|
||||
|
||||
int
|
||||
main (int argc, char **argv)
|
||||
{
|
||||
gboolean terminated = FALSE;
|
||||
GConfEngine *engine;
|
||||
GSList *list;
|
||||
gtk_init (&argc, &argv);
|
||||
|
||||
if (xsettings_manager_check_running (gdk_display, DefaultScreen (gdk_display)))
|
||||
{
|
||||
fprintf (stderr, "You can only run one xsettings manager at a time; exiting");
|
||||
exit (1);
|
||||
}
|
||||
|
||||
if (!terminated)
|
||||
{
|
||||
manager = xsettings_manager_new (gdk_display, DefaultScreen (gdk_display),
|
||||
terminate_cb, &terminated);
|
||||
if (!manager)
|
||||
{
|
||||
fprintf (stderr, "Could not create xsettings manager!");
|
||||
exit (1);
|
||||
}
|
||||
}
|
||||
|
||||
gconf_init (argc, argv, NULL); /* exits w/ message on failure */
|
||||
|
||||
/* We use GConfEngine not GConfClient because a cache isn't useful
|
||||
* for us
|
||||
*/
|
||||
engine = gconf_engine_get_default ();
|
||||
gnome_settings_xsettings_init (engine);
|
||||
gnome_settings_mouse_init (engine);
|
||||
|
||||
for (list = directories; list; list = list->next)
|
||||
{
|
||||
GError *error = NULL;
|
||||
DirElement *dir_element = list->data;
|
||||
|
||||
gconf_engine_notify_add (engine,
|
||||
dir_element->dir,
|
||||
config_notify,
|
||||
NULL,
|
||||
&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);
|
||||
}
|
||||
}
|
||||
|
||||
gdk_window_add_filter (NULL, manager_event_filter, NULL);
|
||||
|
||||
gnome_settings_xsettings_load (engine);
|
||||
gnome_settings_mouse_load (engine);
|
||||
|
||||
if (!terminated)
|
||||
gtk_main ();
|
||||
|
||||
xsettings_manager_destroy (manager);
|
||||
gconf_engine_unref (engine);
|
||||
|
||||
return 0;
|
||||
}
|
34
gnome-settings-daemon/gnome-settings-daemon.h
Normal file
34
gnome-settings-daemon/gnome-settings-daemon.h
Normal file
|
@ -0,0 +1,34 @@
|
|||
/*
|
||||
* 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>
|
||||
|
||||
typedef void (* KeyCallbackFunc) (GConfEntry *entry);
|
||||
|
||||
void gnome_settings_daemon_register_callback (const char *dir,
|
||||
KeyCallbackFunc func);
|
||||
|
||||
#endif /* GNOME_SETTINGS_XSETTINGS_H */
|
126
gnome-settings-daemon/gnome-settings-mouse.c
Normal file
126
gnome-settings-daemon/gnome-settings-mouse.c
Normal file
|
@ -0,0 +1,126 @@
|
|||
#include <X11/Xlib.h>
|
||||
#include <gdk/gdkx.h>
|
||||
#include <gconf/gconf.h>
|
||||
#include <math.h>
|
||||
|
||||
#define MAX_BUTTONS 10
|
||||
|
||||
static void
|
||||
set_left_handed (gboolean left_handed)
|
||||
{
|
||||
unsigned char buttons[MAX_BUTTONS];
|
||||
gint n_buttons, i;
|
||||
gint idx_1 = 0, idx_3 = 1;
|
||||
|
||||
n_buttons = XGetPointerMapping (GDK_DISPLAY (), buttons, MAX_BUTTONS);
|
||||
|
||||
for (i = 0; i < n_buttons; i++)
|
||||
{
|
||||
if (buttons[i] == 1)
|
||||
idx_1 = i;
|
||||
else if (buttons[i] == ((n_buttons < 3) ? 2 : 3))
|
||||
idx_3 = i;
|
||||
}
|
||||
|
||||
if ((left_handed && idx_1 < idx_3) ||
|
||||
(!left_handed && idx_1 > idx_3))
|
||||
{
|
||||
buttons[idx_1] = ((n_buttons < 3) ? 2 : 3);
|
||||
buttons[idx_3] = 1;
|
||||
}
|
||||
|
||||
XSetPointerMapping (GDK_DISPLAY (), buttons, n_buttons);
|
||||
}
|
||||
|
||||
static void
|
||||
set_motion_acceleration (gfloat motion_acceleration)
|
||||
{
|
||||
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;
|
||||
}
|
||||
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);
|
||||
}
|
||||
|
||||
static void
|
||||
set_motion_threshold (gint motion_threshold)
|
||||
{
|
||||
XChangePointerControl (GDK_DISPLAY (), False, True,
|
||||
0, 0, motion_threshold);
|
||||
}
|
||||
|
||||
static void
|
||||
set_drag_threshold (gint drag_threshold)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
|
||||
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));
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
gnome_settings_mouse_init (GConfEngine *engine)
|
||||
{
|
||||
gnome_settings_daemon_register_callback ("/desktop/gnome/peripherals/mouse", mouse_callback);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
gnome_settings_mouse_load (GConfEngine *engine)
|
||||
{
|
||||
|
||||
}
|
32
gnome-settings-daemon/gnome-settings-mouse.h
Normal file
32
gnome-settings-daemon/gnome-settings-mouse.h
Normal file
|
@ -0,0 +1,32 @@
|
|||
/*
|
||||
* 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.
|
||||
*
|
||||
* 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 MOUSE_SETTINGS_H
|
||||
#define MOUSE_SETTINGS_H
|
||||
|
||||
#include <gconf/gconf.h>
|
||||
|
||||
void gnome_settings_mouse_init (GConfEngine *engine);
|
||||
void gnome_settings_mouse_load (GConfEngine *engine);
|
||||
|
||||
#endif
|
184
gnome-settings-daemon/gnome-settings-xsettings.c
Normal file
184
gnome-settings-daemon/gnome-settings-xsettings.c
Normal file
|
@ -0,0 +1,184 @@
|
|||
#include <stdio.h>
|
||||
|
||||
#include "gnome-settings-daemon.h"
|
||||
#include "gnome-settings-xsettings.h"
|
||||
#include "xsettings-manager.h"
|
||||
|
||||
extern XSettingsManager *manager;
|
||||
|
||||
|
||||
typedef struct _TranslationEntry TranslationEntry;
|
||||
typedef void (* TranslationFunc) (TranslationEntry *trans,
|
||||
GConfValue *value);
|
||||
struct _TranslationEntry
|
||||
{
|
||||
const char *gconf_key;
|
||||
const char *xsetting_name;
|
||||
|
||||
GConfValueType gconf_type;
|
||||
TranslationFunc translate;
|
||||
};
|
||||
|
||||
|
||||
static void
|
||||
translate_int_int (TranslationEntry *trans,
|
||||
GConfValue *value)
|
||||
{
|
||||
g_assert (value->type == trans->gconf_type);
|
||||
|
||||
xsettings_manager_set_int (manager, trans->xsetting_name,
|
||||
gconf_value_get_int (value));
|
||||
}
|
||||
|
||||
static void
|
||||
translate_string_string (TranslationEntry *trans,
|
||||
GConfValue *value)
|
||||
{
|
||||
g_assert (value->type == trans->gconf_type);
|
||||
|
||||
xsettings_manager_set_string (manager,
|
||||
trans->xsetting_name,
|
||||
gconf_value_get_string (value));
|
||||
}
|
||||
|
||||
static TranslationEntry translations [] = {
|
||||
{ "/desktop/standard/double-click-time", "Net/DoubleClickTime", GCONF_VALUE_INT,
|
||||
translate_int_int },
|
||||
{ "/desktop/gtk/gtk-color-palette", "Gtk/ColorPalette", GCONF_VALUE_STRING,
|
||||
translate_string_string },
|
||||
{ "/desktop/gtk/gtk-toolbar-style", "Gtk/ToolbarStyle", GCONF_VALUE_STRING,
|
||||
translate_string_string },
|
||||
{ "/desktop/gtk/gtk-toolbar-icon-size", "Gtk/ToolbarIconSize", GCONF_VALUE_STRING,
|
||||
translate_string_string }
|
||||
};
|
||||
|
||||
static TranslationEntry*
|
||||
find_translation_entry (const char *gconf_key)
|
||||
{
|
||||
int i;
|
||||
|
||||
i = 0;
|
||||
while (i < G_N_ELEMENTS (translations))
|
||||
{
|
||||
if (strcmp (translations[i].gconf_key, gconf_key) == 0)
|
||||
return &translations[i];
|
||||
|
||||
++i;
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static const gchar*
|
||||
type_to_string (GConfValueType type)
|
||||
{
|
||||
switch (type)
|
||||
{
|
||||
case GCONF_VALUE_INT:
|
||||
return "int";
|
||||
break;
|
||||
case GCONF_VALUE_STRING:
|
||||
return "string";
|
||||
break;
|
||||
case GCONF_VALUE_FLOAT:
|
||||
return "float";
|
||||
break;
|
||||
case GCONF_VALUE_BOOL:
|
||||
return "bool";
|
||||
break;
|
||||
case GCONF_VALUE_SCHEMA:
|
||||
return "schema";
|
||||
break;
|
||||
case GCONF_VALUE_LIST:
|
||||
return "list";
|
||||
break;
|
||||
case GCONF_VALUE_PAIR:
|
||||
return "pair";
|
||||
break;
|
||||
case GCONF_VALUE_INVALID:
|
||||
return "*invalid*";
|
||||
break;
|
||||
default:
|
||||
g_assert_not_reached();
|
||||
return NULL; /* for warnings */
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
process_value (TranslationEntry *trans,
|
||||
GConfValue *val)
|
||||
{
|
||||
if (val == NULL)
|
||||
{
|
||||
xsettings_manager_delete_setting (manager, 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;
|
||||
trans = find_translation_entry (entry->key);
|
||||
|
||||
if (trans == NULL)
|
||||
return;
|
||||
|
||||
process_value (trans, entry->value);
|
||||
|
||||
xsettings_manager_notify (manager);
|
||||
}
|
||||
|
||||
void
|
||||
gnome_settings_xsettings_init (GConfEngine *engine)
|
||||
{
|
||||
gnome_settings_daemon_register_callback ("/desktop/standard", xsettings_callback);
|
||||
gnome_settings_daemon_register_callback ("/desktop/gtk", xsettings_callback);
|
||||
}
|
||||
|
||||
void
|
||||
gnome_settings_xsettings_load (GConfEngine *engine)
|
||||
{
|
||||
int i;
|
||||
|
||||
i = 0;
|
||||
while (i < G_N_ELEMENTS (translations))
|
||||
{
|
||||
GConfValue *val;
|
||||
GError *err;
|
||||
|
||||
err = NULL;
|
||||
val = gconf_engine_get (engine,
|
||||
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);
|
||||
}
|
||||
|
||||
++i;
|
||||
}
|
||||
|
||||
xsettings_manager_notify (manager);
|
||||
}
|
33
gnome-settings-daemon/gnome-settings-xsettings.h
Normal file
33
gnome-settings-daemon/gnome-settings-xsettings.h
Normal file
|
@ -0,0 +1,33 @@
|
|||
/*
|
||||
* 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 (GConfEngine *engine);
|
||||
void gnome_settings_xsettings_load (GConfEngine *engine);
|
||||
|
||||
|
||||
#endif /* GNOME_SETTINGS_XSETTINGS_H */
|
261
gnome-settings-daemon/xsettings-common.c
Normal file
261
gnome-settings-daemon/xsettings-common.c
Normal file
|
@ -0,0 +1,261 @@
|
|||
/*
|
||||
* 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.
|
||||
*
|
||||
* Author: Owen Taylor, Red Hat, Inc.
|
||||
*/
|
||||
#include "string.h"
|
||||
#include "stdlib.h"
|
||||
|
||||
#include <X11/Xlib.h>
|
||||
#include <X11/Xmd.h> /* For CARD32 */
|
||||
|
||||
#include "xsettings-common.h"
|
||||
|
||||
XSettingsSetting *
|
||||
xsettings_setting_copy (XSettingsSetting *setting)
|
||||
{
|
||||
XSettingsSetting *result;
|
||||
size_t str_len;
|
||||
|
||||
result = malloc (sizeof *result);
|
||||
if (!result)
|
||||
return NULL;
|
||||
|
||||
str_len = strlen (setting->name);
|
||||
result->name = malloc (str_len + 1);
|
||||
if (!result->name)
|
||||
goto err;
|
||||
|
||||
memcpy (result->name, setting->name, str_len + 1);
|
||||
|
||||
result->type = setting->type;
|
||||
|
||||
switch (setting->type)
|
||||
{
|
||||
case XSETTINGS_TYPE_INT:
|
||||
result->data.v_int = setting->data.v_int;
|
||||
break;
|
||||
case XSETTINGS_TYPE_COLOR:
|
||||
result->data.v_color = setting->data.v_color;
|
||||
break;
|
||||
case XSETTINGS_TYPE_STRING:
|
||||
str_len = strlen (setting->data.v_string);
|
||||
result->data.v_string = malloc (str_len + 1);
|
||||
if (!result->data.v_string)
|
||||
goto err;
|
||||
|
||||
memcpy (result->data.v_string, setting->data.v_string, str_len + 1);
|
||||
break;
|
||||
}
|
||||
|
||||
result->last_change_serial = setting->last_change_serial;
|
||||
|
||||
return result;
|
||||
|
||||
err:
|
||||
if (result->name)
|
||||
free (result->name);
|
||||
free (result);
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
XSettingsList *
|
||||
xsettings_list_copy (XSettingsList *list)
|
||||
{
|
||||
XSettingsList *new = NULL;
|
||||
XSettingsList *old_iter = list;
|
||||
XSettingsList *new_iter = NULL;
|
||||
|
||||
while (old_iter)
|
||||
{
|
||||
XSettingsList *new_node;
|
||||
|
||||
new_node = malloc (sizeof *new_node);
|
||||
if (!new_node)
|
||||
goto error;
|
||||
|
||||
new_node->setting = xsettings_setting_copy (old_iter->setting);
|
||||
if (!new_node->setting)
|
||||
{
|
||||
free (new_node);
|
||||
goto error;
|
||||
}
|
||||
|
||||
if (new_iter)
|
||||
new_iter->next = new_node;
|
||||
else
|
||||
new = new_node;
|
||||
|
||||
new_iter = new_node;
|
||||
|
||||
old_iter = old_iter->next;
|
||||
}
|
||||
|
||||
return new;
|
||||
|
||||
error:
|
||||
xsettings_list_free (new);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
int
|
||||
xsettings_setting_equal (XSettingsSetting *setting_a,
|
||||
XSettingsSetting *setting_b)
|
||||
{
|
||||
if (setting_a->type != setting_b->type)
|
||||
return 0;
|
||||
|
||||
if (strcmp (setting_a->name, setting_b->name) != 0)
|
||||
return 0;
|
||||
|
||||
switch (setting_a->type)
|
||||
{
|
||||
case XSETTINGS_TYPE_INT:
|
||||
return setting_a->data.v_int == setting_b->data.v_int;
|
||||
case XSETTINGS_TYPE_COLOR:
|
||||
return (setting_a->data.v_color.red == setting_b->data.v_color.red &&
|
||||
setting_a->data.v_color.green == setting_b->data.v_color.green &&
|
||||
setting_a->data.v_color.blue == setting_b->data.v_color.blue &&
|
||||
setting_a->data.v_color.alpha == setting_b->data.v_color.alpha);
|
||||
case XSETTINGS_TYPE_STRING:
|
||||
return strcmp (setting_a->data.v_string, setting_b->data.v_string) == 0;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void
|
||||
xsettings_setting_free (XSettingsSetting *setting)
|
||||
{
|
||||
if (setting->type == XSETTINGS_TYPE_STRING)
|
||||
free (setting->data.v_string);
|
||||
|
||||
free (setting);
|
||||
}
|
||||
|
||||
void
|
||||
xsettings_list_free (XSettingsList *list)
|
||||
{
|
||||
while (list)
|
||||
{
|
||||
XSettingsList *next = list->next;
|
||||
|
||||
xsettings_setting_free (list->setting);
|
||||
free (list);
|
||||
|
||||
list = next;
|
||||
}
|
||||
}
|
||||
|
||||
XSettingsResult
|
||||
xsettings_list_insert (XSettingsList **list,
|
||||
XSettingsSetting *setting)
|
||||
{
|
||||
XSettingsList *node;
|
||||
XSettingsList *iter;
|
||||
XSettingsList *last = NULL;
|
||||
|
||||
node = malloc (sizeof *node);
|
||||
if (!node)
|
||||
return XSETTINGS_NO_MEM;
|
||||
node->setting = setting;
|
||||
|
||||
iter = *list;
|
||||
while (iter)
|
||||
{
|
||||
int cmp = strcmp (setting->name, iter->setting->name);
|
||||
|
||||
if (cmp < 0)
|
||||
break;
|
||||
else if (cmp == 0)
|
||||
{
|
||||
free (node);
|
||||
return XSETTINGS_DUPLICATE_ENTRY;
|
||||
}
|
||||
|
||||
last = iter;
|
||||
iter = iter->next;
|
||||
}
|
||||
|
||||
if (last)
|
||||
last->next = node;
|
||||
else
|
||||
*list = node;
|
||||
|
||||
node->next = iter;
|
||||
|
||||
return XSETTINGS_SUCCESS;
|
||||
}
|
||||
|
||||
XSettingsResult
|
||||
xsettings_list_delete (XSettingsList **list,
|
||||
const char *name)
|
||||
{
|
||||
XSettingsList *iter;
|
||||
XSettingsList *last = NULL;
|
||||
|
||||
iter = *list;
|
||||
while (iter)
|
||||
{
|
||||
if (strcmp (name, iter->setting->name) == 0)
|
||||
{
|
||||
if (last)
|
||||
last->next = iter->next;
|
||||
else
|
||||
*list = iter->next;
|
||||
|
||||
xsettings_setting_free (iter->setting);
|
||||
free (iter);
|
||||
|
||||
return XSETTINGS_SUCCESS;
|
||||
}
|
||||
|
||||
last = iter;
|
||||
iter = iter->next;
|
||||
}
|
||||
|
||||
return XSETTINGS_FAILED;
|
||||
}
|
||||
|
||||
XSettingsSetting *
|
||||
xsettings_list_lookup (XSettingsList *list,
|
||||
const char *name)
|
||||
{
|
||||
XSettingsList *iter;
|
||||
|
||||
iter = list;
|
||||
while (iter)
|
||||
{
|
||||
if (strcmp (name, iter->setting->name) == 0)
|
||||
return iter->setting;
|
||||
|
||||
iter = iter->next;
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
char
|
||||
xsettings_byte_order (void)
|
||||
{
|
||||
CARD32 myint = 0x01020304;
|
||||
return (*(char *)&myint == 1) ? MSBFirst : LSBFirst;
|
||||
}
|
110
gnome-settings-daemon/xsettings-common.h
Normal file
110
gnome-settings-daemon/xsettings-common.h
Normal file
|
@ -0,0 +1,110 @@
|
|||
/*
|
||||
* 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.
|
||||
*
|
||||
* Author: Owen Taylor, Red Hat, Inc.
|
||||
*/
|
||||
#ifndef XSETTINGS_COMMON_H
|
||||
#define XSETTINGS_COMMON_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif /* __cplusplus */
|
||||
|
||||
typedef struct _XSettingsBuffer XSettingsBuffer;
|
||||
typedef struct _XSettingsColor XSettingsColor;
|
||||
typedef struct _XSettingsList XSettingsList;
|
||||
typedef struct _XSettingsSetting XSettingsSetting;
|
||||
|
||||
/* Types of settings possible. Enum values correspond to
|
||||
* protocol values.
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
XSETTINGS_TYPE_INT = 0,
|
||||
XSETTINGS_TYPE_STRING = 1,
|
||||
XSETTINGS_TYPE_COLOR = 2
|
||||
} XSettingsType;
|
||||
|
||||
typedef enum
|
||||
{
|
||||
XSETTINGS_SUCCESS,
|
||||
XSETTINGS_NO_MEM,
|
||||
XSETTINGS_ACCESS,
|
||||
XSETTINGS_FAILED,
|
||||
XSETTINGS_NO_ENTRY,
|
||||
XSETTINGS_DUPLICATE_ENTRY
|
||||
} XSettingsResult;
|
||||
|
||||
struct _XSettingsBuffer
|
||||
{
|
||||
char byte_order;
|
||||
size_t len;
|
||||
unsigned char *data;
|
||||
unsigned char *pos;
|
||||
};
|
||||
|
||||
struct _XSettingsColor
|
||||
{
|
||||
unsigned short red, green, blue, alpha;
|
||||
};
|
||||
|
||||
struct _XSettingsList
|
||||
{
|
||||
XSettingsSetting *setting;
|
||||
XSettingsList *next;
|
||||
};
|
||||
|
||||
struct _XSettingsSetting
|
||||
{
|
||||
char *name;
|
||||
XSettingsType type;
|
||||
|
||||
union {
|
||||
int v_int;
|
||||
char *v_string;
|
||||
XSettingsColor v_color;
|
||||
} data;
|
||||
|
||||
unsigned long last_change_serial;
|
||||
};
|
||||
|
||||
XSettingsSetting *xsettings_setting_copy (XSettingsSetting *setting);
|
||||
void xsettings_setting_free (XSettingsSetting *setting);
|
||||
int xsettings_setting_equal (XSettingsSetting *setting_a,
|
||||
XSettingsSetting *setting_b);
|
||||
|
||||
void xsettings_list_free (XSettingsList *list);
|
||||
XSettingsList *xsettings_list_copy (XSettingsList *list);
|
||||
XSettingsResult xsettings_list_insert (XSettingsList **list,
|
||||
XSettingsSetting *setting);
|
||||
XSettingsSetting *xsettings_list_lookup (XSettingsList *list,
|
||||
const char *name);
|
||||
XSettingsResult xsettings_list_delete (XSettingsList **list,
|
||||
const char *name);
|
||||
|
||||
char xsettings_byte_order (void);
|
||||
|
||||
#define XSETTINGS_PAD(n,m) ((n + m - 1) & (~(m-1)))
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif /* __cplusplus */
|
||||
|
||||
#endif /* XSETTINGS_COMMON_H */
|
424
gnome-settings-daemon/xsettings-manager.c
Normal file
424
gnome-settings-daemon/xsettings-manager.c
Normal file
|
@ -0,0 +1,424 @@
|
|||
/*
|
||||
* 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.
|
||||
*
|
||||
* Author: Owen Taylor, Red Hat, Inc.
|
||||
*/
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include <X11/Xmd.h> /* For CARD16 */
|
||||
|
||||
#include "xsettings-manager.h"
|
||||
|
||||
struct _XSettingsManager
|
||||
{
|
||||
Display *display;
|
||||
int screen;
|
||||
|
||||
Window window;
|
||||
Atom manager_atom;
|
||||
Atom selection_atom;
|
||||
Atom xsettings_atom;
|
||||
|
||||
XSettingsTerminateFunc terminate;
|
||||
void *cb_data;
|
||||
|
||||
XSettingsList *settings;
|
||||
unsigned long serial;
|
||||
};
|
||||
|
||||
XSettingsList *settings;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
Window window;
|
||||
Atom timestamp_prop_atom;
|
||||
} TimeStampInfo;
|
||||
|
||||
static Bool
|
||||
timestamp_predicate (Display *display,
|
||||
XEvent *xevent,
|
||||
XPointer arg)
|
||||
{
|
||||
TimeStampInfo *info = (TimeStampInfo *)arg;
|
||||
|
||||
if (xevent->type == PropertyNotify &&
|
||||
xevent->xproperty.window == info->window &&
|
||||
xevent->xproperty.atom == info->timestamp_prop_atom)
|
||||
return True;
|
||||
|
||||
return False;
|
||||
}
|
||||
|
||||
/**
|
||||
* get_server_time:
|
||||
* @display: display from which to get the time
|
||||
* @window: a #Window, used for communication with the server.
|
||||
* The window must have PropertyChangeMask in its
|
||||
* events mask or a hang will result.
|
||||
*
|
||||
* Routine to get the current X server time stamp.
|
||||
*
|
||||
* Return value: the time stamp.
|
||||
**/
|
||||
static Time
|
||||
get_server_time (Display *display,
|
||||
Window window)
|
||||
{
|
||||
unsigned char c = 'a';
|
||||
XEvent xevent;
|
||||
TimeStampInfo info;
|
||||
|
||||
info.timestamp_prop_atom = XInternAtom (display, "_TIMESTAMP_PROP", False);
|
||||
info.window = window;
|
||||
|
||||
XChangeProperty (display, window,
|
||||
info.timestamp_prop_atom, info.timestamp_prop_atom,
|
||||
8, PropModeReplace, &c, 1);
|
||||
|
||||
XIfEvent (display, &xevent,
|
||||
timestamp_predicate, (XPointer)&info);
|
||||
|
||||
return xevent.xproperty.time;
|
||||
}
|
||||
|
||||
Bool
|
||||
xsettings_manager_check_running (Display *display,
|
||||
int screen)
|
||||
{
|
||||
char buffer[256];
|
||||
Atom selection_atom;
|
||||
|
||||
sprintf(buffer, "_XSETTINGS_S%d", screen);
|
||||
selection_atom = XInternAtom (display, buffer, False);
|
||||
|
||||
if (XGetSelectionOwner (display, selection_atom))
|
||||
return True;
|
||||
else
|
||||
return False;
|
||||
}
|
||||
|
||||
XSettingsManager *
|
||||
xsettings_manager_new (Display *display,
|
||||
int screen,
|
||||
XSettingsTerminateFunc terminate,
|
||||
void *cb_data)
|
||||
{
|
||||
XSettingsManager *manager;
|
||||
Time timestamp;
|
||||
XClientMessageEvent xev;
|
||||
|
||||
char buffer[256];
|
||||
|
||||
manager = malloc (sizeof *manager);
|
||||
if (!manager)
|
||||
return NULL;
|
||||
|
||||
manager->display = display;
|
||||
manager->screen = screen;
|
||||
|
||||
sprintf(buffer, "_XSETTINGS_S%d", screen);
|
||||
manager->selection_atom = XInternAtom (display, buffer, False);
|
||||
manager->xsettings_atom = XInternAtom (display, "_XSETTINGS_SETTINGS", False);
|
||||
manager->manager_atom = XInternAtom (display, "MANAGER", False);
|
||||
|
||||
manager->terminate = terminate;
|
||||
manager->cb_data = cb_data;
|
||||
|
||||
manager->settings = NULL;
|
||||
manager->serial = 0;
|
||||
|
||||
manager->window = XCreateSimpleWindow (display,
|
||||
RootWindow (display, screen),
|
||||
0, 0, 10, 10, 0,
|
||||
WhitePixel (display, screen),
|
||||
WhitePixel (display, screen));
|
||||
|
||||
XSelectInput (display, manager->window, PropertyChangeMask);
|
||||
timestamp = get_server_time (display, manager->window);
|
||||
|
||||
XSetSelectionOwner (display, manager->selection_atom,
|
||||
manager->window, timestamp);
|
||||
|
||||
/* Check to see if we managed to claim the selection. If not,
|
||||
* we treat it as if we got it then immediately lost it
|
||||
*/
|
||||
|
||||
if (XGetSelectionOwner (display, manager->selection_atom) ==
|
||||
manager->window)
|
||||
{
|
||||
xev.type = ClientMessage;
|
||||
xev.window = RootWindow (display, screen);
|
||||
xev.message_type = manager->manager_atom;
|
||||
xev.format = 32;
|
||||
xev.data.l[0] = timestamp;
|
||||
xev.data.l[1] = manager->selection_atom;
|
||||
xev.data.l[2] = manager->window;
|
||||
xev.data.l[3] = 0; /* manager specific data */
|
||||
xev.data.l[4] = 0; /* manager specific data */
|
||||
|
||||
XSendEvent (display, RootWindow (display, screen),
|
||||
False, StructureNotifyMask, (XEvent *)&xev);
|
||||
}
|
||||
else
|
||||
{
|
||||
manager->terminate (manager->cb_data);
|
||||
}
|
||||
|
||||
return manager;
|
||||
}
|
||||
|
||||
void
|
||||
xsettings_manager_destroy (XSettingsManager *manager)
|
||||
{
|
||||
XDestroyWindow (manager->display, manager->window);
|
||||
|
||||
xsettings_list_free (manager->settings);
|
||||
free (manager);
|
||||
}
|
||||
|
||||
Window
|
||||
xsettings_manager_get_window (XSettingsManager *manager)
|
||||
{
|
||||
return manager->window;
|
||||
}
|
||||
|
||||
Bool
|
||||
xsettings_manager_process_event (XSettingsManager *manager,
|
||||
XEvent *xev)
|
||||
{
|
||||
if (xev->xany.window == manager->window &&
|
||||
xev->xany.type == SelectionClear &&
|
||||
xev->xselectionclear.selection == manager->selection_atom)
|
||||
{
|
||||
manager->terminate (manager->cb_data);
|
||||
return True;
|
||||
}
|
||||
|
||||
return False;
|
||||
}
|
||||
|
||||
XSettingsResult
|
||||
xsettings_manager_delete_setting (XSettingsManager *manager,
|
||||
const char *name)
|
||||
{
|
||||
return xsettings_list_delete (&settings, name);
|
||||
}
|
||||
|
||||
XSettingsResult
|
||||
xsettings_manager_set_setting (XSettingsManager *manager,
|
||||
XSettingsSetting *setting)
|
||||
{
|
||||
XSettingsSetting *old_setting = xsettings_list_lookup (settings, setting->name);
|
||||
XSettingsSetting *new_setting;
|
||||
XSettingsResult result;
|
||||
|
||||
if (old_setting)
|
||||
{
|
||||
if (xsettings_setting_equal (old_setting, setting))
|
||||
return XSETTINGS_SUCCESS;
|
||||
|
||||
xsettings_list_delete (&settings, setting->name);
|
||||
}
|
||||
|
||||
new_setting = xsettings_setting_copy (setting);
|
||||
if (!new_setting)
|
||||
return XSETTINGS_NO_MEM;
|
||||
|
||||
new_setting->last_change_serial = manager->serial;
|
||||
|
||||
result = xsettings_list_insert (&settings, new_setting);
|
||||
|
||||
if (result != XSETTINGS_SUCCESS)
|
||||
xsettings_setting_free (new_setting);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
XSettingsResult
|
||||
xsettings_manager_set_int (XSettingsManager *manager,
|
||||
const char *name,
|
||||
int value)
|
||||
{
|
||||
XSettingsSetting setting;
|
||||
|
||||
setting.name = (char *)name;
|
||||
setting.type = XSETTINGS_TYPE_INT;
|
||||
setting.data.v_int = value;
|
||||
|
||||
return xsettings_manager_set_setting (manager, &setting);
|
||||
}
|
||||
|
||||
XSettingsResult
|
||||
xsettings_manager_set_string (XSettingsManager *manager,
|
||||
const char *name,
|
||||
const char *value)
|
||||
{
|
||||
XSettingsSetting setting;
|
||||
|
||||
setting.name = (char *)name;
|
||||
setting.type = XSETTINGS_TYPE_STRING;
|
||||
setting.data.v_string = (char *)value;
|
||||
|
||||
return xsettings_manager_set_setting (manager, &setting);
|
||||
}
|
||||
|
||||
XSettingsResult
|
||||
xsettings_manager_set_color (XSettingsManager *manager,
|
||||
const char *name,
|
||||
XSettingsColor *value)
|
||||
{
|
||||
XSettingsSetting setting;
|
||||
|
||||
setting.name = (char *)name;
|
||||
setting.type = XSETTINGS_TYPE_COLOR;
|
||||
setting.data.v_color = *value;
|
||||
|
||||
return xsettings_manager_set_setting (manager, &setting);
|
||||
}
|
||||
|
||||
size_t
|
||||
setting_length (XSettingsSetting *setting)
|
||||
{
|
||||
size_t length = 8; /* type + pad + name-len + last-change-serial */
|
||||
length += XSETTINGS_PAD (strlen (setting->name), 4);
|
||||
|
||||
switch (setting->type)
|
||||
{
|
||||
case XSETTINGS_TYPE_INT:
|
||||
length += 4;
|
||||
break;
|
||||
case XSETTINGS_TYPE_STRING:
|
||||
length += 4 + XSETTINGS_PAD (strlen (setting->data.v_string), 4);
|
||||
break;
|
||||
case XSETTINGS_TYPE_COLOR:
|
||||
length += 8;
|
||||
break;
|
||||
}
|
||||
|
||||
return length;
|
||||
}
|
||||
|
||||
void
|
||||
setting_store (XSettingsSetting *setting,
|
||||
XSettingsBuffer *buffer)
|
||||
{
|
||||
size_t string_len;
|
||||
size_t length;
|
||||
|
||||
*(buffer->pos++) = setting->type;
|
||||
*(buffer->pos++) = 0;
|
||||
|
||||
string_len = strlen (setting->name);
|
||||
*(CARD16 *)(buffer->pos) = string_len;
|
||||
buffer->pos += 2;
|
||||
|
||||
length = XSETTINGS_PAD (string_len, 4);
|
||||
memcpy (buffer->pos, setting->name, string_len);
|
||||
length -= string_len;
|
||||
buffer->pos += string_len;
|
||||
|
||||
while (length > 0)
|
||||
{
|
||||
*(buffer->pos++) = 0;
|
||||
length--;
|
||||
}
|
||||
|
||||
*(CARD32 *)(buffer->pos) = setting->last_change_serial;
|
||||
buffer->pos += 4;
|
||||
|
||||
switch (setting->type)
|
||||
{
|
||||
case XSETTINGS_TYPE_INT:
|
||||
*(CARD32 *)(buffer->pos) = setting->data.v_int;
|
||||
buffer->pos += 4;
|
||||
break;
|
||||
case XSETTINGS_TYPE_STRING:
|
||||
string_len = strlen (setting->data.v_string);
|
||||
*(CARD32 *)(buffer->pos) = string_len;
|
||||
buffer->pos += 4;
|
||||
|
||||
length = XSETTINGS_PAD (string_len, 4);
|
||||
memcpy (buffer->pos, setting->data.v_string, string_len);
|
||||
length -= string_len;
|
||||
buffer->pos += string_len;
|
||||
|
||||
while (length > 0)
|
||||
{
|
||||
*(buffer->pos++) = 0;
|
||||
length--;
|
||||
}
|
||||
break;
|
||||
case XSETTINGS_TYPE_COLOR:
|
||||
*(CARD16 *)(buffer->pos) = setting->data.v_color.red;
|
||||
*(CARD16 *)(buffer->pos + 2) = setting->data.v_color.green;
|
||||
*(CARD16 *)(buffer->pos + 4) = setting->data.v_color.blue;
|
||||
*(CARD16 *)(buffer->pos + 6) = setting->data.v_color.alpha;
|
||||
buffer->pos += 8;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
XSettingsResult
|
||||
xsettings_manager_notify (XSettingsManager *manager)
|
||||
{
|
||||
XSettingsBuffer buffer;
|
||||
XSettingsList *iter;
|
||||
int n_settings = 0;
|
||||
|
||||
buffer.len = 12; /* byte-order + pad + SERIAL + N_SETTINGS */
|
||||
|
||||
iter = settings;
|
||||
while (iter)
|
||||
{
|
||||
buffer.len += setting_length (iter->setting);
|
||||
n_settings++;
|
||||
iter = iter->next;
|
||||
}
|
||||
|
||||
buffer.data = buffer.pos = malloc (buffer.len);
|
||||
if (!buffer.data)
|
||||
return XSETTINGS_NO_MEM;
|
||||
|
||||
*buffer.pos = xsettings_byte_order ();
|
||||
|
||||
buffer.pos += 4;
|
||||
*(CARD32 *)buffer.pos = manager->serial++;
|
||||
buffer.pos += 4;
|
||||
*(CARD32 *)buffer.pos = n_settings;
|
||||
buffer.pos += 4;
|
||||
|
||||
iter = settings;
|
||||
while (iter)
|
||||
{
|
||||
setting_store (iter->setting, &buffer);
|
||||
iter = iter->next;
|
||||
}
|
||||
|
||||
XChangeProperty (manager->display, manager->window,
|
||||
manager->xsettings_atom, manager->xsettings_atom,
|
||||
8, PropModeReplace, buffer.data, buffer.len);
|
||||
|
||||
free (buffer.data);
|
||||
|
||||
return XSETTINGS_SUCCESS;
|
||||
}
|
||||
|
71
gnome-settings-daemon/xsettings-manager.h
Normal file
71
gnome-settings-daemon/xsettings-manager.h
Normal file
|
@ -0,0 +1,71 @@
|
|||
/*
|
||||
* 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.
|
||||
*
|
||||
* Author: Owen Taylor, Red Hat, Inc.
|
||||
*/
|
||||
#ifndef XSETTINGS_MANAGER_H
|
||||
#define XSETTINGS_MANAGER_H
|
||||
|
||||
#include <X11/Xlib.h>
|
||||
#include "xsettings-common.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif /* __cplusplus */
|
||||
|
||||
typedef struct _XSettingsManager XSettingsManager;
|
||||
|
||||
typedef void (*XSettingsTerminateFunc) (void *cb_data);
|
||||
|
||||
Bool xsettings_manager_check_running (Display *display,
|
||||
int screen);
|
||||
|
||||
XSettingsManager *xsettings_manager_new (Display *display,
|
||||
int screen,
|
||||
XSettingsTerminateFunc terminate,
|
||||
void *cb_data);
|
||||
|
||||
void xsettings_manager_destroy (XSettingsManager *manager);
|
||||
Window xsettings_manager_get_window (XSettingsManager *manager);
|
||||
Bool xsettings_manager_process_event (XSettingsManager *manager,
|
||||
XEvent *xev);
|
||||
|
||||
XSettingsResult xsettings_manager_delete_setting (XSettingsManager *manager,
|
||||
const char *name);
|
||||
XSettingsResult xsettings_manager_set_setting (XSettingsManager *manager,
|
||||
XSettingsSetting *setting);
|
||||
XSettingsResult xsettings_manager_set_int (XSettingsManager *manager,
|
||||
const char *name,
|
||||
int value);
|
||||
XSettingsResult xsettings_manager_set_string (XSettingsManager *manager,
|
||||
const char *name,
|
||||
const char *value);
|
||||
XSettingsResult xsettings_manager_set_color (XSettingsManager *manager,
|
||||
const char *name,
|
||||
XSettingsColor *value);
|
||||
XSettingsResult xsettings_manager_notify (XSettingsManager *manager);
|
||||
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif /* __cplusplus */
|
||||
|
||||
#endif /* XSETTINGS_MANAGER_H */
|
7
schemas/Makefile.am
Normal file
7
schemas/Makefile.am
Normal file
|
@ -0,0 +1,7 @@
|
|||
schemadir = $(sysconfdir)/gconf/schemas
|
||||
schema_DATA = peripherals.schemas
|
||||
|
||||
|
||||
##FIXME: s/gconftool/$(GCONFTOOL) sometime
|
||||
install-data-local:
|
||||
GCONF_CONFIG_SOURCE=$(GCONF_CONFIG_SOURCE) gconftool --makefile-install-rule $(srcdir)/$(schema_DATA)
|
74
schemas/peripherals.schemas
Normal file
74
schemas/peripherals.schemas
Normal file
|
@ -0,0 +1,74 @@
|
|||
<?xml version="1.0"?>
|
||||
<gconfschemafile>
|
||||
<schemalist>
|
||||
<schema>
|
||||
<applyto>/desktop/gnome/peripherals/mouse/left_handed</applyto>
|
||||
<key>/schemas/desktop/gnome/peripherals/mouse/left_handed</key>
|
||||
<owner>gnome</owner>
|
||||
<type>bool</type>
|
||||
<default>true</default>
|
||||
<locale name="C">
|
||||
<short>Mouse button orientation</short>
|
||||
<long>Swap left and right mouse buttons for left-handed mice</long>
|
||||
</locale>
|
||||
</schema>
|
||||
<schema>
|
||||
<applyto>/desktop/gnome/peripherals/mouse/single_click</applyto>
|
||||
<key>/schemas/desktop/gnome/peripherals/mouse/single_click</key>
|
||||
<owner>gnome</owner>
|
||||
<type>bool</type>
|
||||
<default>true</default>
|
||||
<locale name="C">
|
||||
<short>Single Click</short>
|
||||
<long>Single click to open icons</long>
|
||||
</locale>
|
||||
</schema>
|
||||
<schema>
|
||||
<applyto>/desktop/gnome/peripherals/mouse/motion_acceleration</applyto>
|
||||
<key>/schemas/desktop/gnome/peripherals/mouse/motion_acceleration</key>
|
||||
<owner>gnome</owner>
|
||||
<type>float</type>
|
||||
<default>-1</default>
|
||||
<locale name="C">
|
||||
<short>Single Click</short>
|
||||
<long>Acceleration multiplier for mouse motion. A value of -1
|
||||
is the system default.</long>
|
||||
</locale>
|
||||
</schema>
|
||||
<schema>
|
||||
<applyto>/desktop/gnome/peripherals/mouse/motion_threshold</applyto>
|
||||
<key>/schemas/desktop/gnome/peripherals/mouse/motion_threshold</key>
|
||||
<owner>gnome</owner>
|
||||
<type>float</type>
|
||||
<default>-1</default>
|
||||
<locale name="C">
|
||||
<short>Motion Threshold</short>
|
||||
<long>Distance in pixels the pointer must move before
|
||||
accelerated mouse motion is activated. A value of -1 is the
|
||||
system default.</long>
|
||||
</locale>
|
||||
</schema>
|
||||
<schema>
|
||||
<applyto>/desktop/gnome/peripherals/mouse/drag_threshold</applyto>
|
||||
<key>/schemas/desktop/gnome/peripherals/mouse/drag_threshold</key>
|
||||
<owner>gnome</owner>
|
||||
<type>int</type>
|
||||
<default>8</default>
|
||||
<locale name="C">
|
||||
<short>Drag Threshold</short>
|
||||
<long>Distance before a drag is started</long>
|
||||
</locale>
|
||||
</schema>
|
||||
<schema>
|
||||
<applyto>/desktop/gnome/peripherals/mouse/double_click</applyto>
|
||||
<key>/schemas/desktop/gnome/peripherals/mouse/double_click</key>
|
||||
<owner>gnome</owner>
|
||||
<type>int</type>
|
||||
<default>400</default>
|
||||
<locale name="C">
|
||||
<short>Double Click Time</short>
|
||||
<long>Length of a double click</long>
|
||||
</locale>
|
||||
</schema>
|
||||
</schemalist>
|
||||
</gconfschemafile>
|
Loading…
Add table
Add a link
Reference in a new issue