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

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 MenuManager struct {
	Path     dbus.ObjectPath
	DestName string
	core     *dbus.Object
}

func (obj *MenuManager) RegisterMenu() (menuObjectPath dbus.ObjectPath, _err error) {
	_err = obj.core.Call("com.deepin.menu.Manager.RegisterMenu", 0).Store(&menuObjectPath)
	if _err != nil {
		fmt.Println(_err)
	}
	return
}

func (obj *MenuManager) UnregisterMenu(menuObjectPath string) (_err error) {
	_err = obj.core.Call("com.deepin.menu.Manager.UnregisterMenu", 0, menuObjectPath).Store()
	if _err != nil {
		fmt.Println(_err)
	}
	return
}

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

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

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

	return obj, nil
}
