Exemplo n.º 1
0
func NewKeyboard(l *log.Logger) *Keyboard {
	kbd := &Keyboard{}

	kbd.settings = gio.NewSettings("com.deepin.dde.keyboard")
	kbd.CurrentLayout = property.NewGSettingsStringProperty(
		kbd, "CurrentLayout",
		kbd.settings, kbdKeyLayout)
	kbd.RepeatEnabled = property.NewGSettingsBoolProperty(
		kbd, "RepeatEnabled",
		kbd.settings, kbdKeyRepeatEnable)
	kbd.RepeatInterval = property.NewGSettingsUintProperty(
		kbd, "RepeatInterval",
		kbd.settings, kbdKeyRepeatInterval)
	kbd.RepeatDelay = property.NewGSettingsUintProperty(
		kbd, "RepeatDelay",
		kbd.settings, kbdKeyRepeatDelay)
	kbd.CursorBlink = property.NewGSettingsIntProperty(
		kbd, "CursorBlink",
		kbd.settings, kbdKeyCursorBlink)
	kbd.CapslockToggle = property.NewGSettingsBoolProperty(
		kbd, "CapslockToggle",
		kbd.settings, kbdKeyCapslockToggle)
	kbd.UserLayoutList = property.NewGSettingsStrvProperty(
		kbd, "UserLayoutList",
		kbd.settings, kbdKeyUserLayoutList)
	kbd.UserOptionList = property.NewGSettingsStrvProperty(
		kbd, "UserOptionList",
		kbd.settings, kbdKeyLayoutOptions)

	kbd.logger = l
	var err error
	kbd.layoutDescMap, err = getLayoutListByFile(kbdKeyLayoutXml)
	if err != nil {
		//TODO: handle error
		kbd.errorInfo("Get Layout Desc List Failed: %v", err)
		return nil
	}

	kbd.greeter, err = greeterutils.NewGreeterUtils(
		"com.deepin.api.GreeterUtils",
		"/com/deepin/api/GreeterUtils")
	if err != nil {
		kbd.warningInfo("Create GreeterUtils Failed: %v", err)
		kbd.greeter = nil
	}

	kbd.xsettings, err = sessionmanager.NewXSettings(
		"com.deepin.SessionManager",
		"/com/deepin/XSettings",
	)
	if err != nil {
		kbd.warningInfo("Create XSettings Failed: %v", err)
		kbd.xsettings = nil
	}

	kbd.handleGSettings()
	kbd.init()

	return kbd
}
Exemplo n.º 2
0
func (greeter *GreeterTheme) Set(name string) error {
	if !IsNameInInfoList(name, greeter.infoList) {
		return errInvalidTheme
	}

	username := dutils.GetUserName()
	homeDir := os.Getenv("HOME")
	if homeDir == path.Join("/tmp", username) {
		return errInvalidUser
	}

	greeterObj, err := greeterutils.NewGreeterUtils(
		"com.deepin.api.GreeterUtils",
		"/com/deepin/api/GreeterUtils")
	if err != nil {
		return err
	}

	return greeterObj.SetGreeterTheme(username, name)
}