// MenuItem adds a menu item
499085
func (win *Window) MenuItem(lbl label.Label) bool {
	style := &win.ctx.Style
	state, bounds := win.widgetFitting(style.ContextualButton.Padding)
	if !state {
		return false
	}

	if win.flags&windowHDynamic != 0 {
		w := FontWidth(style.Font, lbl.Text) + 2*style.ContextualButton.Padding.X
		if w > win.menuItemWidth {
			win.menuItemWidth = w
		}
	}

	in := win.inputMaybe(state)
	if doButton(win, lbl, bounds, &style.ContextualButton, in, false) {
		win.Close()
		return true
	}

	return false
}
520300
func (item *MenuItem) SetTitle(title string) {
	item.title = title
	item.update()
}
155730
func (menu *Menu) ItemAtCommandID(commandID uint) *MenuItem {
	for _, item := range menu.Items {
		if item.IsCommandID(commandID) {
			return item
		}
		if item.IsSubMenu() {
			result := item.SubMenu.ItemAtCommandID(commandID)
			if result != nil {
				return result
			}
		}
	}
	return nil
}
465415
func newMenuItem(parentCtx context.Context, rootID string, o *MenuItemOptions, c *asticontext.Canceller, d *dispatcher, i *identifier, w *writer) (m *MenuItem) {
	m = &MenuItem{
		o:      o,
		object: newObject(parentCtx, c, d, i, w, i.new()),
		rootID: rootID,
	}
	if o.OnClick != nil {
		m.On(EventNameMenuItemEventClicked, o.OnClick)
	}
	if len(o.SubMenu) > 0 {
		m.s = &SubMenu{newSubMenu(parentCtx, rootID, o.SubMenu, c, d, i, w)}
	}
	return
}
934107
func (m *subMenu) Item(indexes ...int) (mi *MenuItem, err error) {
	var is = m
	if len(indexes) > 1 {
		var s *SubMenu
		if s, err = m.SubMenu(indexes[:len(indexes)-1]...); err != nil {
			return
		}
		is = s.subMenu
	}
	var index = indexes[len(indexes)-1]
	if index >= len(is.items) {
		return nil, fmt.Errorf("Submenu has %d items, invalid index %d", len(is.items), index)
	}
	mi = is.items[index]
	return
}
478277
func encodeItem(data interface{}) (item string) {
	switch v := data.(type) {
	case string:
		item = EncodeString(v)
	case int:
		item = EncodeInt(v)
	case []interface{}:
		item = EncodeList(v)
	case map[string]interface{}:
		item = EncodeDict(v)
	default:
		panic("invalid type when encode item")
	}
	return
}
112734
func (c *LFUCache) removeItem(item *lfuItem) {
	delete(c.items, item.key)
	delete(item.freqElement.Value.(*freqEntry).items, item)
	if c.evictedFunc != nil {
		c.evictedFunc(item.key, item.value)
	}
}
505483
func (c *MenuOption) AddToSubMenu(sub *MenuOption) {
	c.subMenu = append(c.subMenu, *sub)
}
1224816
func QueryItem(item Item) ([]QueryResult, error) {
	resultsRef, err := QueryItemRef(item)
	if err != nil {
		return nil, err
	}
	if resultsRef == nil {
		return nil, nil
	}
	defer Release(resultsRef)

	results := make([]QueryResult, 0, 1)

	typeID := C.CFGetTypeID(resultsRef)
	if typeID == C.CFArrayGetTypeID() {
		arr := CFArrayToArray(C.CFArrayRef(resultsRef))
		for _, ref := range arr {
			elementTypeID := C.CFGetTypeID(ref)
			if elementTypeID == C.CFDictionaryGetTypeID() {
				item, err := convertResult(C.CFDictionaryRef(ref))
				if err != nil {
					return nil, err
				}
				results = append(results, *item)
			} else {
				return nil, fmt.Errorf("invalid result type (If you SetReturnRef(true) you should use QueryItemRef directly)")
			}
		}
	} else if typeID == C.CFDictionaryGetTypeID() {
		item, err := convertResult(C.CFDictionaryRef(resultsRef))
		if err != nil {
			return nil, err
		}
		results = append(results, *item)
	} else if typeID == C.CFDataGetTypeID() {
		b, err := CFDataToBytes(C.CFDataRef(resultsRef))
		if err != nil {
			return nil, err
		}
		item := QueryResult{Data: b}
		results = append(results, item)
	} else {
		return nil, fmt.Errorf("Invalid result type: %s", CFTypeDescription(resultsRef))
	}

	return results, nil
}
344576
func (c *Client) UpdateDictionaryItem(i *UpdateDictionaryItemInput) (*DictionaryItem, error) {
	if i.Service == "" {
		return nil, ErrMissingService
	}

	if i.Dictionary == "" {
		return nil, ErrMissingDictionary
	}

	if i.ItemKey == "" {
		return nil, ErrMissingItemKey
	}

	path := fmt.Sprintf("/service/%s/dictionary/%s/item/%s", i.Service, i.Dictionary, i.ItemKey)
	resp, err := c.PutForm(path, i, nil)
	if err != nil {
		return nil, err
	}

	var b *DictionaryItem
	if err := decodeJSON(&b, resp.Body); err != nil {
		return nil, err
	}
	return b, nil
}
245001
func AddItem(item Item) error {
	cfDict, err := ConvertMapToCFDictionary(item.attr)
	if err != nil {
		return err
	}
	defer Release(C.CFTypeRef(cfDict))

	errCode := C.SecItemAdd(cfDict, nil)
	err = checkError(errCode)
	return err
}
413785
func (f *Form) SetItemPadding(padding int) *Form {
	f.itemPadding = padding
	return f
}
348565
func (p *itemPool) newItem() (*Item, error) {
	if len(p.itemMap) >= p.capacity {
		return nil, ErrItemUnavailable
	}
	i, err := p.itemFactory()
	if err != nil {
		return nil, err
	}

	pItem := &Item{id: p.nextID(), Item: i}
	p.itemMap[pItem.id] = pItem
	return pItem, nil
}
382081
func (s *EndpointBatchRequest) SetItem(v []*EndpointBatchItem) *EndpointBatchRequest {
	s.Item = v
	return s
}
662109
func (s *EndpointsResponse) SetItem(v []*EndpointResponse) *EndpointsResponse {
	s.Item = v
	return s
}
983579
func (menu *Menu) AddSubmenu(commandID uint, label string, child *Menu) {
	command := Command{
		Method: "add_submenu",
		Args: CommandArguments{
			CommandID: commandID,
			Label:     label,
		},
	}

	// Assign Bidirectional navigation elements i.e. DoublyLinkedLists
	child.Parent = menu
	menuItem := MenuItem{
		CommandID: commandID,
		Label:     label,
		SubMenu:   child,
		Parent:    menu,
	}
	menu.Items = append(menu.Items, &menuItem)

	menu.CallWhenChildStable(&command, child)
}
1072757
func (v *ElementBuildingVisitor) getItem(s proto.Schema, name string, data apply.RawElementData) (Item, error) {
	kind, err := getType(data.GetRecorded(), data.GetLocal(), data.GetRemote())
	if err != nil {
		return nil, err
	}
	if kind == nil {
		// All of the items values are nil.
		return &emptyItem{Name: name}, nil
	}

	// Create an item matching the type
	switch kind.Kind() {
	case reflect.Bool, reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64, reflect.Uint,
		reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64, reflect.Float32, reflect.Float64,
		reflect.String:
		p, err := getPrimitive(s)
		if err != nil {
			return nil, fmt.Errorf("expected openapi Primitive, was %T for %v (%v)", s, kind, err)
		}
		return &primitiveItem{name, p, data}, nil
	case reflect.Array, reflect.Slice:
		a, err := getArray(s)
		if err != nil {
			return nil, fmt.Errorf("expected openapi Array, was %T for %v (%v)", s, kind, err)
		}
		return &listItem{
			Name:  name,
			Array: a,
			ListElementData: apply.ListElementData{
				RawElementData: data,
			},
		}, nil
	case reflect.Map:
		if k, err := getKind(s); err == nil {
			return &typeItem{
				Name: name,
				Type: k,
				MapElementData: apply.MapElementData{
					RawElementData: data,
				},
			}, nil
		}
		// If it looks like a map, and no openapi type is found, default to mapItem
		m, err := getMap(s)
		if err != nil {
			return nil, fmt.Errorf("expected openapi Kind or Map, was %T for %v (%v)", s, kind, err)
		}
		return &mapItem{
			Name: name,
			Map:  m,
			MapElementData: apply.MapElementData{
				RawElementData: data,
			},
		}, nil
	}
	return nil, fmt.Errorf("unsupported type %v", kind)
}