1 #ifndef EL__BFU_HIERBOX_H
2 #define EL__BFU_HIERBOX_H
4 #include "bfu/common.h"
5 #include "bfu/listbox.h"
6 #include "util/lists.h"
10 struct hierbox_browser_button
{
12 widget_handler_T
*handler
;
14 /* Should the button be displayed in anonymous mode */
15 unsigned int anonymous
:1;
18 struct hierbox_browser
{
20 void (*expansion_callback
)(void);
21 struct hierbox_browser_button
*buttons
;
24 struct list_head boxes
;
25 struct list_head dialogs
;
26 struct listbox_item root
;
27 struct listbox_ops
*ops
;
29 /* For saving state */
30 unsigned int do_not_save_state
:1;
31 struct listbox_data box_data
;
34 #define struct_hierbox_browser(name, title, buttons, ops) \
35 struct hierbox_browser name = { \
39 sizeof_array(buttons), \
40 { D_LIST_HEAD(name.boxes) }, \
41 { D_LIST_HEAD(name.dialogs) }, \
44 { D_LIST_HEAD(name.root.child) }, \
53 struct hierbox_dialog_list_item
{
54 LIST_HEAD(struct hierbox_dialog_list_item
);
56 struct dialog_data
*dlg_data
;
59 void done_listbox_item(struct hierbox_browser
*browser
, struct listbox_item
*box_item
);
60 void update_hierbox_browser(struct hierbox_browser
*browser
);
63 add_listbox_item(struct hierbox_browser
*browser
, struct listbox_item
*root
,
64 enum listbox_item_type type
, void *data
, int add_position
);
66 #define add_listbox_folder(browser, root,data) \
67 add_listbox_item(browser, root, BI_FOLDER, data, 1)
69 #define add_listbox_leaf(browser, root, data) \
70 add_listbox_item(browser, root, BI_LEAF, data, 1)
72 /* We use hierarchic listbox browsers for the various managers. They consist
73 * of a listbox widget and some buttons.
75 * @term The terminal where the browser should appear.
77 * @title The title of the browser. It is automatically localized.
79 * @add_size The size of extra data to be allocated with the dialog.
81 * @browser The browser structure that contains info to setup listbox data
82 * and manage the dialog list to keep instances of the browser in
83 * sync on various terminals.
85 * @udata Is a reference to any data that the dialog could use.
87 * @buttons Denotes the number of buttons given as varadic arguments.
88 * For each button 4 arguments are extracted:
89 * o First the label text. It is automatically localized.
90 * If NULL, this button is skipped.
91 * o Second a pointer to a widget handler.
92 * XXX: A close button will be installed by default.
94 * XXX: Note that the @listbox_data is detached and freed by the dialog handler.
95 * Any other requirements should be handled by installing a specific
96 * dlg->abort handler. */
99 hierbox_browser(struct hierbox_browser
*browser
, struct session
*ses
);
101 widget_handler_status_T
push_hierbox_info_button(struct dialog_data
*dlg_data
, struct widget_data
*button
);
102 widget_handler_status_T
push_hierbox_goto_button(struct dialog_data
*dlg_data
, struct widget_data
*button
);
103 widget_handler_status_T
push_hierbox_delete_button(struct dialog_data
*dlg_data
, struct widget_data
*button
);
104 widget_handler_status_T
push_hierbox_clear_button(struct dialog_data
*dlg_data
, struct widget_data
*button
);
105 widget_handler_status_T
push_hierbox_search_button(struct dialog_data
*dlg_data
, struct widget_data
*button
);