예제 #1
0
파일: appdbus.go 프로젝트: sqp/godock
// PopupDialog open a dialog box . See cdtype.AppIcon.
//
func (cda *CDDbus) PopupDialog(data cdtype.DialogData) error {
	dialog := map[string]interface{}{
		"message":     data.Message,
		"icon":        data.Icon,
		"time-length": int32(data.TimeLength),
		"force-above": data.ForceAbove,
		"use-markup":  data.UseMarkup,
		"buttons":     data.Buttons,
	}

	var widget map[string]interface{}
	switch dw := data.Widget.(type) {

	case cdtype.DialogWidgetText:
		widget = map[string]interface{}{
			"widget-type":   "text-entry",
			"multi-lines":   dw.MultiLines,
			"editable":      !dw.Locked,
			"visible":       !dw.Hidden,
			"nb-chars":      int32(dw.NbChars),
			"initial-value": dw.InitialValue,
		}

	case cdtype.DialogWidgetScale:
		widget = map[string]interface{}{
			"widget-type":   "scale",
			"min-value":     dw.MinValue,
			"max-value":     dw.MaxValue,
			"nb-digit":      int32(dw.NbDigit),
			"initial-value": dw.InitialValue,
			"min-label":     dw.MinLabel,
			"max-label":     dw.MaxLabel,
		}

	case cdtype.DialogWidgetList:
		widget = map[string]interface{}{
			"widget-type": "list",
			"editable":    dw.Editable,
			"values":      strings.Join(dw.Values, ";"),
		}

		// Recast interface to real type so it won't crash in ToMapVariant.
		switch v := dw.InitialValue.(type) {
		case int32, string:
			widget["initial-value"] = v
			// case int:
			// 	widget["initial-value"] = int32(v)
		}

	default:
		widget = make(map[string]interface{})
	}
	cda.dialogCall = data.Callback

	return cda.dbusIcon.Call("PopupDialog", dbuscommon.ToMapVariant(dialog), dbuscommon.ToMapVariant(widget))
}
예제 #2
0
파일: appdbus.go 프로젝트: sqp/godock
// AddMenuItems adds a list of items to the menu triggered by OnBuildMenu.
//
func (cda *CDDbus) AddMenuItems(items ...map[string]interface{}) error {
	var data []map[string]dbus.Variant
	for _, interf := range items {
		data = append(data, dbuscommon.ToMapVariant(interf))
	}

	return cda.dbusIcon.Call("AddMenuItems", data)
}
예제 #3
0
파일: dockbus.go 프로젝트: sqp/godock
func dockAdd(args map[string]interface{}) func(*Client) error {
	return func(client *Client) error { return client.Call("Add", dbuscommon.ToMapVariant(args)) }
}