ui/ncurses: Add menu option to restart discovery
authorJeremy Kerr <jk@ozlabs.org>
Wed, 2 Apr 2014 07:16:26 +0000 (15:16 +0800)
committerJeremy Kerr <jk@ozlabs.org>
Wed, 2 Apr 2014 07:24:15 +0000 (15:24 +0800)
Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
ui/ncurses/generic-main.c
ui/ncurses/nc-cui.c
ui/ncurses/nc-cui.h

index 7616788d6b7ea9dd583af198a982f24091794713..2cfb9c319f634d2570662b350d3ef598e8a9056c 100644 (file)
@@ -140,6 +140,12 @@ static int pmenu_config(struct pmenu_item *item)
        return 0;
 }
 
+static int pmenu_reinit(struct pmenu_item *item)
+{
+       cui_send_reinit(cui_from_item(item));
+       return 0;
+}
+
 /**
  * pb_mm_init - Setup the main menu instance.
  */
@@ -150,7 +156,7 @@ static struct pmenu *pb_mm_init(struct pb_cui *pb_cui)
        struct pmenu *m;
        struct pmenu_item *i;
 
-       m = pmenu_init(pb_cui->cui, 4, cui_on_exit);
+       m = pmenu_init(pb_cui->cui, 5, cui_on_exit);
 
        if (!m) {
                pb_log("%s: failed\n", __func__);
@@ -172,7 +178,9 @@ static struct pmenu *pb_mm_init(struct pb_cui *pb_cui)
        i->on_execute = pmenu_sysinfo;
        i = pmenu_item_init(m, 2, "System configuration");
        i->on_execute = pmenu_config;
-       i = pmenu_item_init(m, 3, "Exit to shell");
+       i = pmenu_item_init(m, 3, "Rescan devices");
+       i->on_execute = pmenu_reinit;
+       i = pmenu_item_init(m, 4, "Exit to shell");
        i->on_execute = pmenu_exit_cb;
 
        result = pmenu_setup(m);
index fd90419bcbc99eabd417cc78bd93c2b6d5d081c1..88bdd0f18a0a35590609075a56fa5fb7e2946f6a 100644 (file)
@@ -581,6 +581,11 @@ int cui_send_config(struct cui *cui, struct config *config)
        return discover_client_send_config(cui->client, config);
 }
 
+void cui_send_reinit(struct cui *cui)
+{
+       discover_client_send_reinit(cui->client);
+}
+
 static struct discover_client_ops cui_client_ops = {
        .device_add = NULL,
        .boot_option_add = cui_boot_option_add,
index e59a6b67c4de4695b7065947b0200606a1122cff..8632806fcb52d4d2ca38f30f2a1288c39025ea70 100644 (file)
@@ -77,6 +77,7 @@ void cui_show_sysinfo(struct cui *cui);
 void cui_show_config(struct cui *cui);
 void cui_show_help(struct cui *cui, const char *title, const char *text);
 int cui_send_config(struct cui *cui, struct config *config);
+void cui_send_reinit(struct cui *cui);
 
 /* convenience routines */