diff options
author | B. Stack <bgstack15@gmail.com> | 2022-10-09 22:15:57 -0400 |
---|---|---|
committer | B. Stack <bgstack15@gmail.com> | 2022-10-09 22:15:57 -0400 |
commit | 1caa55dc23b1b646fd423376814a0dec967b720a (patch) | |
tree | ff5e041a8d86b34a5c53fa6fba019ee2bae38ff6 | |
parent | remove most images (diff) | |
download | fbxkb-1caa55dc23b1b646fd423376814a0dec967b720a.tar.gz fbxkb-1caa55dc23b1b646fd423376814a0dec967b720a.tar.bz2 fbxkb-1caa55dc23b1b646fd423376814a0dec967b720a.zip |
add variant support
-rw-r--r-- | .gitignore | 1 | ||||
-rw-r--r-- | fbxkb.c | 24 |
2 files changed, 19 insertions, 6 deletions
diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..a01ee28 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +.*.swp @@ -257,7 +257,7 @@ docklet_create() static gboolean my_str_equal (gchar *a, gchar *b) { - return (a[0] == b[0] && a[1] == b[1]); + return strcmp(a,b) == 0; } @@ -273,10 +273,12 @@ sym2flag(char *sym) if (flag) RET(flag); - if (!s) - s = g_string_new(IMGPREFIX "tt.png"); - s->str[s->len-6] = sym[0]; - s->str[s->len-5] = sym[1]; + if (!s) + s = g_string_new(IMGPREFIX); + else + s = g_string_assign(s,IMGPREFIX); + s = g_string_append(s, sym); + s = g_string_append(s, ".png"); flag = gdk_pixbuf_new_from_file_at_size(s->str, 24, 24, NULL); if (!flag) RET(zzflag); @@ -341,7 +343,7 @@ read_kbd_description() // parse kbd info if (sym_name_atom != None) { - char *sym_name, *tmp, *tok; + char *sym_name, *tmp, *tok, *tmp2; int no; sym_name = XGetAtomName(dpy, sym_name_atom); @@ -364,6 +366,12 @@ read_kbd_description() } else { no = 0; } + if((tmp2 = strchr(tok, '('))) { + // these next two statements could be done cleverly in one statement but the compiler warns if you try it. + // strip left paren, and then right paren + tmp2++; + tmp2[strlen(tmp2)-1] = '\0'; + } for (tmp = tok; isalpha(*tmp); tmp++); *tmp = 0; @@ -376,8 +384,12 @@ read_kbd_description() ERR("xkb group #%d is already defined\n", no); } group2info[no].sym = g_strdup(tok); + strcat(tok,","); + // add variant to end of string for the png lookup + strcat(tok,tmp2); group2info[no].flag = sym2flag(tok); group2info[no].name = XGetAtomName(dpy, kbd_desc_ptr->names->groups[no]); + *tmp2 = 0; } XFree(sym_name); } |