-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathswitch-api.c
56 lines (47 loc) · 1.15 KB
/
switch-api.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
/*
* =============================================================================
*
* Filename: switch-api.c
*
* Description: vim-xkbswitch API
*
* Version: 1.0
* Created: 14.12.2019 11:07:27
* Revision: none
* Compiler: gcc
*
* Author: Alexey Radkov (),
* Company:
*
* =============================================================================
*/
#include "switch.h"
static GTree *layouts = NULL;
const char *Xkb_Switch_getXkbLayout( const char *unused )
{
gconstpointer layout = NULL;
if ( layouts == NULL ) {
layouts = g3kb_build_layouts_map( NULL );
if ( layouts == NULL ) {
return "";
}
}
layout = g3kb_safe_get_layout( layouts, NULL );
if ( layout == NULL ) {
return "";
}
return (const char *)layout;
}
const char *Xkb_Switch_setXkbLayout( const char *layout )
{
if ( layouts == NULL ) {
layouts = g3kb_build_layouts_map( NULL );
if ( layouts == NULL ) {
return "";
}
}
if ( !g3kb_safe_set_layout( layouts, layout, NULL ) ) {
return "";
}
return "";
}