Created
October 16, 2013 07:23
-
-
Save jouyouyun/7003896 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
static gboolean | |
set_layouts_from_gsettings (void) | |
{ | |
gchar **kbd_layout = NULL; | |
GSettings *kbd_set = NULL; | |
guint len = 0; | |
gboolean is_ok; | |
kbd_set = g_settings_new ("org.gnome.libgnomekbd.keyboard"); | |
kbd_layout = g_settings_get_strv (kbd_set, "layouts"); | |
len = g_strv_length (kbd_layout); | |
g_debug ("cur kbd layout: %s\tlen: %u\n", kbd_layout[0], len); | |
if ( len < 1 ) { | |
g_debug ("default layout: %s\n", DEFAULT_LAYOUT); | |
gchar *tmp = g_strdup_printf ("%s;", DEFAULT_LAYOUT); | |
kbd_layout = g_strsplit (tmp, ";", -1); | |
g_free (tmp); | |
} | |
is_ok = g_settings_set_strv (kbd_set, "layouts", | |
(const gchar* const*)kbd_layout); | |
if ( !is_ok ) { | |
g_debug ("set layouts failed: %s", kbd_layout[0]); | |
return TRUE; | |
} | |
g_strfreev (kbd_layout); | |
g_settings_sync (); | |
g_object_unref (kbd_set); | |
return FALSE; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment