本文整理汇总了Golang中github.com/sqp/godock/widgets/cfbuild/cftype.Key类的典型用法代码示例。如果您正苦于以下问题:Golang Key类的具体用法?Golang Key怎么用?Golang Key使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Key类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: Separator
// Separator adds a simple horizontal separator.
//
func Separator(key *cftype.Key) {
// GtkWidget *pAlign = gtk_alignment_new (.5, .5, 0.8, 1.);
// g_object_set (pAlign, "height-request", 12, NULL);
widget := newgtk.Separator(gtk.ORIENTATION_HORIZONTAL)
// gtk_container_add (GTK_CONTAINER (pAlign), pOneWidget);
key.PackWidget(widget, false, false, 0)
}
示例2: ListThemeDesktopIcon
// ListThemeDesktopIcon adds a desktop icon-themes list widget.
//
func ListThemeDesktopIcon(key *cftype.Key) {
getList := fieldsPrepend(key.Source().ListThemeDesktopIcon(),
datatype.Field{},
datatype.Field{Key: "_Custom Icons_", Name: tran.Slate("_Custom Icons_")},
)
PackComboBoxWithListField(key, false, false, getList)
}
示例3: addTest
func (lf *lineFeed) addTest(key *cftype.Key) {
def, e := key.Storage().Default(key.Group, key.Name)
if e != nil {
println("default: ", e.Error())
return
}
valStatus := key.ValueState(def)
if !valStatus.IsChanged() {
return
}
lf.countChanged++
lf.valuePrint = func(key *cftype.Key, line tablist.Liner) {
for i, st := range valStatus {
curline := lf.testNewLine(line, i)
switch {
// case cftype.StateUnchanged:
// curline.Set(RowOld, st.Old)
case st.State == cftype.StateEdited && st.New != "":
curline.Set(RowOld, st.New)
case st.State == cftype.StateAdded:
curline.Colored(RowOld, color.FgYellow, st.New)
case st.State == cftype.StateEdited, st.State == cftype.StateRemoved:
curline.Colored(RowOld, color.FgMagenta, "**EMPTY**")
}
}
}
lf.Add(key)
}
示例4: ColorSelector
// ColorSelector adds a color selector widget.
//
func ColorSelector(key *cftype.Key) {
values := key.Value().ListFloat()
if len(values) == 3 {
values = append(values, 1) // no transparency.
}
gdkColor := gdk.NewRGBA(values...)
widget := newgtk.ColorButtonWithRGBA(gdkColor)
var getValue func() interface{}
switch key.Type {
case cftype.KeyColorSelectorRGB:
key.NbElements = 3
getValue = func() interface{} { return widget.GetRGBA().Floats()[:3] } // Need to trunk ?
case cftype.KeyColorSelectorRGBA:
key.NbElements = 4
getValue = func() interface{} { return widget.GetRGBA().Floats() }
}
widget.Set("use-alpha", key.IsType(cftype.KeyColorSelectorRGBA))
key.PackKeyWidget(key,
getValue,
func(uncast interface{}) { widget.SetRGBA(gdk.NewRGBA(uncast.([]float64)...)) },
widget,
)
oldval, e := key.Storage().Default(key.Group, key.Name)
if e == nil {
PackReset(key, oldval.ListFloat())
}
}
示例5: PackKeyWidget
// PackKeyWidget packs a key widget to the page with its getValue call
//
// (was _pack_subwidget).
func (build *builder) PackKeyWidget(key *cftype.Key, getValue func() interface{}, setValue func(interface{}), childs ...gtk.IWidget) {
for _, w := range childs {
build.pWidgetBox.PackStart(w, key.IsAlignedVertical, key.IsAlignedVertical, 0)
}
// key.SetValue = setValue
key.SetWidSetValue(setValue)
key.SetWidGetValue(getValue)
}
示例6: PackValuerAsInt
// PackValuerAsInt packs a valuer widget with its reset button (to given value).
// Values are get and set as int.
//
func PackValuerAsInt(key *cftype.Key, w gtk.IWidget, valuer WidgetValuer, value int) {
key.PackKeyWidget(key,
func() interface{} { return int(valuer.GetValue()) },
func(uncast interface{}) { valuer.SetValue(float64(uncast.(int))) },
w)
oldval, e := key.Storage().Default(key.Group, key.Name)
if e == nil {
PackReset(key, oldval.Int())
}
}
示例7: PackComboBoxWithListField
// PackComboBoxWithListField creates a combo box filled with the getList call.
//
func PackComboBoxWithListField(key *cftype.Key, withEntry, numbered bool, getList func() []datatype.Field) *gtk.ComboBox {
var list []datatype.Field
if getList != nil {
list = getList()
}
current, _ := key.Storage().String(key.Group, key.Name)
widget, _, getValue, setValue := NewComboBox(key, withEntry, numbered, current, list)
key.PackKeyWidget(key, getValue, setValue, widget)
return widget
}
示例8: findID
func findID(list []string, current string, key *cftype.Key) int {
for i, str := range list {
if current == str {
return i
}
}
if key != nil {
key.Log().NewErr("not found", "list findID", current, list)
}
return 0
}
示例9: IntegerSpin
// IntegerSpin adds an integer scale widget.
//
func IntegerSpin(key *cftype.Key) {
if key.NbElements > 1 { // TODO: remove temp test
key.Log().Info("integer multi ffs", key.Type.String())
}
value := key.Value().Int()
minValue, maxValue := minMaxValues(key)
w := newgtk.SpinButtonWithRange(minValue, maxValue, 1)
w.SetValue(float64(value))
PackValuerAsInt(key, w, w, value)
}
示例10: FontSelector
// FontSelector adds a font selector widget.
//
func FontSelector(key *cftype.Key) {
value := key.Value().String()
widget := newgtk.FontButtonWithFont(value)
widget.Set("show-style", true)
widget.Set("show-size", true)
widget.Set("use-size", true)
widget.Set("use-font", true)
key.PackKeyWidget(key,
func() interface{} { return widget.GetFontName() },
func(val interface{}) { widget.SetFontName(val.(string)) },
widget)
}
示例11: ListScreens
// ListScreens adds a screen selection widget.
//
func ListScreens(key *cftype.Key) {
list := key.Source().ListScreens()
combo := PackComboBoxWithListField(key, false, false, fieldsPrepend(list))
if len(list) <= 1 {
combo.SetSensitive(false)
}
// gldi_object_register_notification (&myDesktopMgr,
// NOTIFICATION_DESKTOP_GEOMETRY_CHANGED,
// (GldiNotificationFunc) _on_screen_modified,
// GLDI_RUN_AFTER, pScreensListStore);
// g_signal_connect (pOneWidget, "destroy", G_CALLBACK (_on_list_destroyed), NULL);
}
示例12: valueDefault
func (lf *lineFeed) valueDefault(key *cftype.Key, line tablist.Liner) {
flag := false
def, e := key.Storage().Default(key.Group, key.Name)
if e != nil {
println("default: ", e.Error())
}
valStatus := key.ValueState(def)
for i, st := range valStatus {
curline := lf.testNewLine(line, i)
switch st.State {
case cftype.StateBothEmpty:
line.Set(RowOld, "**EMPTY**")
case cftype.StateUnchanged:
curline.Set(RowOld, st.Old)
case cftype.StateEdited:
curline.Set(RowOld, st.Old)
if st.New == "" {
curline.Colored(RowNew, color.FgMagenta, "**EMPTY**")
} else {
curline.Colored(RowNew, color.FgGreen, st.New)
}
flag = true
case cftype.StateAdded:
curline.Set(RowOld, "**EMPTY**")
curline.Colored(RowNew, color.FgYellow, st.New)
flag = true
case cftype.StateRemoved:
curline.Set(RowOld, st.Old)
curline.Colored(RowNew, color.FgMagenta, "**EMPTY**")
flag = true
}
}
if flag {
lf.countChanged++
}
}
示例13: IntegerScale
// IntegerScale adds an integer scale widget.
//
func IntegerScale(key *cftype.Key) {
if key.NbElements > 1 { // TODO: remove temp test
key.Log().Info("IntegerScale multi", key.NbElements, key.Type.String())
}
value := key.Value().Int()
minValue, maxValue := minMaxValues(key)
step := (maxValue - minValue) / 20
if step < 1 {
step = 1
}
adjustment := newgtk.Adjustment(float64(value), minValue, maxValue, 1, step, 0)
w := newgtk.Scale(gtk.ORIENTATION_HORIZONTAL, adjustment)
w.Set("digits", 0)
PackValuerAsInt(key, WrapKeyScale(key, w), w, value)
}
示例14: modelAddField
// modelAddField adds one field to the model and can save reference of fields+iter.
//
func modelAddField(key *cftype.Key, model *gtk.ListStore, field datatype.Field, ro indexiter.ByString) *gtk.TreeIter {
iter := model.Append()
model.SetCols(iter, gtk.Cols{
RowKey: field.Key,
RowName: field.Name,
RowDesc: "none",
})
if field.Icon != "" {
pix, e := common.PixbufNewFromFile(field.Icon, iconSizeCombo)
if !key.Log().Err(e, "Load icon") {
model.SetValue(iter, RowIcon, pix)
}
}
if ro != nil {
ro.Append(iter, field.Key)
}
return iter
}
示例15: WrapKeyScale
// WrapKeyScale wraps a key scale with its information labels if needed (enough values).
//
// (was _pack_hscale).
func WrapKeyScale(key *cftype.Key, child *gtk.Scale) gtk.IWidget {
child.Set("width-request", 150)
if len(key.AuthorizedValues) >= 4 {
child.Set("value-pos", gtk.POS_TOP)
// log.DEV("MISSING SubScale options", string(key.Type), key.AuthorizedValues)
box := newgtk.Box(gtk.ORIENTATION_HORIZONTAL, 0)
// GtkWidget * pAlign = gtk_alignment_new(1., 1., 0., 0.)
labelLeft := newgtk.Label(key.Translate(key.AuthorizedValues[2]))
// pAlign = gtk_alignment_new(1., 1., 0., 0.)
labelRight := newgtk.Label(key.Translate(key.AuthorizedValues[3]))
box.PackStart(labelLeft, false, false, 0)
box.PackStart(child, false, false, 0)
box.PackStart(labelRight, false, false, 0)
return box
}
child.Set("value-pos", gtk.POS_LEFT)
return child
}