Enabling DBUS, getting rid of bonobo, libgswitchit API update

This commit is contained in:
Sergey V. Udaltsov 2006-06-25 02:16:06 +00:00
parent 98a2fc742a
commit 9412291893
12 changed files with 375 additions and 173 deletions

View file

@ -6,3 +6,7 @@ GNOME_SettingsDaemon-skels.c
GNOME_SettingsDaemon-stubs.c GNOME_SettingsDaemon-stubs.c
GNOME_SettingsDaemon.h GNOME_SettingsDaemon.h
GNOME_SettingsDaemon.server GNOME_SettingsDaemon.server
org.gnome.SettingsDaemon.service
gnome-settings-daemon.pc
gnome-settings-client.h
gnome-settings-server.h

View file

@ -1,3 +1,14 @@
2006-06-23 Sergey Udaltsov <svu@gnome.org>
* factory.c, gnome-settings-daemon.c,
gnome-settings-daemon.h,gnome-settings-daemon.pc.in,
gnome-settings-dbus.c, gnome-settings-keyboard-xkb.c,
gnome-settings-keyboard-xkb.h, gsd-infos.xml,
org.gnome.SettingsDaemon.service.in: g-s-d is now DBUS-enabled,
implements 2 interfaces - one for gnome-session, another for keyboard
indication (see gsd-infos.xml)
Also, major libgswitchit API change.
2006-05-24 Paolo Borelli <pborelli@katamail.com> 2006-05-24 Paolo Borelli <pborelli@katamail.com>
Fixes #342570 Fixes #342570

View file

@ -1,6 +1,6 @@
SUBDIRS = xrdb actions SUBDIRS = xrdb actions
INCLUDES=$(LIBXKLAVIER_CFLAGS) $(GNOME_SETTINGS_DAEMON_CFLAGS) -I$(top_srcdir)/libbackground -I$(top_srcdir) \ INCLUDES=$(DBUS_CFLAGS) $(LIBXKLAVIER_CFLAGS) $(GNOME_SETTINGS_DAEMON_CFLAGS) -I$(top_srcdir)/libbackground -I$(top_srcdir) \
-DGNOMELOCALEDIR="\"$(datadir)/locale\"" \ -DGNOMELOCALEDIR="\"$(datadir)/locale\"" \
-DESD_SERVER="\"$(ESD_SERVER)\"" \ -DESD_SERVER="\"$(ESD_SERVER)\"" \
-DDATADIR="\"$(datadir)\"" \ -DDATADIR="\"$(datadir)\"" \
@ -41,6 +41,8 @@ gnome_settings_daemon_SOURCES = \
gnome-settings-default-editor.h \ gnome-settings-default-editor.h \
gnome-settings-gtk1theme.c \ gnome-settings-gtk1theme.c \
gnome-settings-gtk1theme.h \ gnome-settings-gtk1theme.h \
gnome-settings-server.h \
gnome-settings-dbus.c \
gnome-settings-xrdb.c \ gnome-settings-xrdb.c \
gnome-settings-xrdb.h \ gnome-settings-xrdb.h \
xsettings-common.c \ xsettings-common.c \
@ -66,6 +68,7 @@ gnome_settings_daemon_SOURCES = \
# $(AccessX_files) # $(AccessX_files)
gnome_settings_daemon_LDADD = \ gnome_settings_daemon_LDADD = \
$(DBUS_LIBS) \
$(LIBXKLAVIER_LIBS) \ $(LIBXKLAVIER_LIBS) \
$(top_builddir)/libbackground/libbackground.la \ $(top_builddir)/libbackground/libbackground.la \
$(top_builddir)/libsounds/libsounds.a \ $(top_builddir)/libsounds/libsounds.a \
@ -81,36 +84,35 @@ gnome_settings_daemon_LDADD = \
# AccessXproto.h \ # AccessXproto.h \
# AccessXlibint.h # AccessXlibint.h
CORBA_GENERATED_HEADER_FILES = GNOME_SettingsDaemon.h
CORBA_GENERATED = \
$(CORBA_GENERATED_HEADER_FILES) \
GNOME_SettingsDaemon-common.c \
GNOME_SettingsDaemon-stubs.c \
GNOME_SettingsDaemon-skels.c
BUILT_SOURCES=$(CORBA_GENERATED) BUILT_SOURCES=$(CORBA_GENERATED)
idl_dir = $(top_srcdir)/idl
IDL_FLAGS = -D__GNOME_SettingsDaemon_COMPILATION -I $(idl_dir) -I $(datadir)/idl \
-I $(LIBBONOBO_IDL_DIR) \
-I $(BONOBO_ACTIVATION_IDL_DIR)
$(CORBA_GENERATED): $(idl_dir)/GNOME_SettingsDaemon.idl $(ORBIT_IDL)
$(ORBIT_IDL) $(IDL_FLAGS) $(idl_dir)/GNOME_SettingsDaemon.idl
Gladedir = $(GNOMECC_GLADE_DIR) Gladedir = $(GNOMECC_GLADE_DIR)
Glade_DATA = modmap-dialog.glade Glade_DATA = modmap-dialog.glade
serverfile = GNOME_SettingsDaemon.server.in Dbusapidir = $(includedir)/gnome-settings-daemon-2.0/gnome-settings-daemon
serverdir = $(libdir)/bonobo/servers Dbusapi_DATA = gnome-settings-client.h
install-data-hook :
$(mkinstalldirs) $(DESTDIR)$(serverdir)
sed -e "s|\@LIBEXECDIR\@|$(libexecdir)|" $(srcdir)/$(serverfile) > $(DESTDIR)$(serverdir)/$(serverfile:.in=)
EXTRA_DIST = $(serverfile) $(Glade_DATA) #Rule to generate the binding headers
gnome-settings-server.h: gsd-infos.xml
dbus-binding-tool --prefix=settings_daemon --mode=glib-server $< > $@
gnome-settings-client.h: gsd-infos.xml
dbus-binding-tool --prefix=settings_daemon --mode=glib-client $< > $@
# DBUS stuff
servicedir = $(DBUS_SERVICES_DIR)
service_in_files = org.gnome.SettingsDaemon.service.in
service_DATA = $(service_in_files:.service.in=.service)
org.gnome.SettingsDaemon.service: org.gnome.SettingsDaemon.service.in Makefile
@sed -e "s|\@libexecdir\@|$(libexecdir)|" $< > $@
EXTRA_DIST = $(serverfile) $(Glade_DATA) $(Dbusapi_DATA) \
gnome-settings-daemon.pc.in gsd-infos.xml org.gnome.SettingsDaemon.service.in
CLEANFILES = $(BUILT_SOURCES) CLEANFILES = $(BUILT_SOURCES)
pkgconfigdir = $(libdir)/pkgconfig
pkgconfig_DATA = gnome-settings-daemon.pc
uninstall-local: uninstall-local:
rm -f $(DESTDIR)$(serverdir)/$(serverfile:.in=) rm -f $(DESTDIR)$(serverdir)/$(serverfile:.in=)

View file

@ -2,10 +2,8 @@
#include "gnome-settings-daemon.h" #include "gnome-settings-daemon.h"
#include <libintl.h>
#include <string.h> #include <string.h>
#include <bonobo.h>
#include <bonobo/bonobo-object.h>
#include <bonobo/bonobo-generic-factory.h>
#include <gconf/gconf.h> #include <gconf/gconf.h>
@ -13,32 +11,8 @@
#include <libgnomeui/gnome-ui-init.h> #include <libgnomeui/gnome-ui-init.h>
#include <libgnomeui/gnome-client.h> #include <libgnomeui/gnome-client.h>
static BonoboObject *services_server = NULL;
GConfClient *conf_client = NULL; GConfClient *conf_client = NULL;
static void
register_server (BonoboObject *server)
{
Bonobo_RegistrationResult ret;
GSList *reg_env;
char *display;
char *p;
display = gdk_display_get_name (gdk_display_get_default ());
reg_env = bonobo_activation_registration_env_set (NULL, "DISPLAY", display);
ret = bonobo_activation_register_active_server ("OAFIID:GNOME_SettingsDaemon",
BONOBO_OBJREF (server),
reg_env);
if (ret != Bonobo_ACTIVATION_REG_SUCCESS) {
g_warning ("Encountered problems registering the settings daemon with bonobo-activation. "
"Clients may not detect that the settings daemon is already running.");
}
bonobo_activation_registration_env_free (reg_env);
}
int main (int argc, char *argv []) int main (int argc, char *argv [])
{ {
GnomeClient *session; GnomeClient *session;
@ -56,16 +30,9 @@ int main (int argc, char *argv [])
GNOME_CLIENT_PARAM_SM_CONNECT, FALSE, GNOME_CLIENT_PARAM_SM_CONNECT, FALSE,
NULL); NULL);
if (!bonobo_init (&argc, argv)) {
g_error (_("Could not initialize Bonobo"));
}
gconf_init (argc, argv, NULL); /* exits w/ message on failure */ gconf_init (argc, argv, NULL); /* exits w/ message on failure */
/* start the settings daemon */ gnome_settings_daemon_new ();
services_server = BONOBO_OBJECT (gnome_settings_daemon_new ());
register_server (services_server);
session = gnome_master_client (); session = gnome_master_client ();
gnome_client_set_restart_command (session, 2, restart_argv); gnome_client_set_restart_command (session, 2, restart_argv);

View file

