diff options
author | C. Davis <cd.rattan@gmail.com> | 2012-08-06 19:11:13 -0700 |
---|---|---|
committer | Michael Adam <obnox@samba.org> | 2013-04-29 13:06:03 +0200 |
commit | db5295a7dc61056092b43523409fd11b147e031d (patch) | |
tree | 5f294dd3e87ef3f3b64579210cca989f24807753 /source3/utils/regedit.c | |
parent | 3c14ab13b19fd11f728d61b7f467b09c4e06fc02 (diff) | |
download | samba-db5295a7dc61056092b43523409fd11b147e031d.tar.gz samba-db5295a7dc61056092b43523409fd11b147e031d.tar.xz samba-db5295a7dc61056092b43523409fd11b147e031d.zip |
regedit: Some work on dialogs.
* Make dialogs modal with a separate getch() loop to avoid extra
complexity keeping track of dialogs and getting the result.
* Start work on the value editor dialog.
Reviewed-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Michael Adam <obnox@samba.org>
Diffstat (limited to 'source3/utils/regedit.c')
-rw-r--r-- | source3/utils/regedit.c | 89 |
1 files changed, 29 insertions, 60 deletions
diff --git a/source3/utils/regedit.c b/source3/utils/regedit.c index 14215cb775..cf97668494 100644 --- a/source3/utils/regedit.c +++ b/source3/utils/regedit.c @@ -38,7 +38,6 @@ struct regedit { struct value_list *vl; struct tree_view *keys; bool tree_input; - struct dialog *dia; }; /* load all available hives */ @@ -102,32 +101,6 @@ static void print_heading(WINDOW *win, bool selected, const char *str) wrefresh(win); } -static void delete_key_callback(struct dialog *dia, int selection, void *arg) -{ - struct regedit *regedit = arg; - - //mvwprintw(regedit->main_window, 1, 0, "Selection: %d", selection); - - if (selection == DIALOG_OK) { - /* TODO */ - } - - talloc_free(regedit->dia); - regedit->dia = NULL; -} - -static void delete_value_callback(struct dialog *dia, int selection, void *arg) -{ - struct regedit *regedit = arg; - - if (selection == DIALOG_OK) { - /* TODO */ - } - - talloc_free(regedit->dia); - regedit->dia = NULL; -} - static void handle_tree_input(struct regedit *regedit, int c) { struct tree_node *node; @@ -165,15 +138,21 @@ static void handle_tree_input(struct regedit *regedit, int c) } break; case 'd': - case 'D': + case 'D': { + struct dialog *dia; + int sel; + node = item_userptr(current_item(regedit->keys->menu)); - regedit->dia = dialog_confirm_new(regedit, "Delete Key", - regedit->main_window, - "Really delete key \"%s\"?", - node->name); - dialog_set_cb(regedit->dia, delete_key_callback, regedit); + dia = dialog_confirm_new(regedit, "Delete Key", + regedit->main_window, + "Really delete key \"%s\"?", + node->name); + sel = dialog_modal_loop(dia); + mvwprintw(regedit->main_window, 1, 0, "Sel: %d", sel); + /* TODO */ break; } + } tree_view_show(regedit->keys); value_list_show(regedit->vl); @@ -190,17 +169,28 @@ static void handle_value_input(struct regedit *regedit, int c) case KEY_UP: menu_driver(regedit->vl->menu, REQ_UP_ITEM); break; + case '\n': case KEY_ENTER: + vitem = item_userptr(current_item(regedit->vl->menu)); + if (vitem) { + struct tree_node *node; + node = item_userptr(current_item(regedit->keys->menu)); + dialog_edit_value(regedit, node->key, vitem, regedit->main_window); + } break; case 'd': case 'D': vitem = item_userptr(current_item(regedit->vl->menu)); if (vitem) { - regedit->dia = dialog_confirm_new(regedit, "Delete Value", - regedit->main_window, - "Really delete value \"%s\"?", - vitem->value_name); - dialog_set_cb(regedit->dia, delete_value_callback, regedit); + struct dialog *dia; + int sel; + + dia = dialog_confirm_new(regedit, "Delete Value", + regedit->main_window, + "Really delete value \"%s\"?", + vitem->value_name); + sel = dialog_modal_loop(dia); + mvwprintw(regedit->main_window, 1, 0, "Sel: %d", sel); } break; } @@ -208,22 +198,6 @@ static void handle_value_input(struct regedit *regedit, int c) value_list_show(regedit->vl); } -static void handle_dialog_input(struct regedit *regedit, int c) -{ - switch (c) { - case KEY_LEFT: - dialog_driver(regedit->dia, DIALOG_LEFT); - break; - case KEY_RIGHT: - dialog_driver(regedit->dia, DIALOG_RIGHT); - break; - case '\n': - case KEY_ENTER: - dialog_driver(regedit->dia, DIALOG_ENTER); - break; - } -} - static void handle_main_input(struct regedit *regedit, int c) { switch (c) { @@ -296,12 +270,7 @@ static void display_test_window(TALLOC_CTX *mem_ctx, update_panels(); doupdate(); while ((c = wgetch(regedit->main_window)) != 'q') { - if (regedit->dia) { - handle_dialog_input(regedit, c); - } else { - handle_main_input(regedit, c); - } - + handle_main_input(regedit, c); update_panels(); doupdate(); } |