2005-09-15 13:58:31 +00:00
|
|
|
#ifndef EL__BFU_HIERBOX_H
|
|
|
|
#define EL__BFU_HIERBOX_H
|
|
|
|
|
|
|
|
#include "bfu/common.h"
|
|
|
|
#include "bfu/listbox.h"
|
|
|
|
#include "util/lists.h"
|
|
|
|
|
2020-10-05 18:14:55 +00:00
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
|
|
|
|
2005-09-15 13:58:31 +00:00
|
|
|
struct session;
|
|
|
|
|
2007-08-08 11:18:53 +00:00
|
|
|
/** BFU hierbox browser button */
|
2005-09-15 13:58:31 +00:00
|
|
|
struct hierbox_browser_button {
|
2007-08-08 11:18:53 +00:00
|
|
|
/** The button label text
|
|
|
|
* It is automatically localized. */
|
2021-01-02 15:20:27 +00:00
|
|
|
char *label;
|
2007-08-08 11:18:53 +00:00
|
|
|
|
|
|
|
/** The button handler
|
|
|
|
* The handler gets called when the button is activated */
|
2005-09-15 13:58:31 +00:00
|
|
|
widget_handler_T *handler;
|
|
|
|
|
2007-08-08 11:18:53 +00:00
|
|
|
/** Allow this button in anonymous mode
|
|
|
|
* Should the button be displayed in anonymous mode or not? This
|
|
|
|
* can be used to disable actions that are not safe in anonymous
|
|
|
|
* mode. */
|
2005-09-15 13:58:31 +00:00
|
|
|
unsigned int anonymous:1;
|
|
|
|
};
|
|
|
|
|
2007-08-08 11:18:53 +00:00
|
|
|
/** BFU hierbox browser
|
|
|
|
*
|
|
|
|
* Hierarchic listbox browsers are used for the various (subsystem)
|
|
|
|
* managers. They basically consist of some state data maintained
|
|
|
|
* throughout the life of the dialog (i.e. the listbox widget),
|
|
|
|
* manager specific operations (for modifying the underlying data
|
|
|
|
* structures), and some buttons.
|
|
|
|
*/
|
2005-09-15 13:58:31 +00:00
|
|
|
struct hierbox_browser {
|
2007-08-08 11:18:53 +00:00
|
|
|
/** The title of the browser
|
|
|
|
* Note, it is automatically localized. */
|
2021-01-02 15:20:27 +00:00
|
|
|
char *title;
|
2007-08-08 11:18:53 +00:00
|
|
|
|
|
|
|
/** Callback for (un)expansion of the listboxes
|
|
|
|
* Can be used by subsystems to install a handler to be called
|
|
|
|
* when listboxes are expanded and unexpanded. */
|
2005-09-15 13:58:31 +00:00
|
|
|
void (*expansion_callback)(void);
|
2007-08-08 11:18:53 +00:00
|
|
|
|
|
|
|
/** Array of browser buttons
|
|
|
|
*
|
|
|
|
* Each button represents an action for modifying or interacting
|
|
|
|
* with the items in the manager.
|
|
|
|
*
|
|
|
|
* A close button will be installed by default. */
|
2007-02-04 11:54:07 +00:00
|
|
|
const struct hierbox_browser_button *buttons;
|
2007-08-08 11:18:53 +00:00
|
|
|
/** The number of browser buttons */
|
2005-09-15 13:58:31 +00:00
|
|
|
size_t buttons_size;
|
|
|
|
|
2007-08-08 11:18:53 +00:00
|
|
|
/** List of active listbox containers
|
|
|
|
*
|
|
|
|
* Several instantiations of a manager can exist at the same
|
|
|
|
* time, if the user has more than one terminal open. This list
|
|
|
|
* contains all the listbox contains for this particular manager
|
|
|
|
* that are currently open. */
|
2007-07-26 19:39:08 +00:00
|
|
|
LIST_OF(struct listbox_data) boxes;
|
2007-08-08 11:18:53 +00:00
|
|
|
/** List of active dialogs
|
|
|
|
*
|
|
|
|
* Several instantiations of a manager can exist at the same
|
|
|
|
* time, if the user has more than one terminal open. This list
|
|
|
|
* contains all the manager dialogs for this particular manager
|
|
|
|
* that are currently open. */
|
2007-07-26 19:39:08 +00:00
|
|
|
LIST_OF(struct hierbox_dialog_list_item) dialogs;
|
2007-08-08 11:18:53 +00:00
|
|
|
|
|
|
|
/** The root listbox
|
|
|
|
* The ancestor of all listboxes in this listbox browser. */
|
2005-09-15 13:58:31 +00:00
|
|
|
struct listbox_item root;
|
2007-08-08 11:18:53 +00:00
|
|
|
|
|
|
|
/** Browser specific listbox operations
|
|
|
|
* The operations for managing the underlying data structures of
|
|
|
|
* the listboxes. */
|
2007-02-04 13:17:49 +00:00
|
|
|
const struct listbox_ops *ops;
|
2005-09-15 13:58:31 +00:00
|
|
|
|
2007-08-08 11:18:53 +00:00
|
|
|
/** State saved between invocations
|
|
|
|
* Each time the browser is closed, its current state is saved
|
|
|
|
* in this member so it can be restored when the browser is
|
|
|
|
* opened again. This way the currently selected item can be
|
|
|
|
* preserved across several interactions with the browser. */
|
2005-09-15 13:58:31 +00:00
|
|
|
struct listbox_data box_data;
|
2007-08-08 11:18:53 +00:00
|
|
|
/** Option for not saving the state
|
|
|
|
* Some browsers with highly dynamic content should not have
|
|
|
|
* their state restored. This member can be used to mark such
|
|
|
|
* browsers. */
|
|
|
|
unsigned int do_not_save_state:1;
|
2005-09-15 13:58:31 +00:00
|
|
|
};
|
|
|
|
|
2007-08-08 11:18:53 +00:00
|
|
|
/** Define a hierbox browser
|
|
|
|
* This macro takes care of initializing all the fields of a hierbox
|
|
|
|
* browser so it is ready to use. */
|
2005-09-15 13:58:31 +00:00
|
|
|
#define struct_hierbox_browser(name, title, buttons, ops) \
|
|
|
|
struct hierbox_browser name = { \
|
|
|
|
title, \
|
|
|
|
NULL, \
|
|
|
|
buttons, \
|
|
|
|
sizeof_array(buttons), \
|
2023-06-19 16:43:53 +00:00
|
|
|
{ D_LIST_HEAD_EL(name.boxes) }, \
|
|
|
|
{ D_LIST_HEAD_EL(name.dialogs) }, \
|
2005-09-15 13:58:31 +00:00
|
|
|
{ \
|
2023-06-19 16:43:53 +00:00
|
|
|
NULL_LIST_HEAD_EL, \
|
|
|
|
{ D_LIST_HEAD_EL(name.root.child) }, \
|
2005-09-15 13:58:31 +00:00
|
|
|
BI_FOLDER, \
|
|
|
|
-1, \
|
|
|
|
1, \
|
|
|
|
0, \
|
|
|
|
}, \
|
|
|
|
ops, \
|
|
|
|
}
|
|
|
|
|
2006-06-15 21:14:51 +00:00
|
|
|
struct hierbox_dialog_list_item {
|
2023-06-19 16:43:53 +00:00
|
|
|
LIST_HEAD_EL(struct hierbox_dialog_list_item);
|
2006-06-15 21:14:51 +00:00
|
|
|
|
|
|
|
struct dialog_data *dlg_data;
|
|
|
|
};
|
|
|
|
|
2005-12-31 22:42:15 +00:00
|
|
|
void done_listbox_item(struct hierbox_browser *browser, struct listbox_item *item);
|
2005-09-15 13:58:31 +00:00
|
|
|
void update_hierbox_browser(struct hierbox_browser *browser);
|
|
|
|
|
|
|
|
struct listbox_item *
|
|
|
|
add_listbox_item(struct hierbox_browser *browser, struct listbox_item *root,
|
|
|
|
enum listbox_item_type type, void *data, int add_position);
|
|
|
|
|
|
|
|
#define add_listbox_folder(browser, root,data) \
|
|
|
|
add_listbox_item(browser, root, BI_FOLDER, data, 1)
|
|
|
|
|
|
|
|
#define add_listbox_leaf(browser, root, data) \
|
|
|
|
add_listbox_item(browser, root, BI_LEAF, data, 1)
|
|
|
|
|
2007-08-08 11:18:53 +00:00
|
|
|
/** Open a hierbox browser
|
|
|
|
* Opens an instantiation of a hierbox browser
|
2005-09-15 13:58:31 +00:00
|
|
|
*
|
2007-08-08 11:18:53 +00:00
|
|
|
* @param browser The browser to open.
|
|
|
|
* @param ses The session (and terminal) on which it should appear.
|
|
|
|
* @return A reference to the dialog that was created or NULL.
|
|
|
|
*/
|
2005-09-15 13:58:31 +00:00
|
|
|
struct dialog_data *
|
|
|
|
hierbox_browser(struct hierbox_browser *browser, struct session *ses);
|
|
|
|
|
|
|
|
widget_handler_status_T push_hierbox_info_button(struct dialog_data *dlg_data, struct widget_data *button);
|
|
|
|
widget_handler_status_T push_hierbox_goto_button(struct dialog_data *dlg_data, struct widget_data *button);
|
|
|
|
widget_handler_status_T push_hierbox_delete_button(struct dialog_data *dlg_data, struct widget_data *button);
|
|
|
|
widget_handler_status_T push_hierbox_clear_button(struct dialog_data *dlg_data, struct widget_data *button);
|
|
|
|
widget_handler_status_T push_hierbox_search_button(struct dialog_data *dlg_data, struct widget_data *button);
|
|
|
|
|
2020-10-05 18:14:55 +00:00
|
|
|
#ifdef __cplusplus
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2005-09-15 13:58:31 +00:00
|
|
|
#endif
|