feat(inputdevice): Change gsettings to dconfig#886
Conversation
Reviewer's GuideThis pull request migrates all input device settings from GSettings (gio.Settings and gsprop) to a unified DConfig-based configuration system. It introduces a new dconfig package with extended API, updates each device (Touchpad, Wacom, Mouse, Keyboard, TrackPoint, and Manager) to initialize DConfig, load initial values, listen for remote changes, and persist property updates back to DConfig via DBus callbacks, while removing legacy GSettings bindings. File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
There was a problem hiding this comment.
Hey there - I've reviewed your changes - here's some feedback:
- There’s a lot of repeated boilerplate for initializing DConfig, loading properties and wiring callbacks in each device; consider extracting a shared helper or base type to reduce duplication.
- Panicking on DConfig init failures may be too heavy-handed—prefer returning an error or falling back gracefully instead of crashing the entire daemon.
- The common/dconfig API has multiple conversion methods and two different change‐notification hooks; streamlining these (e.g. unifying ConnectConfigChanged/ConnectValueChanged and type conversions) would make the code easier to maintain.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- There’s a lot of repeated boilerplate for initializing DConfig, loading properties and wiring callbacks in each device; consider extracting a shared helper or base type to reduce duplication.
- Panicking on DConfig init failures may be too heavy-handed—prefer returning an error or falling back gracefully instead of crashing the entire daemon.
- The common/dconfig API has multiple conversion methods and two different change‐notification hooks; streamlining these (e.g. unifying ConnectConfigChanged/ConnectValueChanged and type conversions) would make the code easier to maintain.
## Individual Comments
### Comment 1
<location> `inputdevices1/manager.go:265` </location>
<code_context>
+ managerServerObj := service.GetServerObject(m)
+
+ // WheelSpeed 写回调
+ err := managerServerObj.SetWriteCallback(m, "WheelSpeed", func(write *dbusutil.PropertyWrite) *dbus.Error {
+ err := m.dsgInputdevices.SetValue(dconfigKeyWheelSpeed, m.WheelSpeed)
+ if err != nil {
</code_context>
<issue_to_address>
WheelSpeed write callback uses property value from struct, not from DBus write.
The callback should use write.Value to update WheelSpeed, ensuring the value from DBus is correctly handled.
</issue_to_address>Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
|
TAG Bot New tag: 6.1.53 |
4efe973 to
9fb85b0
Compare
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: fly602, mhduiy The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
Optimize dconfig Common pms: TASK-374909
9fb85b0 to
ef43751
Compare
deepin pr auto review根据提供的代码和diff,我将对代码进行审查,并提出改进意见: 1. 代码质量
2. 代码性能
3. 代码安全
4. 具体改进建议
// 建议增加配置值验证
func (kbd *Keyboard) validateLayout(layout string) bool {
// 实现布局验证逻辑
return true
}
// 建议增加速度范围检查
func (m *Mouse) setWheelSpeed() {
speed := m.WheelSpeed.Get()
if speed < 1 || speed > 100 {
logger.Warningf("Invalid wheel speed: %d, using default value", speed)
speed = 50 // 默认值
}
// ... 其余逻辑
}
// 建议增加配置项联动检查
func (tpad *Touchpad) validateConfig() error {
if tpad.PalmDetect.Get() && (tpad.PalmMinWidth.Get() <= 0 || tpad.PalmMinZ.Get() <= 0) {
return errors.New("palm detect dimensions must be positive")
}
return nil
}
// 建议增加动作枚举验证
func (w *Wacom) validateAction(action int) bool {
_, ok := actionMap[action]
return ok
}
5. 测试建议
总体而言,这次代码重构提升了代码的可维护性和类型安全性,但在错误处理、输入验证和测试覆盖方面还有改进空间。建议按照上述建议进行优化,以提高代码的健壮性和可靠性。 |
Optimize dconfig Common
pms: TASK-374909
Summary by Sourcery
Migrate all input device configuration from GSettings to the new DConfig framework, replacing gio.Settings and gsettings dependencies with common DConfig across touchpad, mouse, wacom, keyboard, trackpoint and manager modules.
New Features:
Enhancements: