diff options
author | marcus <marcus@df743ca5-7f9a-e211-a948-0013205c9059> | 2006-06-17 02:53:12 +0800 |
---|---|---|
committer | marcus <marcus@df743ca5-7f9a-e211-a948-0013205c9059> | 2006-06-17 02:53:12 +0800 |
commit | 579dd5610270afd5e65ba112eed1b82baa3d0f96 (patch) | |
tree | 53ca916a0beb1af10cd35e04be45c47795e086e1 | |
parent | f97b2ec8a03ce1b931eaa800be248277ebc2969f (diff) | |
download | marcuscom-ports-579dd5610270afd5e65ba112eed1b82baa3d0f96.tar marcuscom-ports-579dd5610270afd5e65ba112eed1b82baa3d0f96.tar.gz marcuscom-ports-579dd5610270afd5e65ba112eed1b82baa3d0f96.tar.bz2 marcuscom-ports-579dd5610270afd5e65ba112eed1b82baa3d0f96.tar.lz marcuscom-ports-579dd5610270afd5e65ba112eed1b82baa3d0f96.tar.xz marcuscom-ports-579dd5610270afd5e65ba112eed1b82baa3d0f96.tar.zst marcuscom-ports-579dd5610270afd5e65ba112eed1b82baa3d0f96.zip |
Fix build with new libxklavier.
Obtained from: GNOME CVS
git-svn-id: svn://creme-brulee.marcuscom.com/ports/trunk@6456 df743ca5-7f9a-e211-a948-0013205c9059
-rw-r--r-- | x11/gnome-applets/Makefile | 4 | ||||
-rw-r--r-- | x11/gnome-applets/files/patch-gswitchit | 2915 |
2 files changed, 2916 insertions, 3 deletions
diff --git a/x11/gnome-applets/Makefile b/x11/gnome-applets/Makefile index d78e754dd..10520eeb7 100644 --- a/x11/gnome-applets/Makefile +++ b/x11/gnome-applets/Makefile @@ -3,7 +3,7 @@ # Whom: Joe Marcus Clarke <marcus@FreeBSD.org> # # $FreeBSD$ -# $MCom: ports/x11/gnome-applets/Makefile,v 1.113 2006/06/13 05:09:33 marcus Exp $ +# $MCom: ports/x11/gnome-applets/Makefile,v 1.114 2006/06/13 19:15:18 marcus Exp $ # PORTNAME= gnome-applets @@ -49,8 +49,6 @@ OPTIONS= MINI_COMMANDER "Enable mini-commander applet" off FREEBSD_SYS?= /usr/src/sys -BROKEN= Needs new libgswitchit - .include <bsd.port.pre.mk> .if exists(${LOCALBASE}/libdata/pkgconfig/libnotify.pc) || \ diff --git a/x11/gnome-applets/files/patch-gswitchit b/x11/gnome-applets/files/patch-gswitchit new file mode 100644 index 000000000..fcf3f64eb --- /dev/null +++ b/x11/gnome-applets/files/patch-gswitchit @@ -0,0 +1,2915 @@ +diff -u libgswitchit-/ChangeLog libgswitchit/ChangeLog +--- libgswitchit-/ChangeLog 2006-01-03 07:38:59.000000000 -0500 ++++ libgswitchit/ChangeLog 2006-05-26 20:19:52.000000000 -0400 +@@ -1,3 +1,20 @@ ++2006-05-27 Sergey Udaltsov <svu@gnome.org> ++ ++ * gswitchit_config.[ch]: optimizing dealing with UTF8 descriptions - ++ changed GSList to NULL-terminated gchar ** ++ ++2006-04-22 Sergey Udaltsov <svu@gnome.org> ++ ++ * gswitchit_config.[ch]: save/load preview window coords ++ ++2006-04-20 Sergey Udaltsov <svu@gnome.org> ++ ++ * gswitchit_config.c: added kbd config ToString function ++ ++2006-04-20 Sergey Udaltsov <svu@gnome.org> ++ ++ * *.c,*.h: update for new libxklavier API ++ + 2006-01-03 Kristof Vansant <de_lupus@pandora.be> + + Fixes #171668 +Only in libgswitchit: .ChangeLog.swp +diff -u libgswitchit-/gswitchit_config.c libgswitchit/gswitchit_config.c +--- libgswitchit-/gswitchit_config.c 2006-01-30 05:48:20.000000000 -0500 ++++ libgswitchit/gswitchit_config.c 2006-05-26 20:19:52.000000000 -0400 +@@ -25,8 +25,6 @@ + #include <gdk/gdkx.h> + #include <libgnome/gnome-program.h> + +-#include <libxklavier/xklavier_config.h> +- + #include "gswitchit_config.h" + #include "gswitchit_config_private.h" + +@@ -37,27 +35,41 @@ + + #define GSWITCHIT_CONFIG_KEY_PREFIX KEYBOARD_CONFIG_KEY_PREFIX "/general" + +-const char GSWITCHIT_CONFIG_DIR[] = GSWITCHIT_CONFIG_KEY_PREFIX; +-const char GSWITCHIT_CONFIG_KEY_DEFAULT_GROUP[] = ++const gchar GSWITCHIT_CONFIG_DIR[] = GSWITCHIT_CONFIG_KEY_PREFIX; ++const gchar GSWITCHIT_CONFIG_KEY_DEFAULT_GROUP[] = + GSWITCHIT_CONFIG_KEY_PREFIX "/defaultGroup"; +-const char GSWITCHIT_CONFIG_KEY_GROUP_PER_WINDOW[] = ++const gchar GSWITCHIT_CONFIG_KEY_GROUP_PER_WINDOW[] = + GSWITCHIT_CONFIG_KEY_PREFIX "/groupPerWindow"; +-const char GSWITCHIT_CONFIG_KEY_HANDLE_INDICATORS[] = ++const gchar GSWITCHIT_CONFIG_KEY_HANDLE_INDICATORS[] = + GSWITCHIT_CONFIG_KEY_PREFIX "/handleIndicators"; +-const char GSWITCHIT_CONFIG_KEY_LAYOUT_NAMES_AS_GROUP_NAMES[] ++const gchar GSWITCHIT_CONFIG_KEY_LAYOUT_NAMES_AS_GROUP_NAMES[] + = GSWITCHIT_CONFIG_KEY_PREFIX "/layoutNamesAsGroupNames"; + ++#define GSWITCHIT_PREVIEW_CONFIG_KEY_PREFIX "/apps/gswitchit/preview" ++ ++const gchar GSWITCHIT_PREVIEW_CONFIG_DIR[] = ++ GSWITCHIT_PREVIEW_CONFIG_KEY_PREFIX; ++const gchar GSWITCHIT_PREVIEW_CONFIG_KEY_X[] = ++ GSWITCHIT_PREVIEW_CONFIG_KEY_PREFIX "/x"; ++const gchar GSWITCHIT_PREVIEW_CONFIG_KEY_Y[] = ++ GSWITCHIT_PREVIEW_CONFIG_KEY_PREFIX "/y"; ++const gchar GSWITCHIT_PREVIEW_CONFIG_KEY_WIDTH[] = ++ GSWITCHIT_PREVIEW_CONFIG_KEY_PREFIX "/width"; ++const gchar GSWITCHIT_PREVIEW_CONFIG_KEY_HEIGHT[] = ++ GSWITCHIT_PREVIEW_CONFIG_KEY_PREFIX "/height"; ++ + /** + * GSwitchItAppletConfig + */ + #define GSWITCHIT_APPLET_CONFIG_KEY_PREFIX "/apps/gswitchit/Applet" + +-const char GSWITCHIT_APPLET_CONFIG_DIR[] = GSWITCHIT_APPLET_CONFIG_KEY_PREFIX; +-const char GSWITCHIT_APPLET_CONFIG_KEY_SHOW_FLAGS[] = ++const gchar GSWITCHIT_APPLET_CONFIG_DIR[] = ++ GSWITCHIT_APPLET_CONFIG_KEY_PREFIX; ++const gchar GSWITCHIT_APPLET_CONFIG_KEY_SHOW_FLAGS[] = + GSWITCHIT_APPLET_CONFIG_KEY_PREFIX "/showFlags"; +-const char GSWITCHIT_APPLET_CONFIG_KEY_ENABLED_PLUGINS[] = ++const gchar GSWITCHIT_APPLET_CONFIG_KEY_ENABLED_PLUGINS[] = + GSWITCHIT_APPLET_CONFIG_KEY_PREFIX "/enabledPlugins"; +-const char GSWITCHIT_APPLET_CONFIG_KEY_SECONDARIES[] = ++const gchar GSWITCHIT_APPLET_CONFIG_KEY_SECONDARIES[] = + GSWITCHIT_APPLET_CONFIG_KEY_PREFIX "/secondary"; + + /** +@@ -65,15 +77,15 @@ + */ + #define GSWITCHIT_KBD_CONFIG_KEY_PREFIX KEYBOARD_CONFIG_KEY_PREFIX "/kbd" + +-const char GSWITCHIT_KBD_CONFIG_DIR[] = GSWITCHIT_KBD_CONFIG_KEY_PREFIX; +-const char GSWITCHIT_KBD_CONFIG_KEY_MODEL[] = ++const gchar GSWITCHIT_KBD_CONFIG_DIR[] = GSWITCHIT_KBD_CONFIG_KEY_PREFIX; ++const gchar GSWITCHIT_KBD_CONFIG_KEY_MODEL[] = + GSWITCHIT_KBD_CONFIG_KEY_PREFIX "/model"; +-const char GSWITCHIT_KBD_CONFIG_KEY_LAYOUTS[] = ++const gchar GSWITCHIT_KBD_CONFIG_KEY_LAYOUTS[] = + GSWITCHIT_KBD_CONFIG_KEY_PREFIX "/layouts"; +-const char GSWITCHIT_KBD_CONFIG_KEY_OPTIONS[] = ++const gchar GSWITCHIT_KBD_CONFIG_KEY_OPTIONS[] = + GSWITCHIT_KBD_CONFIG_KEY_PREFIX "/options"; + +-const char *GSWITCHIT_KBD_CONFIG_ACTIVE[] = { ++const gchar *GSWITCHIT_KBD_CONFIG_ACTIVE[] = { + GSWITCHIT_KBD_CONFIG_KEY_MODEL, + GSWITCHIT_KBD_CONFIG_KEY_LAYOUTS, + GSWITCHIT_KBD_CONFIG_KEY_OPTIONS +@@ -81,16 +93,16 @@ + + #define GSWITCHIT_KBD_CONFIG_SYSBACKUP_KEY_PREFIX KEYBOARD_CONFIG_KEY_PREFIX "/kbd.sysbackup" + +-const char GSWITCHIT_KBD_CONFIG_SYSBACKUP_DIR[] = ++const gchar GSWITCHIT_KBD_CONFIG_SYSBACKUP_DIR[] = + GSWITCHIT_KBD_CONFIG_SYSBACKUP_KEY_PREFIX; +-const char GSWITCHIT_KBD_CONFIG_SYSBACKUP_KEY_MODEL[] = ++const gchar GSWITCHIT_KBD_CONFIG_SYSBACKUP_KEY_MODEL[] = + GSWITCHIT_KBD_CONFIG_SYSBACKUP_KEY_PREFIX "/model"; +-const char GSWITCHIT_KBD_CONFIG_SYSBACKUP_KEY_LAYOUTS[] = ++const gchar GSWITCHIT_KBD_CONFIG_SYSBACKUP_KEY_LAYOUTS[] = + GSWITCHIT_KBD_CONFIG_SYSBACKUP_KEY_PREFIX "/layouts"; +-const char GSWITCHIT_KBD_CONFIG_SYSBACKUP_KEY_OPTIONS[] = ++const gchar GSWITCHIT_KBD_CONFIG_SYSBACKUP_KEY_OPTIONS[] = + GSWITCHIT_KBD_CONFIG_SYSBACKUP_KEY_PREFIX "/options"; + +-const char *GSWITCHIT_KBD_CONFIG_SYSBACKUP[] = { ++const gchar *GSWITCHIT_KBD_CONFIG_SYSBACKUP[] = { + GSWITCHIT_KBD_CONFIG_SYSBACKUP_KEY_MODEL, + GSWITCHIT_KBD_CONFIG_SYSBACKUP_KEY_LAYOUTS, + GSWITCHIT_KBD_CONFIG_SYSBACKUP_KEY_OPTIONS +@@ -111,12 +123,13 @@ + } + + static Bool +-_GSwitchItKbdConfigGetDescriptions (const char *layoutName, +- const char *variantName, +- char **layoutShortDescr, +- char **layoutDescr, +- char **variantShortDescr, +- char **variantDescr) ++_GSwitchItKbdConfigGetDescriptions (XklConfigRegistry * configRegistry, ++ const gchar * layoutName, ++ const gchar * variantName, ++ gchar ** layoutShortDescr, ++ gchar ** layoutDescr, ++ gchar ** variantShortDescr, ++ gchar ** variantDescr) + { + static XklConfigItem litem; + static XklConfigItem vitem; +@@ -124,8 +137,8 @@ + layoutName = g_strdup (layoutName); + + g_snprintf (litem.name, sizeof litem.name, "%s", layoutName); +- if (XklConfigFindLayout (&litem)) { +- *layoutShortDescr = litem.shortDescription; ++ if (xkl_config_registry_find_layout (configRegistry, &litem)) { ++ *layoutShortDescr = litem.short_description; + *layoutDescr = litem.description; + } else + *layoutShortDescr = *layoutDescr = NULL; +@@ -134,8 +147,9 @@ + variantName = g_strdup (variantName); + g_snprintf (vitem.name, sizeof vitem.name, "%s", + variantName); +- if (XklConfigFindVariant (layoutName, &vitem)) { +- *variantShortDescr = vitem.shortDescription; ++ if (xkl_config_registry_find_variant ++ (configRegistry, layoutName, &vitem)) { ++ *variantShortDescr = vitem.short_description; + *variantDescr = vitem.description; + } else + *variantShortDescr = *variantDescr = NULL; +@@ -154,14 +168,15 @@ + GConfClientNotifyFunc func, + gpointer userData, int *pid) + { +- GError *err = NULL; +- XklDebug (150, "Listening to [%s]\n", key); ++ GError *gerror = NULL; ++ xkl_debug (150, "Listening to [%s]\n", key); + *pid = gconf_client_notify_add (confClient, +- key, func, userData, NULL, &err); ++ key, func, userData, NULL, ++ &gerror); + if (0 == *pid) { + g_warning ("Error listening for configuration: [%s]\n", +- err->message); +- g_error_free (err); ++ gerror->message); ++ g_error_free (gerror); + } + } + +@@ -177,10 +192,10 @@ + /** + * extern common functions + */ +-const char * +-GSwitchItKbdConfigMergeItems (const char *parent, const char *child) ++const gchar * ++GSwitchItKbdConfigMergeItems (const gchar * parent, const gchar * child) + { +- static char buffer[XKL_MAX_CI_NAME_LENGTH * 2 - 1]; ++ static gchar buffer[XKL_MAX_CI_NAME_LENGTH * 2 - 1]; + *buffer = '\0'; + if (parent != NULL) { + if (strlen (parent) >= XKL_MAX_CI_NAME_LENGTH) +@@ -197,12 +212,13 @@ + } + + gboolean +-GSwitchItKbdConfigSplitItems (const char *merged, char **parent, char **child) ++GSwitchItKbdConfigSplitItems (const gchar * merged, gchar ** parent, ++ gchar ** child) + { +- static char pbuffer[XKL_MAX_CI_NAME_LENGTH]; +- static char cbuffer[XKL_MAX_CI_NAME_LENGTH]; ++ static gchar pbuffer[XKL_MAX_CI_NAME_LENGTH]; ++ static gchar cbuffer[XKL_MAX_CI_NAME_LENGTH]; + int plen, clen; +- const char *pos; ++ const gchar *pos; + *parent = *child = NULL; + + if (merged == NULL) +@@ -270,25 +286,24 @@ + _GSwitchItKbdConfigCopyFromXklConfig (GSwitchItKbdConfig * kbdConfig, + XklConfigRec * pdata) + { +- int i; + char **p, **p1; + GSwitchItKbdConfigModelSet (kbdConfig, pdata->model); +- XklDebug (150, "Loaded Kbd model: [%s]\n", pdata->model); ++ xkl_debug (150, "Loaded Kbd model: [%s]\n", pdata->model); + + GSwitchItKbdConfigLayoutsReset (kbdConfig); + p = pdata->layouts; + p1 = pdata->variants; +- for (i = pdata->numLayouts; --i >= 0;) { ++ while (p != NULL && *p != NULL) { + if (*p1 == NULL || **p1 == '\0') { +- XklDebug (150, "Loaded Kbd layout: [%s]\n", *p); ++ xkl_debug (150, "Loaded Kbd layout: [%s]\n", *p); + _GSwitchItKbdConfigLayoutsAdd (kbdConfig, *p); + } else { + char fullLayout[XKL_MAX_CI_NAME_LENGTH * 2]; + g_snprintf (fullLayout, sizeof (fullLayout), + "%s\t%s", *p, *p1); +- XklDebug (150, +- "Loaded Kbd layout with variant: [%s]\n", +- fullLayout); ++ xkl_debug (150, ++ "Loaded Kbd layout with variant: [%s]\n", ++ fullLayout); + _GSwitchItKbdConfigLayoutsAdd (kbdConfig, + fullLayout); + } +@@ -298,7 +313,7 @@ + + GSwitchItKbdConfigOptionsReset (kbdConfig); + p = pdata->options; +- for (i = pdata->numOptions; --i >= 0;) { ++ while (p != NULL && *p != NULL) { + char group[XKL_MAX_CI_NAME_LENGTH]; + char *option = *p; + char *delim = +@@ -308,8 +323,8 @@ + ((len = (delim - option)) < XKL_MAX_CI_NAME_LENGTH)) { + strncpy (group, option, len); + group[len] = 0; +- XklDebug (150, "Loaded Kbd option: [%s][%s]\n", +- group, option); ++ xkl_debug (150, "Loaded Kbd option: [%s][%s]\n", ++ group, option); + GSwitchItKbdConfigOptionsAdd (kbdConfig, group, + option); + } +@@ -322,63 +337,69 @@ + XklConfigRec * pdata) + { + int i; ++ int numLayouts, numOptions; + pdata->model = +- (kbdConfig->model == NULL) ? NULL : strdup (kbdConfig->model); ++ (kbdConfig->model == ++ NULL) ? NULL : g_strdup (kbdConfig->model); + +- pdata->numLayouts = pdata->numVariants = ++ numLayouts = + (kbdConfig->layouts == + NULL) ? 0 : g_slist_length (kbdConfig->layouts); +- pdata->numOptions = ++ numOptions = + (kbdConfig->options == + NULL) ? 0 : g_slist_length (kbdConfig->options); + +- XklDebug (150, "Taking %d layouts\n", pdata->numLayouts); +- if (pdata->numLayouts != 0) { ++ xkl_debug (150, "Taking %d layouts\n", numLayouts); ++ if (numLayouts != 0) { + GSList *theLayout = kbdConfig->layouts; + char **p1 = pdata->layouts = +- calloc ((sizeof (char *)) * pdata->numLayouts, 1); ++ g_new0 (char *, numLayouts + 1); + char **p2 = pdata->variants = +- calloc ((sizeof (char *)) * pdata->numVariants, 1); +- for (i = pdata->numLayouts; --i >= 0;) { ++ g_new0 (char *, numLayouts + 1); ++ for (i = numLayouts; --i >= 0;) { + char *layout, *variant; + if (GSwitchItKbdConfigSplitItems + (theLayout->data, &layout, &variant) + && variant != NULL) { + *p1 = + (layout == +- NULL) ? NULL : strdup (layout); ++ NULL) ? g_strdup ("") : ++ g_strdup (layout); + *p2 = + (variant == +- NULL) ? NULL : strdup (variant); ++ NULL) ? g_strdup ("") : ++ g_strdup (variant); + } else { + *p1 = + (theLayout->data == +- NULL) ? NULL : strdup (theLayout-> +- data); +- *p2 = NULL; ++ NULL) ? g_strdup ("") : ++ g_strdup (theLayout->data); ++ *p2 = g_strdup (""); + } +- XklDebug (150, "Adding [%s]/%p and [%s]/%p\n", +- *p1 ? *p1 : "(nil)", *p1, +- *p2 ? *p2 : "(nil)", *p2); ++ xkl_debug (150, "Adding [%s]/%p and [%s]/%p\n", ++ *p1 ? *p1 : "(nil)", *p1, ++ *p2 ? *p2 : "(nil)", *p2); + p1++; + p2++; + theLayout = theLayout->next; + } + } + +- if (pdata->numOptions != 0) { ++ if (numOptions != 0) { + GSList *theOption = kbdConfig->options; + char **p = pdata->options = +- calloc ((sizeof (char *)) * pdata->numOptions, 1); +- for (i = pdata->numOptions; --i >= 0;) { ++ g_new0 (char *, numOptions + 1); ++ for (i = numOptions; --i >= 0;) { + char *group, *option; + if (GSwitchItKbdConfigSplitItems + (theOption->data, &group, &option) + && option != NULL) +- *(p++) = strdup (option); +- else +- XklDebug (150, "Could not split [%s]\n", +- theOption->data); ++ *(p++) = g_strdup (option); ++ else { ++ *(p++) = g_strdup (""); ++ xkl_debug (150, "Could not split [%s]\n", ++ theOption->data); ++ } + theOption = theOption->next; + } + } +@@ -404,7 +425,7 @@ + + static void + _GSwitchItKbdConfigLoadParams (GSwitchItKbdConfig * kbdConfig, +- const char *paramNames[]) ++ const gchar * paramNames[]) + { + GError *gerror = NULL; + gchar *pc; +@@ -425,7 +446,8 @@ + GSwitchItKbdConfigModelSet (kbdConfig, pc); + g_free (pc); + } +- XklDebug (150, "Loaded Kbd model: [%s]\n", kbdConfig->model ? kbdConfig->model : "(null)"); ++ xkl_debug (150, "Loaded Kbd model: [%s]\n", ++ kbdConfig->model ? kbdConfig->model : "(null)"); + + GSwitchItKbdConfigLayoutsReset (kbdConfig); + +@@ -442,11 +464,11 @@ + } + + while (pl != NULL) { +- XklDebug (150, "Loaded Kbd layout: [%s]\n", pl->data); ++ xkl_debug (150, "Loaded Kbd layout: [%s]\n", pl->data); + _GSwitchItKbdConfigLayoutsAdd (kbdConfig, pl->data); + pl = pl->next; + } +- _GSwitchItConfigStringListReset(&pl); ++ _GSwitchItConfigStringListReset (&pl); + + GSwitchItKbdConfigOptionsReset (kbdConfig); + +@@ -463,52 +485,58 @@ + } + + while (pl != NULL) { +- XklDebug (150, "Loaded Kbd option: [%s]\n", pl->data); ++ xkl_debug (150, "Loaded Kbd option: [%s]\n", pl->data); + _GSwitchItKbdConfigOptionsAdd (kbdConfig, +- (const char *) pl->data); ++ (const gchar *) pl->data); + pl = pl->next; + } +- _GSwitchItConfigStringListReset(&pl); ++ _GSwitchItConfigStringListReset (&pl); + } + + static void + _GSwitchItKbdConfigSaveParams (GSwitchItKbdConfig * kbdConfig, + GConfChangeSet * cs, +- const char *paramNames[]) ++ const gchar * paramNames[]) + { + GSList *pl; + + if (kbdConfig->model) +- gconf_change_set_set_string (cs, paramNames[0], kbdConfig->model); ++ gconf_change_set_set_string (cs, paramNames[0], ++ kbdConfig->model); + else + gconf_change_set_unset (cs, paramNames[0]); +- XklDebug (150, "Saved Kbd model: [%s]\n", kbdConfig->model ? kbdConfig->model : "(null)"); ++ xkl_debug (150, "Saved Kbd model: [%s]\n", ++ kbdConfig->model ? kbdConfig->model : "(null)"); + + if (kbdConfig->layouts) { + pl = kbdConfig->layouts; + while (pl != NULL) { +- XklDebug (150, "Saved Kbd layout: [%s]\n", pl->data); ++ xkl_debug (150, "Saved Kbd layout: [%s]\n", ++ pl->data); + pl = pl->next; + } + gconf_change_set_set_list (cs, + paramNames[1], +- GCONF_VALUE_STRING, kbdConfig->layouts); ++ GCONF_VALUE_STRING, ++ kbdConfig->layouts); + } else { +- XklDebug (150, "Saved Kbd layouts: []\n"); ++ xkl_debug (150, "Saved Kbd layouts: []\n"); + gconf_change_set_unset (cs, paramNames[1]); + } + + if (kbdConfig->options) { + pl = kbdConfig->options; + while (pl != NULL) { +- XklDebug (150, "Saved Kbd option: [%s]\n", pl->data); ++ xkl_debug (150, "Saved Kbd option: [%s]\n", ++ pl->data); + pl = pl->next; + } + gconf_change_set_set_list (cs, + paramNames[2], +- GCONF_VALUE_STRING, kbdConfig->options); ++ GCONF_VALUE_STRING, ++ kbdConfig->options); + } else { +- XklDebug (150, "Saved Kbd options: []\n"); ++ xkl_debug (150, "Saved Kbd options: []\n"); + gconf_change_set_unset (cs, paramNames[2]); + } + } +@@ -517,13 +545,14 @@ + * extern GSwitchItConfig config functions + */ + void +-GSwitchItConfigInit (GSwitchItConfig * config, +- GConfClient * confClient) ++GSwitchItConfigInit (GSwitchItConfig * config, GConfClient * confClient, ++ XklEngine * engine) + { + GError *gerror = NULL; + + memset (config, 0, sizeof (*config)); + config->confClient = confClient; ++ config->engine = engine; + g_object_ref (config->confClient); + + gconf_client_add_dir (config->confClient, +@@ -559,7 +588,7 @@ + g_error_free (gerror); + gerror = NULL; + } +- XklDebug (150, "groupPerApp: %d\n", config->groupPerApp); ++ xkl_debug (150, "groupPerApp: %d\n", config->groupPerApp); + + config->handleIndicators = + gconf_client_get_bool (config->confClient, +@@ -572,7 +601,8 @@ + g_error_free (gerror); + gerror = NULL; + } +- XklDebug (150, "handleIndicators: %d\n", config->handleIndicators); ++ xkl_debug (150, "handleIndicators: %d\n", ++ config->handleIndicators); + + config->layoutNamesAsGroupNames = + gconf_client_get_bool (config->confClient, +@@ -585,7 +615,8 @@ + g_error_free (gerror); + gerror = NULL; + } +- XklDebug (150, "layoutNamesAsGroupNames: %d\n", config->layoutNamesAsGroupNames); ++ xkl_debug (150, "layoutNamesAsGroupNames: %d\n", ++ config->layoutNamesAsGroupNames); + + config->defaultGroup = + gconf_client_get_int (config->confClient, +@@ -600,9 +631,10 @@ + } + + if (config->defaultGroup < -1 +- || config->defaultGroup >= XklGetMaxNumGroups ()) ++ || config->defaultGroup >= ++ xkl_engine_get_max_num_groups (config->engine)) + config->defaultGroup = -1; +- XklDebug (150, "defaultGroup: %d\n", config->defaultGroup); ++ xkl_debug (150, "defaultGroup: %d\n", config->defaultGroup); + } + + void +@@ -642,38 +674,40 @@ + { + gboolean rv = TRUE; + +- XklSetGroupPerApp (config->groupPerApp); +- XklSetIndicatorsHandling (config->handleIndicators); +- XklSetDefaultGroup (config->defaultGroup); ++ xkl_engine_set_group_per_toplevel_window (config->engine, ++ config->groupPerApp); ++ xkl_engine_set_indicators_handling (config->engine, ++ config->handleIndicators); ++ xkl_engine_set_default_group (config->engine, ++ config->defaultGroup); + + return rv; + } + + void +-GSwitchItConfigLockNextGroup (void) ++GSwitchItConfigLockNextGroup (GSwitchItConfig * config) + { +- int group = XklGetNextGroup (); +- XklLockGroup (group); ++ int group = xkl_engine_get_next_group (config->engine); ++ xkl_engine_lock_group (config->engine, group); + } + + void +-GSwitchItConfigLockPrevGroup (void) ++GSwitchItConfigLockPrevGroup (GSwitchItConfig * config) + { +- int group = XklGetPrevGroup (); +- XklLockGroup (group); ++ int group = xkl_engine_get_prev_group (config->engine); ++ xkl_engine_lock_group (config->engine, group); + } + + void +-GSwitchItConfigRestoreGroup (void) ++GSwitchItConfigRestoreGroup (GSwitchItConfig * config) + { +- int group = XklGetRestoreGroup (); +- XklLockGroup (group); ++ int group = xkl_engine_get_current_window_group (config->engine); ++ xkl_engine_lock_group (config->engine, group); + } + + void + GSwitchItConfigStartListen (GSwitchItConfig * config, +- GConfClientNotifyFunc func, +- gpointer userData) ++ GConfClientNotifyFunc func, gpointer userData) + { + _GSwitchItConfigAddListener (config->confClient, + GSWITCHIT_CONFIG_DIR, func, +@@ -686,17 +720,19 @@ + _GSwitchItConfigRemoveListener (config->confClient, + &config->configListenerId); + } ++ + /** + * extern GSwitchItKbdConfig config functions + */ + void + GSwitchItKbdConfigInit (GSwitchItKbdConfig * kbdConfig, +- GConfClient * confClient) ++ GConfClient * confClient, XklEngine * engine) + { + GError *gerror = NULL; + + memset (kbdConfig, 0, sizeof (*kbdConfig)); + kbdConfig->confClient = confClient; ++ kbdConfig->engine = engine; + g_object_ref (kbdConfig->confClient); + + gconf_client_add_dir (kbdConfig->confClient, +@@ -731,14 +767,15 @@ + GSList *pl; + + if (kbdConfig->model == NULL) +- kbdConfig->model = g_strdup (kbdConfigDefault->model); ++ kbdConfig->model = ++ g_strdup (kbdConfigDefault->model); + + if (kbdConfig->layouts == NULL) { + pl = kbdConfigDefault->layouts; + while (pl != NULL) { + kbdConfig->layouts = +- g_slist_append (kbdConfig->layouts, +- g_strdup (pl->data)); ++ g_slist_append (kbdConfig->layouts, ++ g_strdup (pl->data)); + pl = pl->next; + } + } +@@ -747,8 +784,8 @@ + pl = kbdConfigDefault->options; + while (pl != NULL) { + kbdConfig->options = +- g_slist_append (kbdConfig->options, +- g_strdup (pl->data)); ++ g_slist_append (kbdConfig->options, ++ g_strdup (pl->data)); + pl = pl->next; + } + } +@@ -765,29 +802,27 @@ + void + GSwitchItKbdConfigLoadFromXCurrent (GSwitchItKbdConfig * kbdConfig) + { +- XklConfigRec data; +- XklConfigRecInit (&data); +- if (XklConfigGetFromServer (&data)) +- _GSwitchItKbdConfigCopyFromXklConfig (kbdConfig, &data); ++ XklConfigRec *data = xkl_config_rec_new (); ++ if (xkl_config_rec_get_from_server (data, kbdConfig->engine)) ++ _GSwitchItKbdConfigCopyFromXklConfig (kbdConfig, data); + else +- XklDebug (150, +- "Could not load keyboard config from server: [%s]\n", +- XklGetLastError ()); +- XklConfigRecDestroy (&data); ++ xkl_debug (150, ++ "Could not load keyboard config from server: [%s]\n", ++ xkl_get_last_error ()); ++ g_object_unref (G_OBJECT (data)); + } + + void + GSwitchItKbdConfigLoadFromXInitial (GSwitchItKbdConfig * kbdConfig) + { +- XklConfigRec data; +- XklConfigRecInit (&data); +- if (XklConfigGetFromBackup (&data)) +- _GSwitchItKbdConfigCopyFromXklConfig (kbdConfig, &data); ++ XklConfigRec *data = xkl_config_rec_new (); ++ if (xkl_config_rec_get_from_backup (data, kbdConfig->engine)) ++ _GSwitchItKbdConfigCopyFromXklConfig (kbdConfig, data); + else +- XklDebug (150, +- "Could not load keyboard config from backup: [%s]\n", +- XklGetLastError ()); +- XklConfigRecDestroy (&data); ++ xkl_debug (150, ++ "Could not load keyboard config from backup: [%s]\n", ++ xkl_get_last_error ()); ++ g_object_unref (G_OBJECT (data)); + } + + gboolean +@@ -856,7 +891,8 @@ + if (kbdConfig->model != NULL) + g_free (kbdConfig->model); + kbdConfig->model = +- (modelName == NULL || modelName[0] == '\0') ? NULL : g_strdup (modelName); ++ (modelName == NULL ++ || modelName[0] == '\0') ? NULL : g_strdup (modelName); + } + + void +@@ -864,7 +900,7 @@ + const gchar * layoutName, + const gchar * variantName) + { +- const char *merged; ++ const gchar *merged; + if (layoutName == NULL) + return; + merged = GSwitchItKbdConfigMergeItems (layoutName, variantName); +@@ -890,7 +926,7 @@ + const gchar * groupName, + const gchar * optionName) + { +- const char *merged; ++ const gchar *merged; + if (groupName == NULL || optionName == NULL) + return; + merged = GSwitchItKbdConfigMergeItems (groupName, optionName); +@@ -904,7 +940,7 @@ + const gchar * groupName, + const gchar * optionName) + { +- const char *merged = ++ const gchar *merged = + GSwitchItKbdConfigMergeItems (groupName, optionName); + if (merged == NULL) + return FALSE; +@@ -918,14 +954,11 @@ + GSwitchItKbdConfigActivate (GSwitchItKbdConfig * kbdConfig) + { + gboolean rv; ++ XklConfigRec *data = xkl_config_rec_new (); + +- XklConfigRec data; +- XklConfigRecInit (&data); +- +- _GSwitchItKbdConfigCopyToXklConfig (kbdConfig, &data); +- +- rv = XklConfigActivate (&data); +- XklConfigRecDestroy (&data); ++ _GSwitchItKbdConfigCopyToXklConfig (kbdConfig, data); ++ rv = xkl_config_rec_activate (data, kbdConfig->engine); ++ g_object_unref (G_OBJECT (data)); + + return rv; + } +@@ -937,7 +970,8 @@ + { + _GSwitchItConfigAddListener (kbdConfig->confClient, + GSWITCHIT_KBD_CONFIG_DIR, func, +- userData, &kbdConfig->configListenerId); ++ userData, ++ &kbdConfig->configListenerId); + } + + void +@@ -954,15 +988,15 @@ + GSwitchItAppletConfigFreeImages (GSwitchItAppletConfig * appletConfig) + { + GdkPixbuf *pi; +- GSList* imgNode; +- while ((imgNode = appletConfig->images) != NULL) +- { ++ GSList *imgNode; ++ while ((imgNode = appletConfig->images) != NULL) { + pi = GDK_PIXBUF (imgNode->data); + /* It can be NULL - some images may be missing */ + if (pi != NULL) { + gdk_pixbuf_unref (pi); + } +- appletConfig->images = g_slist_remove_link (appletConfig->images, imgNode); ++ appletConfig->images = ++ g_slist_remove_link (appletConfig->images, imgNode); + g_slist_free_1 (imgNode); + } + } +@@ -986,7 +1020,8 @@ + + if (fullLayoutName != NULL) { + char *l, *v; +- GSwitchItKbdConfigSplitItems (fullLayoutName, &l, &v); ++ GSwitchItKbdConfigSplitItems (fullLayoutName, &l, ++ &v); + if (l != NULL) { + // probably there is something in theme? + iconInfo = gtk_icon_theme_lookup_icon +@@ -1018,53 +1053,62 @@ + if (!appletConfig->showFlags) + return; + +- for (i = XklGetMaxNumGroups (); --i >= 0;) { ++ for (i = xkl_engine_get_max_num_groups (appletConfig->engine); ++ --i >= 0;) { + GdkPixbuf *image = NULL; + char *imageFile = + GSwitchItAppletConfigGetImagesFile (appletConfig, + kbdConfig, i); + + if (imageFile != NULL) { +- GError *err = NULL; ++ GError *gerror = NULL; + image = +- gdk_pixbuf_new_from_file (imageFile, &err); ++ gdk_pixbuf_new_from_file (imageFile, &gerror); + if (image == NULL) { +- GtkWidget *dialog = gtk_message_dialog_new (NULL, +- GTK_DIALOG_DESTROY_WITH_PARENT, +- GTK_MESSAGE_ERROR, +- GTK_BUTTONS_OK, +- _("There was an error loading an image: %s"), +- err->message); ++ GtkWidget *dialog = ++ gtk_message_dialog_new (NULL, ++ GTK_DIALOG_DESTROY_WITH_PARENT, ++ GTK_MESSAGE_ERROR, ++ GTK_BUTTONS_OK, ++ _ ++ ("There was an error loading an image: %s"), ++ gerror-> ++ message); + g_signal_connect (G_OBJECT (dialog), + "response", +- G_CALLBACK (gtk_widget_destroy), NULL); ++ G_CALLBACK ++ (gtk_widget_destroy), ++ NULL); + +- gtk_window_set_resizable (GTK_WINDOW (dialog), FALSE); ++ gtk_window_set_resizable (GTK_WINDOW ++ (dialog), FALSE); + + gtk_widget_show (dialog); +- g_error_free (err); ++ g_error_free (gerror); + } +- XklDebug (150, +- "Image %d[%s] loaded -> %p[%dx%d]\n", +- i, imageFile, image, +- gdk_pixbuf_get_width (image), +- gdk_pixbuf_get_height (image)); ++ xkl_debug (150, ++ "Image %d[%s] loaded -> %p[%dx%d]\n", ++ i, imageFile, image, ++ gdk_pixbuf_get_width (image), ++ gdk_pixbuf_get_height (image)); + g_free (imageFile); + } + /* We append the image anyway - even if it is NULL! */ +- appletConfig->images = g_slist_prepend (appletConfig->images, image); ++ appletConfig->images = ++ g_slist_prepend (appletConfig->images, image); + } + } + + void + GSwitchItAppletConfigInit (GSwitchItAppletConfig * appletConfig, +- GConfClient * confClient) ++ GConfClient * confClient, XklEngine * engine) + { + GError *gerror = NULL; + gchar *sp, *datadir; + + memset (appletConfig, 0, sizeof (*appletConfig)); + appletConfig->confClient = confClient; ++ appletConfig->engine = engine; + g_object_ref (appletConfig->confClient); + + gconf_client_add_dir (appletConfig->confClient, +@@ -1204,7 +1248,9 @@ + void + GSwitchItAppletConfigActivate (GSwitchItAppletConfig * appletConfig) + { +- XklSetSecondaryGroupsMask (appletConfig->secondaryGroupsMask); ++ xkl_engine_set_secondary_groups_mask (appletConfig->engine, ++ appletConfig-> ++ secondaryGroupsMask); + } + + void +@@ -1214,7 +1260,8 @@ + { + _GSwitchItConfigAddListener (appletConfig->confClient, + GSWITCHIT_APPLET_CONFIG_DIR, func, +- userData, &appletConfig->configListenerId); ++ userData, ++ &appletConfig->configListenerId); + } + + void +@@ -1225,27 +1272,31 @@ + } + + Bool +-GSwitchItKbdConfigGetDescriptions (const char *name, +- char **layoutShortDescr, +- char **layoutDescr, +- char **variantShortDescr, +- char **variantDescr) ++GSwitchItKbdConfigGetDescriptions (XklConfigRegistry * configRegistry, ++ const gchar * name, ++ gchar ** layoutShortDescr, ++ gchar ** layoutDescr, ++ gchar ** variantShortDescr, ++ gchar ** variantDescr) + { + char *layoutName = NULL, *variantName = NULL; +- if (!GSwitchItKbdConfigSplitItems (name, &layoutName, &variantName)) ++ if (!GSwitchItKbdConfigSplitItems ++ (name, &layoutName, &variantName)) + return FALSE; +- return _GSwitchItKbdConfigGetDescriptions (layoutName, variantName, +- layoutShortDescr, +- layoutDescr, +- variantShortDescr, +- variantDescr); ++ return _GSwitchItKbdConfigGetDescriptions (configRegistry, ++ layoutName, ++ variantName, ++ layoutShortDescr, ++ layoutDescr, ++ variantShortDescr, ++ variantDescr); + } + +-const char * +-GSwitchItKbdConfigFormatFullLayout (const char *layoutDescr, +- const char *variantDescr) ++const gchar * ++GSwitchItKbdConfigFormatFullLayout (const gchar * layoutDescr, ++ const gchar * variantDescr) + { +- static char fullDescr[XKL_MAX_CI_DESC_LENGTH * 2]; ++ static gchar fullDescr[XKL_MAX_CI_DESC_LENGTH * 2]; + if (variantDescr == NULL) + g_snprintf (fullDescr, sizeof (fullDescr), "%s", + layoutDescr); +@@ -1255,55 +1306,221 @@ + return fullDescr; + } + +-GSList * +-GSwitchItConfigLoadGroupDescriptionsUtf8 (GSwitchItConfig * config) ++gchar ** ++GSwitchItConfigLoadGroupDescriptionsUtf8 (GSwitchItConfig * config, ++ XklConfigRegistry * ++ configRegistry) + { + int i; +- const char **pNativeNames = XklGetGroupNames (); +- GSList *rv = NULL; +- if ((XklGetBackendFeatures() & XKLF_MULTIPLE_LAYOUTS_SUPPORTED) && +- config->layoutNamesAsGroupNames) { +- XklConfigRec xklConfig; +- XklConfigRecInit (&xklConfig); +- if (XklConfigGetFromServer (&xklConfig)) { +- char **pl = xklConfig.layouts; +- char **pv = xklConfig.variants; +- for (i = xklConfig.numLayouts; --i >= 0;) { ++ const gchar **pNativeNames = ++ xkl_engine_get_groups_names (config->engine); ++ guint totalGroups = xkl_engine_get_num_groups (config->engine); ++ guint totalLayouts; ++ gchar **rv = g_new0 (char *, totalGroups + 1); ++ gchar **pCurrentDescr = rv; ++ ++ if ((xkl_engine_get_features (config->engine) & ++ XKLF_MULTIPLE_LAYOUTS_SUPPORTED) ++ && config->layoutNamesAsGroupNames) { ++ XklConfigRec *xklConfig = xkl_config_rec_new (); ++ if (xkl_config_rec_get_from_server ++ (xklConfig, config->engine)) { ++ char **pl = xklConfig->layouts; ++ char **pv = xklConfig->variants; ++ i = totalGroups; ++ while (pl != NULL && *pl != NULL && i >= 0) { + char *lSDescr; + char *lDescr; + char *vSDescr; + char *vDescr; + if (_GSwitchItKbdConfigGetDescriptions +- (*pl++, *pv++, &lSDescr, &lDescr, +- &vSDescr, &vDescr)) { ++ (configRegistry, *pl++, *pv++, ++ &lSDescr, &lDescr, &vSDescr, ++ &vDescr)) { + char *nameUtf = + g_locale_to_utf8 + (GSwitchItKbdConfigFormatFullLayout + (lDescr, vDescr), -1, NULL, + NULL, NULL); +- rv = g_slist_append (rv, nameUtf); ++ *pCurrentDescr++ = nameUtf; + } else { +- rv = g_slist_append (rv, g_strdup("")); ++ *pCurrentDescr++ = g_strdup (""); + } + } + } +- XklConfigRecDestroy (&xklConfig); ++ g_object_unref (G_OBJECT (xklConfig)); + /* Worst case - multiple layous - but SOME of them are multigrouped :((( + We cannot do much - just add empty descriptions. + The UI is going to be messy. + Canadian layouts are famous for this sh.t. */ +- if (g_slist_length (rv) != XklGetNumGroups()) +- { +- XklDebug (0, "The mismatch between " +- "the number of groups: %d and number of layouts: %d\n", +- XklGetNumGroups(), g_slist_length (rv)); +- for (i = XklGetNumGroups() - g_slist_length (rv); --i>=0;) +- rv = g_slist_append (rv, g_strdup("")); ++ totalLayouts = g_strv_length (rv); ++ if (totalLayouts != totalGroups) { ++ xkl_debug (0, ++ "The mismatch between " ++ "the number of groups: %d and number of layouts: %d\n", ++ totalGroups, totalLayouts); ++ pCurrentDescr = rv + totalLayouts; ++ for (i = totalGroups - totalLayouts; --i >= 0;) ++ *pCurrentDescr++ = g_strdup (""); + } + } +- if (rv == NULL) +- for (i = XklGetNumGroups (); --i >= 0;) +- rv = g_slist_append (rv, g_strdup (*pNativeNames++)); ++ totalLayouts = g_strv_length (rv); ++ if (!totalLayouts) ++ for (i = totalGroups; --i >= 0;) ++ *pCurrentDescr++ = g_strdup (*pNativeNames++); + + return rv; + } ++ ++gchar * ++GSwitchItKbdConfigToString (const GSwitchItKbdConfig * config) ++{ ++ gchar *layouts = NULL, *options = NULL; ++ GString *buffer = g_string_new (NULL); ++ ++ GSList *iter; ++ gint count; ++ gchar *result; ++ ++ if (config->layouts) { ++ /* g_slist_length is "expensive", so we determinate the length on the fly */ ++ for (iter = config->layouts, count = 0; iter; ++ iter = iter->next, ++count) { ++ if (buffer->len) ++ g_string_append (buffer, " "); ++ ++ g_string_append (buffer, ++ (const gchar *) iter->data); ++ } ++ ++ layouts = ++ g_strdup_printf (ngettext ++ ("layout \"%s\"", "layouts \"%s\"", ++ count), buffer->str); ++ g_string_truncate (buffer, 0); ++ } ++ if (config->options) { ++ /* g_slist_length is "expensive", so we determinate the length on the fly */ ++ for (iter = config->options, count = 0; iter; ++ iter = iter->next, ++count) { ++ if (buffer->len) ++ g_string_append (buffer, " "); ++ ++ g_string_append (buffer, ++ (const gchar *) iter->data); ++ } ++ ++ options = ++ g_strdup_printf (ngettext ++ ("option \"%s\"", "options \"%s\"", ++ count), buffer->str); ++ g_string_truncate (buffer, 0); ++ } ++ ++ g_string_free (buffer, TRUE); ++ ++ result = ++ g_strdup_printf (_("model \"%s\", %s and %s"), config->model, ++ layouts ? layouts : _("no layout"), ++ options ? options : _("no options")); ++ ++ g_free (options); ++ g_free (layouts); ++ ++ return result; ++} ++ ++GdkRectangle * ++GSwitchItPreviewLoad (void) ++{ ++ GError *gerror = NULL; ++ GdkRectangle *rv = NULL; ++ gint x, y, w, h; ++ GConfClient *confClient = gconf_client_get_default (); ++ ++ if (confClient == NULL) ++ return NULL; ++ ++ x = gconf_client_get_int (confClient, ++ GSWITCHIT_PREVIEW_CONFIG_KEY_X, &gerror); ++ if (gerror != NULL) { ++ xkl_debug (0, "Error getting the preview x: %s\n", ++ gerror->message); ++ g_error_free (gerror); ++ g_object_unref (G_OBJECT (confClient)); ++ return NULL; ++ } ++ ++ y = gconf_client_get_int (confClient, ++ GSWITCHIT_PREVIEW_CONFIG_KEY_Y, &gerror); ++ if (gerror != NULL) { ++ xkl_debug (0, "Error getting the preview y: %s\n", ++ gerror->message); ++ g_error_free (gerror); ++ g_object_unref (G_OBJECT (confClient)); ++ return NULL; ++ } ++ ++ w = gconf_client_get_int (confClient, ++ GSWITCHIT_PREVIEW_CONFIG_KEY_WIDTH, ++ &gerror); ++ if (gerror != NULL) { ++ xkl_debug (0, "Error getting the preview width: %s\n", ++ gerror->message); ++ g_error_free (gerror); ++ g_object_unref (G_OBJECT (confClient)); ++ return NULL; ++ } ++ ++ h = gconf_client_get_int (confClient, ++ GSWITCHIT_PREVIEW_CONFIG_KEY_HEIGHT, ++ &gerror); ++ if (gerror != NULL) { ++ xkl_debug (0, "Error getting the preview height: %s\n", ++ gerror->message); ++ g_error_free (gerror); ++ g_object_unref (G_OBJECT (confClient)); ++ return NULL; ++ } ++ ++ g_object_unref (G_OBJECT (confClient)); ++ ++ // default values should be just ignored ++ if (x == -1 || y == -1 || w == -1 || h == -1) ++ return NULL; ++ ++ rv = g_new (GdkRectangle, 1); ++ rv->x = x; ++ rv->y = y; ++ rv->width = w; ++ rv->height = h; ++ return rv; ++} ++ ++void ++GSwitchItPreviewSave (GdkRectangle * rect) ++{ ++ GConfClient *confClient = gconf_client_get_default (); ++ GConfChangeSet *cs; ++ GError *gerror = NULL; ++ ++ cs = gconf_change_set_new (); ++ ++ gconf_change_set_set_int (cs, GSWITCHIT_PREVIEW_CONFIG_KEY_X, ++ rect->x); ++ gconf_change_set_set_int (cs, GSWITCHIT_PREVIEW_CONFIG_KEY_Y, ++ rect->y); ++ gconf_change_set_set_int (cs, GSWITCHIT_PREVIEW_CONFIG_KEY_WIDTH, ++ rect->width); ++ gconf_change_set_set_int (cs, GSWITCHIT_PREVIEW_CONFIG_KEY_HEIGHT, ++ rect->height); ++ ++ gconf_client_commit_change_set (confClient, cs, TRUE, &gerror); ++ if (gerror != NULL) { ++ g_warning ("Error saving preview configuration: %s\n", ++ gerror->message); ++ g_error_free (gerror); ++ } ++ gconf_change_set_unref (cs); ++ g_object_unref (G_OBJECT (confClient)); ++} +diff -u libgswitchit-/gswitchit_config.h libgswitchit/gswitchit_config.h +--- libgswitchit-/gswitchit_config.h 2005-07-26 16:38:25.000000000 -0400 ++++ libgswitchit/gswitchit_config.h 2006-05-26 20:19:52.000000000 -0400 +@@ -27,22 +27,30 @@ + #include <gdk-pixbuf/gdk-pixbuf.h> + #include <gconf/gconf-client.h> + +-extern const char GSWITCHIT_CONFIG_DIR[]; +-extern const char GSWITCHIT_CONFIG_KEY_DEFAULT_GROUP[]; +-extern const char GSWITCHIT_CONFIG_KEY_GROUP_PER_WINDOW[]; +-extern const char GSWITCHIT_CONFIG_KEY_HANDLE_INDICATORS[]; +-extern const char GSWITCHIT_CONFIG_KEY_LAYOUT_NAMES_AS_GROUP_NAMES[]; +- +-extern const char GSWITCHIT_KBD_CONFIG_DIR[]; +-extern const char GSWITCHIT_KBD_CONFIG_KEY_MODEL[]; +-extern const char GSWITCHIT_KBD_CONFIG_KEY_LAYOUTS[]; +-extern const char GSWITCHIT_KBD_CONFIG_KEY_OPTIONS[]; ++#include <libxklavier/xklavier.h> ++ ++extern const gchar GSWITCHIT_CONFIG_DIR[]; ++extern const gchar GSWITCHIT_CONFIG_KEY_DEFAULT_GROUP[]; ++extern const gchar GSWITCHIT_CONFIG_KEY_GROUP_PER_WINDOW[]; ++extern const gchar GSWITCHIT_CONFIG_KEY_HANDLE_INDICATORS[]; ++extern const gchar GSWITCHIT_CONFIG_KEY_LAYOUT_NAMES_AS_GROUP_NAMES[]; ++ ++extern const gchar GSWITCHIT_PREVIEW_CONFIG_DIR[]; ++extern const gchar GSWITCHIT_PREVIEW_CONFIG_KEY_X[]; ++extern const gchar GSWITCHIT_PREVIEW_CONFIG_KEY_Y[]; ++extern const gchar GSWITCHIT_PREVIEW_CONFIG_KEY_WIDTH[]; ++extern const gchar GSWITCHIT_PREVIEW_CONFIG_KEY_HEIGHT[]; ++ ++extern const gchar GSWITCHIT_KBD_CONFIG_DIR[]; ++extern const gchar GSWITCHIT_KBD_CONFIG_KEY_MODEL[]; ++extern const gchar GSWITCHIT_KBD_CONFIG_KEY_LAYOUTS[]; ++extern const gchar GSWITCHIT_KBD_CONFIG_KEY_OPTIONS[]; + + /* + * General configuration + */ + typedef struct _GSwitchItConfig { +- int defaultGroup; ++ gint defaultGroup; + gboolean groupPerApp; + gboolean handleIndicators; + gboolean layoutNamesAsGroupNames; +@@ -50,6 +58,7 @@ + /* private, transient */ + GConfClient *confClient; + int configListenerId; ++ XklEngine *engine; + } GSwitchItConfig; + + /* +@@ -63,6 +72,7 @@ + /* private, transient */ + GConfClient *confClient; + int configListenerId; ++ XklEngine *engine; + } GSwitchItKbdConfig; + + /* +@@ -79,13 +89,15 @@ + GSList *images; + GtkIconTheme *iconTheme; + int configListenerId; ++ XklEngine *engine; + } GSwitchItAppletConfig; + + /** + * GSwitchItConfig functions + */ + extern void GSwitchItConfigInit (GSwitchItConfig * config, +- GConfClient * confClient); ++ GConfClient * confClient, ++ XklEngine * engine); + extern void GSwitchItConfigTerm (GSwitchItConfig * config); + + extern void GSwitchItConfigLoadFromGConf (GSwitchItConfig * config); +@@ -95,17 +107,19 @@ + extern gboolean GSwitchItConfigActivate (GSwitchItConfig * config); + + /* Affected by XKB and XKB/GConf configuration */ +-extern GSList * +-GSwitchItConfigLoadGroupDescriptionsUtf8 (GSwitchItConfig * config); ++extern gchar **GSwitchItConfigLoadGroupDescriptionsUtf8 (GSwitchItConfig * ++ config, ++ XklConfigRegistry ++ * configRegistry); + +-extern void GSwitchItConfigLockNextGroup (void); ++extern void GSwitchItConfigLockNextGroup (GSwitchItConfig * config); + +-extern void GSwitchItConfigLockPrevGroup (void); ++extern void GSwitchItConfigLockPrevGroup (GSwitchItConfig * config); + +-extern void GSwitchItConfigRestoreGroup (void); ++extern void GSwitchItConfigRestoreGroup (GSwitchItConfig * config); + + extern void GSwitchItConfigStartListen (GSwitchItConfig * config, +- GConfClientNotifyFunc func, ++ GConfClientNotifyFunc func, + gpointer user_data); + + extern void GSwitchItConfigStopListen (GSwitchItConfig * config); +@@ -114,24 +128,31 @@ + * GSwitchItKbdConfig functions + */ + extern void GSwitchItKbdConfigInit (GSwitchItKbdConfig * kbdConfig, +- GConfClient * confClient); ++ GConfClient * confClient, ++ XklEngine * engine); + extern void GSwitchItKbdConfigTerm (GSwitchItKbdConfig * kbdConfig); + +-extern void GSwitchItKbdConfigLoadFromGConf (GSwitchItKbdConfig * kbdConfig, +- GSwitchItKbdConfig * kbdConfigDefault); ++extern void GSwitchItKbdConfigLoadFromGConf (GSwitchItKbdConfig * ++ kbdConfig, ++ GSwitchItKbdConfig * ++ kbdConfigDefault); + + extern void GSwitchItKbdConfigSaveToGConf (GSwitchItKbdConfig * kbdConfig); + +-extern void GSwitchItKbdConfigLoadFromGConfBackup (GSwitchItKbdConfig * kbdConfig); ++extern void GSwitchItKbdConfigLoadFromGConfBackup (GSwitchItKbdConfig * ++ kbdConfig); + +-extern void GSwitchItKbdConfigSaveToGConfBackup (GSwitchItKbdConfig * kbdConfig); ++extern void GSwitchItKbdConfigSaveToGConfBackup (GSwitchItKbdConfig * ++ kbdConfig); + +-extern void GSwitchItKbdConfigLoadFromXInitial (GSwitchItKbdConfig * kbdConfig); ++extern void GSwitchItKbdConfigLoadFromXInitial (GSwitchItKbdConfig * ++ kbdConfig); + +-extern void GSwitchItKbdConfigLoadFromXCurrent (GSwitchItKbdConfig * kbdConfig); ++extern void GSwitchItKbdConfigLoadFromXCurrent (GSwitchItKbdConfig * ++ kbdConfig); + + extern void GSwitchItKbdConfigStartListen (GSwitchItKbdConfig * kbdConfig, +- GConfClientNotifyFunc func, ++ GConfClientNotifyFunc func, + gpointer user_data); + + extern void GSwitchItKbdConfigStopListen (GSwitchItKbdConfig * kbdConfig); +@@ -139,55 +160,85 @@ + extern gboolean GSwitchItKbdConfigEquals (GSwitchItKbdConfig * kbdConfig1, + GSwitchItKbdConfig * kbdConfig2); + +-extern gboolean GSwitchItKbdConfigActivate (GSwitchItKbdConfig * kbdConfig); ++extern gboolean GSwitchItKbdConfigActivate (GSwitchItKbdConfig * ++ kbdConfig); + +-extern const char *GSwitchItKbdConfigMergeItems (const char *parent, +- const char *child); ++extern const gchar *GSwitchItKbdConfigMergeItems (const gchar * parent, ++ const gchar * child); + +-extern gboolean GSwitchItKbdConfigSplitItems (const char *merged, +- char **parent, char **child); ++extern gboolean GSwitchItKbdConfigSplitItems (const gchar * merged, ++ gchar ** parent, ++ gchar ** child); ++ ++extern Bool GSwitchItKbdConfigGetDescriptions (XklConfigRegistry * ++ configRegistry, ++ const gchar * name, ++ gchar ** layoutShortDescr, ++ gchar ** layoutDescr, ++ gchar ** variantShortDescr, ++ gchar ** variantDescr); ++ ++extern const gchar *GSwitchItKbdConfigFormatFullLayout (const gchar ++ * layoutDescr, ++ const gchar * ++ variantDescr); + +-extern Bool GSwitchItKbdConfigGetDescriptions (const char *name, +- char **layoutShortDescr, +- char **layoutDescr, +- char **variantShortDescr, +- char **variantDescr); ++extern gchar *GSwitchItKbdConfigToString (const GSwitchItKbdConfig * ++ config); + +-extern const char *GSwitchItKbdConfigFormatFullLayout (const char *layoutDescr, +- const char *variantDescr); + + /** + * GSwitchItAppletConfig functions - + * some of them require GSwitchItKbdConfig as well - + * for loading approptiate images + */ +-extern void GSwitchItAppletConfigInit (GSwitchItAppletConfig * appletConfig, +- GConfClient * confClient); +-extern void GSwitchItAppletConfigTerm (GSwitchItAppletConfig * appletConfig); +- +-extern void GSwitchItAppletConfigLoadFromGConf (GSwitchItAppletConfig * appletConfig); +-extern void GSwitchItAppletConfigSaveToGConf (GSwitchItAppletConfig * appletConfig); +- +-extern char +-*GSwitchItAppletConfigGetImagesFile (GSwitchItAppletConfig * appletConfig, +- GSwitchItKbdConfig * kbdConfig, +- int group); +- +-extern void GSwitchItAppletConfigLoadImages (GSwitchItAppletConfig * appletConfig, +- GSwitchItKbdConfig * kbdConfig); +-extern void GSwitchItAppletConfigFreeImages (GSwitchItAppletConfig * appletConfig); ++extern void GSwitchItAppletConfigInit (GSwitchItAppletConfig * ++ appletConfig, ++ GConfClient * confClient, ++ XklEngine * engine); ++extern void GSwitchItAppletConfigTerm (GSwitchItAppletConfig * ++ appletConfig); ++ ++extern void GSwitchItAppletConfigLoadFromGConf (GSwitchItAppletConfig * ++ appletConfig); ++extern void GSwitchItAppletConfigSaveToGConf (GSwitchItAppletConfig * ++ appletConfig); ++ ++extern gchar *GSwitchItAppletConfigGetImagesFile (GSwitchItAppletConfig * ++ appletConfig, ++ GSwitchItKbdConfig * ++ kbdConfig, int group); ++ ++extern void GSwitchItAppletConfigLoadImages (GSwitchItAppletConfig * ++ appletConfig, ++ GSwitchItKbdConfig * ++ kbdConfig); ++extern void GSwitchItAppletConfigFreeImages (GSwitchItAppletConfig * ++ appletConfig); + + /* Should be updated on Applet/GConf and Kbd/GConf configuration change */ +-extern void GSwitchItAppletConfigUpdateImages (GSwitchItAppletConfig * appletConfig, +- GSwitchItKbdConfig * kbdConfig); ++extern void GSwitchItAppletConfigUpdateImages (GSwitchItAppletConfig * ++ appletConfig, ++ GSwitchItKbdConfig * ++ kbdConfig); + + /* Should be updated on Applet/GConf configuration change */ +-extern void GSwitchItAppletConfigActivate (GSwitchItAppletConfig * appletConfig); ++extern void GSwitchItAppletConfigActivate (GSwitchItAppletConfig * ++ appletConfig); + +-extern void GSwitchItAppletConfigStartListen (GSwitchItAppletConfig * appletConfig, +- GConfClientNotifyFunc func, ++extern void GSwitchItAppletConfigStartListen (GSwitchItAppletConfig * ++ appletConfig, ++ GConfClientNotifyFunc func, + gpointer user_data); + +-extern void GSwitchItAppletConfigStopListen (GSwitchItAppletConfig * appletConfig); ++extern void GSwitchItAppletConfigStopListen (GSwitchItAppletConfig * ++ appletConfig); ++ ++/** ++ * GSwitchItPreview functions ++ */ ++extern GdkRectangle *GSwitchItPreviewLoad (void); ++ ++extern void GSwitchItPreviewSave (GdkRectangle * rect); + + #endif +diff -u libgswitchit-/gswitchit_plugin.h libgswitchit/gswitchit_plugin.h +--- libgswitchit-/gswitchit_plugin.h 2005-12-06 18:25:44.000000000 -0500 ++++ libgswitchit/gswitchit_plugin.h 2006-05-26 20:27:01.000000000 -0400 +@@ -35,7 +35,8 @@ + typedef gboolean (*GSwitchItPluginInitFunc) (GSwitchItPluginContainer * + pc); + +-typedef void (*GSwitchItPluginGroupChangedFunc) (GtkWidget * notebook, int newGroup); ++typedef void (*GSwitchItPluginGroupChangedFunc) (GtkWidget * notebook, ++ int newGroup); + + typedef void (*GSwitchItPluginConfigChangedFunc) (const GSwitchItKbdConfig + * from, +@@ -105,7 +106,8 @@ + + extern guint GSwitchItPluginGetNumGroups (GSwitchItPluginContainer * pc); + +-extern GSList* +-GSwitchItPluginLoadLocalizedGroupNames (GSwitchItPluginContainer * pc); ++extern gchar ++ **GSwitchItPluginLoadLocalizedGroupNames (GSwitchItPluginContainer * ++ pc); + + #endif +diff -u libgswitchit-/gswitchit_plugin_manager.c libgswitchit/gswitchit_plugin_manager.c +--- libgswitchit-/gswitchit_plugin_manager.c 2005-12-06 18:25:44.000000000 -0500 ++++ libgswitchit/gswitchit_plugin_manager.c 2006-04-19 19:18:00.000000000 -0400 +@@ -46,11 +46,11 @@ + if (dir == NULL) + return; + +- XklDebug (100, "Scanning [%s]...\n", dirname); ++ xkl_debug (100, "Scanning [%s]...\n", dirname); + while ((filename = g_dir_read_name (dir)) != NULL) { + gchar *fullPath = + g_build_filename (dirname, filename, NULL); +- XklDebug (100, "Loading plugin module [%s]...\n", ++ xkl_debug (100, "Loading plugin module [%s]...\n", + fullPath); + if (fullPath != NULL) { + GModule *module = g_module_open (fullPath, 0); +@@ -68,7 +68,7 @@ + g_new0 + (GSwitchItPluginManagerRecord, + 1); +- XklDebug (100, ++ xkl_debug (100, + "Loaded plugin from [%s]: [%s]/[%s]...\n", + fullPath, + plugin->name, +@@ -84,12 +84,12 @@ + continue; + } + } else +- XklDebug (0, ++ xkl_debug (0, + "Bad plugin: [%s]\n", + fullPath); + g_module_close (module); + } else +- XklDebug (0, "Bad module: [%s], %s\n", ++ xkl_debug (0, "Bad module: [%s], %s\n", + fullPath, g_module_error()); + g_free (fullPath); + } +@@ -101,7 +101,7 @@ + _GSwitchItPluginManagerLoadAll (GSwitchItPluginManager *manager) + { + if (!g_module_supported ()) { +- XklDebug (0, "Modules are not supported - no plugins!\n"); ++ xkl_debug (0, "Modules are not supported - no plugins!\n"); + return; + } + _GSwitchItPluginManagerAddPluginsDir (manager, SYS_PLUGIN_DIR); +@@ -113,7 +113,7 @@ + { + const GSwitchItPlugin *plugin = rec->plugin; + if (plugin != NULL) { +- XklDebug (100, "Terminating plugin: [%s]...\n", ++ xkl_debug (100, "Terminating plugin: [%s]...\n", + plugin->name); + if (plugin->termCallback) + (*plugin->termCallback) (); +@@ -123,7 +123,7 @@ + static void + _GSwitchItPluginManagerRecDestroy (GSwitchItPluginManagerRecord *rec) + { +- XklDebug (100, "Unloading plugin: [%s]...\n", rec->plugin->name); ++ xkl_debug (100, "Unloading plugin: [%s]...\n", rec->plugin->name); + + g_module_close (rec->module); + g_free (rec); +@@ -158,7 +158,7 @@ + GSList *pluginNameNode = enabledPlugins; + if (manager->allPluginRecs == NULL) + return; +- XklDebug (100, "Initializing all enabled plugins...\n"); ++ xkl_debug (100, "Initializing all enabled plugins...\n"); + while (pluginNameNode != NULL) { + const char *fullPath = pluginNameNode->data; + if (fullPath != NULL) { +@@ -171,7 +171,7 @@ + const GSwitchItPlugin *plugin = + rec->plugin; + gboolean initialized = FALSE; +- XklDebug (100, ++ xkl_debug (100, + "Initializing plugin: [%s] from [%s]...\n", + plugin->name, fullPath); + if (plugin->initCallback != NULL) +@@ -183,7 +183,7 @@ + manager->initedPluginRecs = + g_slist_append (manager-> + initedPluginRecs, rec); +- XklDebug (100, ++ xkl_debug (100, + "Plugin [%s] initialized: %d\n", + plugin->name, initialized); + } +@@ -324,7 +324,7 @@ + int groupToAssign = + (*plugin->windowCreatedCallback) (win, parent); + if (groupToAssign != -1) { +- XklDebug (100, ++ xkl_debug (100, + "Plugin [%s] assigned group %d to new window %ld\n", + plugin->name, groupToAssign, win); + return groupToAssign; +@@ -348,7 +348,7 @@ + groupDescription, + kbdConfig); + if (decoratedWidget != NULL) { +- XklDebug (100, ++ xkl_debug (100, + "Plugin [%s] decorated widget %p to %p\n", + plugin->name, widget, decoratedWidget); + return decoratedWidget; +@@ -383,9 +383,3 @@ + { + g_object_unref (pc->confClient); + } +- +-guint +-GSwitchItPluginGetNumGroups (GSwitchItPluginContainer *pc) +-{ +- return XklGetNumGroups (); +-} +diff -u libgswitchit-/gswitchit_util.c libgswitchit/gswitchit_util.c +--- libgswitchit-/gswitchit_util.c 2005-03-16 07:53:08.000000000 -0500 ++++ libgswitchit/gswitchit_util.c 2006-04-19 19:18:00.000000000 -0400 +@@ -72,5 +72,5 @@ + void + GSwitchItInstallGlibLogAppender (void) + { +- XklSetLogAppender (GSwitchItLogAppender); ++ xkl_set_log_appender (GSwitchItLogAppender); + } +Only in libgswitchit: .indent.pro +Only in libgswitchit: MAINTAINERS +diff -u gswitchit-/ChangeLog gswitchit/ChangeLog +--- gswitchit-/ChangeLog 2006-04-08 13:27:51.000000000 -0400 ++++ gswitchit/ChangeLog 2006-05-26 20:21:10.000000000 -0400 +@@ -1,3 +1,17 @@ ++2006-05-27 Sergey Udaltsov <svu@gnome.org> ++ ++ * gswitchit-applet.c, gswitchit-plugin.c: Better UTF-8 description ++ handling, changed GSList to NULL-terminated gchar ** ++ ++2006-05-23 Sergey Udaltsov <svu@gnome.org> ++ ++ * gswitchit-applet.c: Mouse wheel events are ignored ++ ++2006-04-23 Sergey Udaltsov <svu@gnome.org> ++ ++ * gswitchit-applet.c: Layout View keeps track of the window ++ geometry (same as gnome-keyboard-properties "Add Layout" dialog) ++ + 2006-04-08 cyphra <serrador@cvs.gnome.org> + + * help/es/es.po: Updated Spanish translation +diff -u gswitchit-/gswitchit-applet.c gswitchit/gswitchit-applet.c +--- gswitchit-/gswitchit-applet.c 2006-03-29 12:30:57.000000000 -0500 ++++ gswitchit/gswitchit-applet.c 2006-05-26 20:21:10.000000000 -0400 +@@ -32,8 +32,6 @@ + #include <gdk/gdkx.h> + #include <glade/glade.h> + +-#include <libxklavier/xklavier_config.h> +- + #define GROUPS_SUBMENU_PATH "/popups/popup/groups" + + /* we never build applet without XKB, so far: TODO */ +@@ -45,8 +43,14 @@ + * 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 + +@@ -64,7 +68,7 @@ + GSList* cur; \ + for (cur = globals.appletInstances; cur != NULL; cur = cur->next) { \ + GSwitchItApplet * sia = (GSwitchItApplet*)cur->data; +-#define NextApplet \ ++#define NextApplet() \ + } \ + } + +@@ -150,9 +154,9 @@ + GSwitchItAppletRevalidate (sia); + + /* also, update tooltips */ +- currentState = XklGetCurrentState (); ++ currentState = xkl_engine_get_current_state (globals.engine); + if (currentState->group >= 0) { +- pname = g_slist_nth_data (globals.groupNames, currentState->group); ++ pname = globals.groupNames[currentState->group]; + GSwitchItAppletSetTooltip (sia, pname); + } + } +@@ -160,78 +164,82 @@ + /* Should be called once for all applets */ + static void + GSwitchItConfigChanged (GConfClient * client, +- guint cnxn_id, +- GConfEntry * entry) ++ guint cnxn_id, GConfEntry * entry) + { +- XklDebug (100, +- "General configuration changed in GConf - reiniting...\n"); ++ xkl_debug (100, ++ "General configuration changed in GConf - reiniting...\n"); + GSwitchItConfigLoadFromGConf (&globals.config); + GSwitchItConfigActivate (&globals.config); +- ForAllApplets () ++ ForAllApplets () { + GSwitchItAppletReinitUi (sia); +- NextApplet ++ } NextApplet (); + } + + /* Should be called once for all applets */ + static void + GSwitchItAppletConfigChanged (GConfClient * client, +- guint cnxn_id, +- GConfEntry * entry) ++ guint cnxn_id, GConfEntry * entry) + { +- GSList* enabledPlugins = NULL; ++ GSList *enabledPlugins = NULL; + +- XklDebug (100, +- "Applet configuration changed in GConf - reiniting...\n"); ++ xkl_debug (100, ++ "Applet configuration changed in GConf - reiniting...\n"); + GSwitchItAppletConfigLoadFromGConf (&globals.appletConfig); +- GSwitchItAppletConfigUpdateImages (&globals.appletConfig, &globals.kbdConfig); ++ GSwitchItAppletConfigUpdateImages (&globals.appletConfig, ++ &globals.kbdConfig); + GSwitchItAppletConfigActivate (&globals.appletConfig); +- ++ + GSwitchItPluginManagerTogglePlugins (&globals.pluginManager, + &globals.pluginContainer, +- globals.appletConfig.enabledPlugins); ++ globals.appletConfig. ++ enabledPlugins); + +- ForAllApplets () ++ ForAllApplets () { + GSwitchItAppletReinitUi (sia); +- NextApplet ++ } NextApplet (); + } + + /* Should be called once for all applets */ + static void +-GSwitchItAppletKbdConfigCallback (void) ++GSwitchItAppletKbdConfigCallback (XklEngine * engine) + { +- XklDebug (100, +- "XKB configuration changed on X Server - reiniting...\n"); ++ xkl_debug (100, ++ "XKB configuration changed on X Server - reiniting...\n"); + + GSwitchItKbdConfigLoadFromXCurrent (&globals.kbdConfig); +- GSwitchItAppletConfigUpdateImages (&globals.appletConfig, &globals.kbdConfig); ++ GSwitchItAppletConfigUpdateImages (&globals.appletConfig, ++ &globals.kbdConfig); + +- while (globals.groupNames != NULL) { +- GSList * nn = globals.groupNames; +- globals.groupNames = g_slist_remove_link (globals.groupNames, nn); +- g_free (nn->data); +- g_slist_free_1 (nn); +- } +- globals.groupNames = GSwitchItConfigLoadGroupDescriptionsUtf8 (&globals.config); ++ g_strfreev (globals.groupNames); ++ globals.groupNames = ++ GSwitchItConfigLoadGroupDescriptionsUtf8 (&globals.config, ++ globals. ++ configRegistry); + +- ForAllApplets () ++ ForAllApplets () { + GSwitchItAppletReinitUi (sia); +- NextApplet ++ } ++ NextApplet (); + } + + /* Should be called once for all applets */ + static void +-GSwitchItAppletStateCallback (XklStateChange changeType, +- int group, Bool restore) ++GSwitchItAppletStateCallback (XklEngine * engine, ++ XklEngineStateChange changeType, gint group, ++ gboolean restore) + { +- XklDebug (150, "group is now %d, restore: %d\n", group, restore); ++ xkl_debug (150, "group is now %d, restore: %d\n", group, restore); + + if (changeType == GROUP_CHANGED) { +- ForAllApplets () +- GSwitchItPluginManagerGroupChanged (&globals.pluginManager, +- sia->notebook, group); +- XklDebug (200, "do repaint\n"); ++ ForAllApplets () { ++ GSwitchItPluginManagerGroupChanged (&globals. ++ pluginManager, ++ sia->notebook, ++ group); ++ xkl_debug (200, "do repaint\n"); + GSwitchItAppletRevalidateGroup (sia, group); +- NextApplet ++ } ++ NextApplet (); + } + } + +@@ -241,37 +249,43 @@ + { + XEvent *xevent = (XEvent *) xev; + +- XklFilterEvents (xevent); ++ xkl_engine_filter_events (globals.engine, xevent); + switch (xevent->type) { + case DestroyNotify: + { +- XDestroyWindowEvent *de = (XDestroyWindowEvent *) xev; +- +- ForAllApplets () +- GdkWindow * w = sia->appletAncestor; ++ XDestroyWindowEvent *de = ++ (XDestroyWindowEvent *) xev; ++ ++ ForAllApplets () { ++ GdkWindow *w = sia->appletAncestor; + + /* compare the applet's parent window with the even window */ +- if (w != NULL && GDK_WINDOW_XID (w) == de->window) { ++ if (w != NULL ++ && GDK_WINDOW_XID (w) == de->window) { + sia->appletAncestor = NULL; + } +- NextApplet +- ++ } ++ NextApplet (); + } + break; + case ReparentNotify: + { + XReparentEvent *rne = (XReparentEvent *) xev; + +- ForAllApplets () +- GdkWindow * w = sia->appletAncestor; ++ ForAllApplets () { ++ GdkWindow *w = sia->appletAncestor; + + /* compare the applet's parent window with the even window */ +- if (w != NULL && GDK_WINDOW_XID (w) == rne->window) { +- /* if so - make it transparent...*/ +- XklSetTransparent (rne->window, TRUE); +- break; /* once is enough */ ++ if (w != NULL ++ && GDK_WINDOW_XID (w) == rne->window) { ++ /* if so - make it transparent... */ ++ xkl_engine_set_window_transparent ++ (globals.engine, rne->window, ++ TRUE); ++ break; /* once is enough */ + } +- NextApplet ++ } ++ NextApplet (); + } + break; + } +@@ -283,7 +297,7 @@ + GSwitchItAppletRevalidate (GSwitchItApplet * sia) + { + XklState *currentState; +- currentState = XklGetCurrentState (); ++ currentState = xkl_engine_get_current_state (globals.engine); + if (currentState->group >= 0) + GSwitchItAppletRevalidateGroup (sia, currentState->group); + } +@@ -318,8 +332,7 @@ + image = GDK_PIXBUF (pimage); + orient = + panel_applet_get_orient (PANEL_APPLET (sia->applet)); +- psize = +- panel_applet_get_size (PANEL_APPLET (sia->applet)); ++ psize = panel_applet_get_size (PANEL_APPLET (sia->applet)); + isize = psize - 4; + xyratio = + 1.0 * gdk_pixbuf_get_width (image) / +@@ -340,8 +353,11 @@ + ysize1 = psize / xyratio; + break; + } +- XklDebug (150, "Resizing the applet for size %d: %d X %d\n", isize, xsize, ysize); +- XklDebug (150, "Would be %d: %d X %d\n", psize, xsize1, ysize1); ++ xkl_debug (150, ++ "Resizing the applet for size %d: %d X %d\n", ++ isize, xsize, ysize); ++ xkl_debug (150, "Would be %d: %d X %d\n", psize, xsize1, ++ ysize1); + + scaled = + gdk_pixbuf_scale_simple (image, xsize, ysize, +@@ -350,7 +366,7 @@ + gtk_container_add (GTK_CONTAINER (sia->ebox), flagImg); + g_object_unref (G_OBJECT (scaled)); + } else { +- gpointer pcounter = NULL; ++ gpointer pcounter = NULL; + char *prevLayoutName = NULL; + char *labelTitle = NULL; + int counter = 0; +@@ -359,12 +375,15 @@ + GtkWidget *align, *label; + static GHashTable *shortDescrs = NULL; + if (group == 0) +- shortDescrs = g_hash_table_new_full (g_str_hash, g_str_equal, +- g_free, NULL); ++ shortDescrs = ++ g_hash_table_new_full (g_str_hash, g_str_equal, ++ g_free, NULL); + +- if (XklGetBackendFeatures() & XKLF_MULTIPLE_LAYOUTS_SUPPORTED) { ++ if (xkl_engine_get_features (globals.engine) & ++ XKLF_MULTIPLE_LAYOUTS_SUPPORTED) { + char *fullLayoutName = +- (char *) g_slist_nth_data (globals.kbdConfig.layouts, ++ (char *) g_slist_nth_data (globals.kbdConfig. ++ layouts, + group); + char *variantName; + if (!GSwitchItKbdConfigSplitItems +@@ -376,44 +395,45 @@ + sizeof (configItem.name), "%s", + layoutName); + +- if (XklConfigFindLayout (&configItem)) { +- char *sd = configItem.shortDescription; ++ if (xkl_config_registry_find_layout ++ (globals.configRegistry, &configItem)) { ++ char *sd = configItem.short_description; + if (sd != NULL && *sd != '\0') { +- layoutName = ++ layoutName = + g_locale_to_utf8 (sd, -1, NULL, + NULL, NULL); + } + } + } else +- layoutName = g_strdup (g_slist_nth_data (globals.groupNames, group)); ++ layoutName = g_strdup (globals.groupNames[group]); + + if (layoutName == NULL) + layoutName = g_strdup ("?"); + +- if (g_hash_table_lookup_extended (shortDescrs, layoutName, +- (gpointer*)&prevLayoutName, &pcounter)) +- { ++ if (g_hash_table_lookup_extended (shortDescrs, layoutName, ++ (gpointer *) & ++ prevLayoutName, ++ &pcounter)) { + /* "next" same description */ +- char* appendix = NULL; +- counter = GPOINTER_TO_INT(pcounter); ++ char *appendix = NULL; ++ counter = GPOINTER_TO_INT (pcounter); + appendix = g_strnfill (counter, '*'); +- labelTitle = g_strconcat (layoutName, appendix, NULL); ++ labelTitle = ++ g_strconcat (layoutName, appendix, NULL); + g_free (appendix); + /* layoutName is g_freed inside g_hash_table_insert function */ +- } +- else +- { ++ } else { + /* "first" time this description */ + labelTitle = g_strdup (layoutName); + } +- g_hash_table_insert (shortDescrs, layoutName, GINT_TO_POINTER (counter + 1)); ++ g_hash_table_insert (shortDescrs, layoutName, ++ GINT_TO_POINTER (counter + 1)); + + align = gtk_alignment_new (0.5, 0.5, 1.0, 1.0); + label = gtk_label_new (labelTitle); + g_free (labelTitle); + +- if (group == XklGetNumGroups ()) +- { ++ if (group == xkl_engine_get_num_groups (globals.engine)) { + g_hash_table_destroy (shortDescrs); + shortDescrs = NULL; + } +@@ -425,13 +445,11 @@ + } + g_signal_connect (G_OBJECT (sia->ebox), + "button_press_event", +- G_CALLBACK +- (GSwitchItAppletButtonPressed), sia); ++ G_CALLBACK (GSwitchItAppletButtonPressed), sia); + + g_signal_connect (G_OBJECT (sia->applet), + "key_press_event", +- G_CALLBACK +- (GSwitchItAppletKeyPressed), sia); ++ G_CALLBACK (GSwitchItAppletKeyPressed), sia); + + return sia->ebox; + } +@@ -440,23 +458,24 @@ + GSwitchItAppletFillNotebook (GSwitchItApplet * sia) + { + int grp; +- int totalGroups = XklGetNumGroups (); ++ int totalGroups = xkl_engine_get_num_groups (globals.engine); + GtkNotebook *notebook = GTK_NOTEBOOK (sia->notebook); + + for (grp = 0; grp < totalGroups; grp++) { + GtkWidget *page, *decoratedPage; +- XklDebug (150, +- "The widget for the group %d is not ready, let's prepare it!\n", +- grp); ++ xkl_debug (150, ++ "The widget for the group %d is not ready, let's prepare it!\n", ++ grp); + page = GSwitchItAppletPrepareDrawing (sia, grp); + + decoratedPage = +- GSwitchItPluginManagerDecorateWidget (&globals.pluginManager, ++ GSwitchItPluginManagerDecorateWidget (&globals. ++ pluginManager, + page, grp, +- g_slist_nth_data ( +- globals.groupNames, +- grp), +- &globals.kbdConfig); ++ globals. ++ groupNames[grp], ++ &globals. ++ kbdConfig); + page = decoratedPage == NULL ? page : decoratedPage; + + gtk_notebook_append_page (notebook, page, NULL); +@@ -468,11 +487,12 @@ + GSwitchItAppletRevalidateGroup (GSwitchItApplet * sia, int group) + { + const char *pname; +- XklDebug (200, "Revalidating for group %d\n", group); ++ xkl_debug (200, "Revalidating for group %d\n", group); + +- gtk_notebook_set_current_page (GTK_NOTEBOOK (sia->notebook), group + 1); ++ gtk_notebook_set_current_page (GTK_NOTEBOOK (sia->notebook), ++ group + 1); + +- pname = g_slist_nth_data (globals.groupNames, group); ++ pname = globals.groupNames[group]; + GSwitchItAppletSetTooltip (sia, pname); + } + +@@ -486,56 +506,57 @@ + GSwitchItAppletRevalidate (sia); + } + +-static void +-GSwitchItAppletSetBackground(PanelAppletBackgroundType type, +- GtkRcStyle * rc_style, +- GtkWidget * w, +- GdkColor * color, +- GdkPixmap * pixmap) ++static void ++GSwitchItAppletSetBackground (PanelAppletBackgroundType type, ++ GtkRcStyle * rc_style, ++ GtkWidget * w, ++ GdkColor * color, GdkPixmap * pixmap) + { + GtkStyle *style; + + gtk_widget_set_style (GTK_WIDGET (w), NULL); + gtk_widget_modify_style (GTK_WIDGET (w), rc_style); + +- switch (type) +- { ++ switch (type) { + case PANEL_NO_BACKGROUND: +- break; ++ break; + case PANEL_COLOR_BACKGROUND: +- gtk_widget_modify_bg (GTK_WIDGET (w), +- GTK_STATE_NORMAL, color); ++ gtk_widget_modify_bg (GTK_WIDGET (w), ++ GTK_STATE_NORMAL, color); + break; + case PANEL_PIXMAP_BACKGROUND: + style = gtk_style_copy (w->style); + if (style->bg_pixmap[GTK_STATE_NORMAL]) +- g_object_unref (style->bg_pixmap[GTK_STATE_NORMAL]); ++ g_object_unref (style-> ++ bg_pixmap[GTK_STATE_NORMAL]); + style->bg_pixmap[GTK_STATE_NORMAL] = g_object_ref (pixmap); + gtk_widget_set_style (w, style); + g_object_unref (style); + break; + } + /* go down */ +- if (GTK_IS_CONTAINER (w)) +- { +- GList * child = gtk_container_get_children (GTK_CONTAINER (w)); +- while (child != NULL) +- { ++ if (GTK_IS_CONTAINER (w)) { ++ GList *child = ++ gtk_container_get_children (GTK_CONTAINER (w)); ++ while (child != NULL) { + GSwitchItAppletSetBackground (type, rc_style, +- GTK_WIDGET (child->data), color, pixmap); ++ GTK_WIDGET (child-> ++ data), ++ color, pixmap); + child = child->next; + } + } + } + + static void +-GSwitchItAppletChangeBackground (PanelApplet * widget, ++GSwitchItAppletChangeBackground (PanelApplet * widget, + PanelAppletBackgroundType type, + GdkColor * color, GdkPixmap * pixmap, + GSwitchItApplet * sia) + { + GtkRcStyle *rc_style = gtk_rc_style_new (); +- GSwitchItAppletSetBackground(type, rc_style, sia->applet, color, pixmap); ++ GSwitchItAppletSetBackground (type, rc_style, sia->applet, color, ++ pixmap); + gtk_rc_style_unref (rc_style); + } + +@@ -552,7 +573,7 @@ + case GDK_Return: + case GDK_space: + case GDK_KP_Space: +- GSwitchItConfigLockNextGroup (); ++ GSwitchItConfigLockNextGroup (&globals.config); + return TRUE; + default: + break; +@@ -566,13 +587,12 @@ + GdkEventButton * + event, GSwitchItAppletConfig * config) + { +- GtkWidget * img = gtk_bin_get_child (GTK_BIN (widget)); +- XklDebug (150, "Flag img size %d x %d\n", +- img->allocation.width, +- img->allocation.height); ++ GtkWidget *img = gtk_bin_get_child (GTK_BIN (widget)); ++ xkl_debug (150, "Flag img size %d x %d\n", ++ img->allocation.width, img->allocation.height); + if (event->button == 1 && event->type == GDK_BUTTON_PRESS) { +- XklDebug (150, "Mouse button pressed on applet\n"); +- GSwitchItConfigLockNextGroup (); ++ xkl_debug (150, "Mouse button pressed on applet\n"); ++ GSwitchItConfigLockNextGroup (&globals.config); + return TRUE; + } + return FALSE; +@@ -595,114 +615,150 @@ + } + } + +-static void +-GSwitchItPreviewResponse (GtkWidget *dialog, gint resp) ++static void ++GSwitchItPreviewResponse (GtkWidget * dialog, gint resp) + { +- switch (resp) +- { +- case GTK_RESPONSE_HELP: +- GSwitchItHelp (GTK_WIDGET (dialog), +- "layout-view"); +- break; +- case GTK_RESPONSE_CLOSE: +- gtk_widget_destroy (dialog); +- default:; ++ GdkRectangle rect; ++ ++ switch (resp) { ++ case GTK_RESPONSE_HELP: ++ GSwitchItHelp (GTK_WIDGET (dialog), "layout-view"); ++ return; ++ case GTK_RESPONSE_CLOSE: ++ gtk_window_get_position (GTK_WINDOW (dialog), &rect.x, ++ &rect.y); ++ gtk_window_get_size (GTK_WINDOW (dialog), &rect.width, ++ &rect.height); ++ GSwitchItPreviewSave (&rect); ++ gtk_widget_destroy (dialog); + } + } + +-static void +-GSwitchItPreviewDestroy (GtkWidget *dialog, gint group) ++static void ++GSwitchItPreviewDestroy (GtkWidget * dialog, gint group) + { +- GladeXML *gladeData = GLADE_XML (gtk_object_get_data (GTK_OBJECT (dialog), "gladeData")); ++ GladeXML *gladeData = ++ GLADE_XML (gtk_object_get_data ++ (GTK_OBJECT (dialog), "gladeData")); + g_object_unref (G_OBJECT (gladeData)); +- g_hash_table_remove (globals.previewDialogs, GINT_TO_POINTER (group)); ++ g_hash_table_remove (globals.previewDialogs, ++ GINT_TO_POINTER (group)); + } + + void + GSwitchItAppletCmdPreview (BonoboUIComponent * + uic, GSwitchItApplet * sia, const gchar * verb) + { +- static KeyboardDrawingGroupLevel groupsLevels[] = { {0,1}, {0,3}, {0,0}, {0,2} }; +- static KeyboardDrawingGroupLevel * pGroupsLevels[] = { +- groupsLevels, groupsLevels + 1, groupsLevels + 2, groupsLevels + 3 }; ++ static KeyboardDrawingGroupLevel groupsLevels[] = ++ { {0, 1}, {0, 3}, {0, 0}, {0, 2} }; ++ static KeyboardDrawingGroupLevel *pGroupsLevels[] = { ++ groupsLevels, groupsLevels + 1, groupsLevels + 2, ++ groupsLevels + 3 ++ }; + #ifdef HAVE_XKB + GladeXML *gladeData; + GtkWidget *dialog, *kbdraw; + XkbComponentNamesRec componentNames; +- XklConfigRec xklData; ++ XklConfigRec *xklData; ++ GdkRectangle *rect; + #endif +- XklState *xklState = XklGetCurrentState (); +- gpointer p = g_hash_table_lookup (globals.previewDialogs, GINT_TO_POINTER (xklState->group)); +- if (p != NULL) +- { ++ XklState *xklState = ++ xkl_engine_get_current_state (globals.config.engine); ++ gpointer p = g_hash_table_lookup (globals.previewDialogs, ++ GINT_TO_POINTER (xklState-> ++ group)); ++ if (p != NULL) { + /* existing window */ + gtk_window_present (GTK_WINDOW (p)); + return; + } + #ifdef HAVE_XKB +- gladeData = glade_xml_new (GNOME_GLADEDIR "/gswitchit.glade", "gswitchit_layout_view", NULL); +- dialog = glade_xml_get_widget (gladeData, "gswitchit_layout_view"); ++ gladeData = ++ glade_xml_new (GNOME_GLADEDIR "/gswitchit.glade", ++ "gswitchit_layout_view", NULL); ++ dialog = glade_xml_get_widget (gladeData, "gswitchit_layout_view"); + kbdraw = keyboard_drawing_new (); + +- if (xklState->group >= 0 && +- xklState->group < g_slist_length (globals.groupNames)) +- { ++ if (xklState->group >= 0 && ++ xklState->group < g_strv_length (globals.groupNames)) { + char title[128]; + snprintf (title, sizeof (title), +- _("Keyboard Layout \"%s\""), +- g_slist_nth_data (globals.groupNames, xklState->group)); +- gtk_window_set_title (GTK_WINDOW(dialog), title); +- } +- +- keyboard_drawing_set_groups_levels (KEYBOARD_DRAWING (kbdraw), pGroupsLevels); +- +- XklConfigRecInit (&xklData); +- if (XklConfigGetFromServer (&xklData)) +- { +- if (xklState->group >= 0 && +- xklState->group < xklData.numLayouts && +- xklState->group < xklData.numVariants) +- { +- char * l = g_strdup (xklData.layouts[xklState->group]); +- char * v = g_strdup (xklData.variants[xklState->group]); +- char ** p; ++ _("Keyboard Layout \"%s\""), ++ globals.groupNames[xklState->group]); ++ gtk_window_set_title (GTK_WINDOW (dialog), title); ++ } ++ ++ keyboard_drawing_set_groups_levels (KEYBOARD_DRAWING (kbdraw), ++ pGroupsLevels); ++ ++ xklData = xkl_config_rec_new (); ++ if (xkl_config_rec_get_from_server (xklData, globals.engine)) { ++ int numLayouts = g_strv_length (xklData->layouts); ++ int numVariants = g_strv_length (xklData->variants); ++ if (xklState->group >= 0 && ++ xklState->group < numLayouts && ++ xklState->group < numVariants) { ++ char *l = ++ g_strdup (xklData->layouts[xklState->group]); ++ char *v = ++ g_strdup (xklData->variants[xklState->group]); ++ char **p; + int i; + +- if( ( p = xklData.layouts ) != NULL ) +- for( i = xklData.numLayouts; --i >= 0; ) +- free( *p++ ); +- +- if( ( p = xklData.variants ) != NULL ) +- for( i = xklData.numVariants; --i >= 0; ) +- free( *p++ ); +- +- xklData.numLayouts = xklData.numVariants = 1; +- xklData.layouts = realloc (xklData.layouts, sizeof (char*)); +- xklData.variants = realloc (xklData.variants, sizeof (char*)); +- xklData.layouts[0] = l; +- xklData.variants[0] = v; ++ if ((p = xklData->layouts) != NULL) ++ for (i = numLayouts; --i >= 0;) ++ g_free (*p++); ++ ++ if ((p = xklData->variants) != NULL) ++ for (i = numVariants; --i >= 0;) ++ g_free (*p++); ++ ++ xklData->layouts = ++ g_realloc (xklData->layouts, ++ sizeof (char *) * 2); ++ xklData->variants = ++ g_realloc (xklData->variants, ++ sizeof (char *) * 2); ++ xklData->layouts[0] = l; ++ xklData->variants[0] = v; ++ xklData->layouts[1] = xklData->variants[1] = NULL; + } + +- if (_XklXkbConfigPrepareNative (&xklData, &componentNames)) +- { +- keyboard_drawing_set_keyboard (KEYBOARD_DRAWING (kbdraw), &componentNames); +- _XklXkbConfigCleanupNative (&componentNames); ++ if (xkl_xkb_config_native_prepare ++ (globals.engine, xklData, &componentNames)) { ++ keyboard_drawing_set_keyboard (KEYBOARD_DRAWING ++ (kbdraw), ++ &componentNames); ++ xkl_xkb_config_native_cleanup (globals.engine, ++ &componentNames); + } + } +- XklConfigRecDestroy (&xklData); ++ g_object_unref (G_OBJECT (xklData)); + + gtk_object_set_data (GTK_OBJECT (dialog), "gladeData", gladeData); + g_signal_connect (GTK_OBJECT (dialog), + "destroy", G_CALLBACK (GSwitchItPreviewDestroy), + GINT_TO_POINTER (xklState->group)); +- g_signal_connect (G_OBJECT (dialog), "response", G_CALLBACK(GSwitchItPreviewResponse), NULL); ++ g_signal_connect (G_OBJECT (dialog), "response", ++ G_CALLBACK (GSwitchItPreviewResponse), NULL); ++ ++ rect = GSwitchItPreviewLoad (); ++ if (rect != NULL) { ++ gtk_window_move (GTK_WINDOW (dialog), rect->x, rect->y); ++ gtk_window_resize (GTK_WINDOW (dialog), rect->width, ++ rect->height); ++ g_free (rect); ++ } else ++ gtk_window_resize (GTK_WINDOW (dialog), 700, 400); + +- gtk_window_resize (GTK_WINDOW (dialog), 700, 400); + gtk_window_set_resizable (GTK_WINDOW (dialog), TRUE); + +- gtk_container_add (GTK_CONTAINER (glade_xml_get_widget (gladeData, "preview_vbox")), kbdraw); +- +- g_hash_table_insert (globals.previewDialogs, GINT_TO_POINTER (xklState->group), dialog); ++ gtk_container_add (GTK_CONTAINER ++ (glade_xml_get_widget ++ (gladeData, "preview_vbox")), kbdraw); ++ ++ g_hash_table_insert (globals.previewDialogs, ++ GINT_TO_POINTER (xklState->group), dialog); + + gtk_widget_show_all (GTK_WIDGET (dialog)); + #endif +@@ -733,24 +789,26 @@ + XklState st; + Window cur; + if (sscanf (verb, "Group_%d", &st.group) != 1) { +- XklDebug (50, "Strange verb: [%s]\n", verb); ++ xkl_debug (50, "Strange verb: [%s]\n", verb); + return; + } + +- XklAllowOneSwitchToSecondaryGroup (); +- cur = XklGetCurrentWindow (); ++ xkl_engine_allow_one_switch_to_secondary_group (globals.engine); ++ cur = xkl_engine_get_current_window (globals.engine); + if (cur != (Window) NULL) { +- XklDebug (150, "Enforcing the state %d for window %lx\n", +- st.group, cur); +- XklSaveState (XklGetCurrentWindow (), &st); ++ xkl_debug (150, "Enforcing the state %d for window %lx\n", ++ st.group, cur); ++ xkl_engine_save_state (globals.engine, ++ xkl_engine_get_current_window ++ (globals.engine), &st); + /* XSetInputFocus( GDK_DISPLAY(), cur, RevertToNone, CurrentTime );*/ + } else { +- XklDebug (150, +- "??? Enforcing the state %d for unknown window\n", +- st.group); ++ xkl_debug (150, ++ "??? Enforcing the state %d for unknown window\n", ++ st.group); + /* strange situation - bad things can happen */ + } +- XklLockGroup (st.group); ++ xkl_engine_lock_group (globals.engine, st.group); + } + + void +@@ -772,20 +830,25 @@ + "Sergey V. Udaltsov<svu@gnome.org>", + NULL + }; +- ++ + const gchar *translator_credits = _("translator-credits"); +- ++ + gtk_show_about_dialog (NULL, +- "name", _("Keyboard Indicator"), +- "version", VERSION, ++ "name", _("Keyboard Indicator"), ++ "version", VERSION, + /* Translators: Please replace (C) with the proper copyright character. */ +- "copyright", _("Copyright (c) Sergey V. Udaltsov 1999-2004"), +- "comments", _("Keyboard layout indicator applet for GNOME"), +- "authors", authors, +- "documenters", documenters, +- "translator-credits", strcmp (translator_credits, "translator-credits") != 0 ? translator_credits : NULL, +- "logo-icon-name", "gswitchit-applet", +- NULL); ++ "copyright", ++ _ ++ ("Copyright (c) Sergey V. Udaltsov 1999-2004"), ++ "comments", ++ _ ++ ("Keyboard layout indicator applet for GNOME"), ++ "authors", authors, "documenters", ++ documenters, "translator-credits", ++ strcmp (translator_credits, ++ "translator-credits") != ++ 0 ? translator_credits : NULL, ++ "logo-icon-name", "gswitchit-applet", NULL); + } + + static void +@@ -795,45 +858,46 @@ + BonoboUIComponent *popup; + popup = + panel_applet_get_popup_component (PANEL_APPLET (sia->applet)); +- for (i = 0;;i++) { ++ for (i = 0;; i++) { + char path[80]; + g_snprintf (path, sizeof (path), + GROUPS_SUBMENU_PATH "/Group_%d", i); + if (bonobo_ui_component_path_exists (popup, path, NULL)) { + bonobo_ui_component_rm (popup, path, NULL); +- XklDebug (160, +- "Unregistered group menu item \'%s\'\n", +- path); ++ xkl_debug (160, ++ "Unregistered group menu item \'%s\'\n", ++ path); + } else + break; + } + +- XklDebug (160, "Unregistered group submenu\n"); ++ xkl_debug (160, "Unregistered group submenu\n"); + } + + static void + GSwitchItAppletSetupGroupsSubmenu (GSwitchItApplet * sia) + { +- unsigned i, nGroups; +- GSList *nameNode = globals.groupNames; ++ unsigned i; ++ gchar **currentName = globals.groupNames; + BonoboUIComponent *popup; + popup = + panel_applet_get_popup_component (PANEL_APPLET (sia->applet)); +- XklDebug (160, "Registering group submenu\n"); +- nGroups = g_slist_length (globals.groupNames); +- for (i = 0; i < nGroups; i++) { ++ xkl_debug (160, "Registering group submenu\n"); ++ for (i = 0; *currentName; i++, currentName++) { + char verb[40]; + BonoboUINode *node; + g_snprintf (verb, sizeof (verb), "Group_%d", i); + node = bonobo_ui_node_new ("menuitem"); + bonobo_ui_node_set_attr (node, "name", verb); + bonobo_ui_node_set_attr (node, "verb", verb); +- bonobo_ui_node_set_attr (node, "label", nameNode->data); ++ bonobo_ui_node_set_attr (node, "label", *currentName); + bonobo_ui_node_set_attr (node, "pixtype", "filename"); + if (globals.appletConfig.showFlags) { + char *imageFile = +- GSwitchItAppletConfigGetImagesFile (&globals.appletConfig, +- &globals.kbdConfig, ++ GSwitchItAppletConfigGetImagesFile (&globals. ++ appletConfig, ++ &globals. ++ kbdConfig, + i); + if (imageFile != NULL) { + bonobo_ui_node_set_attr (node, "pixname", +@@ -846,10 +910,9 @@ + bonobo_ui_component_add_verb (popup, verb, (BonoboUIVerbFn) + GSwitchItAppletCmdSetGroup, + sia); +- XklDebug (160, +- "Registered group menu item \'%s\' as \'%s\'\n", +- verb, nameNode->data); +- nameNode = g_slist_next (nameNode); ++ xkl_debug (160, ++ "Registered group menu item \'%s\' as \'%s\'\n", ++ verb, *currentName); + } + } + +@@ -874,14 +937,15 @@ + (GdkFilterFunc) GSwitchItAppletFilterXEvt, + NULL); + +- XklStartListen (XKLL_TRACK_KEYBOARD_STATE); ++ xkl_engine_start_listen (globals.engine, ++ XKLL_TRACK_KEYBOARD_STATE); + } + + /* Should be called once for all applets */ + static void + GSwitchItAppletStopListen (GSwitchItApplet * sia) + { +- XklStopListen (); ++ xkl_engine_stop_listen (globals.engine); + + gdk_window_remove_filter (NULL, (GdkFilterFunc) + GSwitchItAppletFilterXEvt, NULL); +@@ -894,13 +958,21 @@ + applet, GSwitchItApplet * sia); + + static gboolean ++GSwitchItAppletScrollCallback (GtkWidget * notebook) ++{ ++ /* mouse wheel events should be ignored, otherwise funny effects appear */ ++ return TRUE; ++} ++ ++static gboolean + GSwitchItAppletInit (GSwitchItApplet * sia, PanelApplet * applet) + { + GtkWidget *defDrawingArea; + GtkNotebook *notebook; + GConfClient *confClient; + +- XklDebug (100, "Starting the applet startup process for %p\n", sia); ++ xkl_debug (100, "Starting the applet startup process for %p\n", ++ sia); + + glade_gnome_init (); + gtk_window_set_default_icon_name ("gswitchit-applet"); +@@ -912,7 +984,6 @@ + notebook = GTK_NOTEBOOK (sia->notebook = gtk_notebook_new ()); + gtk_notebook_set_show_tabs (notebook, FALSE); + gtk_notebook_set_show_border (notebook, FALSE); +- + gtk_container_add (GTK_CONTAINER (sia->applet), + GTK_WIDGET (notebook)); + +@@ -931,15 +1002,21 @@ + + if (GSwitchItAppletFirstInstance ()) { + /* GSwitchItInstallGlibLogAppender( ); */ +- if (XklInit (GDK_DISPLAY ()) != 0) { ++ xkl_debug (100, "*** First instance *** \n"); ++ ++ memset (&globals, 0, sizeof (globals)); ++ ++ globals.engine = xkl_engine_get_instance (GDK_DISPLAY ()); ++ if (globals.engine == NULL) { + GSwitchItAppletSetTooltip (sia, +- _("XKB initialization error")); ++ _ ++ ("XKB initialization error")); + return TRUE; + } +- XklDebug (100, "*** First instance *** \n"); + +- XklConfigInit (); +- if (!XklConfigLoadRegistry ()) { ++ globals.configRegistry = ++ xkl_config_registry_get_instance (globals.engine); ++ if (!xkl_config_registry_load (globals.configRegistry)) { + GSwitchItAppletSetTooltip (sia, + _ + ("Error loading XKB configuration registry")); +@@ -948,18 +1025,25 @@ + + confClient = gconf_client_get_default (); + +- memset (&globals, 0, sizeof(globals)); +- +- XklRegisterStateCallback ((XklStateCallback) +- GSwitchItAppletStateCallback, NULL); +- XklRegisterConfigCallback ((XklConfigCallback) +- GSwitchItAppletKbdConfigCallback, NULL); +- GSwitchItPluginContainerInit (&globals.pluginContainer, confClient); +- +- +- GSwitchItConfigInit (&globals.config, confClient); +- GSwitchItKbdConfigInit (&globals.kbdConfig, confClient); +- GSwitchItAppletConfigInit (&globals.appletConfig, confClient); ++ g_signal_connect (globals.engine, "X-state-changed", ++ G_CALLBACK ++ (GSwitchItAppletStateCallback), NULL); ++ g_signal_connect (globals.engine, "X-config-changed", ++ G_CALLBACK ++ (GSwitchItAppletKbdConfigCallback), ++ NULL); ++ ++ ++ GSwitchItPluginContainerInit (&globals.pluginContainer, ++ confClient); ++ ++ ++ GSwitchItConfigInit (&globals.config, confClient, ++ globals.engine); ++ GSwitchItKbdConfigInit (&globals.kbdConfig, confClient, ++ globals.engine); ++ GSwitchItAppletConfigInit (&globals.appletConfig, ++ confClient, globals.engine); + + g_object_unref (confClient); + +@@ -967,37 +1051,53 @@ + GSwitchItConfigActivate (&globals.config); + GSwitchItKbdConfigLoadFromXCurrent (&globals.kbdConfig); + GSwitchItAppletConfigLoadFromGConf (&globals.appletConfig); +- GSwitchItAppletConfigUpdateImages (&globals.appletConfig, &globals.kbdConfig); ++ GSwitchItAppletConfigUpdateImages (&globals.appletConfig, ++ &globals.kbdConfig); + GSwitchItAppletConfigActivate (&globals.appletConfig); + +- globals.groupNames = GSwitchItConfigLoadGroupDescriptionsUtf8 (&globals.config); +- globals.previewDialogs = g_hash_table_new (g_direct_hash, g_direct_equal); ++ globals.groupNames = ++ GSwitchItConfigLoadGroupDescriptionsUtf8 (&globals. ++ config, ++ globals. ++ configRegistry); ++ globals.previewDialogs = ++ g_hash_table_new (g_direct_hash, g_direct_equal); + + GSwitchItPluginManagerInit (&globals.pluginManager); +- GSwitchItPluginManagerInitEnabledPlugins (&globals.pluginManager, +- &globals.pluginContainer, +- globals.appletConfig.enabledPlugins); ++ GSwitchItPluginManagerInitEnabledPlugins (&globals. ++ pluginManager, ++ &globals. ++ pluginContainer, ++ globals. ++ appletConfig. ++ enabledPlugins); + GSwitchItConfigStartListen (&globals.config, + (GConfClientNotifyFunc) +- GSwitchItConfigChanged, +- NULL); ++ GSwitchItConfigChanged, NULL); + GSwitchItAppletConfigStartListen (&globals.appletConfig, + (GConfClientNotifyFunc) + GSwitchItAppletConfigChanged, + NULL); + GSwitchItAppletStartListen (sia); + +- XklDebug (100, "*** First instance inited globals *** \n"); ++ xkl_debug (100, ++ "*** First instance inited globals *** \n"); + } + GSwitchItAppletFillNotebook (sia); + GSwitchItAppletRevalidate (sia); + + g_signal_connect (G_OBJECT (sia->applet), "change_size", +- G_CALLBACK (GSwitchItAppletChangePixelSize), sia); ++ G_CALLBACK (GSwitchItAppletChangePixelSize), ++ sia); + g_signal_connect (G_OBJECT (sia->applet), "change_background", +- G_CALLBACK (GSwitchItAppletChangeBackground), sia); ++ G_CALLBACK (GSwitchItAppletChangeBackground), ++ sia); + g_signal_connect (G_OBJECT (sia->applet), "button_press_event", + G_CALLBACK (GSwitchItAppletButtonPressed), sia); ++ g_signal_connect (sia->notebook, "scroll_event", ++ G_CALLBACK ++ (GSwitchItAppletScrollCallback), NULL); ++ + + gtk_widget_add_events (sia->applet, GDK_BUTTON_PRESS_MASK); + +@@ -1011,21 +1111,21 @@ + void + GSwitchItAppletTerm (PanelApplet * applet, GSwitchItApplet * sia) + { +- XklDebug (100, "Starting the applet shutdown process for %p\n", sia); ++ xkl_debug (100, "Starting the applet shutdown process for %p\n", ++ sia); + /* remove BEFORE all termination work is finished */ +- globals.appletInstances = g_slist_remove (globals.appletInstances, sia); ++ globals.appletInstances = ++ g_slist_remove (globals.appletInstances, sia); + + if (GSwitchItAppletLastInstance ()) { +- XklDebug (100, "*** Last instance *** \n"); ++ xkl_debug (100, "*** Last instance *** \n"); + GSwitchItAppletStopListen (sia); + + GSwitchItConfigStopListen (&globals.config); + GSwitchItAppletConfigStopListen (&globals.appletConfig); + +- XklRegisterStateCallback (NULL, NULL); +- XklRegisterConfigCallback (NULL, NULL); +- +- GSwitchItPluginManagerTermInitializedPlugins (&globals.pluginManager); ++ GSwitchItPluginManagerTermInitializedPlugins (&globals. ++ pluginManager); + GSwitchItPluginManagerTerm (&globals.pluginManager); + + g_hash_table_destroy (globals.previewDialogs); +@@ -1036,23 +1136,23 @@ + + GSwitchItPluginContainerTerm (&globals.pluginContainer); + +- XklConfigFreeRegistry (); +- XklConfigTerm (); +- XklDebug (100, "*** Last instance terminated globals *** \n"); +- XklTerm (); ++ xkl_debug (100, ++ "*** Last instance terminated globals *** \n"); ++ g_object_unref (G_OBJECT (globals.configRegistry)); ++ g_object_unref (G_OBJECT (globals.engine)); + } + + GSwitchItAppletCleanupNotebook (sia); + + g_free (sia); +- XklDebug (100, "The applet successfully terminated\n"); ++ xkl_debug (100, "The applet successfully terminated\n"); + } + + gboolean + GSwitchItAppletNew (PanelApplet * applet) + { + gboolean rv = TRUE; +- GSwitchItApplet * sia; ++ GSwitchItApplet *sia; + #if 0 + GLogLevelFlags fatal_mask; + fatal_mask = G_LOG_LEVEL_WARNING | G_LOG_LEVEL_CRITICAL; +@@ -1061,8 +1161,9 @@ + sia = g_new0 (GSwitchItApplet, 1); + rv = GSwitchItAppletInit (sia, applet); + /* append AFTER all initialization work is finished */ +- globals.appletInstances = g_slist_append (globals.appletInstances, sia); +- XklDebug (100, "The applet successfully started: %d\n", rv); ++ globals.appletInstances = ++ g_slist_append (globals.appletInstances, sia); ++ xkl_debug (100, "The applet successfully started: %d\n", rv); + return rv; + } + +@@ -1070,12 +1171,12 @@ + void + GSwitchItPluginContainerReinitUi (GSwitchItPluginContainer * pc) + { +- ForAllApplets () ++ ForAllApplets () { + GSwitchItAppletReinitUi (sia); +- NextApplet ++ } NextApplet (); + } + +-GSList * ++gchar ** + GSwitchItPluginLoadLocalizedGroupNames (GSwitchItPluginContainer * pc) + { + return globals.groupNames; +diff -u gswitchit-/gswitchit-applet.h gswitchit/gswitchit-applet.h +--- gswitchit-/gswitchit-applet.h 2005-07-27 20:37:58.000000000 -0400 ++++ gswitchit/gswitchit-applet.h 2006-05-26 20:21:10.000000000 -0400 +@@ -38,9 +38,11 @@ + GSwitchItConfig config; + GSwitchItAppletConfig appletConfig; + GSwitchItKbdConfig kbdConfig; +- GSList *groupNames; ++ gchar **groupNames; + GSList *appletInstances; + GHashTable *previewDialogs; ++ XklEngine *engine; ++ XklConfigRegistry *configRegistry; + } GSwitchItAppletGlobals; + + extern void GSwitchItAppletRevalidate (GSwitchItApplet * sia); +diff -u gswitchit-/gswitchit-plugins-add.c gswitchit/gswitchit-plugins-add.c +--- gswitchit-/gswitchit-plugins-add.c 2005-03-16 07:51:35.000000000 -0500 ++++ gswitchit/gswitchit-plugins-add.c 2006-04-19 19:16:25.000000000 -0400 +@@ -26,7 +26,6 @@ + #include <libbonobo.h> + + #include <libxklavier/xklavier.h> +-#include <libxklavier/xklavier_config.h> + + static void + CappletAddAvailablePluginFunc (const char *fullPath, +diff -u gswitchit-/gswitchit-plugins.c gswitchit/gswitchit-plugins.c +--- gswitchit-/gswitchit-plugins.c 2005-07-26 17:11:56.000000000 -0400 ++++ gswitchit/gswitchit-plugins.c 2006-05-26 20:21:10.000000000 -0400 +@@ -28,7 +28,6 @@ + #include <libgnomeui/gnome-ui-init.h> + + #include <libxklavier/xklavier.h> +-#include <libxklavier/xklavier_config.h> + + static GSwitchItKbdConfig initialSysKbdConfig; + +@@ -257,7 +256,9 @@ + gtk_window_set_default_icon_name ("gswitchit-properties-capplet"); + + /* default domain! */ +- data = glade_xml_new (GNOME_GLADEDIR "/gswitchit-plugins.glade", "gswitchit_plugins", NULL); ++ data = ++ glade_xml_new (GNOME_GLADEDIR "/gswitchit-plugins.glade", ++ "gswitchit_plugins", NULL); + gswic->capplet = capplet = + glade_xml_get_widget (data, "gswitchit_plugins"); + +@@ -324,7 +325,7 @@ + memset (&gswic, 0, sizeof (gswic)); + gnome_program_init ("gswitchit", VERSION, + LIBGNOMEUI_MODULE, argc, argv, +- GNOME_PROGRAM_STANDARD_PROPERTIES, NULL); ++ GNOME_PROGRAM_STANDARD_PROPERTIES, NULL); + if (!gconf_init (argc, argv, &gconf_error)) { + g_warning (_("Failed to init GConf: %s\n"), + gconf_error->message); +@@ -332,24 +333,28 @@ + return 1; + } + gconf_error = NULL; +- /*GSwitchItInstallGlibLogAppender( );*/ +- XklInit (GDK_DISPLAY ()); +- XklConfigInit (); +- XklConfigLoadRegistry (); ++ /*GSwitchItInstallGlibLogAppender( ); */ ++ gswic.engine = xkl_engine_get_instance (GDK_DISPLAY ()); ++ gswic.configRegistry = ++ xkl_config_registry_get_instance (gswic.engine); + + confClient = gconf_client_get_default (); + GSwitchItPluginContainerInit (&gswic.pluginContainer, confClient); + g_object_unref (confClient); + +- GSwitchItKbdConfigInit (&gswic.kbdConfig, confClient); +- GSwitchItKbdConfigInit (&initialSysKbdConfig, confClient); ++ GSwitchItKbdConfigInit (&gswic.kbdConfig, confClient, ++ gswic.engine); ++ GSwitchItKbdConfigInit (&initialSysKbdConfig, confClient, ++ gswic.engine); + +- GSwitchItAppletConfigInit (&gswic.appletConfig, confClient); ++ GSwitchItAppletConfigInit (&gswic.appletConfig, confClient, ++ gswic.engine); + + GSwitchItPluginManagerInit (&gswic.pluginManager); + + GSwitchItKbdConfigLoadFromXInitial (&initialSysKbdConfig); +- GSwitchItKbdConfigLoadFromGConf (&gswic.kbdConfig, &initialSysKbdConfig); ++ GSwitchItKbdConfigLoadFromGConf (&gswic.kbdConfig, ++ &initialSysKbdConfig); + + GSwitchItAppletConfigLoadFromGConf (&gswic.appletConfig); + CappletSetup (&gswic); +@@ -363,9 +368,8 @@ + GSwitchItKbdConfigTerm (&initialSysKbdConfig); + + GSwitchItPluginContainerTerm (&gswic.pluginContainer); +- XklConfigFreeRegistry (); +- XklConfigTerm (); +- XklTerm (); ++ g_object_unref (G_OBJECT (gswic.configRegistry)); ++ g_object_unref (G_OBJECT (gswic.engine)); + return 0; + } + +@@ -375,8 +379,10 @@ + { + } + +-GSList * ++gchar ** + GSwitchItPluginLoadLocalizedGroupNames (GSwitchItPluginContainer * pc) + { +- return GSwitchItConfigLoadGroupDescriptionsUtf8 (&(((GSwitchItPluginsCapplet *) pc)->config)); ++ return ++ GSwitchItConfigLoadGroupDescriptionsUtf8 (& ++ (((GSwitchItPluginsCapplet *) pc)->config), (((GSwitchItPluginsCapplet *) pc)->configRegistry)); + } +diff -u gswitchit-/gswitchit-plugins.h gswitchit/gswitchit-plugins.h +--- gswitchit-/gswitchit-plugins.h 2005-03-16 07:51:35.000000000 -0500 ++++ gswitchit/gswitchit-plugins.h 2006-04-19 19:16:25.000000000 -0400 +@@ -32,6 +32,8 @@ + GSwitchItAppletConfig appletConfig; + GSwitchItKbdConfig kbdConfig; + GSwitchItPluginManager pluginManager; ++ XklEngine *engine; ++ XklConfigRegistry *configRegistry; + } GSwitchItPluginsCapplet; + + #define NAME_COLUMN 0 +Common subdirectories: gswitchit-/help and gswitchit/help +Only in gswitchit: .indent.pro |