@ -59,8 +59,6 @@
#include "gnome-settings-xrdb.h" #include "gnome-settings-xrdb.h"
#include "gnome-settings-typing-break.h" #include "gnome-settings-typing-break.h"
#include "GNOME_SettingsDaemon.h"
#include "clipboard-manager.h" #include "clipboard-manager.h"
static GObjectClass *parent_class = NULL; static GObjectClass *parent_class = NULL;
@ -214,18 +212,6 @@ manager_event_filter (GdkXEvent *xevent,
return GDK_FILTER_CONTINUE; return GDK_FILTER_CONTINUE;
} }
static CORBA_boolean
awake_impl (PortableServer_Servant servant,
const CORBA_char *service,
CORBA_Environment *ev)
{
#if 0
printf ("I received an activate request for %s\n", service);
#endif
return TRUE;
}
static void static void
finalize (GObject *object) finalize (GObject *object)
{ {
@ -257,8 +243,6 @@ gnome_settings_daemon_class_init (GnomeSettingsDaemonClass *klass)
object_class->finalize = finalize; object_class->finalize = finalize;
klass->epv.awake = awake_impl;
parent_class = g_type_class_peek_parent (klass); parent_class = g_type_class_peek_parent (klass);
} }
@ -268,8 +252,8 @@ gnome_settings_daemon_init (GnomeSettingsDaemon *settings)
settings->private = g_new (GnomeSettingsDaemonPrivate, 1); settings->private = g_new (GnomeSettingsDaemonPrivate, 1);
} }
BONOBO_TYPE_FUNC_FULL(GnomeSettingsDaemon, GNOME_SettingsDaemon, G_DEFINE_TYPE (GnomeSettingsDaemon, gnome_settings_daemon,
BONOBO_TYPE_OBJECT, gnome_settings_daemon) G_TYPE_OBJECT)
GObject * GObject *
gnome_settings_daemon_new (void) gnome_settings_daemon_new (void)

View file

