update for new libxklavier API
This commit is contained in:
parent
31a5fd7828
commit
ee5dccce96
9 changed files with 213 additions and 153 deletions
|
@ -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
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue