1
/* -*- mode: c; style: linux -*- */
3
/* gnome-keyboard-properties-xkbpv.c
4
* Copyright (C) 2003-2007 Sergey V. Udaltsov
6
* Written by: Sergey V. Udaltsov <svu@gnome.org>
8
* This program is free software; you can redistribute it and/or modify
9
* it under the terms of the GNU General Public License as published by
10
* the Free Software Foundation; either version 2, or (at your option)
13
* This program is distributed in the hope that it will be useful,
14
* but WITHOUT ANY WARRANTY; without even the implied warranty of
15
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16
* GNU General Public License for more details.
18
* You should have received a copy of the GNU General Public License
19
* along with this program; if not, write to the Free Software
20
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
28
#include <libgnomekbd/gkbd-keyboard-drawing.h>
30
#include "capplet-util.h"
31
#include "gnome-keyboard-properties-xkb.h"
33
#ifdef HAVE_X11_EXTENSIONS_XKB_H
34
#include "X11/XKBlib.h"
36
* BAD STYLE: Taken from xklavier_private_xkb.h
37
* Any ideas on architectural improvements are WELCOME
39
extern gboolean xkl_xkb_config_native_prepare (XklEngine * engine,
40
const XklConfigRec * data,
44
extern void xkl_xkb_config_native_cleanup (XklEngine * engine,
51
static GkbdKeyboardDrawingGroupLevel groupsLevels[] =
52
{ {0, 1}, {0, 3}, {0, 0}, {0, 2} };
53
static GkbdKeyboardDrawingGroupLevel *pGroupsLevels[] = {
54
groupsLevels, groupsLevels + 1, groupsLevels + 2, groupsLevels + 3
58
xkb_layout_preview_create_widget (GtkBuilder * chooserDialog)
60
GtkWidget *kbdraw = gkbd_keyboard_drawing_new ();
62
gkbd_keyboard_drawing_set_groups_levels (GKBD_KEYBOARD_DRAWING
63
(kbdraw), pGroupsLevels);
68
xkb_layout_preview_update (GtkBuilder * chooser_dialog)
70
#ifdef HAVE_X11_EXTENSIONS_XKB_H
71
GtkWidget *chooser = CWID ("xkb_layout_chooser");
73
GTK_WIDGET (g_object_get_data (G_OBJECT (chooser), "kbdraw"));
74
gchar *id = xkb_layout_chooser_get_selected_id (chooser_dialog);
75
xkb_layout_preview_set_drawing_layout (kbdraw, id);
81
xkb_layout_preview_set_drawing_layout (GtkWidget * kbdraw,
84
#ifdef HAVE_X11_EXTENSIONS_XKB_H
88
char **p, *layout, *variant;
89
XkbComponentNamesRec component_names;
91
data = xkl_config_rec_new ();
92
if (xkl_config_rec_get_from_server (data, engine)) {
93
if ((p = data->layouts) != NULL)
94
g_strfreev (data->layouts);
96
if ((p = data->variants) != NULL)
97
g_strfreev (data->variants);
99
data->layouts = g_new0 (char *, 2);
100
data->variants = g_new0 (char *, 2);
101
if (gkbd_keyboard_config_split_items
102
(id, &layout, &variant)
103
&& variant != NULL) {
115
NULL) ? NULL : g_strdup (id);
116
data->variants[0] = NULL;
119
if (xkl_xkb_config_native_prepare
120
(engine, data, &component_names)) {
121
gkbd_keyboard_drawing_set_keyboard
122
(GKBD_KEYBOARD_DRAWING
123
(kbdraw), &component_names);
125
xkl_xkb_config_native_cleanup
126
(engine, &component_names);
129
g_object_unref (G_OBJECT (data));
131
gkbd_keyboard_drawing_set_keyboard
132
(GKBD_KEYBOARD_DRAWING (kbdraw), NULL);