Пример #1
0
// PackComboBoxWithIndexHandbooker creates a combo box filled with the getList call.
//
func PackComboBoxWithIndexHandbooker(key *cftype.Key, index map[string]datatype.Handbooker) {
	model := newModelSimple()
	model.SetSortColumnId(RowName, gtk.SORT_ASCENDING)
	widget, getValue := NewComboBoxWithModel(model, key.Log(), false, false, false)

	value := key.Value().String()

	details := handbook.New(key.Log())
	key.PackWidget(details, false, false, 0)

	widget.Connect("changed", func() {
		name := key.Value().String()
		pack, ok := index[name]
		if ok {
			details.SetPackage(pack)
		} else {
			key.Log().NewErr("key missing", "ComboHandbook select preview:", name)
		}
	})

	fields := datatype.IndexHandbooksToFields(index)
	saved := indexiter.NewByString(widget, key.Log())
	iter := fillModelWithFields(key, model, fields, value, saved)
	widget.SetActiveIter(iter) // Set iter after connect, to update with current value.

	key.PackKeyWidget(key,
		getValue,
		func(uncast interface{}) { saved.SetActive(uncast.(string)) },
		widget,
	)
}
Пример #2
0
// Handbook adds a handbook widget to show basic applet informations.
//
func Handbook(key *cftype.Key) {
	appletName := key.Value().String()

	widget := handbook.New(key.Log())
	widget.ShowVersion = true

	book := key.Source().Handbook(appletName)

	if widget == nil || book == nil {
		key.Log().NewErr("Handbook no widget")
		return
	}
	widget.SetPackage(book)
	key.BoxPage().PackStart(widget, true, true, 0)

	key.PackKeyWidget(key,
		func() interface{} { return appletName },
		func(uncast interface{}) {
			appletName = uncast.(string)
			book := key.Source().Handbook(appletName)
			widget.SetPackage(book)
		},
	)
}