Mega change to the LCDd's header files:
1. Use <stdbool.h> if it is available but keep a compatibility shim in
shared/defines.h in case it is not.
2. Unbreak the circular header dependencies (mostly):
2a. client.c and client.h may NOT depend on 'struct Menu'. Use a void pointer
and casts instead.
2b. Separate the data type definitions in client.h and screen.h from
function prototypes which may require other data structures. This makes
header dependencies much more easy to maintain. Usually the data types
should have been moved to their own files but I (mmdolze) chose to
separate them using different header guards.
2c. Remove many now unused header includes.
Apply (old BSD-) style on menuscreens.c.
This commit is contained in:
+150
-114
@@ -1,7 +1,7 @@
|
||||
/** \file server/menuscreens.c
|
||||
* Creates the server menu screen(s) and creates the menus that should be
|
||||
* displayed on this screen.
|
||||
* It also handles its keypresses and converts them to menu tokens for
|
||||
* It also handles its key presses and converts them to menu tokens for
|
||||
* easier processing.
|
||||
*
|
||||
* \note
|
||||
@@ -9,7 +9,8 @@
|
||||
* a menu or on a separate SCREEN, for flexibility.
|
||||
*/
|
||||
|
||||
/* This file is part of LCDd, the lcdproc server.
|
||||
/*-
|
||||
* This file is part of LCDd, the lcdproc server.
|
||||
*
|
||||
* This file is released under the GNU General Public License.
|
||||
* Refer to the COPYING file distributed with this package.
|
||||
@@ -23,6 +24,7 @@
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
#include <assert.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "screen.h"
|
||||
#include "screenlist.h"
|
||||
@@ -53,7 +55,7 @@ Screen *menuscreen = NULL;
|
||||
MenuItem *active_menuitem = NULL;
|
||||
/** the "real" main_menu */
|
||||
Menu *main_menu = NULL;
|
||||
/** customizable entry point into the menu system (see menu_set_main()). */
|
||||
/** customizable entry point into the menu system (see menuscreen_set_main()). */
|
||||
Menu *custom_main_menu = NULL;
|
||||
Menu *screens_menu = NULL;
|
||||
|
||||
@@ -75,14 +77,17 @@ MenuEventFunc(titlespeed_handler);
|
||||
MenuEventFunc(contrast_handler);
|
||||
MenuEventFunc(brightness_handler);
|
||||
|
||||
int menuscreens_init(void)
|
||||
int
|
||||
menuscreens_init(void)
|
||||
{
|
||||
const char *tmp;
|
||||
|
||||
debug(RPT_DEBUG, "%s()", __FUNCTION__);
|
||||
|
||||
/* Get keys from config file: MenuKey, EnterKey, UpKey, DownKey, LeftKey, RightKey.
|
||||
* For a working menu at least 3 are necessary: MenuKey, EnterKey, UpKey/DownKey.
|
||||
/*
|
||||
* Get keys from config file: MenuKey, EnterKey, UpKey, DownKey,
|
||||
* LeftKey, RightKey. For a working menu at least 3 are necessary:
|
||||
* MenuKey, EnterKey, UpKey/DownKey.
|
||||
*/
|
||||
keymask = 0;
|
||||
menu_key = enter_key = NULL;
|
||||
@@ -150,7 +155,8 @@ int menuscreens_init(void)
|
||||
}
|
||||
|
||||
|
||||
int menuscreens_shutdown(void)
|
||||
int
|
||||
menuscreens_shutdown(void)
|
||||
{
|
||||
debug(RPT_DEBUG, "%s()", __FUNCTION__);
|
||||
|
||||
@@ -175,30 +181,31 @@ int menuscreens_shutdown(void)
|
||||
/* Forget menu's key reservations */
|
||||
input_release_client_keys(NULL);
|
||||
|
||||
if (menu_key != NULL)
|
||||
if (menu_key != NULL)
|
||||
free(menu_key);
|
||||
if (enter_key != NULL)
|
||||
if (enter_key != NULL)
|
||||
free(enter_key);
|
||||
if (up_key != NULL)
|
||||
if (up_key != NULL)
|
||||
free(up_key);
|
||||
if (down_key != NULL)
|
||||
if (down_key != NULL)
|
||||
free(down_key);
|
||||
if (left_key != NULL)
|
||||
free(left_key);
|
||||
free(left_key);
|
||||
if (right_key != NULL)
|
||||
free(right_key);
|
||||
keymask = 0;
|
||||
free(right_key);
|
||||
keymask = 0;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
void menuscreen_inform_item_destruction(MenuItem *item)
|
||||
void
|
||||
menuscreen_inform_item_destruction(MenuItem * item)
|
||||
{
|
||||
MenuItem *i;
|
||||
|
||||
debug(RPT_DEBUG, "%s(item=[%s])", __FUNCTION__,
|
||||
((item != NULL) ? item->id : "(null)"));
|
||||
((item != NULL) ? item->id : "(null)"));
|
||||
|
||||
/* Are we currently in (a subitem of) the given item ? */
|
||||
for (i = active_menuitem; i != NULL; i = i->parent) {
|
||||
@@ -208,10 +215,11 @@ void menuscreen_inform_item_destruction(MenuItem *item)
|
||||
}
|
||||
}
|
||||
|
||||
void menuscreen_inform_item_modified(MenuItem *item)
|
||||
void
|
||||
menuscreen_inform_item_modified(MenuItem * item)
|
||||
{
|
||||
debug(RPT_DEBUG, "%s(item=[%s])", __FUNCTION__,
|
||||
((item != NULL) ? item->id : "(null)"));
|
||||
((item != NULL) ? item->id : "(null)"));
|
||||
|
||||
if ((active_menuitem == NULL) || (item == NULL))
|
||||
return;
|
||||
@@ -222,7 +230,8 @@ void menuscreen_inform_item_modified(MenuItem *item)
|
||||
}
|
||||
}
|
||||
|
||||
bool is_menu_key(const char *key)
|
||||
bool
|
||||
is_menu_key(const char *key)
|
||||
{
|
||||
if ((menu_key != NULL) && (key != NULL) && (strcmp(key, menu_key) == 0))
|
||||
return true;
|
||||
@@ -230,12 +239,13 @@ bool is_menu_key(const char *key)
|
||||
return false;
|
||||
}
|
||||
|
||||
/** This function changes the menuitem to the given one, and does necesary
|
||||
/** This function changes the menuitem to the given one, and does necessary
|
||||
* actions.
|
||||
* 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;
|
||||
|
||||
@@ -249,16 +259,19 @@ void menuscreen_switch_item(MenuItem *new_menuitem)
|
||||
/* What was the state change ? */
|
||||
if (!old_menuitem && !new_menuitem) {
|
||||
/* Nothing to be done */
|
||||
} else if (old_menuitem && !new_menuitem) {
|
||||
}
|
||||
else if (old_menuitem && !new_menuitem) {
|
||||
/* leave menu system */
|
||||
menuscreen->priority = PRI_HIDDEN;
|
||||
} else if (!old_menuitem && new_menuitem) {
|
||||
}
|
||||
else if (!old_menuitem && new_menuitem) {
|
||||
/* Menu is becoming active */
|
||||
menuitem_reset(active_menuitem);
|
||||
menuitem_rebuild_screen(active_menuitem, menuscreen);
|
||||
|
||||
menuscreen->priority = PRI_INPUT;
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
/* We're left with the usual case: a menu level switch */
|
||||
if (old_menuitem->parent != new_menuitem) {
|
||||
menuitem_reset(new_menuitem);
|
||||
@@ -266,34 +279,36 @@ void menuscreen_switch_item(MenuItem *new_menuitem)
|
||||
menuitem_rebuild_screen(active_menuitem, menuscreen);
|
||||
}
|
||||
|
||||
if (old_menuitem && old_menuitem->event_func)
|
||||
old_menuitem->event_func(old_menuitem, MENUEVENT_LEAVE);
|
||||
if (new_menuitem && new_menuitem->event_func)
|
||||
new_menuitem->event_func(new_menuitem, MENUEVENT_ENTER);
|
||||
if (old_menuitem && old_menuitem->event_func)
|
||||
old_menuitem->event_func(old_menuitem, MENUEVENT_LEAVE);
|
||||
if (new_menuitem && new_menuitem->event_func)
|
||||
new_menuitem->event_func(new_menuitem, MENUEVENT_ENTER);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
static void handle_quit(void)
|
||||
static void
|
||||
handle_quit(void)
|
||||
{
|
||||
debug(RPT_DEBUG, "%s: Closing menu screen", __FUNCTION__);
|
||||
menuscreen_switch_item(NULL);
|
||||
}
|
||||
|
||||
static void handle_close(void)
|
||||
static void
|
||||
handle_close(void)
|
||||
{
|
||||
debug(RPT_DEBUG, "%s: Closing item", __FUNCTION__);
|
||||
menuscreen_switch_item(
|
||||
(active_menuitem == menuscreen_get_main())
|
||||
? NULL
|
||||
: active_menuitem->parent);
|
||||
(active_menuitem == menuscreen_get_main())
|
||||
? NULL
|
||||
: active_menuitem->parent);
|
||||
}
|
||||
|
||||
static void handle_none(void)
|
||||
static void
|
||||
handle_none(void)
|
||||
{
|
||||
debug(RPT_DEBUG, "%s: Staying in item", __FUNCTION__);
|
||||
if (active_menuitem)
|
||||
{
|
||||
if (active_menuitem) {
|
||||
menuitem_update_screen(active_menuitem, menuscreen);
|
||||
/* No rebuild needed, only value can be changed */
|
||||
}
|
||||
@@ -305,45 +320,49 @@ static void handle_none(void)
|
||||
* own screen. The menuitem_process_input function should do
|
||||
* things like toggling checkboxes !
|
||||
*/
|
||||
static void handle_enter(void)
|
||||
static void
|
||||
handle_enter(void)
|
||||
{
|
||||
debug(RPT_DEBUG, "%s: Entering subitem", __FUNCTION__);
|
||||
menuscreen_switch_item(menu_get_current_item(active_menuitem));
|
||||
}
|
||||
|
||||
static void handle_predecessor(void)
|
||||
static void
|
||||
handle_predecessor(void)
|
||||
{
|
||||
MenuItem* predecessor;
|
||||
MenuItem* item = (active_menuitem->type == MENUITEM_MENU)
|
||||
MenuItem *predecessor;
|
||||
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'.",
|
||||
__FUNCTION__, item->predecessor_id, item->id);
|
||||
__FUNCTION__, item->predecessor_id, item->id);
|
||||
predecessor = menuitem_search(item->predecessor_id,
|
||||
(Client *) active_menuitem->client);
|
||||
if (predecessor == NULL) {
|
||||
// note: if _quit_, _close_, _none_ get here this
|
||||
// would be an implementation error - they should
|
||||
// have been handled via different MENURESULT codes.
|
||||
/*
|
||||
* 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'.",
|
||||
__FUNCTION__, item->predecessor_id, item->id);
|
||||
__FUNCTION__, item->predecessor_id, item->id);
|
||||
return;
|
||||
}
|
||||
switch (predecessor->type) {
|
||||
case MENUITEM_ACTION:
|
||||
case MENUITEM_CHECKBOX:
|
||||
case MENUITEM_RING:
|
||||
case MENUITEM_ACTION:
|
||||
case MENUITEM_CHECKBOX:
|
||||
case MENUITEM_RING:
|
||||
if (active_menuitem != predecessor->parent)
|
||||
menuscreen_switch_item(predecessor->parent);
|
||||
// this won't work for hidden subitems
|
||||
/* this won't work for hidden subitems */
|
||||
menu_select_subitem(active_menuitem, item->predecessor_id);
|
||||
menuitem_update_screen(active_menuitem, menuscreen);
|
||||
break;
|
||||
default:
|
||||
default:
|
||||
if ((predecessor->parent != NULL) &&
|
||||
(predecessor->parent->type == MENUITEM_MENU)) {
|
||||
// update parent menu too
|
||||
/* update parent menu too */
|
||||
menu_select_subitem(predecessor->parent, predecessor->id);
|
||||
}
|
||||
menuscreen_switch_item(predecessor);
|
||||
@@ -351,39 +370,42 @@ static void handle_predecessor(void)
|
||||
}
|
||||
}
|
||||
|
||||
static void handle_successor(void)
|
||||
static void
|
||||
handle_successor(void)
|
||||
{
|
||||
MenuItem *successor;
|
||||
MenuItem* item = (active_menuitem->type == MENUITEM_MENU)
|
||||
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'.",
|
||||
__FUNCTION__, item->successor_id, item->id);
|
||||
__FUNCTION__, item->successor_id, item->id);
|
||||
successor = menuitem_search(item->successor_id,
|
||||
(Client *) active_menuitem->client);
|
||||
if (successor == NULL) {
|
||||
// note: if _quit_, _close_, _none_ get here this
|
||||
// would be an implementation error - they should
|
||||
// have been handled via different MENURESULT codes.
|
||||
/*
|
||||
* 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'.",
|
||||
__FUNCTION__, item->successor_id, item->id);
|
||||
__FUNCTION__, item->successor_id, item->id);
|
||||
return;
|
||||
}
|
||||
switch (successor->type) {
|
||||
case MENUITEM_ACTION:
|
||||
case MENUITEM_CHECKBOX:
|
||||
case MENUITEM_RING:
|
||||
case MENUITEM_ACTION:
|
||||
case MENUITEM_CHECKBOX:
|
||||
case MENUITEM_RING:
|
||||
if (active_menuitem != successor->parent)
|
||||
menuscreen_switch_item(successor->parent);
|
||||
// this won't work for hidden subitems
|
||||
/* this won't work for hidden subitems */
|
||||
menu_select_subitem(active_menuitem, item->successor_id);
|
||||
menuitem_update_screen(active_menuitem, menuscreen);
|
||||
break;
|
||||
default:
|
||||
default:
|
||||
if ((successor->parent != NULL) &&
|
||||
(successor->parent->type == MENUITEM_MENU)) {
|
||||
// update parent menu too
|
||||
/* update parent menu too */
|
||||
menu_select_subitem(successor->parent, successor->id);
|
||||
}
|
||||
menuscreen_switch_item(successor);
|
||||
@@ -391,7 +413,8 @@ static void handle_successor(void)
|
||||
}
|
||||
}
|
||||
|
||||
void menuscreen_key_handler(const char *key)
|
||||
void
|
||||
menuscreen_key_handler(const char *key)
|
||||
{
|
||||
MenuToken token = MENUTOKEN_NONE;
|
||||
MenuResult res;
|
||||
@@ -429,34 +452,35 @@ void menuscreen_key_handler(const char *key)
|
||||
|
||||
res = menuitem_process_input(active_menuitem, token, key, keymask);
|
||||
switch (res) {
|
||||
case MENURESULT_ERROR:
|
||||
case MENURESULT_ERROR:
|
||||
report(RPT_ERR, "%s: Error from menuitem_process_input", __FUNCTION__);
|
||||
break;
|
||||
case MENURESULT_NONE:
|
||||
case MENURESULT_NONE:
|
||||
handle_none();
|
||||
break;
|
||||
case MENURESULT_ENTER:
|
||||
case MENURESULT_ENTER:
|
||||
handle_enter();
|
||||
break;
|
||||
case MENURESULT_CLOSE:
|
||||
case MENURESULT_CLOSE:
|
||||
handle_close();
|
||||
break;
|
||||
case MENURESULT_QUIT:
|
||||
case MENURESULT_QUIT:
|
||||
handle_quit();
|
||||
break;
|
||||
case MENURESULT_PREDECESSOR:
|
||||
case MENURESULT_PREDECESSOR:
|
||||
handle_predecessor();
|
||||
break;
|
||||
case MENURESULT_SUCCESSOR:
|
||||
case MENURESULT_SUCCESSOR:
|
||||
handle_successor();
|
||||
break;
|
||||
default:
|
||||
default:
|
||||
assert(!"unexpected menuresult");
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void menuscreen_create_menu(void)
|
||||
void
|
||||
menuscreen_create_menu(void)
|
||||
{
|
||||
Menu *options_menu;
|
||||
Menu *driver_menu;
|
||||
@@ -480,10 +504,10 @@ void menuscreen_create_menu(void)
|
||||
menu_add_item(main_menu, options_menu);
|
||||
|
||||
#ifdef LCDPROC_TESTMENUS
|
||||
/* TODO:
|
||||
* Menu items in the screens menu currently have no functions assigned.
|
||||
* Thefore only enable the menu for testing. If functions are available,
|
||||
* this code should be outside the #ifdef.
|
||||
/*
|
||||
* TODO: Menu items in the screens menu currently have no functions
|
||||
* assigned. Therefore only enable the menu for testing. If functions
|
||||
* are available, this code should be outside the #ifdef.
|
||||
*/
|
||||
screens_menu = menu_create("screens", NULL, "Screens", NULL);
|
||||
if (screens_menu == NULL) {
|
||||
@@ -495,8 +519,10 @@ void menuscreen_create_menu(void)
|
||||
menuscreen_create_testmenu();
|
||||
#endif
|
||||
|
||||
/* add option menu contents:
|
||||
* menu's client is NULL since we're in the server */
|
||||
/*
|
||||
* add option menu contents: 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);
|
||||
|
||||
@@ -507,8 +533,10 @@ void menuscreen_create_menu(void)
|
||||
"TitleSpeed", NULL, "0", "10", TITLESPEED_NO, TITLESPEED_MAX, 1, titlespeed);
|
||||
menu_add_item(options_menu, slider);
|
||||
|
||||
/* add driver specific option menus for each driver:
|
||||
* menu's client is NULL since we're in the server */
|
||||
/*
|
||||
* add driver specific option menus for each driver: menu's client is
|
||||
* NULL since we're in the server
|
||||
*/
|
||||
for (driver = drivers_getfirst(); driver; driver = drivers_getnext()) {
|
||||
int contrast_avail = (driver->get_contrast && driver->set_contrast) ? 1 : 0;
|
||||
int brightness_avail = (driver->get_brightness && driver->set_brightness) ? 1 : 0;
|
||||
@@ -518,7 +546,7 @@ void menuscreen_create_menu(void)
|
||||
driver_menu = menu_create(driver->name, NULL, driver->name, NULL);
|
||||
if (driver_menu == NULL) {
|
||||
report(RPT_ERR, "%s: Cannot create menu for driver %s",
|
||||
__FUNCTION__, driver->name);
|
||||
__FUNCTION__, driver->name);
|
||||
continue;
|
||||
}
|
||||
menu_set_association(driver_menu, driver);
|
||||
@@ -528,7 +556,7 @@ void menuscreen_create_menu(void)
|
||||
|
||||
/* menu's client is NULL since we're in the server */
|
||||
slider = menuitem_create_slider("contrast", contrast_handler, "Contrast",
|
||||
NULL, "min", "max", 0, 1000, 25, contrast);
|
||||
NULL, "min", "max", 0, 1000, 25, contrast);
|
||||
menu_add_item(driver_menu, slider);
|
||||
}
|
||||
if (brightness_avail) {
|
||||
@@ -536,11 +564,11 @@ void menuscreen_create_menu(void)
|
||||
int offbrightness = driver->get_brightness(driver, BACKLIGHT_OFF);
|
||||
|
||||
slider = menuitem_create_slider("onbrightness", brightness_handler, "On Brightness",
|
||||
NULL, "min", "max", 0, 1000, 25, onbrightness);
|
||||
NULL, "min", "max", 0, 1000, 25, onbrightness);
|
||||
menu_add_item(driver_menu, slider);
|
||||
|
||||
slider = menuitem_create_slider("offbrightness", brightness_handler, "Off Brightness",
|
||||
NULL, "min", "max", 0, 1000, 25, offbrightness);
|
||||
NULL, "min", "max", 0, 1000, 25, offbrightness);
|
||||
menu_add_item(driver_menu, slider);
|
||||
}
|
||||
}
|
||||
@@ -548,7 +576,9 @@ void menuscreen_create_menu(void)
|
||||
}
|
||||
|
||||
#ifdef LCDPROC_TESTMENUS
|
||||
void menuscreen_create_testmenu(void) {
|
||||
void
|
||||
menuscreen_create_testmenu(void)
|
||||
{
|
||||
MenuItem *test_item;
|
||||
Menu *test_menu;
|
||||
|
||||
@@ -609,20 +639,20 @@ void menuscreen_create_testmenu(void) {
|
||||
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");
|
||||
test_item = menuitem_create_ip("", NULL, "IPv4", NULL, false, "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");
|
||||
test_item = menuitem_create_ip("", NULL, "IPv6", NULL, true, "1080:0:0:0:8:800:200C:417A");
|
||||
menu_add_item(test_menu, test_item);
|
||||
|
||||
|
||||
test_item = menuitem_create_ring("", NULL, "Charset", NULL, testiso, 0);
|
||||
menu_add_item(test_menu, test_item);
|
||||
}
|
||||
#endif /*LCDPROC_TESTMENUS*/
|
||||
#endif /* LCDPROC_TESTMENUS */
|
||||
|
||||
MenuEventFunc (heartbeat_handler)
|
||||
MenuEventFunc(heartbeat_handler)
|
||||
{
|
||||
debug(RPT_DEBUG, "%s(item=[%s], event=%d)", __FUNCTION__,
|
||||
((item != NULL) ? item->id : "(null)"), event);
|
||||
((item != NULL) ? item->id : "(null)"), event);
|
||||
|
||||
if ((item != NULL) && (event == MENUEVENT_UPDATE)) {
|
||||
/* Set heartbeat setting */
|
||||
@@ -632,10 +662,10 @@ MenuEventFunc (heartbeat_handler)
|
||||
return 0;
|
||||
}
|
||||
|
||||
MenuEventFunc (backlight_handler)
|
||||
MenuEventFunc(backlight_handler)
|
||||
{
|
||||
debug(RPT_DEBUG, "%s(item=[%s], event=%d)", __FUNCTION__,
|
||||
((item != NULL) ? item->id : "(null)"), event);
|
||||
((item != NULL) ? item->id : "(null)"), event);
|
||||
|
||||
if ((item != NULL) && (event == MENUEVENT_UPDATE)) {
|
||||
/* Set backlight setting */
|
||||
@@ -645,10 +675,10 @@ MenuEventFunc (backlight_handler)
|
||||
return 0;
|
||||
}
|
||||
|
||||
MenuEventFunc (titlespeed_handler)
|
||||
MenuEventFunc(titlespeed_handler)
|
||||
{
|
||||
debug(RPT_DEBUG, "%s(item=[%s], event=%d)", __FUNCTION__,
|
||||
((item != NULL) ? item->id : "(null)"), event);
|
||||
((item != NULL) ? item->id : "(null)"), event);
|
||||
|
||||
if ((item != NULL) && ((event == MENUEVENT_MINUS) || (event == MENUEVENT_PLUS))) {
|
||||
/* set titlespeed setting */
|
||||
@@ -658,12 +688,15 @@ MenuEventFunc (titlespeed_handler)
|
||||
return 0;
|
||||
}
|
||||
|
||||
MenuEventFunc (contrast_handler)
|
||||
MenuEventFunc(contrast_handler)
|
||||
{
|
||||
debug(RPT_DEBUG, "%s(item=[%s], event=%d)", __FUNCTION__,
|
||||
((item != NULL) ? item->id : "(null)"), event);
|
||||
((item != NULL) ? item->id : "(null)"), event);
|
||||
|
||||
/* This function can be called by one of several drivers that support contrast */
|
||||
/*
|
||||
* This function can be called by one of several drivers that support
|
||||
* contrast
|
||||
*/
|
||||
if ((item != NULL) && ((event == MENUEVENT_MINUS) || (event == MENUEVENT_PLUS))) {
|
||||
/* Determine the driver by following the menu's association */
|
||||
Driver *driver = item->parent->data.menu.association;
|
||||
@@ -671,18 +704,21 @@ MenuEventFunc (contrast_handler)
|
||||
if (driver != NULL) {
|
||||
driver->set_contrast(driver, item->data.slider.value);
|
||||
report(RPT_INFO, "Menu: set contrast of [%.40s] to %d",
|
||||
driver->name, item->data.slider.value);
|
||||
driver->name, item->data.slider.value);
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
MenuEventFunc (brightness_handler)
|
||||
MenuEventFunc(brightness_handler)
|
||||
{
|
||||
debug(RPT_DEBUG, "%s(item=[%s], event=%d)", __FUNCTION__,
|
||||
((item != NULL) ? item->id : "(null)"), event);
|
||||
((item != NULL) ? item->id : "(null)"), event);
|
||||
|
||||
/* This function can be called by one of several drivers that support brightness ! */
|
||||
/*
|
||||
* This function can be called by one of several drivers that support
|
||||
* brightness !
|
||||
*/
|
||||
if ((item != NULL) && ((event == MENUEVENT_MINUS) || (event == MENUEVENT_PLUS))) {
|
||||
/* Determine the driver by following the menu's association */
|
||||
Driver *driver = item->parent->data.menu.association;
|
||||
@@ -706,7 +742,7 @@ menuscreen_add_screen(Screen *s)
|
||||
MenuItem *mi;
|
||||
|
||||
debug(RPT_DEBUG, "%s(s=[%s])", __FUNCTION__,
|
||||
((s != NULL) ? s->id : "(null)"));
|
||||
((s != NULL) ? s->id : "(null)"));
|
||||
|
||||
/* screens have not been created or no screen given ... */
|
||||
if ((screens_menu == NULL) || (s == NULL))
|
||||
@@ -735,7 +771,7 @@ menuscreen_add_screen(Screen *s)
|
||||
menu_add_item(m, mi);
|
||||
|
||||
mi = menuitem_create_ring("", NULL, "Priority", s->client,
|
||||
"Hidden\tBackground\tForeground\tAlert\tInput", s->priority);
|
||||
"Hidden\tBackground\tForeground\tAlert\tInput", s->priority);
|
||||
menu_add_item(m, mi);
|
||||
}
|
||||
|
||||
@@ -744,7 +780,7 @@ void
|
||||
menuscreen_remove_screen(Screen *s)
|
||||
{
|
||||
debug(RPT_DEBUG, "%s(s=[%s])", __FUNCTION__,
|
||||
(s != NULL) ? s->id : "(NULL)");
|
||||
(s != NULL) ? s->id : "(NULL)");
|
||||
|
||||
/* allow to remove the menuscreen itself */
|
||||
if ((s == NULL) || (s == menuscreen))
|
||||
@@ -759,22 +795,22 @@ menuscreen_remove_screen(Screen *s)
|
||||
}
|
||||
|
||||
int
|
||||
menuscreen_goto(Menu *menu)
|
||||
menuscreen_goto(Menu * menu)
|
||||
{
|
||||
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);
|
||||
return 0;
|
||||
__FUNCTION__, (menu != NULL) ? menu->id : "(NULL)",
|
||||
(active_menuitem != NULL) ? active_menuitem->id : "(NULL)");
|
||||
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])",
|
||||
__FUNCTION__, (menu != NULL) ? menu->id : "(NULL)");
|
||||
__FUNCTION__, (menu != NULL) ? menu->id : "(NULL)");
|
||||
custom_main_menu = menu;
|
||||
return 0;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user