aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.gitignore1
-rw-r--r--fbxkb.c24
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
diff --git a/fbxkb.c b/fbxkb.c
index 2341464..0f71b70 100644
--- a/fbxkb.c
+++ b/fbxkb.c
@@ -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);
}
bgstack15