summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJeremy Kerr <jk@ozlabs.org>2013-10-16 11:30:29 +0800
committerJeremy Kerr <jk@ozlabs.org>2013-11-13 17:31:04 +0800
commitd57d1c9c4cd7365063da7aa1f018736166bb3a50 (patch)
tree71581953001d5bc44203fe3d4d03eac4c7a42b9c
parent31ae49c6bfaa3cd65969bff7448be0f6385a6255 (diff)
downloadtalos-petitboot-d57d1c9c4cd7365063da7aa1f018736166bb3a50.tar.gz
talos-petitboot-d57d1c9c4cd7365063da7aa1f018736166bb3a50.zip
ui/ncurses: Add nc_scr_{un,}post()
We may have nc_scrs that aren't interested in post/unpost information, so create helper functions that allow a NULL callback. Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
-rw-r--r--ui/ncurses/nc-cui.c19
-rw-r--r--ui/ncurses/nc-menu.c4
-rw-r--r--ui/ncurses/nc-scr.c14
-rw-r--r--ui/ncurses/nc-scr.h3
4 files changed, 29 insertions, 11 deletions
diff --git a/ui/ncurses/nc-cui.c b/ui/ncurses/nc-cui.c
index adbb3d6..b734cdc 100644
--- a/ui/ncurses/nc-cui.c
+++ b/ui/ncurses/nc-cui.c
@@ -201,7 +201,7 @@ static void cui_boot_editor_on_exit(struct boot_editor *boot_editor,
/* Re-attach the items array. */
set_menu_items(menu->ncm, menu->items);
- menu->scr.post(&menu->scr);
+ nc_scr_post(&menu->scr);
} else {
cod = item->data;
}
@@ -249,10 +249,11 @@ struct nc_scr *cui_set_current(struct cui *cui, struct nc_scr *scr)
assert(cui->current != scr);
old = cui->current;
- old->unpost(old);
+ nc_scr_unpost(old);
cui->current = scr;
- cui->current->post(cui->current);
+
+ nc_scr_post(cui->current);
return old;
}
@@ -365,7 +366,7 @@ static int cui_boot_option_add(struct device *dev, struct boot_option *opt,
selected = current_item(cui->main->ncm);
if (cui->current == &cui->main->scr)
- cui->current->unpost(cui->current);
+ nc_scr_unpost(cui->current);
/* This disconnects items array from menu. */
@@ -421,7 +422,7 @@ static int cui_boot_option_add(struct device *dev, struct boot_option *opt,
set_current_item(cui->main->ncm, selected);
if (cui->current == &cui->main->scr)
- cui->current->post(cui->current);
+ nc_scr_post(cui->current);
return 0;
}
@@ -442,7 +443,7 @@ static void cui_device_remove(struct device *dev, void *arg)
pb_log("%s: %p %s\n", __func__, dev, dev->id);
if (cui->current == &cui->main->scr)
- cui->current->unpost(cui->current);
+ nc_scr_unpost(cui->current);
/* This disconnects items array from menu. */
@@ -472,7 +473,7 @@ static void cui_device_remove(struct device *dev, void *arg)
}
if (cui->current == &cui->main->scr)
- cui->current->post(cui->current);
+ nc_scr_post(cui->current);
}
static void cui_update_status(struct boot_status *status, void *arg)
@@ -498,7 +499,7 @@ static void cui_update_mm_title(struct cui *cui)
" %s", cui->sysinfo->identifier);
if (cui->current == &cui->main->scr)
- cui->current->post(cui->current);
+ nc_scr_post(cui->current);
}
static void cui_update_sysinfo(struct system_info *sysinfo, void *arg)
@@ -628,7 +629,7 @@ int cui_run(struct cui *cui, struct pmenu *main, unsigned int default_item)
cui->current = &cui->main->scr;
cui->default_item = default_item;
- cui->current->post(cui->current);
+ nc_scr_post(cui->current);
while (1) {
int result = waiter_poll(cui->waitset);
diff --git a/ui/ncurses/nc-menu.c b/ui/ncurses/nc-menu.c
index beb63f3..4dba0ad 100644
--- a/ui/ncurses/nc-menu.c
+++ b/ui/ncurses/nc-menu.c
@@ -162,7 +162,7 @@ int pmenu_item_replace(struct pmenu_item *i, const char *name)
set_item_userptr(nci, i);
- menu->scr.unpost(&menu->scr);
+ nc_scr_unpost(&menu->scr);
set_menu_items(menu->ncm, NULL);
// FIXME: need to assure item name is a talloc string.
@@ -173,7 +173,7 @@ int pmenu_item_replace(struct pmenu_item *i, const char *name)
i->nci = nci;
set_menu_items(menu->ncm, menu->items);
- menu->scr.post(&menu->scr);
+ nc_scr_post(&menu->scr);
return 0;
}
diff --git a/ui/ncurses/nc-scr.c b/ui/ncurses/nc-scr.c
index c6172e1..e8c5fca 100644
--- a/ui/ncurses/nc-scr.c
+++ b/ui/ncurses/nc-scr.c
@@ -40,6 +40,20 @@ static void nc_scr_status_draw(struct nc_scr *scr)
scr->frame.status);
}
+int nc_scr_post(struct nc_scr *scr)
+{
+ if (scr->post)
+ return scr->post(scr);
+ return 0;
+}
+
+int nc_scr_unpost(struct nc_scr *scr)
+{
+ if (scr->unpost)
+ return scr->unpost(scr);
+ return 0;
+}
+
void nc_scr_frame_draw(struct nc_scr *scr)
{
int ltitle_len, rtitle_len;
diff --git a/ui/ncurses/nc-scr.h b/ui/ncurses/nc-scr.h
index 5c4b97b..775e8de 100644
--- a/ui/ncurses/nc-scr.h
+++ b/ui/ncurses/nc-scr.h
@@ -95,4 +95,7 @@ void nc_scr_status_free(struct nc_scr *scr);
void nc_scr_status_printf(struct nc_scr *scr, const char *format, ...);
void nc_scr_frame_draw(struct nc_scr *scr);
+int nc_scr_post(struct nc_scr *src);
+int nc_scr_unpost(struct nc_scr *src);
+
#endif
OpenPOWER on IntegriCloud