Git-Url: 
http://git.frugalware.org/gitweb/gitweb.cgi?p=fwlive.git;a=commitdiff;h=74176ab0717ee2c8c3157ff6adbdbe4c348267b9

commit 74176ab0717ee2c8c3157ff6adbdbe4c348267b9
Author: James Buren <[email protected]>
Date:   Sat Mar 2 05:32:58 2013 -0600

import layout UI

diff --git a/new/fwsetup/local.h b/new/fwsetup/local.h
index 1d5623e..1f2dbee 100644
--- a/new/fwsetup/local.h
+++ b/new/fwsetup/local.h
@@ -176,6 +176,7 @@ extern void ui_dialog_text(const char *title,const char 
*text);
extern bool ui_dialog_yesno(const char *title,const char *text,bool defaultno);
extern bool ui_dialog_progress(const char *title,const char *text,int percent);
extern bool ui_window_locale(const char *var,char **locales,char **locale);
+extern bool ui_window_layout(struct layout **layouts,struct layout **layout);
extern bool ui_window_partition(struct device **devices,struct disk **disks);
extern bool ui_window_format(struct format **targets);
extern bool ui_window_root(struct account *data);
diff --git a/new/fwsetup/ui_newt.c b/new/fwsetup/ui_newt.c
index c2f581d..606ed9a 100644
--- a/new/fwsetup/ui_newt.c
+++ b/new/fwsetup/ui_newt.c
@@ -906,7 +906,7 @@ extern bool ui_window_locale(const char *var,char 
**locales,char **locale)
newtComponent form = 0;
struct newtExitStruct es = {0};
char **p = 0;
-
+
if(var == 0 || locales == 0 || locale == 0)
{
errno = EINVAL;
@@ -971,6 +971,83 @@ extern bool ui_window_locale(const char *var,char 
**locales,char **locale)
return true;
}

+extern bool ui_window_layout(struct layout **layouts,struct layout **layout)
+{
+  int textbox_width = 0;
+  int textbox_height = 0;
+  int next_width = 0;
+  int next_height = 0;
+  int listbox_width = 0;
+  int listbox_height = 0;
+  newtComponent textbox = 0;
+  newtComponent next = 0;
+  newtComponent listbox = 0;
+  newtComponent form = 0;
+  struct newtExitStruct es = {0};
+  struct layout **p = 0;
+
+  if(layouts == 0 || layout == 0)
+  {
+    errno = EINVAL;
+    error(strerror(errno));
+    return false;
+  }
+
+  if(!get_text_screen_size(LAYOUT_TEXT,&textbox_width,&textbox_height))
+    return false;
+
+  if(!get_button_screen_size(NEXT_BUTTON_TEXT,&next_width,&next_height))
+    return false;
+
+  listbox_width = NEWT_WIDTH;
+
+  listbox_height = NEWT_HEIGHT - textbox_height - next_height - 2;
+
+  if(newtCenteredWindow(NEWT_WIDTH,NEWT_HEIGHT,LAYOUT_TITLE) != 0)
+  {
+    eprintf("Failed to open a NEWT window.\n");
+    return false;
+  }
+
+  textbox = newtTextbox(0,0,textbox_width,textbox_height,0);
+
+  newtTextboxSetText(textbox,LAYOUT_TEXT);
+
+  next = 
newtButton(NEWT_WIDTH-next_width,NEWT_HEIGHT-next_height,NEXT_BUTTON_TEXT);
+
+  listbox = newtListbox(0,textbox_height+1,listbox_height,NEWT_FLAG_SCROLL);
+
+  newtListboxSetWidth(listbox,listbox_width);
+
+  for( p = layouts ; *p != 0 ; ++p )
+    newtListboxAppendEntry(listbox,(*p)->kbdlayout,*p);
+
+  newtListboxSetCurrent(listbox,0);
+
+  form = newtForm(0,0,NEWT_FLAG_NOF12);
+
+  newtFormAddComponents(form,textbox,next,listbox,(void *) 0);
+
+  newtFormSetCurrent(form,listbox);
+
+  while(true)
+  {
+    newtFormRun(form,&es);
+
+    if(es.reason == NEWT_EXIT_COMPONENT && es.u.co == next)
+    {
+      *layout = newtListboxGetCurrent(listbox);
+      break;
+    }
+  }
+
+  newtFormDestroy(form);
+
+  newtPopWindow();
+
+  return true;
+}
+
extern bool ui_window_partition(struct device **devices,struct disk **disks)
{
int textbox_width = 0;
_______________________________________________
Frugalware-git mailing list
[email protected]
http://frugalware.org/mailman/listinfo/frugalware-git

Reply via email to