]> git.ipfire.org Git - ipfire-2.x.git/commitdiff
installer: Rewrite license box.
authorMichael Tremer <michael.tremer@ipfire.org>
Mon, 21 Jul 2014 12:59:41 +0000 (14:59 +0200)
committerMichael Tremer <michael.tremer@ipfire.org>
Mon, 21 Jul 2014 12:59:41 +0000 (14:59 +0200)
Used to use wrong button type and was a bit more code
than needed.

src/install+setup/install/main.c
src/install+setup/libsmooth/main.c

index 56b9446db73edd44426fabcce8ce7b2f170f6c97..645bee37d741f2f0694db2904e3dc343c6c5bb24 100644 (file)
@@ -144,6 +144,36 @@ static int newtWinOkCancel(const char* title, const char* message, int width, in
        return ret;
 }
 
+static int newtLicenseBox(const char* title, const char* text, int width, int height) {
+       int ret = 1;
+
+       newtCenteredWindow(width, height, title);
+
+       newtComponent form = newtForm(NULL, NULL, 0);
+
+       newtComponent textbox = newtTextbox(1, 1, width - 2, height - 7,
+               NEWT_FLAG_WRAP|NEWT_FLAG_SCROLL);
+       newtTextboxSetText(textbox, text);
+       newtFormAddComponent(form, textbox);
+
+       char choice;
+       newtComponent checkbox = newtCheckbox(3, height - 3, ctr[TR_LICENSE_ACCEPT],
+               ' ', " *", &choice);
+
+       newtComponent btn = newtButton(width - 15, height - 4, ctr[TR_OK]);
+
+       newtFormAddComponents(form, checkbox, btn, NULL);
+
+       newtComponent answer = newtRunForm(form);
+       if (answer == btn && choice == '*')
+               ret = 0;
+
+       newtFormDestroy(form);
+       newtPopWindow();
+
+       return ret;
+}
+
 int main(int argc, char *argv[]) {
        struct hw* hw = hw_init();
 
@@ -277,8 +307,9 @@ int main(int argc, char *argv[]) {
                        fread(discl_msg, 1, 40000, copying);
                        fclose(copying);
 
-                       if (disclaimerbox(discl_msg)==0) {
+                       if (newtLicenseBox(title, discl_msg, 75, 20)) {
                                errorbox(ctr[TR_LICENSE_NOT_ACCEPTED]);
+
                                goto EXIT;
                        }
                }
index aef3e93225159b6d99e37b90e6a2515f8a871134..14c308469eec21f89e9546d5a2688f79253ab6ee 100644 (file)
@@ -45,61 +45,6 @@ void errorbox(char *message)
        newtWinMessage(ctr[TR_ERROR], ctr[TR_OK], message);
 }
 
-int scrollmsgbox(int width, int height, char *title, char *text, ...)
-{
-       int rc = 0;
-       newtComponent t, f, b, c;
-       char *buf = NULL;
-       char checkbox;
-       int size = 0;
-       int i = 0;
-       va_list args;
-
-       va_start(args, text);
-
-       do {
-               size += 40000;
-               if (buf) free(buf);
-               buf = malloc(size);
-               i = vsnprintf(buf, size, text, args);
-       } while (i == size);
-
-       va_end(args);
-
-       newtCenteredWindow(width, height, title);
-
-       b = newtCompactButton(width - 15 ,height - 2, ctr[TR_OK]);
-       c = newtCheckbox(3, height - 2, ctr[TR_LICENSE_ACCEPT], ' ', " *", &checkbox);
-
-       t = newtTextbox(1, 1, width - 2, height - 4, NEWT_TEXTBOX_WRAP+NEWT_TEXTBOX_SCROLL);
-       newtTextboxSetText(t, buf);
-
-       f = newtForm(NULL, NULL, 0);
-       free(buf);
-
-       newtFormAddComponent(f, c);
-       newtFormAddComponent(f, b);
-       newtFormAddComponent(f, t);
-
-       newtRunForm(f);
-       if (checkbox=='*') rc=1;
-       newtFormDestroy(f);
-       return rc;
-}
-
-int disclaimerbox(char *message)
-{
-       int rc;
-       char title[STRING_SIZE];
-       
-       sprintf (title, "%s v%s - %s", NAME, VERSION, SLOGAN);
-       rc = scrollmsgbox(75, 20, title, message);
-       newtPopWindow();
-       
-       return rc;
-}
-
-
 void statuswindow(int width, int height, char *title, char *text, ...)
 {
        newtComponent t, f;