@ -30,8 +30,6 @@
#include <bonobo/bonobo-object.h> #include <bonobo/bonobo-object.h>
#include "GNOME_SettingsDaemon.h"
typedef void (* KeyCallbackFunc) (GConfEntry *entry); typedef void (* KeyCallbackFunc) (GConfEntry *entry);
void gnome_settings_daemon_register_callback (const char *dir, void gnome_settings_daemon_register_callback (const char *dir,
@ -54,14 +52,13 @@ typedef struct _GnomeSettingsDaemonPrivate GnomeSettingsDaemonPrivate;
struct _GnomeSettingsDaemon struct _GnomeSettingsDaemon
{ {
BonoboObject parent_instance; GObject parent_instance;
GnomeSettingsDaemonPrivate *private; GnomeSettingsDaemonPrivate *private;
}; };
struct _GnomeSettingsDaemonClass struct _GnomeSettingsDaemonClass
{ {
BonoboObjectClass parent_class; GObjectClass parent_class;
POA_GNOME_SettingsDaemon__epv epv;
}; };
GType gnome_settings_daemon_get_type (void); GType gnome_settings_daemon_get_type (void);

View file

@ -0,0 +1,11 @@
prefix=@prefix@
exec_prefix=@exec_prefix@
libdir=@libdir@
includedir=@includedir@
Name: gnome-settings-daemon
Description: Utility library for accessing gnome-settings-daemon over DBUS
Requires: glib-2.0 dbus-1 dbus-glib-1
Version: @VERSION@
Libs: -L${libdir}
Cflags: -DDBUS_API_SUBJECT_TO_CHANGE -I${includedir}/gnome-settings-daemon-2.0

View file

@ -0,0 +1,182 @@
#include <stdio.h>
#include <X11/Xlib.h>
#include <dbus/dbus-glib-bindings.h>
#include "gnome-settings-keyboard-xkb.h"
static GObjectClass *parent_class = NULL;
typedef struct KeyboardConfigRegistry KeyboardConfigRegistry;
typedef struct KeyboardConfigRegistryClass KeyboardConfigRegistryClass;
struct KeyboardConfigRegistry {
GObject parent;
XklConfigRegistry *registry;
};
struct KeyboardConfigRegistryClass {
GObjectClass parent;
DBusGConnection *connection;
};
#define KEYBOARD_CONFIG_TYPE_REGISTRY (keyboard_config_registry_get_type ())
#define KEYBOARD_CONFIG_REGISTRY(object) (G_TYPE_CHECK_INSTANCE_CAST ((object), KEYBOARD_CONFIG_TYPE_REGISTRY, KeyboardConfigRegistry))
#define KEYBOARD_CONFIG_REGISTRY_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), KEYBOARD_CONFIG_TYPE_REGISTRY, KeyboardConfigRegistryClass))
#define KEYBOARD_CONFIG_IS_REGISTRY(object) (G_TYPE_CHECK_INSTANCE_TYPE ((object), KEYBOARD_CONFIG_TYPE_REGISTRY))
#define KEYBOARD_CONFIG_IS_REGISTRY_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), KEYBOARD_CONFIG_TYPE_REGISTRY))
#define KEYBOARD_CONFIG_REGISTRY_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), KEYBOARD_CONFIG_TYPE_REGISTRY, KeyboardConfigRegistryClass))
gboolean
settings_daemon_awake (GObject * object, GError ** error)
{
return TRUE;
}
gboolean
keyboard_config_registry_get_current_descriptions_as_utf8
(KeyboardConfigRegistry * registry,
gchar *** short_layout_descriptions,
gchar *** long_layout_descriptions,
gchar *** short_variant_descriptions,
gchar *** long_variant_descriptions, GError ** error) {
if (!
(xkl_engine_get_features (xkl_engine) &
XKLF_MULTIPLE_LAYOUTS_SUPPORTED))
return FALSE;
XklConfigRec *xkl_config = xkl_config_rec_new ();
if (!xkl_config_rec_get_from_server (xkl_config, xkl_engine))
return FALSE;
char **pl = xkl_config->layouts;
char **pv = xkl_config->variants;
guint total_layouts = g_strv_length (xkl_config->layouts);
gchar **sld = *short_layout_descriptions =
g_new0 (char *, total_layouts + 1);
gchar **lld = *long_layout_descriptions =
g_new0 (char *, total_layouts + 1);
gchar **svd = *short_variant_descriptions =
g_new0 (char *, total_layouts + 1);
gchar **lvd = *long_variant_descriptions =
g_new0 (char *, total_layouts + 1);
while (pl != NULL && *pl != NULL) {
XklConfigItem item;
g_snprintf (item.name, sizeof item.name, "%s", *pl);
if (xkl_config_registry_find_layout
(registry->registry, &item)) {
*sld++ = g_strdup (item.short_description);
*lld++ = g_strdup (item.description);
} else {
*sld++ = g_strdup ("");
*lld++ = g_strdup ("");
}
if (*pv != NULL) {
g_snprintf (item.name, sizeof item.name, "%s",
*pv);
if (xkl_config_registry_find_variant
(registry->registry, *pl, &item)) {
*svd = g_strdup (item.short_description);
*lvd = g_strdup (item.description);
} else {
*svd++ = g_strdup ("");
*lvd++ = g_strdup ("");
}
} else {
*svd++ = g_strdup ("");
*lvd++ = g_strdup ("");
}
*pl++, *pv++;
}
g_object_unref (G_OBJECT (xkl_config));
return TRUE;
}
G_DEFINE_TYPE (KeyboardConfigRegistry, keyboard_config_registry,
G_TYPE_OBJECT)
#include "gnome-settings-server.h"
static void
finalize (GObject * object)
{
KeyboardConfigRegistry *registry;
registry = KEYBOARD_CONFIG_REGISTRY (object);
if (registry->registry == NULL) {
return;
}
g_object_unref (registry->registry);
registry->registry = NULL;
g_object_unref (xkl_engine);
G_OBJECT_CLASS (parent_class)->finalize (object);
}
static void
keyboard_config_registry_class_init (KeyboardConfigRegistryClass * klass)
{
GError *error = NULL;
GObjectClass *object_class;
/* Init the DBus connection, per-klass */
klass->connection = dbus_g_bus_get (DBUS_BUS_SESSION, &error);
if (klass->connection == NULL) {
g_warning ("Unable to connect to dbus: %s",
error->message);
g_error_free (error);
return;
}
/* &dbus_glib__object_info is provided in the server-bindings.h file */
dbus_g_object_type_install_info (KEYBOARD_CONFIG_TYPE_REGISTRY,
&dbus_glib_settings_daemon_object_info);
object_class = G_OBJECT_CLASS (klass);
object_class->finalize = finalize;
parent_class = g_type_class_peek_parent (klass);
}
static void
keyboard_config_registry_init (KeyboardConfigRegistry * registry)
{
GError *error = NULL;
DBusGProxy *driver_proxy;
KeyboardConfigRegistryClass *klass =
KEYBOARD_CONFIG_REGISTRY_GET_CLASS (registry);
unsigned request_ret;
/* Register DBUS path */
dbus_g_connection_register_g_object (klass->connection,
"/org/gnome/SettingsDaemon",
G_OBJECT (registry));
/* Register the service name, the constant here are defined in dbus-glib-bindings.h */
driver_proxy = dbus_g_proxy_new_for_name (klass->connection,
DBUS_SERVICE_DBUS,
DBUS_PATH_DBUS,
DBUS_INTERFACE_DBUS);
if (!org_freedesktop_DBus_request_name (driver_proxy, "org.gnome.SettingsDaemon", 0, &request_ret, /* See tutorial for more infos about these */
&error)) {
g_warning ("Unable to register service: %s",
error->message);
g_error_free (error);
}
g_object_unref (driver_proxy);
/* Init libxklavier stuff */
g_object_ref (xkl_engine);
registry->registry = xkl_config_registry_get_instance (xkl_engine);
xkl_config_registry_load (registry->registry);
}

View file

@ -35,24 +35,23 @@
#include <string.h> #include <string.h>
#include <time.h> #include <time.h>
#include <libxklavier/xklavier.h>
#include <libgswitchit/gswitchit_config.h> #include <libgswitchit/gswitchit_config.h>
#include "gnome-settings-keyboard-xkb.h" #include "gnome-settings-keyboard-xkb.h"
#include "gnome-settings-daemon.h" #include "gnome-settings-daemon.h"
static XklEngine *engine; XklEngine *xkl_engine;
static GSwitchItConfig currentConfig; static GSwitchItConfig current_config;
static GSwitchItKbdConfig currentKbdConfig; static GSwitchItKbdConfig current_kbd_config;
/* never terminated */ /* never terminated */
static GSwitchItKbdConfig initialSysKbdConfig; static GSwitchItKbdConfig initial_sys_kbd_config;
static gboolean initedOk; static gboolean inited_ok;
static PostActivationCallback paCallback = NULL; static PostActivationCallback pa_callback = NULL;
static void *paCallbackUserData = NULL; static void *pa_callback_user_data = NULL;
static const char KNOWN_FILES_KEY[] = static const char KNOWN_FILES_KEY[] =
"/desktop/gnome/peripherals/keyboard/general/known_file_list"; "/desktop/gnome/peripherals/keyboard/general/known_file_list";
@ -130,39 +129,40 @@ activation_error (void)
static void static void
apply_settings (void) apply_settings (void)
{ {
if (!initedOk) if (!inited_ok)
return; return;
GSwitchItConfigLoadFromGConf (&currentConfig); gswitchit_config_load_from_gconf (&current_config);
/* again, probably it would be nice to compare things /* again, probably it would be nice to compare things
before activating them */ before activating them */
GSwitchItConfigActivate (&currentConfig); gswitchit_config_activate (&current_config);
} }
static void static void
apply_xkb_settings (void) apply_xkb_settings (void)
{ {
GConfClient *confClient; GConfClient *conf_client;
GSwitchItKbdConfig currentSysKbdConfig; GSwitchItKbdConfig current_sys_kbd_config;
if (!initedOk) if (!inited_ok)
return; return;
confClient = gnome_settings_daemon_get_conf_client (); conf_client = gnome_settings_daemon_get_conf_client ();
GSwitchItKbdConfigInit (&currentSysKbdConfig, confClient, engine); gswitchit_kbd_config_init (&current_sys_kbd_config, conf_client,
xkl_engine);
GSwitchItKbdConfigLoadFromGConf (&currentKbdConfig, gswitchit_kbd_config_load_from_gconf (&current_kbd_config,
&initialSysKbdConfig); &initial_sys_kbd_config);
GSwitchItKbdConfigLoadFromXCurrent (&currentSysKbdConfig); gswitchit_kbd_config_load_from_x_current (&current_sys_kbd_config);
/* Activate - only if different! */ /* Activate - only if different! */
if (!GSwitchItKbdConfigEquals if (!gswitchit_kbd_config_equals
(&currentKbdConfig, &currentSysKbdConfig)) { (&current_kbd_config, &current_sys_kbd_config)) {
if (GSwitchItKbdConfigActivate (&currentKbdConfig)) { if (gswitchit_kbd_config_activate (&current_kbd_config)) {
GSwitchItKbdConfigSaveToGConfBackup gswitchit_kbd_config_save_to_gconf_backup
(&initialSysKbdConfig); (&initial_sys_kbd_config);
if (paCallback != NULL) { if (pa_callback != NULL) {
(*paCallback) (paCallbackUserData); (*pa_callback) (pa_callback_user_data);
} }
} else { } else {
g_warning g_warning
@ -173,7 +173,7 @@ apply_xkb_settings (void)
xkl_debug (100, xkl_debug (100,
"Actual KBD configuration was not changed: redundant notification\n"); "Actual KBD configuration was not changed: redundant notification\n");
GSwitchItKbdConfigTerm (&currentSysKbdConfig); gswitchit_kbd_config_term (&current_sys_kbd_config);
} }
static void static void
@ -181,29 +181,29 @@ gnome_settings_keyboard_xkb_sysconfig_changed_response (GtkDialog * dialog,
SysConfigChangedMsgResponse SysConfigChangedMsgResponse
what2do) what2do)
{ {
GConfClient *confClient; GConfClient *conf_client;
GSwitchItKbdConfig emptyKbdConfig; GSwitchItKbdConfig empty_kbd_config;
gboolean dontShowAgain = gboolean dont_show_again =
gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON
(g_object_get_data (g_object_get_data
(G_OBJECT (dialog), (G_OBJECT (dialog),
"chkDontShowAgain"))); "chkDontShowAgain")));
confClient = gnome_settings_daemon_get_conf_client (); conf_client = gnome_settings_daemon_get_conf_client ();
switch (what2do) { switch (what2do) {
case RESPONSE_USE_X: case RESPONSE_USE_X:
GSwitchItKbdConfigInit (&emptyKbdConfig, confClient, gswitchit_kbd_config_init (&empty_kbd_config, conf_client,
engine); xkl_engine);
GSwitchItKbdConfigSaveToGConf (&emptyKbdConfig); gswitchit_kbd_config_save_to_gconf (&empty_kbd_config);
break; break;
case RESPONSE_USE_GNOME: case RESPONSE_USE_GNOME:
/* Do absolutely nothing - just keep things the way they are */ /* Do absolutely nothing - just keep things the way they are */
break; break;
} }
if (dontShowAgain) if (dont_show_again)
gconf_client_set_bool (confClient, gconf_client_set_bool (conf_client,
DISABLE_SYSCONF_CHANGED_WARNING_KEY, DISABLE_SYSCONF_CHANGED_WARNING_KEY,
TRUE, NULL); TRUE, NULL);
@ -213,63 +213,73 @@ gnome_settings_keyboard_xkb_sysconfig_changed_response (GtkDialog * dialog,
static void static void
gnome_settings_keyboard_xkb_analyze_sysconfig (void) gnome_settings_keyboard_xkb_analyze_sysconfig (void)
{ {
GConfClient *confClient; GConfClient *conf_client;
GSwitchItKbdConfig backupGConfKbdConfig; GSwitchItKbdConfig backup_gconf_kbd_config;
gboolean isConfigChanged, dontShow; gboolean is_config_changed, dont_show;
if (!initedOk) if (!inited_ok)
return; return;
confClient = gnome_settings_daemon_get_conf_client (); conf_client = gnome_settings_daemon_get_conf_client ();
GSwitchItKbdConfigInit (&backupGConfKbdConfig, confClient, engine); gswitchit_kbd_config_init (&backup_gconf_kbd_config, conf_client,
GSwitchItKbdConfigInit (&initialSysKbdConfig, confClient, engine); xkl_engine);
dontShow = gswitchit_kbd_config_init (&initial_sys_kbd_config, conf_client,
gconf_client_get_bool (confClient, xkl_engine);
dont_show =
gconf_client_get_bool (conf_client,
DISABLE_SYSCONF_CHANGED_WARNING_KEY, DISABLE_SYSCONF_CHANGED_WARNING_KEY,
NULL); NULL);
GSwitchItKbdConfigLoadFromGConfBackup (&backupGConfKbdConfig); gswitchit_kbd_config_load_from_gconf_backup
GSwitchItKbdConfigLoadFromXInitial (&initialSysKbdConfig); (&backup_gconf_kbd_config);
gswitchit_kbd_config_load_from_x_initial (&initial_sys_kbd_config);
isConfigChanged = g_slist_length (backupGConfKbdConfig.layouts) && is_config_changed =
!GSwitchItKbdConfigEquals (&initialSysKbdConfig, g_slist_length (backup_gconf_kbd_config.layouts)
&backupGConfKbdConfig); && !gswitchit_kbd_config_equals (&initial_sys_kbd_config,
&backup_gconf_kbd_config);
/* config was changed!!! */ /* config was changed!!! */
if (isConfigChanged) { if (is_config_changed) {
if (dontShow) { if (dont_show) {
g_warning g_warning
("The system configuration changed - but we remain silent\n"); ("The system configuration changed - but we remain silent\n");
} else { } else {
GtkWidget *chkDontShowAgain = GtkWidget *chk_dont_show_again =
gtk_check_button_new_with_mnemonic (_ gtk_check_button_new_with_mnemonic (_
("Do _not show this warning again")); ("Do _not show this warning again"));
GtkWidget *alignDontShowAgain = gtk_alignment_new (0.5, 0.5, 0, 0); GtkWidget *align_dont_show_again =
gtk_alignment_new (0.5, 0.5, 0, 0);
GtkWidget *msg; GtkWidget *msg;
char *gnome_settings = GSwitchItKbdConfigToString(&backupGConfKbdConfig);
char *system_settings = GSwitchItKbdConfigToString(&initialSysKbdConfig);
msg = gtk_message_dialog_new_with_markup ( char *gnome_settings =
NULL, 0, GTK_MESSAGE_INFO, GTK_BUTTONS_NONE, /* !! temporary one */ gswitchit_kbd_config_to_string
_("<b>The X system keyboard settings differ from your current GNOME keyboard settings.</b>\n\n" (&backup_gconf_kbd_config);
"Expected was %s, but the the following settings were found: %s.\n\n" char *system_settings =
"Which set would you like to use?"), gswitchit_kbd_config_to_string
gnome_settings, system_settings); (&initial_sys_kbd_config);
g_free(gnome_settings); msg = gtk_message_dialog_new_with_markup (NULL, 0, GTK_MESSAGE_INFO, GTK_BUTTONS_NONE, /* !! temporary one */
g_free(system_settings); _
("<b>The X system keyboard settings differ from your current GNOME keyboard settings.</b>\n\n"
"Expected was %s, but the the following settings were found: %s.\n\n"
"Which set would you like to use?"),
gnome_settings,
system_settings);
g_free (gnome_settings);
g_free (system_settings);
gtk_window_set_icon_name (GTK_WINDOW (msg), gtk_window_set_icon_name (GTK_WINDOW (msg),
"gnome-dev-keyboard"); "gnome-dev-keyboard");
gtk_container_set_border_width (GTK_CONTAINER gtk_container_set_border_width (GTK_CONTAINER
(alignDontShowAgain), (align_dont_show_again),
12); 12);
gtk_container_add (GTK_CONTAINER gtk_container_add (GTK_CONTAINER
(alignDontShowAgain), (align_dont_show_again),
chkDontShowAgain); chk_dont_show_again);
gtk_container_add (GTK_CONTAINER gtk_container_add (GTK_CONTAINER
((GTK_DIALOG (msg))->vbox), ((GTK_DIALOG (msg))->vbox),
alignDontShowAgain); align_dont_show_again);
gtk_dialog_add_buttons (GTK_DIALOG (msg), gtk_dialog_add_buttons (GTK_DIALOG (msg),
_("Use X settings"), _("Use X settings"),
@ -280,7 +290,7 @@ gnome_settings_keyboard_xkb_analyze_sysconfig (void)
RESPONSE_USE_GNOME); RESPONSE_USE_GNOME);
g_object_set_data (G_OBJECT (msg), g_object_set_data (G_OBJECT (msg),
"chkDontShowAgain", "chkDontShowAgain",
chkDontShowAgain); chk_dont_show_again);
g_signal_connect (msg, "response", g_signal_connect (msg, "response",
G_CALLBACK G_CALLBACK
(gnome_settings_keyboard_xkb_sysconfig_changed_response), (gnome_settings_keyboard_xkb_sysconfig_changed_response),
@ -288,32 +298,33 @@ gnome_settings_keyboard_xkb_analyze_sysconfig (void)
gtk_widget_show_all (msg); gtk_widget_show_all (msg);
} }
} }
GSwitchItKbdConfigTerm (&backupGConfKbdConfig); gswitchit_kbd_config_term (&backup_gconf_kbd_config);
} }
static gboolean static gboolean
gnome_settings_chk_file_list (void) gnome_settings_chk_file_list (void)
{ {
GDir *homeDir; GDir *home_dir;
G_CONST_RETURN gchar *fname; G_CONST_RETURN gchar *fname;
GSList *file_list = NULL; GSList *file_list = NULL;
GSList *last_login_file_list = NULL; GSList *last_login_file_list = NULL;
GSList *tmp = NULL; GSList *tmp = NULL;
GSList *tmp_l = NULL; GSList *tmp_l = NULL;
gboolean new_file_exist = FALSE; gboolean new_file_exist = FALSE;
GConfClient *confClient = gnome_settings_daemon_get_conf_client (); GConfClient *conf_client =
gnome_settings_daemon_get_conf_client ();
homeDir = g_dir_open (g_get_home_dir (), 0, NULL); home_dir = g_dir_open (g_get_home_dir (), 0, NULL);
while ((fname = g_dir_read_name (homeDir)) != NULL) { while ((fname = g_dir_read_name (home_dir)) != NULL) {
if (g_strrstr (fname, "modmap")) { if (g_strrstr (fname, "modmap")) {
file_list = file_list =
g_slist_append (file_list, g_strdup (fname)); g_slist_append (file_list, g_strdup (fname));
} }
} }
g_dir_close (homeDir); g_dir_close (home_dir);
last_login_file_list = last_login_file_list =
gconf_client_get_list (confClient, KNOWN_FILES_KEY, gconf_client_get_list (conf_client, KNOWN_FILES_KEY,
GCONF_VALUE_STRING, NULL); GCONF_VALUE_STRING, NULL);
/* Compare between the two file list, currently available modmap files /* Compare between the two file list, currently available modmap files
@ -336,7 +347,7 @@ gnome_settings_chk_file_list (void)
} }
if (new_file_exist) if (new_file_exist)
gconf_client_set_list (confClient, KNOWN_FILES_KEY, gconf_client_set_list (conf_client, KNOWN_FILES_KEY,
GCONF_VALUE_STRING, file_list, GCONF_VALUE_STRING, file_list,
NULL); NULL);
@ -362,32 +373,33 @@ gnome_settings_keyboard_xkb_chk_lcl_xmm (void)
void void
gnome_settings_keyboard_xkb_set_post_activation_callback gnome_settings_keyboard_xkb_set_post_activation_callback
(PostActivationCallback fun, void *userData) { (PostActivationCallback fun, void *user_data) {
paCallback = fun; pa_callback = fun;
paCallbackUserData = userData; pa_callback_user_data = user_data;
} }
static GdkFilterReturn static GdkFilterReturn
gnome_settings_keyboard_xkb_evt_filter (GdkXEvent * xev, GdkEvent * event) gnome_settings_keyboard_xkb_evt_filter (GdkXEvent * xev, GdkEvent * event)
{ {
XEvent *xevent = (XEvent *) xev; XEvent *xevent = (XEvent *) xev;
xkl_engine_filter_events (engine, xevent); xkl_engine_filter_events (xkl_engine, xevent);
return GDK_FILTER_CONTINUE; return GDK_FILTER_CONTINUE;
} }
void void
gnome_settings_keyboard_xkb_init (GConfClient * client) gnome_settings_keyboard_xkb_init (GConfClient * client)
{ {
GObject *reg = NULL;
#ifdef GSDKX #ifdef GSDKX
XklSetDebugLevel (200); xkl_set_debug_level (200);
logfile = fopen ("/tmp/gsdkx.log", "a"); logfile = fopen ("/tmp/gsdkx.log", "a");
XklSetLogAppender (gnome_settings_keyboard_log_appender); xkl_set_log_appender (gnome_settings_keyboard_log_appender);
#endif #endif
engine = xkl_engine_get_instance (GDK_DISPLAY ()); xkl_engine = xkl_engine_get_instance (GDK_DISPLAY ());
if (engine) { if (xkl_engine) {
initedOk = TRUE; inited_ok = TRUE;
xkl_engine_backup_names_prop (engine); xkl_engine_backup_names_prop (xkl_engine);
gnome_settings_keyboard_xkb_analyze_sysconfig (); gnome_settings_keyboard_xkb_analyze_sysconfig ();
gnome_settings_keyboard_xkb_chk_lcl_xmm (); gnome_settings_keyboard_xkb_chk_lcl_xmm ();
@ -406,18 +418,23 @@ gnome_settings_keyboard_xkb_init (GConfClient * client)
(GdkFilterFunc) (GdkFilterFunc)
gnome_settings_keyboard_xkb_evt_filter, gnome_settings_keyboard_xkb_evt_filter,
NULL); NULL);
xkl_engine_start_listen (engine, xkl_engine_start_listen (xkl_engine,
XKLL_MANAGE_LAYOUTS | XKLL_MANAGE_LAYOUTS |
XKLL_MANAGE_WINDOW_STATES); XKLL_MANAGE_WINDOW_STATES);
reg =
g_object_new (keyboard_config_registry_get_type (),
NULL);
} }
} }
void void
gnome_settings_keyboard_xkb_load (GConfClient * client) gnome_settings_keyboard_xkb_load (GConfClient * client)
{ {
GSwitchItConfigInit (&currentConfig, client, engine); gswitchit_config_init (&current_config, client, xkl_engine);
apply_settings (); apply_settings ();
GSwitchItKbdConfigInit (&currentKbdConfig, client, engine); gswitchit_kbd_config_init (&current_kbd_config, client,
xkl_engine);
apply_xkb_settings (); apply_xkb_settings ();
} }

View file

@ -28,6 +28,8 @@
#include <gconf/gconf.h> #include <gconf/gconf.h>
#include <gconf/gconf-client.h> #include <gconf/gconf-client.h>
#include <libxklavier/xklavier.h>
void gnome_settings_keyboard_xkb_init (GConfClient * client); void gnome_settings_keyboard_xkb_init (GConfClient * client);
void gnome_settings_keyboard_xkb_load (GConfClient * client); void gnome_settings_keyboard_xkb_load (GConfClient * client);
@ -37,4 +39,8 @@ void gnome_settings_keyboard_xkb_set_post_activation_callback(
PostActivationCallback fun, PostActivationCallback fun,
void *userData ); void *userData );
GType keyboard_config_registry_get_type (void);
extern XklEngine * xkl_engine;
#endif #endif

View file

@ -0,0 +1,18 @@
<?xml version="1.0" encoding="UTF-8"?>
<node name="/org/gnome/SettingsDaemon">
<interface name="org.gnome.SettingsDaemon">
<annotation name="org.freedesktop.DBus.GLib.CSymbol" value="settings_daemon"/>
<method name="Awake"/>
</interface>
<interface name="org.gnome.KeyboardConfigRegistry">
<annotation name="org.freedesktop.DBus.GLib.CSymbol" value="keyboard_config_registry"/>
<method name="GetCurrentDescriptionsAsUtf8">
<arg type="as" name="shortLayoutDescriptions" direction="out" />
<arg type="as" name="longLayoutDescriptions" direction="out" />
<arg type="as" name="shortVariantDescriptions" direction="out" />
<arg type="as" name="longVariantDescriptions" direction="out" />
</method>
<!-- Add more methods/signals if you want -->
</interface>
</node>

View file

@ -0,0 +1,3 @@
[D-BUS Service]
Name=org.gnome.SettingsDaemon
Exec=@libexecdir@/gnome-settings-daemon