| File: | capplets/keyboard/cafe-keyboard-properties-xkbpv.c |
| Warning: | line 96, column 10 Although the value stored to 'p' is used in the enclosing expression, the value is never actually read from 'p' |
Press '?' to see keyboard shortcuts
Keyboard shortcuts:
| 1 | /* -*- mode: c; style: linux -*- */ |
| 2 | |
| 3 | /* cafe-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., 51 Franklin St, Fifth Floor, Boston, MA |
| 21 | * 02110-1301, USA. |
| 22 | */ |
| 23 | |
| 24 | #ifdef HAVE_CONFIG_H1 |
| 25 | # include <config.h> |
| 26 | #endif |
| 27 | |
| 28 | #include <libcafekbd/cafekbd-keyboard-drawing.h> |
| 29 | |
| 30 | #include "capplet-util.h" |
| 31 | #include "cafe-keyboard-properties-xkb.h" |
| 32 | |
| 33 | #ifdef HAVE_X11_EXTENSIONS_XKB_H1 |
| 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 CafekbdKeyboardDrawingGroupLevel groupsLevels[] = |
| 52 | { {0, 1}, {0, 3}, {0, 0}, {0, 2} }; |
| 53 | static CafekbdKeyboardDrawingGroupLevel *pGroupsLevels[] = { |
| 54 | groupsLevels, groupsLevels + 1, groupsLevels + 2, groupsLevels + 3 |
| 55 | }; |
| 56 | |
| 57 | CtkWidget * |
| 58 | xkb_layout_preview_create_widget (CtkBuilder * chooserDialog) |
| 59 | { |
| 60 | CtkWidget *kbdraw = cafekbd_keyboard_drawing_new (); |
| 61 | |
| 62 | cafekbd_keyboard_drawing_set_groups_levels (CAFEKBD_KEYBOARD_DRAWING((((CafekbdKeyboardDrawing*) (void *) g_type_check_instance_cast ((GTypeInstance*) ((kbdraw)), (cafekbd_keyboard_drawing_get_type ()))))) |
| 63 | (kbdraw)((((CafekbdKeyboardDrawing*) (void *) g_type_check_instance_cast ((GTypeInstance*) ((kbdraw)), (cafekbd_keyboard_drawing_get_type ()))))), pGroupsLevels); |
| 64 | return kbdraw; |
| 65 | } |
| 66 | |
| 67 | void |
| 68 | xkb_layout_preview_update (CtkBuilder * chooser_dialog) |
| 69 | { |
| 70 | #ifdef HAVE_X11_EXTENSIONS_XKB_H1 |
| 71 | CtkWidget *chooser = CWID ("xkb_layout_chooser")((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((ctk_builder_get_object (chooser_dialog, "xkb_layout_chooser" ))), ((ctk_widget_get_type ())))))); |
| 72 | CtkWidget *kbdraw = |
| 73 | CTK_WIDGET (g_object_get_data (G_OBJECT (chooser), "kbdraw"))((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((g_object_get_data (((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance*) ((chooser)), (((GType) ((20) << (2)) )))))), "kbdraw"))), ((ctk_widget_get_type ())))))); |
| 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 (CtkWidget * kbdraw, |
| 82 | const gchar * id) |
| 83 | { |
| 84 | #ifdef HAVE_X11_EXTENSIONS_XKB_H1 |
| 85 | if (kbdraw != NULL((void*)0)) { |
| 86 | if (id != NULL((void*)0)) { |
| 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((void*)0)) |
| 94 | g_strfreev (data->layouts); |
| 95 | |
| 96 | if ((p = data->variants) != NULL((void*)0)) |
Although the value stored to 'p' is used in the enclosing expression, the value is never actually read from 'p' | |
| 97 | g_strfreev (data->variants); |
| 98 | |
| 99 | data->layouts = g_new0 (char *, 2)((char * *) g_malloc0_n ((2), sizeof (char *))); |
| 100 | data->variants = g_new0 (char *, 2)((char * *) g_malloc0_n ((2), sizeof (char *))); |
| 101 | if (cafekbd_keyboard_config_split_items |
| 102 | (id, &layout, &variant) |
| 103 | && variant != NULL((void*)0)) { |
| 104 | data->layouts[0] = |
| 105 | (layout == |
| 106 | NULL((void*)0)) ? NULL((void*)0) : |
| 107 | g_strdup (layout)g_strdup_inline (layout); |
| 108 | data->variants[0] = |
| 109 | (variant == |
| 110 | NULL((void*)0)) ? NULL((void*)0) : |
| 111 | g_strdup (variant)g_strdup_inline (variant); |
| 112 | } else { |
| 113 | data->layouts[0] = |
| 114 | (id == |
| 115 | NULL((void*)0)) ? NULL((void*)0) : g_strdup (id)g_strdup_inline (id); |
| 116 | data->variants[0] = NULL((void*)0); |
| 117 | } |
| 118 | |
| 119 | if (xkl_xkb_config_native_prepare |
| 120 | (engine, data, &component_names)) { |
| 121 | cafekbd_keyboard_drawing_set_keyboard |
| 122 | (CAFEKBD_KEYBOARD_DRAWING((((CafekbdKeyboardDrawing*) (void *) g_type_check_instance_cast ((GTypeInstance*) ((kbdraw)), (cafekbd_keyboard_drawing_get_type ()))))) |
| 123 | (kbdraw)((((CafekbdKeyboardDrawing*) (void *) g_type_check_instance_cast ((GTypeInstance*) ((kbdraw)), (cafekbd_keyboard_drawing_get_type ()))))), &component_names); |
| 124 | |
| 125 | xkl_xkb_config_native_cleanup |
| 126 | (engine, &component_names); |
| 127 | } |
| 128 | } |
| 129 | g_object_unref (G_OBJECT (data)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((data)), (((GType) ((20) << (2))))))))); |
| 130 | } else |
| 131 | cafekbd_keyboard_drawing_set_keyboard |
| 132 | (CAFEKBD_KEYBOARD_DRAWING (kbdraw)((((CafekbdKeyboardDrawing*) (void *) g_type_check_instance_cast ((GTypeInstance*) ((kbdraw)), (cafekbd_keyboard_drawing_get_type ()))))), NULL((void*)0)); |
| 133 | |
| 134 | } |
| 135 | #endif |
| 136 | } |