summaryrefslogtreecommitdiffstats
path: root/mdk-stage1/newt-frontend.c
diff options
context:
space:
mode:
Diffstat (limited to 'mdk-stage1/newt-frontend.c')
-rw-r--r--mdk-stage1/newt-frontend.c99
1 files changed, 41 insertions, 58 deletions
diff --git a/mdk-stage1/newt-frontend.c b/mdk-stage1/newt-frontend.c
index 9d14dfc84..c0489b58d 100644
--- a/mdk-stage1/newt-frontend.c
+++ b/mdk-stage1/newt-frontend.c
@@ -1,7 +1,7 @@
/*
- * Guillaume Cottenceau (gc@mandrakesoft.com)
+ * Guillaume Cottenceau (gc)
*
- * Copyright 2000 MandrakeSoft
+ * Copyright 2000 Mandriva
*
* This software may be freely redistributed under the terms of the GNU
* public license.
@@ -24,6 +24,7 @@
* Each different frontend must implement all functions defined in frontend.h
*/
+#define _GNU_SOURCE
#include <stdlib.h>
#include <unistd.h>
@@ -31,7 +32,7 @@
#include <stdio.h>
#include <stdarg.h>
#include <sys/time.h>
-#include "newt/newt.h"
+#include <newt.h>
#include <probing.h>
@@ -43,10 +44,16 @@ void init_frontend(char * welcome_msg)
for (i=0; i<38; i++) printf("\n");
newtInit();
newtCls();
-
- newtDrawRootText(0, 0, welcome_msg);
-
- newtPushHelpLine(" <Alt-F1> for here, <Alt-F3> to see the logs, <Alt-F4> for kernel msg");
+
+ if (welcome_msg[0]) {
+ char *msg;
+ int cols, rows;
+ newtGetScreenSize(&cols, &rows);
+ asprintf(&msg, " %-*s", cols - 1, welcome_msg);
+ newtDrawRootText(0, 0, msg);
+ free(msg);
+ newtPushHelpLine(" <Alt-F1> for here, <Alt-F3> to see the logs, <Alt-F4> for kernel msg");
+ }
newtRefresh();
}
@@ -117,7 +124,7 @@ static int size_progress;
static int actually_drawn;
static char * msg_progress;
-void init_progression(char *msg, int size)
+void init_progression_raw(char *msg, int size)
{
size_progress = size;
if (size) {
@@ -136,7 +143,7 @@ void init_progression(char *msg, int size)
}
}
-void update_progression(int current_size)
+void update_progression_raw(int current_size)
{
if (size_progress) {
if (current_size <= size_progress)
@@ -159,7 +166,7 @@ void update_progression(int current_size)
}
}
-void end_progression(void)
+void end_progression_raw(void)
{
if (size_progress) {
newtPopWindow();
@@ -170,65 +177,43 @@ void end_progression(void)
}
-enum return_type ask_from_list_comments(char *msg, char ** elems, char ** elems_comments, char ** choice)
+enum return_type ask_from_list_index(char *msg, char ** elems, char ** elems_comments, int * answer)
{
- char * items[500];
- int answer = 0, rc;
- char ** sav_elems = elems;
- int i;
+ char * items[50000];
+ int rc;
- probe_that_type(USB_CONTROLLERS, BUS_USB); // we'd need the keyboard for interactions so...
-
- i = 0;
- while (elems && *elems) {
- int j = (*elems_comments) ? strlen(*elems_comments) : 0;
- items[i] = malloc(sizeof(char) * (strlen(*elems) + j + 4));
- strcpy(items[i], *elems);
- if (*elems_comments) {
- strcat(items[i], " (");
- strcat(items[i], *elems_comments);
- strcat(items[i], ")");
- }
- elems_comments++;
- i++;
- elems++;
+ if (elems_comments) {
+ int i;
+
+ i = 0;
+ while (elems && *elems) {
+ int j = (*elems_comments) ? strlen(*elems_comments) : 0;
+ items[i] = malloc(sizeof(char) * (strlen(*elems) + j + 4));
+ strcpy(items[i], *elems);
+ if (*elems_comments) {
+ strcat(items[i], " (");
+ strcat(items[i], *elems_comments);
+ strcat(items[i], ")");
+ }
+ elems_comments++;
+ i++;
+ elems++;
+ }
+ items[i] = NULL;
}
- items[i] = NULL;
-
- rc = newtWinMenu("Please choose...", msg, 52, 5, 5, 7, items, &answer, "Ok", "Cancel", NULL);
-
- if (rc == 2)
- return RETURN_BACK;
- *choice = strdup(sav_elems[answer]);
-
- return RETURN_OK;
-}
-
-
-enum return_type ask_from_list(char *msg, char ** elems, char ** choice)
-{
- int answer = 0, rc;
-
- probe_that_type(USB_CONTROLLERS, BUS_USB); // we'd need the keyboard for interactions so...
-
- rc = newtWinMenu("Please choose...", msg, 52, 5, 5, 7, elems, &answer, "Ok", "Cancel", NULL);
+ rc = newtWinMenu("Please choose...", msg, 52, 5, 5, 7, elems_comments ? items : elems, answer, "Ok", "Cancel", NULL);
if (rc == 2)
return RETURN_BACK;
- *choice = strdup(elems[answer]);
-
return RETURN_OK;
}
-
enum return_type ask_yes_no(char *msg)
{
int rc;
- probe_that_type(USB_CONTROLLERS, BUS_USB); // we'd need the keyboard for interactions so...
-
rc = newtWinTernary("Please answer...", "Yes", "No", "Back", msg);
if (rc == 1)
@@ -314,7 +299,7 @@ static int mynewtWinEntries(char * title, char * text, int suggestedWidth, int f
for (i = 0; i < numItems; i++) {
newtComponent entr = newtEntry(-1, -1, items[i].value ?
*items[i].value : NULL, dataWidth,
- items[i].value, items[i].flags);
+ (const char**)items[i].value, items[i].flags);
newtGridSetField(subgrid, 0, i, NEWT_GRID_COMPONENT,
newtLabel(-1, -1, items[i].text),
@@ -366,8 +351,6 @@ enum return_type ask_from_entries(char *msg, char ** questions, char *** answers
int rc;
char ** already_answers = NULL;
- probe_that_type(USB_CONTROLLERS, BUS_USB); // we'd need the keyboard for interactions so...
-
while (questions && *questions) {
entries[i].text = *questions;
entries[i].flags = NEWT_FLAG_SCROLL | (!strcmp(*questions, "Password") ? NEWT_FLAG_PASSWORD : 0);
@@ -378,7 +361,7 @@ enum return_type ask_from_entries(char *msg, char ** questions, char *** answers
entries[i].value = NULL;
if (*answers == NULL)
- *answers = (char **) malloc(sizeof(char *) * i);
+ *answers = (char **) calloc(1, sizeof(char *) * i);
else
already_answers = *answers;