~kroq-gar78/ubuntu/precise/gnome-control-center/fix-885947

« back to all changes in this revision

Viewing changes to capplets/keyboard/gnome-keyboard-properties-xkbpv.c

  • Committer: Bazaar Package Importer
  • Author(s): Rodrigo Moya
  • Date: 2011-05-17 10:47:27 UTC
  • mfrom: (0.1.11 experimental) (1.1.45 upstream)
  • Revision ID: james.westby@ubuntu.com-20110517104727-lqel6m8vhfw5jby1
Tags: 1:3.0.1.1-1ubuntu1
* Rebase on Debian, remaining Ubuntu changes:
* debian/control:
  - Build-Depend on hardening-wrapper, dpkg-dev and dh-autoreconf
  - Add dependency on ubuntu-system-service
  - Remove dependency on gnome-icon-theme-symbolic
  - Move dependency on apg, gnome-icon-theme-symbolic and accountsservice to
    be a Recommends: until we get them in main
* debian/rules:
  - Use autoreconf
  - Add binary-post-install rule for gnome-control-center-data
  - Run dh-autoreconf
* debian/gnome-control-center.dirs:
* debian/gnome-control-center.links:
  - Add a link to the control center shell for indicators
* debian/patches/00_disable-nm.patch:
  - Temporary patch to disable building with NetworkManager until we get
    the new one in the archive
* debian/patches/01_git_remove_gettext_calls.patch:
  - Remove calls to AM_GNU_GETTEXT, IT_PROG_INTLTOOL should be enough
* debian/patches/01_git_kill_warning.patch:
  - Kill warning
* debian/patches/50_ubuntu_systemwide_prefs.patch:
  - Ubuntu specific proxy preferences
* debian/patches/51_ubuntu_system_keyboard.patch:
  - Implement the global keyboard spec at https://wiki.ubuntu.com/DefaultKeyboardSettings

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/* -*- mode: c; style: linux -*- */
2
 
 
3
 
/* gnome-keyboard-properties-xkbpv.c
4
 
 * Copyright (C) 2003-2007 Sergey V. Udaltsov
5
 
 *
6
 
 * Written by: Sergey V. Udaltsov <svu@gnome.org>
7
 
 *
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)
11
 
 * any later version.
12
 
 *
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.
17
 
 *
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
21
 
 * 02111-1307, USA.
22
 
 */
23
 
 
24
 
#ifdef HAVE_CONFIG_H
25
 
#  include <config.h>
26
 
#endif
27
 
 
28
 
#include <libgnomekbd/gkbd-keyboard-drawing.h>
29
 
 
30
 
#include "capplet-util.h"
31
 
#include "gnome-keyboard-properties-xkb.h"
32
 
 
33
 
#ifdef HAVE_X11_EXTENSIONS_XKB_H
34
 
#include "X11/XKBlib.h"
35
 
/**
36
 
 * BAD STYLE: Taken from xklavier_private_xkb.h
37
 
 * Any ideas on architectural improvements are WELCOME
38
 
 */
39
 
extern gboolean xkl_xkb_config_native_prepare (XklEngine * engine,
40
 
                                               const XklConfigRec * data,
41
 
                                               XkbComponentNamesPtr
42
 
                                               component_names);
43
 
 
44
 
extern void xkl_xkb_config_native_cleanup (XklEngine * engine,
45
 
                                           XkbComponentNamesPtr
46
 
                                           component_names);
47
 
 
48
 
/* */
49
 
#endif
50
 
 
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
55
 
};
56
 
 
57
 
GtkWidget *
58
 
xkb_layout_preview_create_widget (GtkBuilder * chooserDialog)
59
 
{
60
 
        GtkWidget *kbdraw = gkbd_keyboard_drawing_new ();
61
 
 
62
 
        gkbd_keyboard_drawing_set_groups_levels (GKBD_KEYBOARD_DRAWING
63
 
                                                 (kbdraw), pGroupsLevels);
64
 
        return kbdraw;
65
 
}
66
 
 
67
 
void
68
 
xkb_layout_preview_update (GtkBuilder * chooser_dialog)
69
 
{
70
 
#ifdef HAVE_X11_EXTENSIONS_XKB_H
71
 
        GtkWidget *chooser = CWID ("xkb_layout_chooser");
72
 
        GtkWidget *kbdraw =
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);
76
 
        g_free (id);
77
 
#endif
78
 
}
79
 
 
80
 
void
81
 
xkb_layout_preview_set_drawing_layout (GtkWidget * kbdraw,
82
 
                                       const gchar * id)
83
 
{
84
 
#ifdef HAVE_X11_EXTENSIONS_XKB_H
85
 
        if (kbdraw != NULL) {
86
 
                if (id != NULL) {
87
 
                        XklConfigRec *data;
88
 
                        char **p, *layout, *variant;
89
 
                        XkbComponentNamesRec component_names;
90
 
 
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);
95
 
 
96
 
                                if ((p = data->variants) != NULL)
97
 
                                        g_strfreev (data->variants);
98
 
 
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) {
104
 
                                        data->layouts[0] =
105
 
                                            (layout ==
106
 
                                             NULL) ? NULL :
107
 
                                            g_strdup (layout);
108
 
                                        data->variants[0] =
109
 
                                            (variant ==
110
 
                                             NULL) ? NULL :
111
 
                                            g_strdup (variant);
112
 
                                } else {
113
 
                                        data->layouts[0] =
114
 
                                            (id ==
115
 
                                             NULL) ? NULL : g_strdup (id);
116
 
                                        data->variants[0] = NULL;
117
 
                                }
118
 
 
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);
124
 
 
125
 
                                        xkl_xkb_config_native_cleanup
126
 
                                            (engine, &component_names);
127
 
                                }
128
 
                        }
129
 
                        g_object_unref (G_OBJECT (data));
130
 
                } else
131
 
                        gkbd_keyboard_drawing_set_keyboard
132
 
                            (GKBD_KEYBOARD_DRAWING (kbdraw), NULL);
133
 
 
134
 
        }
135
 
#endif
136
 
}