Git-Url: http://git.frugalware.org/gitweb/gitweb.cgi?p=fwlive.git;a=commitdiff;h=08608355d73260541a092716ffa1b7303f3a2c64
commit 08608355d73260541a092716ffa1b7303f3a2c64 Author: James Buren <[email protected]> Date: Sat Mar 2 06:39:43 2013 -0600 add code for prompting for layout and then exporting the selection globally for future use diff --git a/new/fwsetup/layout.c b/new/fwsetup/layout.c index 1827a5e..b74aee2 100644 --- a/new/fwsetup/layout.c +++ b/new/fwsetup/layout.c @@ -39,14 +39,27 @@ static inline void put_token(char *in,char **out) *out = (strcmp(in,"-") == 0) ? 0 : strdup(in); } +static inline void put_layout(char *in,char **out) +{ + *out = (in == 0) ? 0 : strdup(in); +} + static int qsort_compare(const void *A,const void *B) { - struct layout *a = *(struct layout **) A; - struct layout *b = *(struct layout **) B; + const struct layout *a = *(struct layout **) A; + const struct layout *b = *(struct layout **) B; return strcmp(a->kbdlayout,b->kbdlayout); } +static int bsearch_compare(const void *A,const void *B) +{ + const char *a = (char *) A; + const struct layout *b = *(struct layout **) B; + + return strcmp(a,b->kbdlayout); +} + static bool layout_setup(void) { FILE *file = 0; @@ -59,7 +72,6 @@ static bool layout_setup(void) char *xkbvariant = 0; char *xkboptions = 0; struct layout *layout = 0; - char *entry = 0; if((file = fopen("/usr/share/systemd/kbd-model-map","rb")) == 0) { @@ -117,10 +129,44 @@ static bool layout_setup(void) return true; } +static bool layout_do_layout(void) +{ + char *entry = 0; + size_t i = 0; + struct layout *layout = 0; + + if(!ui_window_list(LAYOUT_TITLE,LAYOUT_TEXT,entries,&entry)) + return false; + + for( ; layouts[i] != 0 ; ++i ) + ; + + if((layout = bsearch(entry,layouts,i,sizeof(struct layout *),bsearch_compare)) == 0) + { + error("no matching layout"); + return false; + } + + put_layout(layout->kbdlayout,&g->kbdlayout); + + put_layout(layout->xkblayout,&g->xkblayout); + + put_layout(layout->xkbmodel,&g->xkbmodel); + + put_layout(layout->xkbvariant,&g->xkbvariant); + + put_layout(layout->xkboptions,&g->xkboptions); + + return true; +} + static bool layout_run(void) { if(!layout_setup()) - return true; + return false; + + if(!layout_do_layout()) + return false; return true; } diff --git a/new/fwsetup/local.h b/new/fwsetup/local.h index bb2639c..5d2f92a 100644 --- a/new/fwsetup/local.h +++ b/new/fwsetup/local.h @@ -56,7 +56,11 @@ struct global { - bool netinstall; + char *kbdlayout; + char *xkblayout; + char *xkbmodel; + char *xkbvariant; + char *xkboptions; }; struct device; diff --git a/new/fwsetup/main.c b/new/fwsetup/main.c index 84d2b75..01bcc0f 100644 --- a/new/fwsetup/main.c +++ b/new/fwsetup/main.c @@ -54,10 +54,7 @@ extern int main(int argc,char **argv) return code; } -static struct global local = -{ - .netinstall = true -}; +static struct global local = {0}; struct global *g = &local; _______________________________________________ Frugalware-git mailing list [email protected] http://frugalware.org/mailman/listinfo/frugalware-git
