Remove ntdb from scripts
[Samba.git] / source3 / utils / regedit_dialog.h
blob5c7c84a3d118beff627d2a5f0b1a7e1463df04f8
1 /*
2 * Samba Unix/Linux SMB client library
3 * Registry Editor
4 * Copyright (C) Christopher Davis 2012
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 3 of the License, or
9 * (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program. If not, see <http://www.gnu.org/licenses/>.
20 #ifndef _REGEDIT_DIALOG_H_
21 #define _REGEDIT_DIALOG_H_
23 #include <ncurses.h>
24 #include <panel.h>
25 #include <menu.h>
27 struct dialog;
28 struct dialog_section;
30 /* dialog submit cb. return true to close dialog, false to keep
31 it open */
32 typedef bool (*dialog_submit_cb)(struct dialog *, struct dialog_section *,
33 void *);
35 struct dialog {
36 char *title;
37 WINDOW *window;
38 WINDOW *pad;
39 PANEL *panel;
40 int x;
41 int y;
42 short color;
43 bool centered;
44 dialog_submit_cb submit;
45 void *submit_arg;
46 struct dialog_section *head_section;
47 struct dialog_section *tail_section;
48 struct dialog_section *current_section;
51 enum dialog_action {
52 DIALOG_IGNORE,
53 DIALOG_OK,
54 DIALOG_CANCEL
57 struct dialog_section_ops {
58 /* create section */
59 WERROR (*create)(struct dialog *, struct dialog_section *);
61 /* (optional) cleanup the section */
62 void (*destroy)(struct dialog_section *);
64 /* (optional) handle character input */
65 void (*on_input)(struct dialog *, struct dialog_section *, int c);
67 /* (optional) handle a tab character. return true if section dealt
68 with the tab internally, or false to advance focus to
69 the next dialog section. */
70 bool (*on_tab)(struct dialog *, struct dialog_section *);
72 /* (optional) handle a btab character. return true if section dealt
73 with the tab internally, or false to move focus to
74 the previous dialog section. */
75 bool (*on_btab)(struct dialog *, struct dialog_section *);
77 /* */
78 bool (*on_up)(struct dialog *, struct dialog_section *);
80 /* */
81 bool (*on_down)(struct dialog *, struct dialog_section *);
83 /* */
84 bool (*on_left)(struct dialog *, struct dialog_section *);
86 /* */
87 bool (*on_right)(struct dialog *, struct dialog_section *);
89 /* (optional) handle enter key. return DIALOG_OK to submit
90 dialog, DIALOG_CANCEL to close dialog, or DIALOG_IGNORE to
91 handle the enter internally. */
92 enum dialog_action (*on_enter)(struct dialog *,
93 struct dialog_section *);
95 /* (optional) called when this section is about to take focus. forward
96 is set to true when focus has landed here from forward traversal,
97 such as from a tab. return true to accept focus, false to pass to an
98 adjacent section. */
99 bool (*on_focus)(struct dialog *, struct dialog_section *, bool forward);
101 /* (optional) called when focus is leaving this section */
102 void (*on_leave_focus)(struct dialog *, struct dialog_section *);
105 enum section_justify {
106 SECTION_JUSTIFY_LEFT,
107 SECTION_JUSTIFY_CENTER,
108 SECTION_JUSTIFY_RIGHT,
111 struct dialog_section {
112 char *name;
113 int nlines;
114 int ncols;
115 WINDOW *window;
116 enum section_justify justify;
117 const struct dialog_section_ops *ops;
118 struct dialog_section *next;
119 struct dialog_section *prev;
122 struct dialog *dialog_new(TALLOC_CTX *ctx, short color,
123 const char *title, int y, int x);
125 void dialog_section_destroy(struct dialog_section *section);
126 void dialog_section_init(struct dialog_section *section,
127 const struct dialog_section_ops *ops,
128 int nlines, int ncols);
130 void dialog_section_set_name(struct dialog_section *section, const char *name);
131 const char *dialog_section_get_name(struct dialog_section *section);
132 void dialog_section_set_justify(struct dialog_section *section,
133 enum section_justify justify);
135 void dialog_append_section(struct dialog *dia,
136 struct dialog_section *section);
137 struct dialog_section *dialog_find_section(struct dialog *dia,
138 const char *name);
140 WERROR dialog_create(struct dialog *dia);
141 void dialog_show(struct dialog *dia);
142 void dialog_destroy(struct dialog *dia);
143 void dialog_set_submit_cb(struct dialog *dia, dialog_submit_cb cb, void *arg);
144 bool dialog_handle_input(struct dialog *dia, WERROR *err,
145 enum dialog_action *action);
146 void dialog_modal_loop(struct dialog *dia, WERROR *err,
147 enum dialog_action *action);
149 struct dialog_section *dialog_section_label_new_va(TALLOC_CTX *ctx,
150 const char *msg, va_list ap);
151 struct dialog_section *dialog_section_label_new(TALLOC_CTX *ctx,
152 const char *msg, ...);
154 struct dialog_section *dialog_section_hsep_new(TALLOC_CTX *ctx, int sep);
157 struct dialog_section *dialog_section_text_field_new(TALLOC_CTX *ctx,
158 int height, int width);
159 const char *dialog_section_text_field_get(TALLOC_CTX *ctx,
160 struct dialog_section *section);
161 const char **dialog_section_text_field_get_lines(TALLOC_CTX *ctx,
162 struct dialog_section *section);
163 bool dialog_section_text_field_get_int(struct dialog_section *section,
164 long long *out);
165 bool dialog_section_text_field_get_uint(struct dialog_section *section,
166 unsigned long long *out);
167 void dialog_section_text_field_set(struct dialog_section *section,
168 const char *s);
169 WERROR dialog_section_text_field_set_lines(TALLOC_CTX *ctx,
170 struct dialog_section *section,
171 const char **array);
173 struct dialog_section *dialog_section_hexedit_new(TALLOC_CTX *ctx, int height);
174 WERROR dialog_section_hexedit_set_buf(struct dialog_section *section,
175 const void *data, size_t size);
176 void dialog_section_hexedit_get_buf(struct dialog_section *section,
177 const void **data, size_t *size);
178 WERROR dialog_section_hexedit_resize(struct dialog_section *section,
179 size_t size);
181 struct button_spec {
182 const char *label;
183 enum dialog_action (*on_enter)(struct dialog *,
184 struct dialog_section *);
185 enum dialog_action action;
187 /* internal */
188 int col;
190 struct dialog_section *dialog_section_buttons_new(TALLOC_CTX *ctx,
191 const struct button_spec *spec);
193 struct option_spec {
194 const char *label;
195 bool *state;
197 /* internal */
198 int col;
199 int row;
201 struct dialog_section *dialog_section_options_new(TALLOC_CTX *ctx,
202 const struct option_spec *spec,
203 int maxcol, bool single_select);
205 enum dialog_type {
206 DIA_ALERT,
207 DIA_CONFIRM
210 int dialog_notice(TALLOC_CTX *ctx, enum dialog_type type,
211 const char *title, const char *msg, ...);
213 int dialog_input(TALLOC_CTX *ctx, const char **output, const char *title,
214 const char *msg, ...);
215 int dialog_input_long(TALLOC_CTX *ctx, long *output,
216 const char *title, const char *msg, ...);
217 int dialog_input_ulong(TALLOC_CTX *ctx, unsigned long *output,
218 const char *title, const char *msg, ...);
220 struct registry_key;
221 struct value_item;
223 int dialog_edit_value(TALLOC_CTX *ctx, struct registry_key *key,
224 uint32_t type, const struct value_item *vitem,
225 bool force_binary, WERROR *err,
226 const char **name);
228 int dialog_select_type(TALLOC_CTX *ctx, int *type);
230 struct regedit_search_opts;
232 int dialog_search_input(TALLOC_CTX *ctx, struct regedit_search_opts *opts);
234 #endif