summaryrefslogtreecommitdiffstats
path: root/mdk-stage1/newt-frontend.c
diff options
context:
space:
mode:
authorGuillaume Cottenceau <gc@mandriva.com>2000-12-07 23:16:19 +0000
committerGuillaume Cottenceau <gc@mandriva.com>2000-12-07 23:16:19 +0000
commit0c0b00ab8086c07600680d41e2f8feefe0f8f150 (patch)
tree0da2100a6944b5efed0aa02d950d98a071bec0cc /mdk-stage1/newt-frontend.c
parent71d6a65fa155d25fc325d6a9b83a746f5845922e (diff)
downloaddrakx-0c0b00ab8086c07600680d41e2f8feefe0f8f150.tar
drakx-0c0b00ab8086c07600680d41e2f8feefe0f8f150.tar.gz
drakx-0c0b00ab8086c07600680d41e2f8feefe0f8f150.tar.bz2
drakx-0c0b00ab8086c07600680d41e2f8feefe0f8f150.tar.xz
drakx-0c0b00ab8086c07600680d41e2f8feefe0f8f150.zip
first draft can detect your cdrom drives
soon will launch the stage2
Diffstat (limited to 'mdk-stage1/newt-frontend.c')
-rw-r--r--mdk-stage1/newt-frontend.c149
1 files changed, 149 insertions, 0 deletions
diff --git a/mdk-stage1/newt-frontend.c b/mdk-stage1/newt-frontend.c
new file mode 100644
index 000000000..2c7e5434b
--- /dev/null
+++ b/mdk-stage1/newt-frontend.c
@@ -0,0 +1,149 @@
+/*
+ * Guillaume Cottenceau (gc@mandrakesoft.com)
+ *
+ * Copyright 2000 MandrakeSoft
+ *
+ * This software may be freely redistributed under the terms of the GNU
+ * public license.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ *
+ */
+
+/*
+ * Portions from Erik Troan (ewt@redhat.com)
+ *
+ * Copyright 1996 Red Hat Software
+ *
+ */
+
+
+/*
+ * Each different frontend must implement all functions defined in frontend.h
+ */
+
+
+#include <stdlib.h>
+#include <unistd.h>
+#include <string.h>
+#include <stdio.h>
+#include <stdarg.h>
+#include "stage1.h"
+#include "log.h"
+#include "newt.h"
+
+#include "frontend.h"
+
+
+void init_frontend(void)
+{
+ newtInit();
+ newtCls();
+
+ newtDrawRootText(0, 0, "Welcome to Linux-Mandrake (" VERSION ") " __DATE__ " " __TIME__);
+
+ newtPushHelpLine(" <Tab>/<Alt-Tab> between elements, <Space>/<Enter> selects");
+}
+
+
+void finish_frontend(void)
+{
+ newtFinished();
+}
+
+
+void error_message(char *msg)
+{
+ newtWinMessage("Error", "Ok", msg);
+}
+
+void wait_message(char *msg, ...)
+{
+ int width = 36;
+ int height = 3;
+ char * title = "Please wait...";
+ newtComponent t, f;
+ char * buf = NULL;
+ int size = 0;
+ int i = 0;
+ va_list args;
+
+ va_start(args, msg);
+
+ do {
+ size += 1000;
+ if (buf) free(buf);
+ buf = malloc(size);
+ i = vsnprintf(buf, size, msg, args);
+ } while (i == size);
+
+ va_end(args);
+
+ newtCenteredWindow(width, height, title);
+
+ t = newtTextbox(1, 1, width - 2, height - 2, NEWT_TEXTBOX_WRAP);
+ newtTextboxSetText(t, buf);
+ f = newtForm(NULL, NULL, 0);
+
+ free(buf);
+
+ newtFormAddComponent(f, t);
+
+ newtDrawForm(f);
+ newtRefresh();
+ newtFormDestroy(f);
+}
+
+void remove_wait_message(void)
+{
+ newtPopWindow();
+}
+
+
+enum return_type ask_from_list_comments(char *msg, char ** elems, char ** elems_comments, char ** choice)
+{
+ char * items[50];
+ int answer = 0, rc;
+ char ** sav_elems = elems;
+ int i;
+
+ i = 0;
+ while (elems && *elems) {
+ items[i] = malloc(sizeof(char) * (strlen(*elems) + strlen(*elems_comments) + 3));
+ strcpy(items[i], *elems);
+ strcat(items[i], " (");
+ strcat(items[i], *elems_comments);
+ strcat(items[i], ")");
+ i++;
+ elems++;
+ elems_comments++;
+ }
+ 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);
+
+ if (rc == 2)
+ return RETURN_BACK;
+
+ *choice = strdup(elems[answer]);
+
+ return RETURN_OK;
+}
+