update for new libxklavier API
This commit is contained in:
parent
31a5fd7828
commit
ee5dccce96
9 changed files with 213 additions and 153 deletions
|
@ -1,3 +1,11 @@
|
|||
2006-04-20 Sergey Udaltsov <svu@gnome.org>
|
||||
|
||||
* configure.in:
|
||||
* gnome-settings-daemon/gnome-settings-keyboard-xkb.c:
|
||||
* capplets/keyboard/*.c:
|
||||
* capplets/keyboard/*.h:
|
||||
update for new libxklavier API
|
||||
|
||||
2006-04-17 Kjartan Maraas <kmaraas@gnome.org>
|
||||
|
||||
* configure.in: Remove obsolete entry for no_NO.
|
||||
|
|
|
@ -40,12 +40,15 @@
|
|||
|
||||
#include "gnome-keyboard-properties-xkb.h"
|
||||
|
||||
XklEngine *engine;
|
||||
XklConfigRegistry *configRegistry;
|
||||
|
||||
GSwitchItKbdConfig initialConfig;
|
||||
|
||||
GConfClient *xkbGConfClient;
|
||||
|
||||
char *
|
||||
xci_desc_to_utf8 (XklConfigItem * ci)
|
||||
xci_desc_to_utf8 (const XklConfigItem * ci)
|
||||
{
|
||||
char *sd = g_strstrip (ci->description);
|
||||
return sd[0] == 0 ? g_strdup (ci->name) :
|
||||
|
@ -71,7 +74,7 @@ set_model_text (GtkWidget * entry,
|
|||
|
||||
g_snprintf (ci.name, sizeof (ci.name), "%s", model);
|
||||
|
||||
if (XklConfigFindModel (&ci))
|
||||
if (xkl_config_registry_find_model (configRegistry, &ci))
|
||||
{
|
||||
char * d;
|
||||
|
||||
|
@ -119,10 +122,11 @@ static void
|
|||
cleanup_xkb_tabs (GladeXML * dialog)
|
||||
{
|
||||
GSwitchItKbdConfigTerm (&initialConfig);
|
||||
XklConfigFreeRegistry ();
|
||||
XklConfigTerm ();
|
||||
XklTerm ();
|
||||
g_object_unref (xkbGConfClient);
|
||||
g_object_unref (G_OBJECT (configRegistry));
|
||||
configRegistry = NULL;
|
||||
g_object_unref (G_OBJECT (engine));
|
||||
engine = NULL;
|
||||
g_object_unref (G_OBJECT (xkbGConfClient));
|
||||
xkbGConfClient = NULL;
|
||||
}
|
||||
|
||||
|
@ -131,7 +135,7 @@ reset_to_defaults (GtkWidget * button, GladeXML * dialog)
|
|||
{
|
||||
GSwitchItKbdConfig emptyKbdConfig;
|
||||
|
||||
GSwitchItKbdConfigInit (&emptyKbdConfig, xkbGConfClient);
|
||||
GSwitchItKbdConfigInit (&emptyKbdConfig, xkbGConfClient, engine);
|
||||
GSwitchItKbdConfigSaveToGConfBackup (&emptyKbdConfig);
|
||||
GSwitchItKbdConfigSaveToGConf (&emptyKbdConfig);
|
||||
GSwitchItKbdConfigTerm (&emptyKbdConfig);
|
||||
|
@ -154,11 +158,11 @@ setup_xkb_tabs (GladeXML * dialog, GConfChangeSet * changeset)
|
|||
GObject * peditor;
|
||||
xkbGConfClient = gconf_client_get_default ();
|
||||
|
||||
XklInit (GDK_DISPLAY ());
|
||||
XklConfigInit ();
|
||||
XklConfigLoadRegistry ();
|
||||
engine = xkl_engine_get_instance (GDK_DISPLAY ());
|
||||
configRegistry = xkl_config_registry_get_instance (engine);
|
||||
xkl_config_registry_load (configRegistry);
|
||||
|
||||
GSwitchItKbdConfigInit (&initialConfig, xkbGConfClient);
|
||||
GSwitchItKbdConfigInit (&initialConfig, xkbGConfClient, engine);
|
||||
GSwitchItKbdConfigLoadFromXInitial (&initialConfig);
|
||||
|
||||
setup_model_entry (dialog);
|
||||
|
@ -203,7 +207,7 @@ enable_disable_restoring (GladeXML * dialog)
|
|||
GSwitchItKbdConfig gswic;
|
||||
gboolean enable;
|
||||
|
||||
GSwitchItKbdConfigInit (&gswic, xkbGConfClient);
|
||||
GSwitchItKbdConfigInit (&gswic, xkbGConfClient, engine);
|
||||
GSwitchItKbdConfigLoadFromGConf (&gswic, NULL);
|
||||
|
||||
enable = !GSwitchItKbdConfigEquals (&gswic, &initialConfig);
|
||||
|
|
|
@ -24,7 +24,7 @@
|
|||
#ifndef __GNOME_KEYBOARD_PROPERTY_XKB_H
|
||||
#define __GNOME_KEYBOARD_PROPERTY_XKB_H
|
||||
|
||||
#include <libxklavier/xklavier_config.h>
|
||||
#include <libxklavier/xklavier.h>
|
||||
#include <gconf/gconf-client.h>
|
||||
|
||||
#include "libgswitchit/gswitchit_config.h"
|
||||
|
@ -40,6 +40,8 @@ G_BEGIN_DECLS
|
|||
|
||||
#define CWID(s) glade_xml_get_widget (chooserDialog, s)
|
||||
|
||||
extern XklEngine *engine;
|
||||
extern XklConfigRegistry *configRegistry;
|
||||
extern GConfClient *xkbGConfClient;
|
||||
extern GSwitchItKbdConfig initialConfig;
|
||||
|
||||
|
@ -71,7 +73,7 @@ extern void xkb_options_load_options (GladeXML * dialog);
|
|||
|
||||
extern void clear_xkb_elements_list (GSList * list);
|
||||
|
||||
extern char *xci_desc_to_utf8 (XklConfigItem * ci);
|
||||
extern char *xci_desc_to_utf8 (const XklConfigItem * ci);
|
||||
|
||||
extern void sort_tree_content (GtkWidget * treeView);
|
||||
|
||||
|
|
|
@ -154,7 +154,8 @@ def_group_in_gconf_changed (GConfClient * client,
|
|||
}
|
||||
|
||||
static void
|
||||
add_variant_to_available_layouts_tree (const XklConfigItemPtr configItem,
|
||||
add_variant_to_available_layouts_tree (XklConfigRegistry * configRegistry,
|
||||
const XklConfigItem * configItem,
|
||||
GladeXML * chooserDialog)
|
||||
{
|
||||
GtkWidget *layoutsTree = CWID ("xkb_layouts_available");
|
||||
|
@ -173,7 +174,8 @@ add_variant_to_available_layouts_tree (const XklConfigItemPtr configItem,
|
|||
}
|
||||
|
||||
static void
|
||||
add_layout_to_available_layouts_tree (const XklConfigItemPtr configItem,
|
||||
add_layout_to_available_layouts_tree (XklConfigRegistry * configRegistry,
|
||||
const XklConfigItem * configItem,
|
||||
GladeXML * chooserDialog)
|
||||
{
|
||||
GtkWidget *layoutsTree = CWID ("xkb_layouts_available");
|
||||
|
@ -189,7 +191,7 @@ add_layout_to_available_layouts_tree (const XklConfigItemPtr configItem,
|
|||
|
||||
current1stLevelId = configItem->name;
|
||||
|
||||
XklConfigEnumLayoutVariants (configItem->name,
|
||||
xkl_config_registry_foreach_layout_variant (configRegistry, configItem->name,
|
||||
(ConfigItemProcessFunc)add_variant_to_available_layouts_tree,
|
||||
chooserDialog);
|
||||
}
|
||||
|
@ -300,7 +302,7 @@ xkb_layouts_prepare_selected_tree (GladeXML * dialog, GConfChangeSet * changeset
|
|||
g_signal_connect_swapped (G_OBJECT (selection), "changed",
|
||||
G_CALLBACK
|
||||
(xkb_layouts_enable_disable_buttons), dialog);
|
||||
maxSelectedLayouts = XklGetMaxNumGroups();
|
||||
maxSelectedLayouts = xkl_engine_get_max_num_groups (engine);
|
||||
|
||||
gconf_client_notify_add (xkbGConfClient,
|
||||
GSWITCHIT_CONFIG_KEY_DEFAULT_GROUP,
|
||||
|
@ -341,7 +343,7 @@ xkb_layouts_fill_selected_tree (GladeXML * dialog)
|
|||
char *v1, *utfVisible;
|
||||
const char *visible = (char *) curLayout->data;
|
||||
gtk_list_store_append (listStore, &iter);
|
||||
if (GSwitchItKbdConfigGetDescriptions (visible, &sl, &l, &sv, &v))
|
||||
if (GSwitchItKbdConfigGetDescriptions (configRegistry, visible, &sl, &l, &sv, &v))
|
||||
visible = GSwitchItKbdConfigFormatFullLayout (l, v);
|
||||
v1 = g_strdup (visible);
|
||||
utfVisible = g_locale_to_utf8 (g_strstrip (v1), -1, NULL, NULL, NULL);
|
||||
|
@ -417,7 +419,7 @@ xkb_layouts_fill_available_tree (GladeXML * chooserDialog)
|
|||
GTK_TREE_MODEL (treeStore));
|
||||
gtk_tree_view_append_column (GTK_TREE_VIEW (treeView), column);
|
||||
|
||||
XklConfigEnumLayouts ((ConfigItemProcessFunc)
|
||||
xkl_config_registry_foreach_layout (configRegistry, (ConfigItemProcessFunc)
|
||||
add_layout_to_available_layouts_tree, chooserDialog);
|
||||
|
||||
sort_tree_content (treeView);
|
||||
|
@ -556,9 +558,10 @@ xkb_layout_chooser_response(GtkDialog *dialog,
|
|||
if (!anySwitcher)
|
||||
{
|
||||
XklConfigItem ci;
|
||||
g_snprintf( ci.name, XKL_MAX_CI_NAME_LENGTH, DEFAULT_GROUP_SWITCH );
|
||||
if (XklConfigFindOption( GROUP_SWITCHERS_GROUP,
|
||||
&ci ))
|
||||
g_snprintf(ci.name, XKL_MAX_CI_NAME_LENGTH, DEFAULT_GROUP_SWITCH );
|
||||
if (xkl_config_registry_find_option (configRegistry,
|
||||
GROUP_SWITCHERS_GROUP,
|
||||
&ci))
|
||||
{
|
||||
const gchar* id = GSwitchItKbdConfigMergeItems (GROUP_SWITCHERS_GROUP, DEFAULT_GROUP_SWITCH);
|
||||
optionsList = g_slist_append (optionsList, g_strdup (id));
|
||||
|
@ -602,7 +605,7 @@ xkb_layout_choose (GladeXML * dialog)
|
|||
xkb_layout_chooser_selection_changed (chooserDialog);
|
||||
|
||||
#ifdef HAVE_X11_EXTENSIONS_XKB_H
|
||||
if (!strcmp (XklGetBackendName(), "XKB"))
|
||||
if (!strcmp (xkl_engine_get_backend_name (engine), "XKB"))
|
||||
{
|
||||
kbdraw = xkb_layout_preview_create_widget (chooserDialog);
|
||||
g_object_set_data (G_OBJECT (chooser), "kbdraw", kbdraw);
|
||||
|
|
|
@ -43,7 +43,9 @@
|
|||
static gchar* currentModelName = NULL;
|
||||
|
||||
static void
|
||||
add_model_to_list (const XklConfigItemPtr configItem, GtkTreeView * modelsList)
|
||||
add_model_to_list (XklConfigRegistry * configRegistry,
|
||||
const XklConfigItem * configItem,
|
||||
GtkTreeView * modelsList)
|
||||
{
|
||||
GtkTreeIter iter;
|
||||
GtkListStore * listStore = GTK_LIST_STORE (gtk_tree_view_get_model (modelsList));
|
||||
|
@ -87,8 +89,9 @@ fill_models_list (GladeXML * chooserDialog)
|
|||
gtk_tree_sortable_set_sort_column_id (GTK_TREE_SORTABLE (listStore),
|
||||
0, GTK_SORT_ASCENDING);
|
||||
|
||||
XklConfigEnumModels ((ConfigItemProcessFunc)
|
||||
add_model_to_list, modelsList);
|
||||
xkl_config_registry_foreach_model (configRegistry,
|
||||
(ConfigItemProcessFunc) add_model_to_list,
|
||||
modelsList);
|
||||
|
||||
if (currentModelName != NULL)
|
||||
{
|
||||
|
|
|
@ -205,8 +205,9 @@ option_update_cb (GConfClient * client,
|
|||
This function makes particular use of the current... variables at
|
||||
the top of this file. */
|
||||
static void
|
||||
xkb_options_add_option (const XklConfigItemPtr
|
||||
configItem, GladeXML * dialog)
|
||||
xkb_options_add_option (XklConfigRegistry * configRegistry,
|
||||
const XklConfigItem * configItem,
|
||||
GladeXML * dialog)
|
||||
{
|
||||
GtkWidget *option_check;
|
||||
gchar *utfOptionName = xci_desc_to_utf8 (configItem);
|
||||
|
@ -259,12 +260,13 @@ xkb_options_add_option (const XklConfigItemPtr
|
|||
/* Add a group of options: create title and layout widgets and then
|
||||
add widgets for all the options in the group. */
|
||||
static void
|
||||
xkb_options_add_group (const XklConfigItemPtr
|
||||
configItem,
|
||||
Bool allowMultipleSelection,
|
||||
GladeXML * dialog)
|
||||
xkb_options_add_group (XklConfigRegistry * configRegistry,
|
||||
const XklConfigItem * configItem,
|
||||
GladeXML * dialog)
|
||||
{
|
||||
GtkWidget *expander, *align, *vbox;
|
||||
gboolean allowMultipleSelection = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (configItem),
|
||||
XCI_PROP_ALLOW_MULTIPLE_SELECTION));
|
||||
|
||||
GSList * expanders_list = g_object_get_data (G_OBJECT (dialog), EXPANDERS_PROP);
|
||||
|
||||
|
@ -287,8 +289,9 @@ xkb_options_add_group (const XklConfigItemPtr
|
|||
currentRadioGroup = NULL;
|
||||
|
||||
current1stLevelId = configItem->name;
|
||||
XklConfigEnumOptions (configItem->name, (ConfigItemProcessFunc)
|
||||
xkb_options_add_option, dialog);
|
||||
xkl_config_registry_foreach_option (configRegistry, configItem->name,
|
||||
(ConfigItemProcessFunc)xkb_options_add_option,
|
||||
dialog);
|
||||
|
||||
xkb_options_expander_highlight (expander);
|
||||
|
||||
|
@ -313,8 +316,9 @@ xkb_options_load_options (GladeXML * dialog)
|
|||
GtkWidget * expander;
|
||||
|
||||
/* fill the list */
|
||||
XklConfigEnumOptionGroups ((GroupProcessFunc)
|
||||
xkb_options_add_group, dialog);
|
||||
xkl_config_registry_foreach_option_group (configRegistry,
|
||||
(ConfigItemProcessFunc)xkb_options_add_group,
|
||||
dialog);
|
||||
/* sort it */
|
||||
expanders_list = g_object_get_data (G_OBJECT (dialog), EXPANDERS_PROP);
|
||||
expanders_list = g_slist_sort (expanders_list, (GCompareFunc)xkb_options_expanders_compare);
|
||||
|
|
|
@ -41,8 +41,13 @@
|
|||
* BAD STYLE: Taken from xklavier_private_xkb.h
|
||||
* Any ideas on architectural improvements are WELCOME
|
||||
*/
|
||||
extern Bool _XklXkbConfigPrepareNative( const XklConfigRecPtr data, XkbComponentNamesPtr componentNamesPtr );
|
||||
extern void _XklXkbConfigCleanupNative( XkbComponentNamesPtr componentNamesPtr );
|
||||
extern gboolean xkl_xkb_config_native_prepare (XklEngine * engine,
|
||||
const XklConfigRec * data,
|
||||
XkbComponentNamesPtr component_names);
|
||||
|
||||
extern void xkl_xkb_config_native_cleanup (XklEngine * engine,
|
||||
XkbComponentNamesPtr component_names);
|
||||
|
||||
/* */
|
||||
#endif
|
||||
|
||||
|
@ -74,45 +79,42 @@ xkb_layout_preview_update (GladeXML * chooserDialog)
|
|||
gtk_tree_selection_get_selected (selection, &model, &selectedIter))
|
||||
{
|
||||
gchar *id;
|
||||
XklConfigRec data;
|
||||
XklConfigRec *data;
|
||||
char **p, *layout, *variant;
|
||||
int i;
|
||||
XkbComponentNamesRec componentNames;
|
||||
|
||||
gtk_tree_model_get (model, &selectedIter, AVAIL_LAYOUT_TREE_COL_ID, &id, -1);
|
||||
XklConfigRecInit (&data);
|
||||
if (XklConfigGetFromServer (&data))
|
||||
data = xkl_config_rec_new ();
|
||||
if (xkl_config_rec_get_from_server (data, engine))
|
||||
{
|
||||
if( ( p = data.layouts ) != NULL )
|
||||
for( i = data.numLayouts; --i >= 0; )
|
||||
free( *p++ );
|
||||
if( ( p = data->layouts ) != NULL )
|
||||
g_strfreev(data->layouts);
|
||||
|
||||
if( ( p = data.variants ) != NULL )
|
||||
for( i = data.numVariants; --i >= 0; )
|
||||
free( *p++ );
|
||||
if( ( p = data->variants ) != NULL )
|
||||
g_strfreev(data->variants);
|
||||
|
||||
data.numLayouts =
|
||||
data.numVariants = 1;
|
||||
data.layouts = realloc (data.layouts, sizeof (char*));
|
||||
data.variants = realloc (data.variants, sizeof (char*));
|
||||
data->layouts = g_realloc (data->layouts, sizeof (char*) * 2);
|
||||
data->variants = g_realloc (data->variants, sizeof (char*) * 2);
|
||||
if (GSwitchItKbdConfigSplitItems (id, &layout, &variant)
|
||||
&& variant != NULL)
|
||||
{
|
||||
data.layouts[0] = (layout == NULL) ? NULL : strdup (layout);
|
||||
data.variants[0] = (variant == NULL) ? NULL : strdup (variant);
|
||||
data->layouts[0] = (layout == NULL) ? NULL : g_strdup (layout);
|
||||
data->variants[0] = (variant == NULL) ? NULL : g_strdup (variant);
|
||||
} else
|
||||
{
|
||||
data.layouts[0] = (id == NULL) ? NULL : strdup (id);
|
||||
data.variants[0] = NULL;
|
||||
data->layouts[0] = (id == NULL) ? NULL : g_strdup (id);
|
||||
data->variants[0] = NULL;
|
||||
}
|
||||
if (_XklXkbConfigPrepareNative (&data, &componentNames))
|
||||
data->layouts[1] = data->variants[1] = NULL;
|
||||
|
||||
if (xkl_xkb_config_native_prepare (engine, data, &componentNames))
|
||||
{
|
||||
keyboard_drawing_set_keyboard (KEYBOARD_DRAWING (kbdraw), &componentNames);
|
||||
|
||||
_XklXkbConfigCleanupNative( &componentNames );
|
||||
xkl_xkb_config_native_cleanup (engine, &componentNames);
|
||||
}
|
||||
}
|
||||
XklConfigRecDestroy (&data);
|
||||
g_object_unref (G_OBJECT (data));
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
|
|
@ -108,7 +108,7 @@ PKG_CHECK_MODULES(GNOME_DESKTOP, gnome-desktop-2.0)
|
|||
PKG_CHECK_MODULES(DEFAULT_APPLICATIONS_CAPPLET, libxml-2.0)
|
||||
PKG_CHECK_MODULES(SOUND_CAPPLET, esound)
|
||||
PKG_CHECK_MODULES(METACITY, libmetacity-private)
|
||||
PKG_CHECK_MODULES(LIBXKLAVIER, libxklavier >= 1.14,,
|
||||
PKG_CHECK_MODULES(LIBXKLAVIER, libxklavier >= 2.91,,
|
||||
AC_MSG_ERROR([gnome-control-center depends on libxklavier.
|
||||
The latest release is available from http://prdownloads.sourceforge.net/gswitchit], 1))
|
||||
|
||||
|
|
|
@ -36,12 +36,13 @@
|
|||
#include <time.h>
|
||||
|
||||
#include <libxklavier/xklavier.h>
|
||||
#include <libxklavier/xklavier_config.h>
|
||||
#include <libgswitchit/gswitchit_config.h>
|
||||
|
||||
#include "gnome-settings-keyboard-xkb.h"
|
||||
#include "gnome-settings-daemon.h"
|
||||
|
||||
static XklEngine *engine;
|
||||
|
||||
static GSwitchItConfig currentConfig;
|
||||
static GSwitchItKbdConfig currentKbdConfig;
|
||||
|
||||
|
@ -69,14 +70,15 @@ typedef enum {
|
|||
static FILE *logfile;
|
||||
|
||||
static void
|
||||
gnome_settings_keyboard_log_appender (const char file[], const char function[],
|
||||
int level, const char format[], va_list args)
|
||||
gnome_settings_keyboard_log_appender (const char file[],
|
||||
const char function[], int level,
|
||||
const char format[], va_list args)
|
||||
{
|
||||
time_t now = time (NULL);
|
||||
fprintf (logfile, "[%08ld,%03d,%s:%s/] \t", now,
|
||||
level, file, function);
|
||||
vfprintf (logfile, format, args);
|
||||
fflush(logfile);
|
||||
time_t now = time (NULL);
|
||||
fprintf (logfile, "[%08ld,%03d,%s:%s/] \t", now,
|
||||
level, file, function);
|
||||
vfprintf (logfile, format, args);
|
||||
fflush (logfile);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
@ -90,36 +92,36 @@ activation_error (void)
|
|||
&& (release / 100000 == 403);
|
||||
|
||||
GtkWidget *dialog;
|
||||
|
||||
|
||||
/* VNC viewers will not work, do not barrage them with warnings */
|
||||
if (NULL != vendor && NULL != strstr (vendor, "VNC"))
|
||||
return;
|
||||
return;
|
||||
|
||||
dialog = gtk_message_dialog_new_with_markup (NULL,
|
||||
0,
|
||||
GTK_MESSAGE_ERROR,
|
||||
GTK_BUTTONS_CLOSE,
|
||||
_
|
||||
("Error activating XKB configuration.\n"
|
||||
"It can happen under various circumstances:\n"
|
||||
"- a bug in libxklavier library\n"
|
||||
"- a bug in X server (xkbcomp, xmodmap utilities)\n"
|
||||
"- X server with incompatible libxkbfile implementation\n\n"
|
||||
"X server version data:\n%s\n%d\n%s\n"
|
||||
"If you report this situation as a bug, please include:\n"
|
||||
"- The result of <b>%s</b>\n"
|
||||
"- The result of <b>%s</b>"),
|
||||
vendor,
|
||||
release,
|
||||
badXFree430Release
|
||||
?
|
||||
_
|
||||
("You are using XFree 4.3.0.\n"
|
||||
"There are known problems with complex XKB configurations.\n"
|
||||
"Try using a simpler configuration or taking a fresher version of XFree software.")
|
||||
: "",
|
||||
"xprop -root | grep XKB",
|
||||
"gconftool-2 -R /desktop/gnome/peripherals/keyboard/kbd");
|
||||
0,
|
||||
GTK_MESSAGE_ERROR,
|
||||
GTK_BUTTONS_CLOSE,
|
||||
_
|
||||
("Error activating XKB configuration.\n"
|
||||
"It can happen under various circumstances:\n"
|
||||
"- a bug in libxklavier library\n"
|
||||
"- a bug in X server (xkbcomp, xmodmap utilities)\n"
|
||||
"- X server with incompatible libxkbfile implementation\n\n"
|
||||
"X server version data:\n%s\n%d\n%s\n"
|
||||
"If you report this situation as a bug, please include:\n"
|
||||
"- The result of <b>%s</b>\n"
|
||||
"- The result of <b>%s</b>"),
|
||||
vendor,
|
||||
release,
|
||||
badXFree430Release
|
||||
?
|
||||
_
|
||||
("You are using XFree 4.3.0.\n"
|
||||
"There are known problems with complex XKB configurations.\n"
|
||||
"Try using a simpler configuration or taking a fresher version of XFree software.")
|
||||
: "",
|
||||
"xprop -root | grep XKB",
|
||||
"gconftool-2 -R /desktop/gnome/peripherals/keyboard/kbd");
|
||||
g_signal_connect (dialog, "response",
|
||||
G_CALLBACK (gtk_widget_destroy), NULL);
|
||||
gtk_widget_show (dialog);
|
||||
|
@ -147,24 +149,29 @@ apply_xkb_settings (void)
|
|||
return;
|
||||
|
||||
confClient = gnome_settings_daemon_get_conf_client ();
|
||||
GSwitchItKbdConfigInit (¤tSysKbdConfig, confClient);
|
||||
GSwitchItKbdConfigInit (¤tSysKbdConfig, confClient, engine);
|
||||
|
||||
GSwitchItKbdConfigLoadFromGConf (¤tKbdConfig, &initialSysKbdConfig);
|
||||
GSwitchItKbdConfigLoadFromGConf (¤tKbdConfig,
|
||||
&initialSysKbdConfig);
|
||||
|
||||
GSwitchItKbdConfigLoadFromXCurrent (¤tSysKbdConfig);
|
||||
/* Activate - only if different! */
|
||||
if (!GSwitchItKbdConfigEquals (¤tKbdConfig, ¤tSysKbdConfig)) {
|
||||
if (!GSwitchItKbdConfigEquals
|
||||
(¤tKbdConfig, ¤tSysKbdConfig)) {
|
||||
if (GSwitchItKbdConfigActivate (¤tKbdConfig)) {
|
||||
GSwitchItKbdConfigSaveToGConfBackup (&initialSysKbdConfig);
|
||||
GSwitchItKbdConfigSaveToGConfBackup
|
||||
(&initialSysKbdConfig);
|
||||
if (paCallback != NULL) {
|
||||
(*paCallback) (paCallbackUserData);
|
||||
}
|
||||
} else {
|
||||
g_warning ("Could not activate the XKB configuration");
|
||||
g_warning
|
||||
("Could not activate the XKB configuration");
|
||||
activation_error ();
|
||||
}
|
||||
} else
|
||||
XklDebug (100, "Actual KBD configuration was not changed: redundant notification\n");
|
||||
xkl_debug (100,
|
||||
"Actual KBD configuration was not changed: redundant notification\n");
|
||||
|
||||
GSwitchItKbdConfigTerm (¤tSysKbdConfig);
|
||||
}
|
||||
|
@ -176,14 +183,18 @@ gnome_settings_keyboard_xkb_sysconfig_changed_response (GtkDialog * dialog,
|
|||
{
|
||||
GConfClient *confClient;
|
||||
GSwitchItKbdConfig emptyKbdConfig;
|
||||
gboolean dontShowAgain = gtk_toggle_button_get_active (
|
||||
GTK_TOGGLE_BUTTON (g_object_get_data (G_OBJECT (dialog), "chkDontShowAgain")));
|
||||
gboolean dontShowAgain =
|
||||
gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON
|
||||
(g_object_get_data
|
||||
(G_OBJECT (dialog),
|
||||
"chkDontShowAgain")));
|
||||
|
||||
confClient = gnome_settings_daemon_get_conf_client ();
|
||||
|
||||
switch (what2do) {
|
||||
case RESPONSE_USE_X:
|
||||
GSwitchItKbdConfigInit (&emptyKbdConfig, confClient);
|
||||
GSwitchItKbdConfigInit (&emptyKbdConfig, confClient,
|
||||
engine);
|
||||
GSwitchItKbdConfigSaveToGConf (&emptyKbdConfig);
|
||||
break;
|
||||
case RESPONSE_USE_GNOME:
|
||||
|
@ -192,7 +203,9 @@ gnome_settings_keyboard_xkb_sysconfig_changed_response (GtkDialog * dialog,
|
|||
}
|
||||
|
||||
if (dontShowAgain)
|
||||
gconf_client_set_bool (confClient, DISABLE_SYSCONF_CHANGED_WARNING_KEY, TRUE, NULL);
|
||||
gconf_client_set_bool (confClient,
|
||||
DISABLE_SYSCONF_CHANGED_WARNING_KEY,
|
||||
TRUE, NULL);
|
||||
|
||||
gtk_widget_destroy (GTK_WIDGET (dialog));
|
||||
}
|
||||
|
@ -207,40 +220,53 @@ gnome_settings_keyboard_xkb_analyze_sysconfig (void)
|
|||
if (!initedOk)
|
||||
return;
|
||||
confClient = gnome_settings_daemon_get_conf_client ();
|
||||
GSwitchItKbdConfigInit (&backupGConfKbdConfig, confClient);
|
||||
GSwitchItKbdConfigInit (&initialSysKbdConfig, confClient);
|
||||
dontShow = gconf_client_get_bool (confClient, DISABLE_SYSCONF_CHANGED_WARNING_KEY, NULL);
|
||||
GSwitchItKbdConfigInit (&backupGConfKbdConfig, confClient, engine);
|
||||
GSwitchItKbdConfigInit (&initialSysKbdConfig, confClient, engine);
|
||||
dontShow =
|
||||
gconf_client_get_bool (confClient,
|
||||
DISABLE_SYSCONF_CHANGED_WARNING_KEY,
|
||||
NULL);
|
||||
GSwitchItKbdConfigLoadFromGConfBackup (&backupGConfKbdConfig);
|
||||
GSwitchItKbdConfigLoadFromXInitial (&initialSysKbdConfig);
|
||||
|
||||
isConfigChanged = g_slist_length (backupGConfKbdConfig.layouts) &&
|
||||
!GSwitchItKbdConfigEquals (&initialSysKbdConfig, &backupGConfKbdConfig);
|
||||
!GSwitchItKbdConfigEquals (&initialSysKbdConfig,
|
||||
&backupGConfKbdConfig);
|
||||
/* config was changed!!! */
|
||||
if (isConfigChanged) {
|
||||
if (dontShow) {
|
||||
g_warning ("The system configuration changed - but we remain silent\n");
|
||||
g_warning
|
||||
("The system configuration changed - but we remain silent\n");
|
||||
} else {
|
||||
GtkWidget *chkDontShowAgain = gtk_check_button_new_with_mnemonic (_ ("Do _not show this warning again"));
|
||||
GtkWidget *alignDontShowAgain = gtk_alignment_new (0.5,
|
||||
0.5,
|
||||
0,
|
||||
0);
|
||||
GtkWidget *msg = gtk_message_dialog_new_with_markup (NULL,
|
||||
0,
|
||||
GTK_MESSAGE_INFO,
|
||||
GTK_BUTTONS_NONE,
|
||||
GtkWidget *chkDontShowAgain =
|
||||
gtk_check_button_new_with_mnemonic (_
|
||||
("Do _not show this warning again"));
|
||||
GtkWidget *alignDontShowAgain =
|
||||
gtk_alignment_new (0.5,
|
||||
0.5,
|
||||
0,
|
||||
0);
|
||||
GtkWidget *msg =
|
||||
gtk_message_dialog_new_with_markup (NULL,
|
||||
0,
|
||||
GTK_MESSAGE_INFO,
|
||||
GTK_BUTTONS_NONE,
|
||||
/* !! temporary one */
|
||||
_
|
||||
("The X system keyboard settings differ from your current GNOME "
|
||||
"keyboard settings. Which set would you like to use?"));
|
||||
_
|
||||
("The X system keyboard settings differ from your current GNOME "
|
||||
"keyboard settings. Which set would you like to use?"));
|
||||
|
||||
gtk_window_set_icon_name (GTK_WINDOW (msg), "gnome-dev-keyboard");
|
||||
gtk_window_set_icon_name (GTK_WINDOW (msg),
|
||||
"gnome-dev-keyboard");
|
||||
|
||||
gtk_container_set_border_width (GTK_CONTAINER (alignDontShowAgain),
|
||||
12);
|
||||
gtk_container_add (GTK_CONTAINER (alignDontShowAgain),
|
||||
gtk_container_set_border_width (GTK_CONTAINER
|
||||
(alignDontShowAgain),
|
||||
12);
|
||||
gtk_container_add (GTK_CONTAINER
|
||||
(alignDontShowAgain),
|
||||
chkDontShowAgain);
|
||||
gtk_container_add (GTK_CONTAINER ((GTK_DIALOG (msg))->vbox),
|
||||
gtk_container_add (GTK_CONTAINER
|
||||
((GTK_DIALOG (msg))->vbox),
|
||||
alignDontShowAgain);
|
||||
|
||||
gtk_dialog_add_buttons (GTK_DIALOG (msg),
|
||||
|
@ -250,7 +276,9 @@ gnome_settings_keyboard_xkb_analyze_sysconfig (void)
|
|||
RESPONSE_USE_GNOME, NULL);
|
||||
gtk_dialog_set_default_response (GTK_DIALOG (msg),
|
||||
RESPONSE_USE_GNOME);
|
||||
g_object_set_data (G_OBJECT (msg), "chkDontShowAgain", chkDontShowAgain);
|
||||
g_object_set_data (G_OBJECT (msg),
|
||||
"chkDontShowAgain",
|
||||
chkDontShowAgain);
|
||||
g_signal_connect (msg, "response",
|
||||
G_CALLBACK
|
||||
(gnome_settings_keyboard_xkb_sysconfig_changed_response),
|
||||
|
@ -261,7 +289,7 @@ gnome_settings_keyboard_xkb_analyze_sysconfig (void)
|
|||
GSwitchItKbdConfigTerm (&backupGConfKbdConfig);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
static gboolean
|
||||
gnome_settings_chk_file_list (void)
|
||||
{
|
||||
GDir *homeDir;
|
||||
|
@ -276,12 +304,15 @@ gnome_settings_chk_file_list (void)
|
|||
homeDir = g_dir_open (g_get_home_dir (), 0, NULL);
|
||||
while ((fname = g_dir_read_name (homeDir)) != NULL) {
|
||||
if (g_strrstr (fname, "modmap")) {
|
||||
file_list = g_slist_append (file_list, g_strdup (fname));
|
||||
file_list =
|
||||
g_slist_append (file_list, g_strdup (fname));
|
||||
}
|
||||
}
|
||||
g_dir_close (homeDir);
|
||||
|
||||
last_login_file_list = gconf_client_get_list (confClient, KNOWN_FILES_KEY, GCONF_VALUE_STRING, NULL);
|
||||
last_login_file_list =
|
||||
gconf_client_get_list (confClient, KNOWN_FILES_KEY,
|
||||
GCONF_VALUE_STRING, NULL);
|
||||
|
||||
/* Compare between the two file list, currently available modmap files
|
||||
and the files available in the last log in */
|
||||
|
@ -293,8 +324,7 @@ gnome_settings_chk_file_list (void)
|
|||
if (strcmp (tmp->data, tmp_l->data) == 0) {
|
||||
new_file_exist = FALSE;
|
||||
break;
|
||||
}
|
||||
else
|
||||
} else
|
||||
tmp_l = tmp_l->next;
|
||||
}
|
||||
if (new_file_exist)
|
||||
|
@ -304,7 +334,9 @@ gnome_settings_chk_file_list (void)
|
|||
}
|
||||
|
||||
if (new_file_exist)
|
||||
gconf_client_set_list (confClient, KNOWN_FILES_KEY, GCONF_VALUE_STRING, file_list, NULL);
|
||||
gconf_client_set_list (confClient, KNOWN_FILES_KEY,
|
||||
GCONF_VALUE_STRING, file_list,
|
||||
NULL);
|
||||
|
||||
g_slist_foreach (file_list, (GFunc) g_free, NULL);
|
||||
g_slist_free (file_list);
|
||||
|
@ -323,24 +355,22 @@ gnome_settings_keyboard_xkb_chk_lcl_xmm (void)
|
|||
gnome_settings_modmap_dialog_call ();
|
||||
gnome_settings_load_modmap_files ();
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
void
|
||||
gnome_settings_keyboard_xkb_set_post_activation_callback
|
||||
(PostActivationCallback fun, void *userData)
|
||||
{
|
||||
gnome_settings_keyboard_xkb_set_post_activation_callback
|
||||
(PostActivationCallback fun, void *userData) {
|
||||
paCallback = fun;
|
||||
paCallbackUserData = userData;
|
||||
}
|
||||
|
||||
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;
|
||||
XklFilterEvents (xevent);
|
||||
return GDK_FILTER_CONTINUE;
|
||||
XEvent *xevent = (XEvent *) xev;
|
||||
xkl_engine_filter_events (engine, xevent);
|
||||
return GDK_FILTER_CONTINUE;
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -349,12 +379,13 @@ gnome_settings_keyboard_xkb_init (GConfClient * client)
|
|||
#ifdef GSDKX
|
||||
XklSetDebugLevel (200);
|
||||
logfile = fopen ("/tmp/gsdkx.log", "a");
|
||||
XklSetLogAppender (gnome_settings_keyboard_log_appender);
|
||||
XklSetLogAppender (gnome_settings_keyboard_log_appender);
|
||||
#endif
|
||||
|
||||
if (!XklInit (GDK_DISPLAY ())) {
|
||||
engine = xkl_engine_get_instance (GDK_DISPLAY ());
|
||||
if (!engine) {
|
||||
initedOk = TRUE;
|
||||
XklBackupNamesProp ();
|
||||
xkl_engine_backup_names_prop (engine);
|
||||
gnome_settings_keyboard_xkb_analyze_sysconfig ();
|
||||
gnome_settings_keyboard_xkb_chk_lcl_xmm ();
|
||||
|
||||
|
@ -366,22 +397,25 @@ gnome_settings_keyboard_xkb_init (GConfClient * client)
|
|||
(GSWITCHIT_KBD_CONFIG_DIR,
|
||||
(KeyCallbackFunc) apply_xkb_settings);
|
||||
|
||||
gdk_window_add_filter (NULL,
|
||||
(GdkFilterFunc) gnome_settings_keyboard_xkb_evt_filter,
|
||||
gdk_window_add_filter (NULL, (GdkFilterFunc)
|
||||
gnome_settings_keyboard_xkb_evt_filter,
|
||||
NULL);
|
||||
gdk_window_add_filter (gdk_get_default_root_window(),
|
||||
(GdkFilterFunc) gnome_settings_keyboard_xkb_evt_filter,
|
||||
gdk_window_add_filter (gdk_get_default_root_window (),
|
||||
(GdkFilterFunc)
|
||||
gnome_settings_keyboard_xkb_evt_filter,
|
||||
NULL);
|
||||
XklStartListen (XKLL_MANAGE_LAYOUTS | XKLL_MANAGE_WINDOW_STATES);
|
||||
xkl_engine_start_listen (engine,
|
||||
XKLL_MANAGE_LAYOUTS |
|
||||
XKLL_MANAGE_WINDOW_STATES);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
gnome_settings_keyboard_xkb_load (GConfClient * client)
|
||||
{
|
||||
GSwitchItConfigInit (¤tConfig, client);
|
||||
GSwitchItConfigInit (¤tConfig, client, engine);
|
||||
apply_settings ();
|
||||
|
||||
GSwitchItKbdConfigInit (¤tKbdConfig, client);
|
||||
GSwitchItKbdConfigInit (¤tKbdConfig, client, engine);
|
||||
apply_xkb_settings ();
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue