static void handle_none(void) { debug(RPT_DEBUG, "%s: Staying in item", __FUNCTION__); if (active_menuitem) { menuitem_update_screen(active_menuitem, menuscreen); /* No rebuild needed, only value can be changed */ } /* Nothing extra to be done */ }
static void handle_successor(void) { MenuItem *successor; 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); 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. */ report(RPT_ERR, "%s: cannot find successor '%s' of '%s'.", __FUNCTION__, item->successor_id, item->id); return; } switch (successor->type) { 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 */ menu_select_subitem(active_menuitem, item->successor_id); menuitem_update_screen(active_menuitem, menuscreen); break; default: if ((successor->parent != NULL) && (successor->parent->type == MENUITEM_MENU)) { /* update parent menu too */ menu_select_subitem(successor->parent, successor->id); } menuscreen_switch_item(successor); break; } }
void menuitem_rebuild_screen(MenuItem *item, Screen *s) { Widget *w; void (*build_screen) (MenuItem *item, Screen *s); debug(RPT_DEBUG, "%s(item=[%s], screen=[%s])", __FUNCTION__, ((item != NULL) ? item->id : "(null)"), ((s != NULL) ? s->id : "(null)")); if (!display_props) { /* Nothing to build if no display size is known */ report(RPT_ERR, "%s: display size unknown", __FUNCTION__); return; } if (s != NULL) { /* First remove all widgets from the screen */ while ((w = screen_getfirst_widget(s)) != NULL) { /* We know these widgets don't have subwidgets, so we can * easily remove them */ screen_remove_widget(s, w); widget_destroy(w); } if (item != NULL) { /* Call type specific screen building function */ build_screen = build_screen_table [item->type]; if (build_screen) { build_screen(item, s); } else { report(RPT_ERR, "%s: given menuitem cannot be active", __FUNCTION__); return; } /* Also always call update_screen */ menuitem_update_screen(item, s); } } }