2003-11-12 21:58:51 +00:00
|
|
|
|
/* -*- mode: c; style: linux -*- */
|
|
|
|
|
|
|
|
|
|
/* gnome-settings-keyboard-xkb.c
|
|
|
|
|
*
|
|
|
|
|
* Copyright <EFBFBD> 2001 Udaltsoft
|
|
|
|
|
*
|
|
|
|
|
* Written by Sergey V. Oudaltsov <svu@users.sourceforge.net>
|
|
|
|
|
*
|
|
|
|
|
* 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.
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
|
# include "config.h"
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
#include <gdk/gdk.h>
|
|
|
|
|
#include <gdk/gdkx.h>
|
|
|
|
|
#include <gconf/gconf-client.h>
|
|
|
|
|
|
|
|
|
|
#include <string.h>
|
|
|
|
|
|
2003-11-23 02:44:21 +00:00
|
|
|
|
#include <libgnome/gnome-i18n.h>
|
|
|
|
|
|
2003-11-12 21:58:51 +00:00
|
|
|
|
#include <libxklavier/xklavier.h>
|
|
|
|
|
#include <libgswitchit/gswitchit_xkb_config.h>
|
|
|
|
|
|
|
|
|
|
#include "gnome-settings-keyboard-xkb.h"
|
|
|
|
|
#include "gnome-settings-daemon.h"
|
|
|
|
|
|
|
|
|
|
static GSwitchItXkbConfig gswic;
|
|
|
|
|
static gboolean initedOk;
|
|
|
|
|
|
2003-11-23 02:44:21 +00:00
|
|
|
|
static void
|
|
|
|
|
activation_error (void)
|
|
|
|
|
{
|
|
|
|
|
char *vendor = ServerVendor (GDK_DISPLAY ());
|
|
|
|
|
int release = VendorRelease (GDK_DISPLAY ());
|
|
|
|
|
gboolean badXFree430Release = (!strcmp (vendor,
|
|
|
|
|
"The XFree86 Project, Inc"))
|
|
|
|
|
&& (release == 40300000);
|
|
|
|
|
|
|
|
|
|
GtkWidget *msg = gtk_message_dialog_new (NULL,
|
|
|
|
|
GTK_DIALOG_MODAL |
|
|
|
|
|
GTK_DIALOG_DESTROY_WITH_PARENT,
|
|
|
|
|
GTK_MESSAGE_ERROR,
|
|
|
|
|
GTK_BUTTONS_OK,
|
|
|
|
|
_
|
|
|
|
|
("Error activating XKB configuration.\n"
|
|
|
|
|
"Probably internal X server problem.\n\nX server version data:\n%s\n%d%s"),
|
|
|
|
|
vendor,
|
|
|
|
|
release,
|
|
|
|
|
badXFree430Release ?
|
|
|
|
|
_
|
|
|
|
|
("You are using XFree 4.3.0.\n"
|
|
|
|
|
"There are known problems with complex XKB configurations.\n"
|
|
|
|
|
"Try using simpler configuration or taking more fresh version of XFree software.")
|
|
|
|
|
: "");
|
|
|
|
|
gtk_dialog_run (GTK_DIALOG (msg));
|
|
|
|
|
gtk_widget_destroy (msg);
|
|
|
|
|
}
|
|
|
|
|
|
2003-11-12 21:58:51 +00:00
|
|
|
|
static void
|
|
|
|
|
apply_settings (void)
|
|
|
|
|
{
|
|
|
|
|
GConfClient *confClient;
|
|
|
|
|
|
|
|
|
|
memset (&gswic, 0, sizeof (gswic));
|
|
|
|
|
|
|
|
|
|
confClient = gconf_client_get_default ();
|
|
|
|
|
GSwitchItXkbConfigInit (&gswic, confClient);
|
|
|
|
|
g_object_unref (confClient);
|
|
|
|
|
GSwitchItXkbConfigLoad (&gswic);
|
|
|
|
|
|
|
|
|
|
if (!gswic.overrideSettings)
|
|
|
|
|
GSwitchItXkbConfigLoadInitial (&gswic);
|
|
|
|
|
|
2003-11-23 02:44:21 +00:00
|
|
|
|
if (!GSwitchItXkbConfigActivate (&gswic)) {
|
2003-11-12 21:58:51 +00:00
|
|
|
|
g_warning ("Could not activate the XKB configuration");
|
2003-11-23 02:44:21 +00:00
|
|
|
|
activation_error ();
|
|
|
|
|
}
|
2003-11-12 21:58:51 +00:00
|
|
|
|
|
|
|
|
|
GSwitchItXkbConfigTerm (&gswic);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
gnome_settings_keyboard_xkb_init (GConfClient * client)
|
|
|
|
|
{
|
|
|
|
|
if (!XklInit (GDK_DISPLAY ())) {
|
|
|
|
|
initedOk = TRUE;
|
|
|
|
|
gnome_settings_daemon_register_callback
|
|
|
|
|
("/desktop/gnome/peripherals/keyboard/xkb",
|
|
|
|
|
(KeyCallbackFunc) apply_settings);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
gnome_settings_keyboard_xkb_load (GConfClient * client)
|
|
|
|
|
{
|
|
|
|
|
if (initedOk)
|
|
|
|
|
apply_settings ();
|
|
|
|
|
}
|