diff options
Diffstat (limited to 'mdk-stage1/newt-frontend.c')
-rw-r--r-- | mdk-stage1/newt-frontend.c | 101 |
1 files changed, 49 insertions, 52 deletions
diff --git a/mdk-stage1/newt-frontend.c b/mdk-stage1/newt-frontend.c index e0bc7c5ce..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,9 @@ #include <stdio.h> #include <stdarg.h> #include <sys/time.h> -#include "newt/newt.h" +#include <newt.h> + +#include <probing.h> #include "frontend.h" @@ -41,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(); } @@ -115,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) { @@ -134,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) @@ -157,7 +166,7 @@ void update_progression(int current_size) } } -void end_progression(void) +void end_progression_raw(void) { if (size_progress) { newtPopWindow(); @@ -168,55 +177,39 @@ 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; - 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; - - 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; @@ -233,7 +226,7 @@ enum return_type ask_yes_no(char *msg) static void (*callback_real_function)(char ** strings) = NULL; -static void default_callback(newtComponent co, void * data) +static void default_callback(newtComponent co __attribute__ ((unused)), void * data) { newtComponent * entries = data; char * strings[50], ** ptr; @@ -306,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), @@ -368,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; @@ -381,7 +374,7 @@ enum return_type ask_from_entries(char *msg, char ** questions, char *** answers *(entries[j].value) = NULL; } - rc = mynewtWinEntries("Please fill entries...", msg, 52, 5, 5, entry_size, callback_func, entries, "Ok", "Cancel", NULL); + rc = mynewtWinEntries("Please fill in entries...", msg, 52, 5, 5, entry_size, callback_func, entries, "Ok", "Cancel", NULL); if (rc == 3) return RETURN_BACK; @@ -390,3 +383,7 @@ enum return_type ask_from_entries(char *msg, char ** questions, char *** answers return RETURN_OK; } + + +void suspend_to_console(void) { newtSuspend(); } +void resume_from_suspend(void) { newtResume(); } |