本文整理汇总了Golang中github.com/sqp/godock/widgets/cfbuild/cftype.Key类的典型用法代码示例。如果您正苦于以下问题:Golang Key类的具体用法?Golang Key怎么用?Golang Key使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Key类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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)
}
开发者ID:sqp,项目名称:godock,代码行数:9,代码来源:widgets.go
示例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)
}
开发者ID:sqp,项目名称:godock,代码行数:9,代码来源:widgets.go
示例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)
}
开发者ID:sqp,项目名称:godock,代码行数:35,代码来源:cfprint.go
示例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())
}
}
开发者ID:sqp,项目名称:godock,代码行数:33,代码来源:widgets.go
示例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)
}
开发者ID:sqp,项目名称:godock,代码行数:11,代码来源:builder.go
示例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())
}
}
开发者ID:sqp,项目名称:godock,代码行数:14,代码来源:others.go
示例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
}
开发者ID:sqp,项目名称:godock,代码行数:13,代码来源:others.go
示例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
}
开发者ID:sqp,项目名称:godock,代码行数:11,代码来源:testvalues.go
示例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)
}
开发者ID:sqp,项目名称:godock,代码行数:15,代码来源:widgets.go
示例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)
}
开发者ID:sqp,项目名称:godock,代码行数:15,代码来源:widgets.go
示例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);
}
开发者ID:sqp,项目名称:godock,代码行数:15,代码来源:widgets.go
示例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++
}
}
开发者ID:sqp,项目名称:godock,代码行数:45,代码来源:cfprint.go
示例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)
}
开发者ID:sqp,项目名称:godock,代码行数:20,代码来源:widgets.go
示例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
}
开发者ID:sqp,项目名称:godock,代码行数:21,代码来源:others.go
示例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
}
开发者ID:sqp,项目名称:godock,代码行数:23,代码来源:others.go
示例16: Link
// Link adds a link widget.
//
func Link(key *cftype.Key) {
var text, link string
if len(key.AuthorizedValues) > 0 {
text = key.AuthorizedValues[0]
} else {
text = tran.Slate("link")
}
if len(key.AuthorizedValues) > 1 { // Custom keys have to use this input way.
link = key.AuthorizedValues[1]
} else {
link = key.Value().String()
}
widget := newgtk.LinkButtonWithLabel(link, text)
key.PackKeyWidget(key,
func() interface{} { return widget.GetUri() },
func(val interface{}) { widget.SetUri(val.(string)) },
widget)
}
开发者ID:sqp,项目名称:godock,代码行数:23,代码来源:widgets.go
示例17: ListThemeApplet
// ListThemeApplet adds an theme list widget.
//
func ListThemeApplet(key *cftype.Key) {
var index map[string]datatype.Handbooker
if len(key.AuthorizedValues) > 2 {
if key.AuthorizedValues[1] == "gauges" {
index = key.Source().ListThemeXML(key.AuthorizedValues[0], key.AuthorizedValues[1], key.AuthorizedValues[2])
} else {
index = key.Source().ListThemeINI(key.AuthorizedValues[0], key.AuthorizedValues[1], key.AuthorizedValues[2])
}
}
PackComboBoxWithIndexHandbooker(key, index)
// // list local packages first.
// _allocate_new_buffer;
// data[0] = pOneWidget;
// data[1] = pMainWindow;
// data[2] = g_key_file_get_string (pKeyFile, cGroupName, cKeyName, NULL); // freed in the callback '_got_themes_combo_list'.
// data[3] = g_strdup (cHint); // idem
// GHashTable *pThemeTable = cairo_dock_list_packages (cShareThemesDir, cUserThemesDir, NULL, NULL);
// _got_themes_combo_list (pThemeTable, (gpointer*)data);
// // list distant packages asynchronously.
// if (cDistantThemesDir != NULL)
// {
// cairo_dock_set_status_message_printf (pMainWindow, _("Listing themes in '%s' ..."), cDistantThemesDir);
// data[2] = g_key_file_get_string (pKeyFile, cGroupName, cKeyName, NULL); // freed in the callback '_got_themes_combo_list'.
// data[3] = g_strdup (cHint);
// CairoDockTask *pTask = cairo_dock_list_packages_async (NULL, NULL, cDistantThemesDir, (CairoDockGetPackagesFunc) _got_themes_combo_list, data, pThemeTable); // the table will be freed along with the task.
// g_object_set_data (G_OBJECT (pOneWidget), "cd-task", pTask);
// g_signal_connect (G_OBJECT (pOneWidget), "destroy", G_CALLBACK (on_delete_async_widget), NULL);
// }
// else
// {
// g_hash_table_destroy (pThemeTable);
// }
// g_free (cUserThemesDir);
// g_free (cShareThemesDir);
}
开发者ID:sqp,项目名称:godock,代码行数:42,代码来源:widgets.go
示例18: NewComboBox
// NewComboBox creates a combo box.
//
func NewComboBox(key *cftype.Key, withEntry, numbered bool, current string, list []datatype.Field) (
widget *gtk.ComboBox, model *gtk.ListStore, getValue func() interface{}, setValue func(interface{})) {
model = newModelSimple()
// gtk_tree_sortable_set_sort_column_id(GTK_TREE_SORTABLE(modele), CAIRO_DOCK_MODEL_NAME, GTK_SORT_ASCENDING)
widget = newgtk.ComboBoxWithModel(model)
renderer := newgtk.CellRendererText()
widget.PackStart(renderer, true)
widget.AddAttribute(renderer, "text", RowName)
// Fill and set current.
iter := fillModelWithFields(key, model, list, current, nil)
widget.SetActiveIter(iter)
switch {
case withEntry: // get and set the entry content string.
entry := newgtk.Entry() // Add entry manually so we don't have to recast a GetChild
entry.SetText(current)
widget.Add(entry)
widget.Set("id-column", RowName)
widget.Connect("changed", func() { entry.SetText(widget.GetActiveID()) })
getValue = func() interface{} { v, _ := entry.GetText(); return v }
setValue = func(uncast interface{}) { entry.SetText(uncast.(string)) }
case numbered: // get and set selected as position int
getValue = func() interface{} { return widget.GetActive() }
setValue = func(uncast interface{}) { widget.SetActive(uncast.(int)) }
default: // get and set selected as content string
widget.Set("id-column", RowKey)
getValue = func() interface{} { return widget.GetActiveID() }
setValue = func(uncast interface{}) {
newID := datatype.ListFieldsIDByName(list, uncast.(string), key.Log())
widget.SetActive(newID)
}
}
return
}
开发者ID:sqp,项目名称:godock,代码行数:42,代码来源:others.go
示例19: ListDeskletDecoration
// ListDeskletDecoration adds a desklet decoration list widget.
//
func ListDeskletDecoration(key *cftype.Key) {
current := key.Value().String()
getList := key.Source().ListDeskletDecorations
if key.IsType(cftype.KeyListDeskletDecoDefault) {
getList = fieldsPrepend(getList(),
datatype.Field{Key: "default", Name: tran.Slate("default")},
)
}
PackComboBoxWithListField(key, false, false, getList)
// gtk_tree_sortable_set_sort_column_id (GTK_TREE_SORTABLE (pListStore), CAIRO_DOCK_MODEL_NAME, GTK_SORT_ASCENDING);
// _allocate_new_buffer;
// data[0] = pKeyBox;
// data[1] = (pFrameVBox != NULL ? pFrameVBox : pGroupBox);
// NbControlled = 9;
// data[2] = GINT_TO_POINTER (NbControlled);
// NbControlled --; // car dans cette fonction, on ne compte pas le separateur.
// g_signal_connect (G_OBJECT (pOneWidget), "changed", G_CALLBACK (_cairo_dock_select_custom_item_in_combo), data);
if current == "personnal" { // Disable the next widgets.
// CDControlWidget *cw = g_new0 (CDControlWidget, 1);
// pControlWidgets = g_list_prepend (pControlWidgets, cw);
// cw->NbControlled = NbControlled;
// cw->iNbSensitiveWidgets = 0;
// cw->iFirstSensitiveWidget = 1;
// cw->pControlContainer = (pFrameVBox != NULL ? pFrameVBox : pGroupBox);
}
}
开发者ID:sqp,项目名称:godock,代码行数:31,代码来源:widgets.go
示例20: valueUpdated
func (lf *lineFeed) valueUpdated(key *cftype.Key, line tablist.Liner) {
flag := false
older := key.Storage().Valuer(key.Group, key.Name)
valStatus := key.ValueState(older)
for i, st := range valStatus {
curline := lf.testNewLine(line, i)
switch st.State {
case cftype.StateBothEmpty:
line.Colored(RowOld, color.FgMagenta, "**EMPTY**")
line.Colored(RowNew, color.BgRed, " == ")
case cftype.StateUnchanged:
curline.Set(RowOld, st.Old)
curline.Colored(RowNew, color.BgRed, " == ")
case cftype.StateEdited:
curline.Set(RowOld, st.Old)
st.New = ternary.String(st.New == "", "**EMPTY**", st.New)
curline.Colored(RowNew, color.FgGreen, st.New)
flag = true
case cftype.StateAdded:
curline.Set(RowOld, "**EMPTY**")
curline.Colored(RowNew, color.FgGreen, st.New)
flag = true
case cftype.StateRemoved:
curline.Set(RowOld, st.Old)
curline.Colored(RowNew, color.FgGreen, "**EMPTY**")
flag = true
}
}
if flag {
lf.countChanged++
}
}
开发者ID:sqp,项目名称:godock,代码行数:39,代码来源:cfprint.go
注:本文中的github.com/sqp/godock/widgets/cfbuild/cftype.Key类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论