ui/ncurses: Use pmenu_item destrutor to free ncurses ITEMs
[petitboot] / ui / ncurses / nc-boot-editor.h
index 6b72f253bccfa82ceba150f07e9938e6a7e27db2..5c22598ba7f544f94736458bb804854f7e1d9dd9 100644 (file)
 #if !defined(_PB_NC_KED_H)
 #define _PB_NC_KED_H
 
-#include <linux/input.h> /* This must be included before ncurses.h */
-#if defined HAVE_NCURSESW_FORM_H
-#  include <ncursesw/form.h>
-#elif defined HAVE_NCURSES_FORM_H
-#  include <ncurses/form.h>
-#elif defined HAVE_FORM_H
-#  include <form.h>
-#else
-#  error "Curses form.h not found."
-#endif
+#include "ui/common/discover-client.h"
 
 #include "types/types.h"
-#include "ui/common/ui-system.h"
-#include "nc-scr.h"
-
-enum boot_editor_attr_cursor {
-       boot_editor_attr_cursor_ins = A_NORMAL,
-       boot_editor_attr_cursor_ovl = A_NORMAL | A_UNDERLINE,
-};
+#include "nc-cui.h"
 
-/**
- * enum boot_editor_result - Result code for boot_editor:on_exit().
- * @boot_editor_cancel: The user canceled the operation.
- * @boot_editor_update: The args were updated.
- */
+struct boot_editor;
 
-enum boot_editor_result {
-       boot_editor_cancel,
-       boot_editor_update,
-};
-
-/**
- * struct boot_editor - kexec args editor.
- */
+struct boot_editor *boot_editor_init(struct cui *cui,
+               struct pmenu_item *item,
+               const struct system_info *sysinfo,
+               void (*on_exit)(struct cui *cui,
+                               struct pmenu_item *item,
+                               struct pb_boot_data *bd));
 
-struct boot_editor {
-       struct nc_scr   scr;
-       void            *data;
-       struct pmenu    *original_pmenu;
-       void            (*on_exit)(struct boot_editor *boot_editor,
-                                       enum boot_editor_result result,
-                                       struct pb_boot_data *bd);
-       enum boot_editor_attr_cursor attr_cursor;
+struct nc_scr *boot_editor_scr(struct boot_editor *boot_editor);
 
-       struct nc_widgetset     *widgetset;
-       struct {
-               struct nc_widget_label          *image_l;
-               struct nc_widget_textbox        *image_f;
-               struct nc_widget_label          *initrd_l;
-               struct nc_widget_textbox        *initrd_f;
-               struct nc_widget_label          *dtb_l;
-               struct nc_widget_textbox        *dtb_f;
-               struct nc_widget_label          *args_l;
-               struct nc_widget_textbox        *args_f;
-               struct nc_widget_button         *ok_b;
-               struct nc_widget_button         *cancel_b;
-       } widgets;
-};
+void boot_editor_update(struct boot_editor *boot_editor,
+               const struct system_info *info);
 
-struct boot_editor *boot_editor_init(struct pmenu *menu,
-               const struct pb_boot_data *bd,
-               void (*on_exit)(struct boot_editor *,
-                               enum boot_editor_result,
-                               struct pb_boot_data *));
 
 #endif