Example #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
}
Example #2
0
func NewMouse(l *log.Logger) *Mouse {
	m := &Mouse{}

	m.settings = gio.NewSettings("com.deepin.dde.mouse")
	m.LeftHanded = property.NewGSettingsBoolProperty(
		m, "LeftHanded",
		m.settings, mouseKeyLeftHanded)
	m.DisableTpad = property.NewGSettingsBoolProperty(
		m, "DisableTpad",
		m.settings, mouseKeyDisableTouchpad)
	m.NaturalScroll = property.NewGSettingsBoolProperty(
		m, "NaturalScroll",
		m.settings, mouseKeyNaturalScroll)
	m.MiddleButtonEmulation = property.NewGSettingsBoolProperty(
		m, "MiddleButtonEmulation",
		m.settings, mouseKeyMiddleButton)

	m.MotionAcceleration = property.NewGSettingsFloatProperty(
		m, "MotionAcceleration",
		m.settings, mouseKeyAcceleration)
	m.MotionThreshold = property.NewGSettingsFloatProperty(
		m, "MotionThreshold",
		m.settings, mouseKeyThreshold)

	m.DoubleClick = property.NewGSettingsIntProperty(
		m, "DoubleClick",
		m.settings, mouseKeyDoubleClick)
	m.DragThreshold = property.NewGSettingsIntProperty(
		m, "DragThreshold",
		m.settings, mouseKeyDragThreshold)

	mouseList, _, _ := wrapper.GetDevicesList()
	m.setPropDeviceList(mouseList)
	if len(mouseList) > 0 {
		m.setPropExist(true)
	} else {
		m.setPropExist(false)
	}

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

	_mouse = m
	m.init()
	m.handleGSettings()

	return m
}
Example #3
0
func NewManager() (*Manager, error) {
	var m = &Manager{}

	var err error
	m.td1, err = timedate1.NewTimedate1("org.freedesktop.timedate1",
		"/org/freedesktop/timedate1")
	if err != nil {
		return nil, err
	}
	m.setPropBool(&m.CanNTP, "CanNTP", m.td1.CanNTP.Get())
	m.setPropBool(&m.NTP, "NTP", m.td1.NTP.Get())
	m.setPropBool(&m.LocalRTC, "LocalRTC", m.td1.LocalRTC.Get())
	m.setPropString(&m.Timezone, "Timezone", m.td1.Timezone.Get())

	m.settings = gio.NewSettings(timedateSchema)
	m.Use24HourFormat = property.NewGSettingsBoolProperty(
		m, "Use24HourFormat",
		m.settings, settingsKey24Hour)
	m.DSTOffset = property.NewGSettingsIntProperty(
		m, "DSTOffset",
		m.settings, settingsKeyDSTOffset)
	m.UserTimezones = property.NewGSettingsStrvProperty(
		m, "UserTimezones",
		m.settings, settingsKeyTimezoneList)
	m.AddUserTimezone(m.Timezone)

	return m, nil
}
Example #4
0
func NewPower() *Power {
	p := &Power{}
	p.coreSettings = gio.NewSettings("com.deepin.daemon.power")
	p.PowerButtonAction = property.NewGSettingsEnumProperty(p, "PowerButtonAction", p.coreSettings, "button-power")
	p.LidClosedAction = property.NewGSettingsEnumProperty(p, "LidClosedAction", p.coreSettings, "lid-close")
	p.LockWhenActive = property.NewGSettingsBoolProperty(p, "LockWhenActive", p.coreSettings, "lock-enabled")

	var err error
	if p.screensaver, err = ss.NewScreenSaver("org.freedesktop.ScreenSaver", "/org/freedesktop/ScreenSaver"); err != nil {
		logger.Warning("Can't build org.freedesktop.ScreenSaver:", err)
	}

	p.initPlan()
	p.initUpower()
	p.initEventHandle()

	p.LinePowerPlan = property.NewGSettingsEnumProperty(p, "LinePowerPlan", p.coreSettings, "ac-plan")
	p.LinePowerPlan.ConnectChanged(func() {
		p.setLinePowerPlan(p.LinePowerPlan.Get())
	})
	p.setLinePowerPlan(p.LinePowerPlan.Get())

	p.BatteryPlan = property.NewGSettingsEnumProperty(p, "BatteryPlan", p.coreSettings, "battery-plan")
	p.BatteryPlan.ConnectChanged(func() {
		p.setBatteryPlan(p.BatteryPlan.Get())
	})
	p.setBatteryPlan(p.BatteryPlan.Get())

	return p
}
Example #5
0
func NewWacom(l *log.Logger) *Wacom {
	w := &Wacom{}

	w.settings = gio.NewSettings("com.deepin.dde.wacom")

	w.LeftHanded = property.NewGSettingsBoolProperty(
		w, "LeftHanded",
		w.settings, wacomKeyLeftHanded)
	w.CursorMode = property.NewGSettingsBoolProperty(
		w, "CursorMode",
		w.settings, wacomKeyCursorMode)

	w.KeyUpAction = property.NewGSettingsStringProperty(
		w, "KeyUpAction",
		w.settings, wacomKeyUpAction)
	w.KeyDownAction = property.NewGSettingsStringProperty(
		w, "KeyDownAction",
		w.settings, wacomKeyDownAction)

	w.DoubleDelta = property.NewGSettingsUintProperty(
		w, "DoubleDelta",
		w.settings, wacomKeyDoubleDelta)
	w.PressureSensitive = property.NewGSettingsUintProperty(
		w, "PressureSensitive",
		w.settings, wacomKeyPressureSensitive)

	_, _, wacomList := wrapper.GetDevicesList()
	w.setPropDeviceList(wacomList)
	if len(w.DeviceList) > 0 {
		w.setPropExist(true)
	} else {
		w.setPropExist(false)
	}

	w.logger = l
	w.ActionInfos = generateActionInfos()

	_wacom = w
	w.init()
	w.handleGSettings()

	return w
}
Example #6
0
func NewMediaMount() *MediaMount {
	if !dutils.IsGSchemaExist(mediaSchema) {
		return nil
	}

	media := &MediaMount{}

	media.settings = gio.NewSettings(mediaSchema)
	media.AutoMountOpen = property.NewGSettingsBoolProperty(
		media, "AutoMountOpen",
		media.settings, MEDIA_KEY_AUTOMOUNT)
	media.listenGSettings()

	return media
}
Example #7
0
func NewTouchpad(l *log.Logger) *Touchpad {
	tpad := &Touchpad{}

	tpad.settings = gio.NewSettings("com.deepin.dde.touchpad")
	tpad.TPadEnable = property.NewGSettingsBoolProperty(
		tpad, "TPadEnable",
		tpad.settings, tpadKeyEnabled)
	tpad.LeftHanded = property.NewGSettingsBoolProperty(
		tpad, "LeftHanded",
		tpad.settings, tpadKeyLeftHanded)
	tpad.DisableIfTyping = property.NewGSettingsBoolProperty(
		tpad, "DisableIfTyping",
		tpad.settings, tpadKeyWhileTyping)
	tpad.NaturalScroll = property.NewGSettingsBoolProperty(
		tpad, "NaturalScroll",
		tpad.settings, tpadKeyNaturalScroll)
	tpad.EdgeScroll = property.NewGSettingsBoolProperty(
		tpad, "EdgeScroll",
		tpad.settings, tpadKeyEdgeScroll)
	tpad.VertScroll = property.NewGSettingsBoolProperty(
		tpad, "VertScroll",
		tpad.settings, tpadKeyVertScroll)
	tpad.HorizScroll = property.NewGSettingsBoolProperty(
		tpad, "HorizScroll",
		tpad.settings, tpadKeyHorizScroll)
	tpad.TapClick = property.NewGSettingsBoolProperty(
		tpad, "TapClick",
		tpad.settings, tpadKeyTapClick)

	tpad.MotionAcceleration = property.NewGSettingsFloatProperty(
		tpad, "MotionAcceleration",
		tpad.settings, tpadKeyAcceleration)
	tpad.MotionThreshold = property.NewGSettingsFloatProperty(
		tpad, "MotionThreshold",
		tpad.settings, tpadKeyThreshold)

	tpad.DeltaScroll = property.NewGSettingsIntProperty(
		tpad, "DeltaScroll",
		tpad.settings, tpadKeyScrollDelta)
	tpad.DoubleClick = property.NewGSettingsIntProperty(
		tpad, "DoubleClick",
		tpad.settings, tpadKeyDoubleClick)
	tpad.DragThreshold = property.NewGSettingsIntProperty(
		tpad, "DragThreshold",
		tpad.settings, tpadKeyDragThreshold)

	_, tpadList, _ := wrapper.GetDevicesList()
	tpad.setPropDeviceList(tpadList)

	if len(tpad.DeviceList) > 0 {
		tpad.setPropExist(true)
	} else {
		tpad.setPropExist(false)
	}

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

	_tpad = tpad
	tpad.init()
	tpad.handleGSettings()

	return tpad
}