コード例 #1
0
ファイル: others.go プロジェクト: sqp/godock
// PackReset adds a reset value button.
//
func PackReset(key *cftype.Key, value interface{}) *gtk.Button {
	fileDefault := key.Storage().FileDefault()
	if fileDefault == "" {
		return nil
	}

	back := newgtk.ButtonFromIconName("edit-clear", gtk.ICON_SIZE_MENU)
	back.Connect("clicked", func() { key.ValueSet(value) })
	key.PackSubWidget(back)
	return back
}
コード例 #2
0
ファイル: testvalues.go プロジェクト: sqp/godock
// TestValues updates the key data with test values.
//
func TestValues(key *cftype.Key) {
	switch key.Type {
	case cftype.KeyBoolButton,
		cftype.KeyBoolCtrl:

		if key.NbElements > 1 {
			val := key.Value().ListBool()
			newval := make([]bool, len(val))
			for i, v := range val {
				newval[i] = !v
			}
			key.ValueSet(newval)

		} else {
			val := key.Value().Bool()
			newval := !val
			key.ValueSet(newval)
		}

	case cftype.KeyIntSpin,
		cftype.KeyIntSize,
		cftype.KeyIntScale:

		if key.NbElements > 1 {
			val := key.Value().ListInt()
			newval := make([]int, len(val))
			for i, v := range val {
				newval[i] = v + 1 + i
			}
			key.ValueSet(newval)
		} else {
			val := key.Value().Int()
			newval := val + 1
			key.ValueSet(newval)
		}

	case cftype.KeyFloatSpin,
		cftype.KeyFloatScale:

		if key.NbElements > 1 {
			val := key.Value().ListFloat()
			newval := make([]float64, len(val))
			for i, v := range val {
				newval[i] = v + 0.1 + float64(i) // hack +0.1 +i
			}
			key.ValueSet(newval)
		} else {
			val := key.Value().Float()
			newval := val + 0.1
			key.ValueSet(newval)
		}

	case cftype.KeyColorSelectorRGB,
		cftype.KeyColorSelectorRGBA:

		val := key.Value().ListFloat()
		newval := make([]float64, len(val))
		for i := range val {
			newval[i] = val[i] + 0.1
			if newval[i] > 1 {
				newval[i]--
			}
		}
		if len(newval) == 3 {
			newval = append(newval, 1)
		}
		key.ValueSet(newval)

	case cftype.KeyLink:

		val := key.Value().String()
		list := []string{urlDock, urlGoTour}
		newval := cycleNextString(list, val, key)
		key.ValueSet(newval)

	case cftype.KeyStringEntry,
		cftype.KeyFileSelector, cftype.KeyFolderSelector,
		cftype.KeyImageSelector, cftype.KeySoundSelector,
		cftype.KeyShortkeySelector, cftype.KeyClassSelector,
		cftype.KeyPasswordEntry,
		cftype.KeyListEntry:

		val := key.Value().String()
		newval := cycleNextString(otherStrings, val, nil)
		key.ValueSet(newval)

	case cftype.KeyFontSelector:

		val := key.Value().String()
		list := []string{"Arial 8", "Monospace 8"}
		newval := cycleNextString(list, val, key)
		key.ValueSet(newval)

	case cftype.KeyTreeViewSortSimple,
		cftype.KeyTreeViewSortModify:

		val := key.Value().ListString()
		newval := reverseStrings(val)
		key.ValueSet(newval)

	case cftype.KeyListNumbered,
		cftype.KeyListNbCtrlSimple,
		cftype.KeyListNbCtrlSelect:

		val := key.Value().Int()
		step := ternary.Int(key.IsType(cftype.KeyListNbCtrlSelect), 3, 1)
		newval := cycleNextID(len(key.AuthorizedValues), val, step)
		key.ValueSet(newval)

	case cftype.KeyListSimple:
		val := key.Value().String()
		newval := cycleNextString(key.AuthorizedValues, val, key)
		key.ValueSet(newval)

	case cftype.KeyListDocks:

		val := key.Value().String()
		list := []string{datatype.KeyMainDock, datatype.KeyNewDock}
		newval := cycleNextString(list, val, key)
		key.ValueSet(newval)

	case cftype.KeyListThemeApplet:

		val := key.Value().String()
		list := []string{"Turbo-night-fuel[0]", "Sound-Mono[0]"}
		newval := cycleNextString(list, val, key)
		key.ValueSet(newval)

	case cftype.KeyHandbook:

		val := key.Value().String()
		list := datatype.ListHandbooksKeys(Handbooks)
		newval := cycleNextString(list, val, key)
		key.ValueSet(newval)

	case cftype.KeyListViews:

		val := key.Value().String()
		books := key.Source().ListViews()
		list := datatype.IndexHandbooksKeys(books)
		newval := cycleNextString(list, val, key)
		key.ValueSet(newval)

	case cftype.KeyListIconsMainDock:

		val := key.Value().String()
		fields := key.Source().ListIconsMainDock()
		newval := cycleNextField(fields, val, key)
		key.ValueSet(newval)

	case cftype.KeyListThemeDesktopIcon:

		val := key.Value().String()
		fields := key.Source().ListThemeDesktopIcon()
		newval := cycleNextField(fields, val, key)
		key.ValueSet(newval)

	}
}