/*This file is automatically generated by pkg.deepin.io/dbus-generator. Don't edit it*/
package fcitx

import "pkg.deepin.io/lib/dbus"
import "pkg.deepin.io/lib/dbus/property"
import "reflect"
import "sync"
import "runtime"
import "fmt"
import "errors"

/*prevent compile error*/
var _ = fmt.Println
var _ = runtime.SetFinalizer
var _ = sync.NewCond
var _ = reflect.TypeOf
var _ = property.BaseObserver{}

type Keyboard struct {
	Path     dbus.ObjectPath
	DestName string
	core     *dbus.Object
}

func (obj *Keyboard) SetDefaultLayout(layout string, variant string) (_err error) {
	_err = obj.core.Call("org.fcitx.Fcitx.Keyboard.SetDefaultLayout", 0, layout, variant).Store()
	if _err != nil {
		fmt.Println(_err)
	}
	return
}

func (obj *Keyboard) GetLayouts() (layouts [][]interface{}, _err error) {
	_err = obj.core.Call("org.fcitx.Fcitx.Keyboard.GetLayouts", 0).Store(&layouts)
	if _err != nil {
		fmt.Println(_err)
	}
	return
}

func (obj *Keyboard) GetLayoutForIM(im string) (layout string, variant string, _err error) {
	_err = obj.core.Call("org.fcitx.Fcitx.Keyboard.GetLayoutForIM", 0, im).Store(&layout, &variant)
	if _err != nil {
		fmt.Println(_err)
	}
	return
}

func (obj *Keyboard) SetLayoutForIM(im string, layout string, variant string) (_err error) {
	_err = obj.core.Call("org.fcitx.Fcitx.Keyboard.SetLayoutForIM", 0, im, layout, variant).Store()
	if _err != nil {
		fmt.Println(_err)
	}
	return
}

func NewKeyboard(destName string, path dbus.ObjectPath) (*Keyboard, error) {
	if !path.IsValid() {
		return nil, errors.New("The path of '" + string(path) + "' is invalid.")
	}

	core := getBus().Object(destName, path)

	obj := &Keyboard{Path: path, DestName: destName, core: core}

	return obj, nil
}
