* coding style harmonization in servers/
- explicitely declare void arguments - make a few string args const * better support for shorter displays in server screen * make target to create top level tag file
This commit is contained in:
+201
-200
@@ -41,152 +41,152 @@
|
||||
/* Next include files are needed for settings that we can modify */
|
||||
#include "render.h"
|
||||
|
||||
char * menu_key;
|
||||
char * enter_key;
|
||||
char * up_key;
|
||||
char * down_key;
|
||||
char * left_key;
|
||||
char * right_key;
|
||||
char *menu_key;
|
||||
char *enter_key;
|
||||
char *up_key;
|
||||
char *down_key;
|
||||
char *left_key;
|
||||
char *right_key;
|
||||
|
||||
Screen * menuscreen = NULL;
|
||||
MenuItem * active_menuitem = NULL;
|
||||
Screen *menuscreen = NULL;
|
||||
MenuItem *active_menuitem = NULL;
|
||||
/** the "real" main_menu */
|
||||
Menu * main_menu = NULL;
|
||||
Menu *main_menu = NULL;
|
||||
/** customizable entry point into the menu system (see menu_set_main()). */
|
||||
Menu * custom_main_menu = NULL;
|
||||
Menu * screens_menu = NULL;
|
||||
Menu *custom_main_menu = NULL;
|
||||
Menu *screens_menu = NULL;
|
||||
|
||||
/* Local prototypes */
|
||||
static void handle_quit();
|
||||
static void handle_close();
|
||||
static void handle_none();
|
||||
static void handle_enter();
|
||||
static void handle_successor();
|
||||
void menuscreen_switch_item (MenuItem * new_menuitem);
|
||||
void menuscreen_create_menu ();
|
||||
Menu* menuscreen_get_main ();
|
||||
MenuEventFunc (heartbeat_handler);
|
||||
MenuEventFunc (backlight_handler);
|
||||
MenuEventFunc (contrast_handler);
|
||||
MenuEventFunc (brightness_handler);
|
||||
static void handle_quit(void);
|
||||
static void handle_close(void);
|
||||
static void handle_none(void);
|
||||
static void handle_enter(void);
|
||||
static void handle_successor(void);
|
||||
void menuscreen_switch_item(MenuItem *new_menuitem);
|
||||
void menuscreen_create_menu(void);
|
||||
Menu *menuscreen_get_main(void);
|
||||
MenuEventFunc(heartbeat_handler);
|
||||
MenuEventFunc(backlight_handler);
|
||||
MenuEventFunc(contrast_handler);
|
||||
MenuEventFunc(brightness_handler);
|
||||
|
||||
int menuscreens_init()
|
||||
int menuscreens_init(void)
|
||||
{
|
||||
const char *tmp;
|
||||
|
||||
debug (RPT_DEBUG, "%s()", __FUNCTION__);
|
||||
debug(RPT_DEBUG, "%s()", __FUNCTION__);
|
||||
|
||||
/* Get keys from config file */
|
||||
menu_key = strdup (config_get_string ("menu", "MenuKey", 0, "Menu"));
|
||||
enter_key = strdup (config_get_string ("menu", "EnterKey", 0, "Enter"));
|
||||
up_key = strdup (config_get_string ("menu", "UpKey", 0, "Up"));
|
||||
down_key = strdup (config_get_string ("menu", "DownKey", 0, "Down"));
|
||||
menu_key = strdup(config_get_string("menu", "MenuKey", 0, "Menu"));
|
||||
enter_key = strdup(config_get_string("menu", "EnterKey", 0, "Enter"));
|
||||
up_key = strdup(config_get_string("menu", "UpKey", 0, "Up"));
|
||||
down_key = strdup(config_get_string("menu", "DownKey", 0, "Down"));
|
||||
|
||||
/* if the user has specified in the conf file a left and right key */
|
||||
left_key = right_key = NULL;
|
||||
tmp = config_get_string ("menu", "LeftKey", 0, NULL);
|
||||
tmp = config_get_string("menu", "LeftKey", 0, NULL);
|
||||
if (tmp)
|
||||
left_key = strdup(tmp);
|
||||
tmp = config_get_string ("menu", "RightKey", 0, NULL);
|
||||
tmp = config_get_string("menu", "RightKey", 0, NULL);
|
||||
if (tmp)
|
||||
right_key = strdup(tmp);
|
||||
|
||||
|
||||
/* Now reserve keys */
|
||||
input_reserve_key (menu_key, true, NULL);
|
||||
input_reserve_key (enter_key, false, NULL);
|
||||
input_reserve_key (up_key, false, NULL);
|
||||
input_reserve_key (down_key, false, NULL);
|
||||
input_reserve_key(menu_key, true, NULL);
|
||||
input_reserve_key(enter_key, false, NULL);
|
||||
input_reserve_key(up_key, false, NULL);
|
||||
input_reserve_key(down_key, false, NULL);
|
||||
if (left_key)
|
||||
input_reserve_key (left_key, false, NULL);
|
||||
input_reserve_key(left_key, false, NULL);
|
||||
if (right_key)
|
||||
input_reserve_key (right_key, false, NULL);
|
||||
input_reserve_key(right_key, false, NULL);
|
||||
|
||||
/* Create screen */
|
||||
menuscreen = screen_create ("_menu_screen", NULL);
|
||||
menuscreen = screen_create("_menu_screen", NULL);
|
||||
if (menuscreen != NULL)
|
||||
menuscreen->priority = PRI_HIDDEN;
|
||||
active_menuitem = NULL;
|
||||
|
||||
screenlist_add (menuscreen);
|
||||
screenlist_add(menuscreen);
|
||||
|
||||
/* Build menu */
|
||||
menuscreen_create_menu ();
|
||||
menuscreen_create_menu();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
int menuscreens_shutdown()
|
||||
int menuscreens_shutdown(void)
|
||||
{
|
||||
debug (RPT_DEBUG, "%s()", __FUNCTION__ );
|
||||
debug(RPT_DEBUG, "%s()", __FUNCTION__);
|
||||
|
||||
/* Program shutdown before completed startup */
|
||||
if (!menuscreen)
|
||||
return -1;
|
||||
|
||||
/* Quit menu just to make sure */
|
||||
menuscreen_switch_item (NULL);
|
||||
menuscreen_switch_item(NULL);
|
||||
|
||||
/* Destroy the menuscreen */
|
||||
screenlist_remove (menuscreen);
|
||||
screen_destroy (menuscreen);
|
||||
screenlist_remove(menuscreen);
|
||||
screen_destroy(menuscreen);
|
||||
menuscreen = NULL;
|
||||
|
||||
/* Destroy all menus */
|
||||
menuitem_destroy (main_menu);
|
||||
menuitem_destroy(main_menu);
|
||||
main_menu = NULL;
|
||||
custom_main_menu = NULL;
|
||||
screens_menu = NULL;
|
||||
|
||||
/* Forget menu's key reservations */
|
||||
input_release_client_keys (NULL);
|
||||
input_release_client_keys(NULL);
|
||||
|
||||
free (menu_key);
|
||||
free (enter_key);
|
||||
free (up_key);
|
||||
free (down_key);
|
||||
free(menu_key);
|
||||
free(enter_key);
|
||||
free(up_key);
|
||||
free(down_key);
|
||||
if (left_key)
|
||||
free (left_key);
|
||||
free(left_key);
|
||||
if (right_key)
|
||||
free (right_key);
|
||||
free(right_key);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
void menuscreen_inform_item_destruction (MenuItem * item)
|
||||
void menuscreen_inform_item_destruction(MenuItem *item)
|
||||
{
|
||||
MenuItem * i;
|
||||
MenuItem *i;
|
||||
|
||||
debug (RPT_DEBUG, "%s( item=[%s] )", __FUNCTION__,
|
||||
debug(RPT_DEBUG, "%s(item=[%s])", __FUNCTION__,
|
||||
((item != NULL) ? item->id : "(null)"));
|
||||
|
||||
/* Are we currently in (a subitem of) the given item ? */
|
||||
for( i = active_menuitem; i != NULL; i = i->parent ) {
|
||||
if( i == item ) {
|
||||
menuscreen_switch_item (item->parent);
|
||||
for (i = active_menuitem; i != NULL; i = i->parent) {
|
||||
if (i == item) {
|
||||
menuscreen_switch_item(item->parent);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void menuscreen_inform_item_modified (MenuItem * item)
|
||||
void menuscreen_inform_item_modified(MenuItem *item)
|
||||
{
|
||||
debug (RPT_DEBUG, "%s( item=[%s] )", __FUNCTION__,
|
||||
debug(RPT_DEBUG, "%s(item=[%s])", __FUNCTION__,
|
||||
((item != NULL) ? item->id : "(null)"));
|
||||
|
||||
if ((active_menuitem == NULL) || (item == NULL))
|
||||
return;
|
||||
|
||||
/* Are we currently in the item or the parent of the item ? */
|
||||
if( active_menuitem == item || active_menuitem == item->parent ) {
|
||||
menuitem_rebuild_screen( active_menuitem, menuscreen );
|
||||
if (active_menuitem == item || active_menuitem == item->parent) {
|
||||
menuitem_rebuild_screen(active_menuitem, menuscreen);
|
||||
}
|
||||
}
|
||||
|
||||
bool is_menu_key (const char * key)
|
||||
bool is_menu_key(const char *key)
|
||||
{
|
||||
if (menu_key && key && strcmp (key, menu_key) == 0)
|
||||
if (menu_key && key && strcmp(key, menu_key) == 0)
|
||||
return true;
|
||||
else
|
||||
return false;
|
||||
@@ -197,11 +197,11 @@ bool is_menu_key (const char * key)
|
||||
* To leave the menu system, specify NULL for new_menuitem.
|
||||
* The item will not be reset when the new item is a child of the last one.
|
||||
*/
|
||||
void menuscreen_switch_item (MenuItem * new_menuitem)
|
||||
void menuscreen_switch_item(MenuItem *new_menuitem)
|
||||
{
|
||||
MenuItem * old_menuitem = active_menuitem;
|
||||
MenuItem *old_menuitem = active_menuitem;
|
||||
|
||||
debug (RPT_DEBUG, "%s( item=[%s] ) from active_menuitem=[%s]", __FUNCTION__,
|
||||
debug(RPT_DEBUG, "%s(item=[%s]) from active_menuitem=[%s]", __FUNCTION__,
|
||||
((new_menuitem != NULL) ? new_menuitem->id : "(null)"),
|
||||
((old_menuitem != NULL) ? old_menuitem->id : "(null)"));
|
||||
|
||||
@@ -216,16 +216,16 @@ void menuscreen_switch_item (MenuItem * new_menuitem)
|
||||
menuscreen->priority = PRI_HIDDEN;
|
||||
} else if (!old_menuitem && new_menuitem) {
|
||||
/* Menu is becoming active */
|
||||
menuitem_reset (active_menuitem);
|
||||
menuitem_rebuild_screen (active_menuitem, menuscreen);
|
||||
menuitem_reset(active_menuitem);
|
||||
menuitem_rebuild_screen(active_menuitem, menuscreen);
|
||||
|
||||
menuscreen->priority = PRI_INPUT;
|
||||
} else {
|
||||
/* We're left with the usual case: a menu level switch */
|
||||
if( old_menuitem->parent != new_menuitem) {
|
||||
menuitem_reset (new_menuitem);
|
||||
if (old_menuitem->parent != new_menuitem) {
|
||||
menuitem_reset(new_menuitem);
|
||||
}
|
||||
menuitem_rebuild_screen (active_menuitem, menuscreen);
|
||||
menuitem_rebuild_screen(active_menuitem, menuscreen);
|
||||
}
|
||||
|
||||
if (old_menuitem && old_menuitem->event_func)
|
||||
@@ -236,27 +236,27 @@ void menuscreen_switch_item (MenuItem * new_menuitem)
|
||||
return;
|
||||
}
|
||||
|
||||
static void handle_quit()
|
||||
static void handle_quit(void)
|
||||
{
|
||||
debug (RPT_DEBUG, "%s: Closing menu screen", __FUNCTION__);
|
||||
debug(RPT_DEBUG, "%s: Closing menu screen", __FUNCTION__);
|
||||
menuscreen_switch_item(NULL);
|
||||
}
|
||||
|
||||
static void handle_close()
|
||||
static void handle_close(void)
|
||||
{
|
||||
debug (RPT_DEBUG, "%s: Closing item", __FUNCTION__);
|
||||
debug(RPT_DEBUG, "%s: Closing item", __FUNCTION__);
|
||||
menuscreen_switch_item(
|
||||
(active_menuitem == menuscreen_get_main())
|
||||
? NULL
|
||||
: active_menuitem->parent);
|
||||
}
|
||||
|
||||
static void handle_none()
|
||||
static void handle_none(void)
|
||||
{
|
||||
debug (RPT_DEBUG, "%s: Staying in item", __FUNCTION__);
|
||||
debug(RPT_DEBUG, "%s: Staying in item", __FUNCTION__);
|
||||
if (active_menuitem)
|
||||
{
|
||||
menuitem_update_screen (active_menuitem, menuscreen);
|
||||
menuitem_update_screen(active_menuitem, menuscreen);
|
||||
/* No rebuild needed, only value can be changed */
|
||||
}
|
||||
/* Nothing extra to be done */
|
||||
@@ -267,19 +267,19 @@ static void handle_none()
|
||||
* own screen. The menuitem_process_input function should do
|
||||
* things like toggling checkboxes !
|
||||
*/
|
||||
static void handle_enter()
|
||||
static void handle_enter(void)
|
||||
{
|
||||
debug (RPT_DEBUG, "%s: Entering subitem", __FUNCTION__);
|
||||
menuscreen_switch_item (menu_get_current_item (active_menuitem));
|
||||
debug(RPT_DEBUG, "%s: Entering subitem", __FUNCTION__);
|
||||
menuscreen_switch_item(menu_get_current_item(active_menuitem));
|
||||
}
|
||||
|
||||
static void handle_predecessor()
|
||||
static void handle_predecessor(void)
|
||||
{
|
||||
MenuItem* item = (active_menuitem->type == MENUITEM_MENU)
|
||||
? menu_get_item_for_predecessor_check(active_menuitem)
|
||||
: active_menuitem;
|
||||
assert(item != NULL);
|
||||
debug (RPT_DEBUG, "%s: Switching to registered predecessor '%s' of '%s'.",
|
||||
debug(RPT_DEBUG, "%s: Switching to registered predecessor '%s' of '%s'.",
|
||||
__FUNCTION__, item->predecessor_id, item->id);
|
||||
MenuItem *predecessor = menuitem_search(
|
||||
item->predecessor_id, (Client*)active_menuitem->client);
|
||||
@@ -288,7 +288,7 @@ static void handle_predecessor()
|
||||
// note: if _quit_, _close_, _none_ get here this
|
||||
// would be an implementation error - they should
|
||||
// have been handled via different MENURESULT codes.
|
||||
report (RPT_ERR, "%s: cannot find predecessor '%s' of '%s'.",
|
||||
report(RPT_ERR, "%s: cannot find predecessor '%s' of '%s'.",
|
||||
__FUNCTION__, item->predecessor_id, item->id);
|
||||
return;
|
||||
}
|
||||
@@ -314,13 +314,13 @@ static void handle_predecessor()
|
||||
}
|
||||
}
|
||||
|
||||
static void handle_successor()
|
||||
static void handle_successor(void)
|
||||
{
|
||||
MenuItem* item = (active_menuitem->type == MENUITEM_MENU)
|
||||
? menu_get_item_for_successor_check(active_menuitem)
|
||||
: active_menuitem;
|
||||
assert(item != NULL);
|
||||
debug (RPT_DEBUG, "%s: Switching to registered successor '%s' of '%s'.",
|
||||
debug(RPT_DEBUG, "%s: Switching to registered successor '%s' of '%s'.",
|
||||
__FUNCTION__, item->successor_id, item->id);
|
||||
MenuItem *successor = menuitem_search(
|
||||
item->successor_id, (Client*)active_menuitem->client);
|
||||
@@ -329,7 +329,7 @@ static void handle_successor()
|
||||
// note: if _quit_, _close_, _none_ get here this
|
||||
// would be an implementation error - they should
|
||||
// have been handled via different MENURESULT codes.
|
||||
report (RPT_ERR, "%s: cannot find successor '%s' of '%s'.",
|
||||
report(RPT_ERR, "%s: cannot find successor '%s' of '%s'.",
|
||||
__FUNCTION__, item->successor_id, item->id);
|
||||
return;
|
||||
}
|
||||
@@ -355,29 +355,29 @@ static void handle_successor()
|
||||
}
|
||||
}
|
||||
|
||||
void menuscreen_key_handler (const char *key)
|
||||
void menuscreen_key_handler(const char *key)
|
||||
{
|
||||
char token = 0;
|
||||
MenuResult res;
|
||||
|
||||
debug (RPT_DEBUG, "%s( \"%s\" )", __FUNCTION__, key);
|
||||
debug(RPT_DEBUG, "%s(\"%s\")", __FUNCTION__, key);
|
||||
|
||||
if (strcmp (key, menu_key) == 0) {
|
||||
if (strcmp(key, menu_key) == 0) {
|
||||
token = MENUTOKEN_MENU;
|
||||
}
|
||||
else if (strcmp (key, enter_key) == 0) {
|
||||
else if (strcmp(key, enter_key) == 0) {
|
||||
token = MENUTOKEN_ENTER;
|
||||
}
|
||||
else if (strcmp (key, up_key) == 0) {
|
||||
else if (strcmp(key, up_key) == 0) {
|
||||
token = MENUTOKEN_UP;
|
||||
}
|
||||
else if (strcmp (key, down_key) == 0) {
|
||||
else if (strcmp(key, down_key) == 0) {
|
||||
token = MENUTOKEN_DOWN;
|
||||
}
|
||||
else if (left_key && strcmp (key, left_key) == 0) {
|
||||
else if (left_key && strcmp(key, left_key) == 0) {
|
||||
token = MENUTOKEN_LEFT;
|
||||
}
|
||||
else if (right_key && strcmp (key, right_key) == 0) {
|
||||
else if (right_key && strcmp(key, right_key) == 0) {
|
||||
token = MENUTOKEN_RIGHT;
|
||||
}
|
||||
else {
|
||||
@@ -386,17 +386,17 @@ void menuscreen_key_handler (const char *key)
|
||||
|
||||
/* Is the menu already active ? */
|
||||
if (!active_menuitem) {
|
||||
debug (RPT_DEBUG, "%s: Activating menu screen", __FUNCTION__);
|
||||
debug(RPT_DEBUG, "%s: Activating menu screen", __FUNCTION__);
|
||||
menuscreen_switch_item(menuscreen_get_main());
|
||||
return;
|
||||
}
|
||||
|
||||
res = menuitem_process_input (active_menuitem, token, key,
|
||||
res = menuitem_process_input(active_menuitem, token, key,
|
||||
((left_key || right_key) ? 1 : 0));
|
||||
|
||||
switch (res) {
|
||||
case MENURESULT_ERROR:
|
||||
report (RPT_ERR, "%s: Error from menuitem_process_input", __FUNCTION__);
|
||||
report(RPT_ERR, "%s: Error from menuitem_process_input", __FUNCTION__);
|
||||
break;
|
||||
case MENURESULT_NONE:
|
||||
handle_none();
|
||||
@@ -422,38 +422,38 @@ void menuscreen_key_handler (const char *key)
|
||||
}
|
||||
}
|
||||
|
||||
void menuscreen_create_menu ()
|
||||
void menuscreen_create_menu(void)
|
||||
{
|
||||
Menu * options_menu;
|
||||
Menu * driver_menu;
|
||||
MenuItem * checkbox;
|
||||
MenuItem * slider;
|
||||
Driver * driver;
|
||||
Menu *options_menu;
|
||||
Menu *driver_menu;
|
||||
MenuItem *checkbox;
|
||||
MenuItem *slider;
|
||||
Driver *driver;
|
||||
|
||||
#ifdef LCDPROC_TESTMENUS
|
||||
MenuItem * test_item;
|
||||
Menu * test_menu;
|
||||
MenuItem *test_item;
|
||||
Menu *test_menu;
|
||||
#endif /*LCDPROC_TESTMENUS*/
|
||||
|
||||
debug (RPT_DEBUG, "%s()", __FUNCTION__);
|
||||
debug(RPT_DEBUG, "%s()", __FUNCTION__);
|
||||
|
||||
main_menu = menu_create ("mainmenu", NULL, "LCDproc Menu", NULL);
|
||||
main_menu = menu_create("mainmenu", NULL, "LCDproc Menu", NULL);
|
||||
|
||||
options_menu = menu_create ("options", NULL, "Options", NULL);
|
||||
menu_add_item (main_menu, options_menu);
|
||||
options_menu = menu_create("options", NULL, "Options", NULL);
|
||||
menu_add_item(main_menu, options_menu);
|
||||
|
||||
#ifdef LCDPROC_TESTMENUS
|
||||
screens_menu = menu_create ("screens", NULL, "Screens", NULL);
|
||||
menu_add_item (main_menu, screens_menu);
|
||||
screens_menu = menu_create("screens", NULL, "Screens", NULL);
|
||||
menu_add_item(main_menu, screens_menu);
|
||||
#endif /*LCDPROC_TESTMENUS*/
|
||||
|
||||
/* menu's client is NULL since we're in the server */
|
||||
checkbox = menuitem_create_checkbox ("heartbeat", heartbeat_handler, "Heartbeat", NULL, true, heartbeat);
|
||||
menu_add_item (options_menu, checkbox);
|
||||
checkbox = menuitem_create_checkbox("heartbeat", heartbeat_handler, "Heartbeat", NULL, true, heartbeat);
|
||||
menu_add_item(options_menu, checkbox);
|
||||
|
||||
/* menu's client is NULL since we're in the server */
|
||||
checkbox = menuitem_create_checkbox ("backlight", backlight_handler, "Backlight", NULL, true, backlight);
|
||||
menu_add_item (options_menu, checkbox);
|
||||
checkbox = menuitem_create_checkbox("backlight", backlight_handler, "Backlight", NULL, true, backlight);
|
||||
menu_add_item(options_menu, checkbox);
|
||||
|
||||
for (driver = drivers_getfirst(); driver; driver = drivers_getnext()) {
|
||||
int contrast_avail = (driver->get_contrast && driver->set_contrast) ? 1 : 0;
|
||||
@@ -461,83 +461,83 @@ void menuscreen_create_menu ()
|
||||
|
||||
if (contrast_avail || brightness_avail) {
|
||||
/* menu's client is NULL since we're in the server */
|
||||
driver_menu = menu_create (driver->name, NULL, driver->name, NULL);
|
||||
driver_menu = menu_create(driver->name, NULL, driver->name, NULL);
|
||||
menu_set_association(driver_menu, driver);
|
||||
menu_add_item (options_menu, driver_menu);
|
||||
menu_add_item(options_menu, driver_menu);
|
||||
if (contrast_avail) {
|
||||
int contrast = driver->get_contrast(driver);
|
||||
|
||||
/* menu's client is NULL since we're in the server */
|
||||
slider = menuitem_create_slider ("contrast", contrast_handler, "Contrast",
|
||||
slider = menuitem_create_slider("contrast", contrast_handler, "Contrast",
|
||||
NULL, "min", "max", 0, 1000, 25, contrast);
|
||||
menu_add_item (driver_menu, slider);
|
||||
menu_add_item(driver_menu, slider);
|
||||
}
|
||||
if (brightness_avail) {
|
||||
int onbrightness = driver->get_brightness (driver, BACKLIGHT_ON);
|
||||
int offbrightness = driver->get_brightness (driver, BACKLIGHT_OFF);
|
||||
int onbrightness = driver->get_brightness(driver, BACKLIGHT_ON);
|
||||
int offbrightness = driver->get_brightness(driver, BACKLIGHT_OFF);
|
||||
|
||||
slider = menuitem_create_slider ("onbrightness", brightness_handler, "On Brightness",
|
||||
slider = menuitem_create_slider("onbrightness", brightness_handler, "On Brightness",
|
||||
NULL, "min", "max", 0, 1000, 25, onbrightness);
|
||||
menu_add_item (driver_menu, slider);
|
||||
menu_add_item(driver_menu, slider);
|
||||
|
||||
slider = menuitem_create_slider ("offbrightness", brightness_handler, "Off Brightness",
|
||||
slider = menuitem_create_slider("offbrightness", brightness_handler, "Off Brightness",
|
||||
NULL, "min", "max", 0, 1000, 25, offbrightness);
|
||||
menu_add_item (driver_menu, slider);
|
||||
menu_add_item(driver_menu, slider);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef LCDPROC_TESTMENUS
|
||||
test_menu = menu_create ("test", NULL, "Test menu", NULL);
|
||||
menu_add_item (main_menu, test_menu);
|
||||
test_menu = menu_create("test", NULL, "Test menu", NULL);
|
||||
menu_add_item(main_menu, test_menu);
|
||||
|
||||
/* menu's client is NULL since we're in the server */
|
||||
test_item = menuitem_create_action ("", NULL, "Action", NULL, MENURESULT_NONE);
|
||||
menu_add_item (test_menu, test_item);
|
||||
test_item = menuitem_create_action ("", NULL, "Action,closing", NULL, MENURESULT_CLOSE);
|
||||
menu_add_item (test_menu, test_item);
|
||||
test_item = menuitem_create_action ("", NULL, "Action,quitting", NULL, MENURESULT_QUIT);
|
||||
menu_add_item (test_menu, test_item);
|
||||
test_item = menuitem_create_action("", NULL, "Action", NULL, MENURESULT_NONE);
|
||||
menu_add_item(test_menu, test_item);
|
||||
test_item = menuitem_create_action("", NULL, "Action,closing", NULL, MENURESULT_CLOSE);
|
||||
menu_add_item(test_menu, test_item);
|
||||
test_item = menuitem_create_action("", NULL, "Action,quitting", NULL, MENURESULT_QUIT);
|
||||
menu_add_item(test_menu, test_item);
|
||||
|
||||
test_item = menuitem_create_checkbox ("", NULL, "Checkbox", NULL, false, false);
|
||||
menu_add_item (test_menu, test_item);
|
||||
test_item = menuitem_create_checkbox ("", NULL, "Checkbox, gray", NULL, true, false);
|
||||
menu_add_item (test_menu, test_item);
|
||||
test_item = menuitem_create_checkbox("", NULL, "Checkbox", NULL, false, false);
|
||||
menu_add_item(test_menu, test_item);
|
||||
test_item = menuitem_create_checkbox("", NULL, "Checkbox, gray", NULL, true, false);
|
||||
menu_add_item(test_menu, test_item);
|
||||
|
||||
test_item = menuitem_create_ring ("", NULL, "Ring", NULL, "ABC\tDEF\t01234567890\tOr a very long string that will not fit on any display", 1);
|
||||
menu_add_item (test_menu, test_item);
|
||||
test_item = menuitem_create_ring("", NULL, "Ring", NULL, "ABC\tDEF\t01234567890\tOr a very long string that will not fit on any display", 1);
|
||||
menu_add_item(test_menu, test_item);
|
||||
|
||||
test_item = menuitem_create_slider ("", NULL, "Slider", NULL, "mintext", "maxtext", -20, 20, 1, 0);
|
||||
menu_add_item (test_menu, test_item);
|
||||
test_item = menuitem_create_slider ("", NULL, "Slider,step=5", NULL, "mintext", "maxtext", -20, 20, 5, 0);
|
||||
menu_add_item (test_menu, test_item);
|
||||
test_item = menuitem_create_slider("", NULL, "Slider", NULL, "mintext", "maxtext", -20, 20, 1, 0);
|
||||
menu_add_item(test_menu, test_item);
|
||||
test_item = menuitem_create_slider("", NULL, "Slider,step=5", NULL, "mintext", "maxtext", -20, 20, 5, 0);
|
||||
menu_add_item(test_menu, test_item);
|
||||
|
||||
test_item = menuitem_create_numeric ("", NULL, "Numeric", NULL, 1, 365, 15);
|
||||
menu_add_item (test_menu, test_item);
|
||||
test_item = menuitem_create_numeric ("", NULL, "Numeric,signed", NULL, -20, +20, 15);
|
||||
menu_add_item (test_menu, test_item);
|
||||
test_item = menuitem_create_numeric("", NULL, "Numeric", NULL, 1, 365, 15);
|
||||
menu_add_item(test_menu, test_item);
|
||||
test_item = menuitem_create_numeric("", NULL, "Numeric,signed", NULL, -20, +20, 15);
|
||||
menu_add_item(test_menu, test_item);
|
||||
|
||||
test_item = menuitem_create_alpha ("", NULL, "Alpha", NULL, 0, 3, 12, true, true, true, ".-+@", "LCDproc-v0.5");
|
||||
menu_add_item (test_menu, test_item);
|
||||
test_item = menuitem_create_alpha ("", NULL, "Alpha, caps only", NULL, 0, 3, 12, true, false, false, "-", "LCDPROC");
|
||||
menu_add_item (test_menu, test_item);
|
||||
test_item = menuitem_create_alpha("", NULL, "Alpha", NULL, 0, 3, 12, true, true, true, ".-+@", "LCDproc-v0.5");
|
||||
menu_add_item(test_menu, test_item);
|
||||
test_item = menuitem_create_alpha("", NULL, "Alpha, caps only", NULL, 0, 3, 12, true, false, false, "-", "LCDPROC");
|
||||
menu_add_item(test_menu, test_item);
|
||||
|
||||
test_item = menuitem_create_ip ("", NULL, "IPv4", NULL, 0, "192.168.1.245");
|
||||
menu_add_item (test_menu, test_item);
|
||||
test_item = menuitem_create_ip ("", NULL, "IPv6", NULL, 1, "1080:0:0:0:8:800:200C:417A");
|
||||
menu_add_item (test_menu, test_item);
|
||||
test_item = menuitem_create_ip("", NULL, "IPv4", NULL, 0, "192.168.1.245");
|
||||
menu_add_item(test_menu, test_item);
|
||||
test_item = menuitem_create_ip("", NULL, "IPv6", NULL, 1, "1080:0:0:0:8:800:200C:417A");
|
||||
menu_add_item(test_menu, test_item);
|
||||
#endif /*LCDPROC_TESTMENUS*/
|
||||
}
|
||||
|
||||
MenuEventFunc (heartbeat_handler)
|
||||
{
|
||||
debug (RPT_DEBUG, "%s( item=[%s], event=%d )", __FUNCTION__,
|
||||
debug(RPT_DEBUG, "%s(item=[%s], event=%d)", __FUNCTION__,
|
||||
((item != NULL) ? item->id : "(null)"), event);
|
||||
|
||||
if (event == MENUEVENT_UPDATE) {
|
||||
/* Set heartbeat setting */
|
||||
heartbeat = item->data.checkbox.value;
|
||||
report (RPT_INFO, "Menu: set heartbeat to %d",
|
||||
report(RPT_INFO, "Menu: set heartbeat to %d",
|
||||
item->data.checkbox.value);
|
||||
}
|
||||
return 0;
|
||||
@@ -545,14 +545,14 @@ MenuEventFunc (heartbeat_handler)
|
||||
|
||||
MenuEventFunc (backlight_handler)
|
||||
{
|
||||
debug (RPT_DEBUG, "%s( item=[%s], event=%d )", __FUNCTION__,
|
||||
debug(RPT_DEBUG, "%s(item=[%s], event=%d)", __FUNCTION__,
|
||||
((item != NULL) ? item->id : "(null)"), event);
|
||||
|
||||
if (event == MENUEVENT_UPDATE)
|
||||
{
|
||||
/* Set backlight setting */
|
||||
backlight = item->data.checkbox.value;
|
||||
report (RPT_INFO, "Menu: set backlight to %d",
|
||||
report(RPT_INFO, "Menu: set backlight to %d",
|
||||
item->data.checkbox.value);
|
||||
}
|
||||
return 0;
|
||||
@@ -560,7 +560,7 @@ MenuEventFunc (backlight_handler)
|
||||
|
||||
MenuEventFunc (contrast_handler)
|
||||
{
|
||||
debug (RPT_DEBUG, "%s( item=[%s], event=%d )", __FUNCTION__,
|
||||
debug(RPT_DEBUG, "%s(item=[%s], event=%d)", __FUNCTION__,
|
||||
((item != NULL) ? item->id : "(null)"), event);
|
||||
|
||||
/* This function can be called by one of several drivers that
|
||||
@@ -568,10 +568,11 @@ MenuEventFunc (contrast_handler)
|
||||
* We need to check the menu association to see which driver. */
|
||||
if (event == MENUEVENT_MINUS || event == MENUEVENT_PLUS) {
|
||||
/* Determine the driver */
|
||||
Driver * driver = item->parent->data.menu.association;
|
||||
Driver *driver = item->parent->data.menu.association;
|
||||
|
||||
if (driver != NULL) {
|
||||
driver->set_contrast (driver, item->data.slider.value);
|
||||
report (RPT_INFO, "Menu: set contrast of [%.40s] to %d",
|
||||
driver->set_contrast(driver, item->data.slider.value);
|
||||
report(RPT_INFO, "Menu: set contrast of [%.40s] to %d",
|
||||
driver->name, item->data.slider.value);
|
||||
}
|
||||
}
|
||||
@@ -580,7 +581,7 @@ MenuEventFunc (contrast_handler)
|
||||
|
||||
MenuEventFunc (brightness_handler)
|
||||
{
|
||||
debug (RPT_DEBUG, "%s( item=[%s], event=%d )", __FUNCTION__,
|
||||
debug(RPT_DEBUG, "%s(item=[%s], event=%d)", __FUNCTION__,
|
||||
((item != NULL) ? item->id : "(null)"), event);
|
||||
|
||||
/* This function can be called by one of several drivers that
|
||||
@@ -588,14 +589,14 @@ MenuEventFunc (brightness_handler)
|
||||
* We need to check the menu association to see which driver. */
|
||||
if (event == MENUEVENT_MINUS || event == MENUEVENT_PLUS) {
|
||||
/* Determine the driver */
|
||||
Driver * driver = item->parent->data.menu.association;
|
||||
Driver *driver = item->parent->data.menu.association;
|
||||
|
||||
if (driver != NULL) {
|
||||
if ( strcmp (item->id, "onbrightness") == 0) {
|
||||
driver->set_brightness (driver, BACKLIGHT_ON, item->data.slider.value);
|
||||
if (strcmp(item->id, "onbrightness") == 0) {
|
||||
driver->set_brightness(driver, BACKLIGHT_ON, item->data.slider.value);
|
||||
}
|
||||
else if ( strcmp (item->id, "offbrightness") == 0) {
|
||||
driver->set_brightness (driver, BACKLIGHT_OFF, item->data.slider.value);
|
||||
else if (strcmp(item->id, "offbrightness") == 0) {
|
||||
driver->set_brightness(driver, BACKLIGHT_OFF, item->data.slider.value);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -603,12 +604,12 @@ MenuEventFunc (brightness_handler)
|
||||
}
|
||||
|
||||
void
|
||||
menuscreen_add_screen (Screen * s)
|
||||
menuscreen_add_screen(Screen *s)
|
||||
{
|
||||
Menu * m;
|
||||
MenuItem * mi;
|
||||
Menu *m;
|
||||
MenuItem *mi;
|
||||
|
||||
debug (RPT_DEBUG, "%s( s=[%s] )", __FUNCTION__,
|
||||
debug(RPT_DEBUG, "%s(s=[%s])", __FUNCTION__,
|
||||
((s != NULL) ? s->id : "(null)"));
|
||||
|
||||
/* screens have not been created or no screen given ... */
|
||||
@@ -616,33 +617,33 @@ menuscreen_add_screen (Screen * s)
|
||||
return;
|
||||
|
||||
/* Create a menu entry for the screen */
|
||||
m = menu_create (s->id, NULL, ((s->name != NULL) ? s->name : s->id), s->client);
|
||||
m = menu_create(s->id, NULL, ((s->name != NULL) ? s->name : s->id), s->client);
|
||||
menu_set_association(m, s);
|
||||
menu_add_item (screens_menu, m);
|
||||
menu_add_item(screens_menu, m);
|
||||
|
||||
/* And add some items for it... */
|
||||
mi = menuitem_create_action ("", NULL, "(don't work yet)", s->client, MENURESULT_NONE);
|
||||
menu_add_item (m, mi);
|
||||
mi = menuitem_create_action("", NULL, "(don't work yet)", s->client, MENURESULT_NONE);
|
||||
menu_add_item(m, mi);
|
||||
|
||||
mi = menuitem_create_action ("", NULL, "To Front", s->client, MENURESULT_QUIT);
|
||||
menu_add_item (m, mi);
|
||||
mi = menuitem_create_action("", NULL, "To Front", s->client, MENURESULT_QUIT);
|
||||
menu_add_item(m, mi);
|
||||
|
||||
mi = menuitem_create_checkbox ("", NULL, "Visible", s->client, false, true);
|
||||
menu_add_item (m, mi);
|
||||
mi = menuitem_create_checkbox("", NULL, "Visible", s->client, false, true);
|
||||
menu_add_item(m, mi);
|
||||
|
||||
mi = menuitem_create_numeric ("", NULL, "Duration", s->client, 2, 3600, s->duration);
|
||||
menu_add_item (m, mi);
|
||||
mi = menuitem_create_numeric("", NULL, "Duration", s->client, 2, 3600, s->duration);
|
||||
menu_add_item(m, mi);
|
||||
|
||||
mi = menuitem_create_ring ("", NULL, "Priority", s->client,
|
||||
mi = menuitem_create_ring("", NULL, "Priority", s->client,
|
||||
"Hidden\tBackground\tForeground\tAlert\tInput", s->priority);
|
||||
menu_add_item (m, mi);
|
||||
menu_add_item(m, mi);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
menuscreen_remove_screen (Screen * s)
|
||||
menuscreen_remove_screen(Screen *s)
|
||||
{
|
||||
debug (RPT_DEBUG, "%s( s=[%s] )", __FUNCTION__,
|
||||
debug(RPT_DEBUG, "%s(s=[%s])", __FUNCTION__,
|
||||
(s != NULL) ? s->id : "(NULL)");
|
||||
|
||||
/* allow to remove the menuscreen itself */
|
||||
@@ -650,36 +651,36 @@ menuscreen_remove_screen (Screen * s)
|
||||
return;
|
||||
|
||||
if (screens_menu) {
|
||||
Menu * m = menu_find_item (screens_menu, s->id, false);
|
||||
Menu *m = menu_find_item(screens_menu, s->id, false);
|
||||
|
||||
menu_remove_item (screens_menu, m);
|
||||
menuitem_destroy (m);
|
||||
menu_remove_item(screens_menu, m);
|
||||
menuitem_destroy(m);
|
||||
}
|
||||
}
|
||||
|
||||
int
|
||||
menuscreen_goto (Menu * menu)
|
||||
menuscreen_goto(Menu *menu)
|
||||
{
|
||||
debug (RPT_DEBUG, "%s( m=[%s] ): active_menuitem=[%s]",
|
||||
debug(RPT_DEBUG, "%s(m=[%s]): active_menuitem=[%s]",
|
||||
__FUNCTION__, (menu != NULL) ? menu->id : "(NULL)",
|
||||
(active_menuitem != NULL) ? active_menuitem->id : "(NULL)");
|
||||
menuscreen_switch_item (menu);
|
||||
menuscreen_switch_item(menu);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/** sets custom main menu. Use NULL pointer to reset it to the "real" main
|
||||
* menu. */
|
||||
int
|
||||
menuscreen_set_main (Menu * menu)
|
||||
menuscreen_set_main(Menu *menu)
|
||||
{
|
||||
debug (RPT_DEBUG, "%s( m=[%s] )",
|
||||
debug(RPT_DEBUG, "%s(m=[%s])",
|
||||
__FUNCTION__, (menu != NULL) ? menu->id : "(NULL)");
|
||||
custom_main_menu = menu;
|
||||
return 0;
|
||||
}
|
||||
|
||||
Menu*
|
||||
menuscreen_get_main()
|
||||
Menu *
|
||||
menuscreen_get_main(void)
|
||||
{
|
||||
return custom_main_menu ? custom_main_menu : main_menu;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user