2004-07-13 23:11:34 +00:00
|
|
|
/* -*- mode: c; style: linux -*- */
|
|
|
|
|
2007-03-23 00:26:44 +00:00
|
|
|
/* gnome-keyboard-properties-xkbpv.c
|
|
|
|
* Copyright (C) 2003-2007 Sergey V. Udaltsov
|
2004-07-13 23:11:34 +00:00
|
|
|
*
|
2007-03-23 00:26:44 +00:00
|
|
|
* Written by: Sergey V. Udaltsov <svu@gnome.org>
|
2004-07-13 23:11:34 +00:00
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation; either version 2, or (at your option)
|
|
|
|
* any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
|
|
|
|
* 02111-1307, USA.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
# include <config.h>
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#include <gnome.h>
|
|
|
|
#include <glade/glade.h>
|
|
|
|
|
2007-12-17 22:55:31 +00:00
|
|
|
#include <libgnomekbd/gkbd-keyboard-drawing.h>
|
2004-07-13 23:11:34 +00:00
|
|
|
|
2007-12-17 22:55:31 +00:00
|
|
|
#include "capplet-util.h"
|
2004-07-13 23:11:34 +00:00
|
|
|
#include "gnome-keyboard-properties-xkb.h"
|
|
|
|
|
2005-01-02 01:59:28 +00:00
|
|
|
#ifdef HAVE_X11_EXTENSIONS_XKB_H
|
|
|
|
#include "X11/XKBlib.h"
|
|
|
|
/**
|
|
|
|
* BAD STYLE: Taken from xklavier_private_xkb.h
|
|
|
|
* Any ideas on architectural improvements are WELCOME
|
|
|
|
*/
|
2006-04-19 23:30:05 +00:00
|
|
|
extern gboolean xkl_xkb_config_native_prepare (XklEngine * engine,
|
2006-10-18 22:37:40 +00:00
|
|
|
const XklConfigRec * data,
|
|
|
|
XkbComponentNamesPtr
|
|
|
|
component_names);
|
2006-04-19 23:30:05 +00:00
|
|
|
|
|
|
|
extern void xkl_xkb_config_native_cleanup (XklEngine * engine,
|
2006-10-18 22:37:40 +00:00
|
|
|
XkbComponentNamesPtr
|
|
|
|
component_names);
|
2006-04-19 23:30:05 +00:00
|
|
|
|
2005-01-02 01:59:28 +00:00
|
|
|
/* */
|
|
|
|
#endif
|
2004-07-26 23:07:03 +00:00
|
|
|
|
2006-10-18 22:37:40 +00:00
|
|
|
static GkbdKeyboardDrawingGroupLevel groupsLevels[] =
|
|
|
|
{ {0, 1}, {0, 3}, {0, 0}, {0, 2} };
|
|
|
|
static GkbdKeyboardDrawingGroupLevel *pGroupsLevels[] = {
|
|
|
|
groupsLevels, groupsLevels + 1, groupsLevels + 2, groupsLevels + 3
|
|
|
|
};
|
2004-12-31 00:52:49 +00:00
|
|
|
|
2006-10-18 22:37:40 +00:00
|
|
|
GtkWidget *
|
2005-01-02 01:59:28 +00:00
|
|
|
xkb_layout_preview_create_widget (GladeXML * chooserDialog)
|
2004-12-31 00:52:49 +00:00
|
|
|
{
|
2006-10-18 22:37:40 +00:00
|
|
|
GtkWidget *kbdraw = gkbd_keyboard_drawing_new ();
|
|
|
|
|
|
|
|
gkbd_keyboard_drawing_set_groups_levels (GKBD_KEYBOARD_DRAWING
|
|
|
|
(kbdraw), pGroupsLevels);
|
|
|
|
return kbdraw;
|
2004-12-31 00:52:49 +00:00
|
|
|
}
|
|
|
|
|
2004-07-26 23:07:03 +00:00
|
|
|
void
|
2006-06-25 02:23:08 +00:00
|
|
|
xkb_layout_preview_update (GladeXML * chooser_dialog)
|
2004-07-26 23:07:03 +00:00
|
|
|
{
|
2005-01-02 01:59:28 +00:00
|
|
|
#ifdef HAVE_X11_EXTENSIONS_XKB_H
|
2006-10-18 22:37:40 +00:00
|
|
|
GtkWidget *chooser = CWID ("xkb_layout_chooser");
|
|
|
|
GtkWidget *kbdraw =
|
|
|
|
GTK_WIDGET (g_object_get_data (G_OBJECT (chooser), "kbdraw"));
|
2007-11-03 02:22:05 +00:00
|
|
|
gchar *id = xkb_layout_chooser_get_selected_id (chooser_dialog);
|
2007-12-11 23:09:28 +00:00
|
|
|
xkb_layout_preview_set_drawing_layout (kbdraw, id);
|
|
|
|
g_free (id);
|
|
|
|
#endif
|
|
|
|
}
|
2007-03-23 23:54:05 +00:00
|
|
|
|
2007-12-11 23:09:28 +00:00
|
|
|
void
|
2008-04-27 15:13:32 +00:00
|
|
|
xkb_layout_preview_set_drawing_layout (GtkWidget * kbdraw,
|
|
|
|
const gchar * id)
|
2007-12-11 23:09:28 +00:00
|
|
|
{
|
|
|
|
#ifdef HAVE_X11_EXTENSIONS_XKB_H
|
2008-04-27 15:13:32 +00:00
|
|
|
if (kbdraw != NULL) {
|
|
|
|
if (id != NULL) {
|
|
|
|
XklConfigRec *data;
|
|
|
|
char **p, *layout, *variant;
|
|
|
|
XkbComponentNamesRec component_names;
|
|
|
|
|
|
|
|
data = xkl_config_rec_new ();
|
|
|
|
if (xkl_config_rec_get_from_server (data, engine)) {
|
|
|
|
if ((p = data->layouts) != NULL)
|
|
|
|
g_strfreev (data->layouts);
|
|
|
|
|
|
|
|
if ((p = data->variants) != NULL)
|
|
|
|
g_strfreev (data->variants);
|
|
|
|
|
|
|
|
data->layouts = g_new0 (char *, 2);
|
|
|
|
data->variants = g_new0 (char *, 2);
|
|
|
|
if (gkbd_keyboard_config_split_items
|
|
|
|
(id, &layout, &variant)
|
|
|
|
&& variant != NULL) {
|
|
|
|
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 : g_strdup (id);
|
|
|
|
data->variants[0] = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (xkl_xkb_config_native_prepare
|
|
|
|
(engine, data, &component_names)) {
|
|
|
|
gkbd_keyboard_drawing_set_keyboard
|
|
|
|
(GKBD_KEYBOARD_DRAWING
|
|
|
|
(kbdraw), &component_names);
|
|
|
|
|
|
|
|
xkl_xkb_config_native_cleanup
|
|
|
|
(engine, &component_names);
|
|
|
|
}
|
2006-10-18 22:37:40 +00:00
|
|
|
}
|
2008-04-27 15:13:32 +00:00
|
|
|
g_object_unref (G_OBJECT (data));
|
|
|
|
} else
|
|
|
|
gkbd_keyboard_drawing_set_keyboard
|
|
|
|
(GKBD_KEYBOARD_DRAWING (kbdraw), NULL);
|
2006-10-18 22:37:40 +00:00
|
|
|
|
|
|
|
}
|
2005-01-02 01:59:28 +00:00
|
|
|
#endif
|
2004-07-13 23:11:34 +00:00
|
|
|
}
|