Skip to content

Conversation

@mhduiy
Copy link
Contributor

@mhduiy mhduiy commented Apr 7, 2025

gsettings -> dconfig

pms: TASK-374909

Summary by Sourcery

Migrate power module configuration from GSettings to DConfig

Enhancements:

  • Replace GSettings-based configuration with DConfig for power management settings
  • Update property handling to work with DConfig instead of GSettings

Chores:

  • Remove GSettings-related imports and dependencies
  • Update constant definitions to use DConfig keys

@deepin-ci-robot
Copy link

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: mhduiy

The full list of commands accepted by this bot can be found here.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@sourcery-ai
Copy link

sourcery-ai bot commented Apr 7, 2025

Reviewer's Guide by Sourcery

This pull request migrates the power management daemon from using gsettings to dconfig for managing configuration settings. This involves replacing gio.Settings and gsprop with dconfig and direct property access, updating initialization and reset logic, and adjusting property change signals.

No diagrams generated as the changes look simple and do not need a visual representation.

File-Level Changes

Change Details Files
Replaced gsettings with dconfig for managing power settings.
  • Removed gio import.
  • Removed gsprop import.
  • Removed gsettings related code.
  • Added dconfig related code.
  • Replaced gsettings calls with dconfig calls.
  • Modified property access to use direct struct fields instead of gsprop.
  • Adjusted property change signals to emit based on direct field changes.
  • Updated initialization and reset logic to use dconfig.
  • Removed gsettings connect changed and replaced with dconfig connect changed.
session/power1/manager.go
session/power1/power_dbusutil.go
session/power1/warn_level_config.go
session/power1/power_save_plan.go
session/power1/constant.go
session/power1/utils.go
session/power1/manager_events.go
Refactored WarnLevelConfigManager to directly manage settings and use callbacks.
  • Removed gio.Settings dependency from WarnLevelConfigManager.
  • Modified WarnLevelConfigManager to use direct property access.
  • Adjusted initialization and change notification mechanisms.
  • Removed gsprop bind and replaced with direct assignment.
session/power1/warn_level_config.go
session/power1/manager.go
Updated power save plan to use dconfig for settings.
  • Replaced gsettings calls with dconfig calls in powerSavePlan.
  • Adjusted brightness saving and loading to use dconfig.
  • Removed gsprop bind and replaced with direct assignment.
session/power1/power_save_plan.go
Modified property setters and emitters in power_dbusutil.go.
  • Updated property setters to directly assign values and emit change signals.
  • Removed gsprop set and emit and replaced with direct assignment and emit.
session/power1/power_dbusutil.go
Updated constants to use dconfig keys.
  • Replaced gsettings keys with dconfig keys in constant.go.
session/power1/constant.go
Updated utils to use dconfig.
  • Replaced gsettings connect changed and replaced with dconfig connect changed.
session/power1/utils.go
Updated manager events to use dconfig.
  • Replaced gsettings connect changed and replaced with dconfig connect changed.
session/power1/manager_events.go

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!
  • Generate a plan of action for an issue: Comment @sourcery-ai plan on
    an issue to generate a plan of action for it.

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

Copy link

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey @mhduiy - I've reviewed your changes - here's some feedback:

Overall Comments:

  • Consider extracting the dconfig keys into a separate file or a dedicated section within the existing constant.go for better organization.
  • It looks like you've removed the gio dependency, make sure that there are no other packages that depend on it.
Here's what I looked at during the review
  • 🟢 General issues: all looks good
  • 🟢 Security: all looks good
  • 🟢 Testing: all looks good
  • 🟡 Complexity: 1 issue found
  • 🟢 Documentation: all looks good

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

return v.service.EmitPropertyChanged(v, "HasAmbientLightSensor", value)
}

func (v *Manager) setPropLinePowerScreensaverDelay(value int) (changed bool) {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

issue (complexity): Consider using a generic helper function to reduce code duplication in the property setters by abstracting the common logic for setting a property and emitting the change signal.

You can reduce the duplication by abstracting the common logic into a single generic helper. For example, if you’re using Go 1.18+ you can define a generic setter that takes a pointer to the property, its new value, and the property name:

func (v *Manager) updateProp[T comparable](prop *T, newVal T, name string) bool {
    if *prop == newVal {
        return false
    }
    *prop = newVal
    _ = v.service.EmitPropertyChanged(v, name, newVal)
    return true
}

Then update the individual setters to delegate to this helper:

func (v *Manager) setPropLinePowerScreensaverDelay(value int) bool {
    return v.updateProp(&v.LinePowerScreensaverDelay, value, "LinePowerScreensaverDelay")
}

func (v *Manager) setPropScreenBlackLock(value bool) bool {
    return v.updateProp(&v.ScreenBlackLock, value, "ScreenBlackLock")
}

This approach keeps the functionality intact while reducing code repetition and complexity.

gsettings -> dconfig

pms: TASK-374909
@deepin-bot
Copy link
Contributor

deepin-bot bot commented Apr 17, 2025

TAG Bot

New tag: 6.1.27
DISTRIBUTION: unstable
Suggest: synchronizing this PR through rebase #767

@deepin-bot
Copy link
Contributor

deepin-bot bot commented Apr 22, 2025

TAG Bot

New tag: 6.1.28
DISTRIBUTION: unstable
Suggest: synchronizing this PR through rebase #769

@deepin-bot
Copy link
Contributor

deepin-bot bot commented Apr 29, 2025

TAG Bot

New tag: 6.1.29
DISTRIBUTION: unstable
Suggest: synchronizing this PR through rebase #775

@deepin-bot
Copy link
Contributor

deepin-bot bot commented May 8, 2025

TAG Bot

New tag: 6.1.30
DISTRIBUTION: unstable
Suggest: synchronizing this PR through rebase #780

@deepin-bot
Copy link
Contributor

deepin-bot bot commented May 13, 2025

TAG Bot

New tag: 6.1.31
DISTRIBUTION: unstable
Suggest: synchronizing this PR through rebase #784

@deepin-bot
Copy link
Contributor

deepin-bot bot commented May 13, 2025

TAG Bot

New tag: 6.1.32
DISTRIBUTION: unstable
Suggest: synchronizing this PR through rebase #786

@deepin-bot
Copy link
Contributor

deepin-bot bot commented May 27, 2025

TAG Bot

New tag: 6.1.33
DISTRIBUTION: unstable
Suggest: synchronizing this PR through rebase #793

@deepin-bot
Copy link
Contributor

deepin-bot bot commented Jun 5, 2025

TAG Bot

New tag: 6.1.35
DISTRIBUTION: unstable
Suggest: synchronizing this PR through rebase #803

@deepin-bot
Copy link
Contributor

deepin-bot bot commented Jun 12, 2025

TAG Bot

New tag: 6.1.36
DISTRIBUTION: unstable
Suggest: synchronizing this PR through rebase #809

@deepin-bot
Copy link
Contributor

deepin-bot bot commented Jun 19, 2025

TAG Bot

New tag: 6.1.37
DISTRIBUTION: unstable
Suggest: synchronizing this PR through rebase #811

@deepin-bot
Copy link
Contributor

deepin-bot bot commented Jun 20, 2025

TAG Bot

New tag: 6.1.38
DISTRIBUTION: unstable
Suggest: synchronizing this PR through rebase #815

@deepin-bot
Copy link
Contributor

deepin-bot bot commented Jun 21, 2025

TAG Bot

New tag: 6.1.39
DISTRIBUTION: unstable
Suggest: synchronizing this PR through rebase #817

@deepin-bot
Copy link
Contributor

deepin-bot bot commented Jun 23, 2025

TAG Bot

New tag: 6.1.40
DISTRIBUTION: unstable
Suggest: synchronizing this PR through rebase #819

@deepin-bot
Copy link
Contributor

deepin-bot bot commented Jun 27, 2025

TAG Bot

New tag: 6.1.41
DISTRIBUTION: unstable
Suggest: synchronizing this PR through rebase #822

@deepin-bot
Copy link
Contributor

deepin-bot bot commented Jul 3, 2025

TAG Bot

New tag: 6.1.42
DISTRIBUTION: unstable
Suggest: synchronizing this PR through rebase #828

@deepin-bot
Copy link
Contributor

deepin-bot bot commented Jul 10, 2025

TAG Bot

New tag: 6.1.43
DISTRIBUTION: unstable
Suggest: synchronizing this PR through rebase #834

@deepin-bot
Copy link
Contributor

deepin-bot bot commented Jul 15, 2025

TAG Bot

New tag: 6.1.44
DISTRIBUTION: unstable
Suggest: synchronizing this PR through rebase #837

@deepin-bot
Copy link
Contributor

deepin-bot bot commented Jul 22, 2025

TAG Bot

New tag: 6.1.45
DISTRIBUTION: unstable
Suggest: synchronizing this PR through rebase #843

@deepin-bot
Copy link
Contributor

deepin-bot bot commented Jul 31, 2025

TAG Bot

New tag: 6.1.46
DISTRIBUTION: unstable
Suggest: synchronizing this PR through rebase #852

@deepin-bot
Copy link
Contributor

deepin-bot bot commented Aug 1, 2025

TAG Bot

New tag: 6.1.47
DISTRIBUTION: unstable
Suggest: synchronizing this PR through rebase #853

@deepin-bot
Copy link
Contributor

deepin-bot bot commented Aug 8, 2025

TAG Bot

New tag: 6.1.48
DISTRIBUTION: unstable
Suggest: synchronizing this PR through rebase #856

@deepin-bot
Copy link
Contributor

deepin-bot bot commented Aug 12, 2025

TAG Bot

New tag: 6.1.49
DISTRIBUTION: unstable
Suggest: synchronizing this PR through rebase #857

@deepin-bot
Copy link
Contributor

deepin-bot bot commented Aug 15, 2025

TAG Bot

New tag: 6.1.50
DISTRIBUTION: unstable
Suggest: synchronizing this PR through rebase #862

@deepin-bot
Copy link
Contributor

deepin-bot bot commented Aug 21, 2025

TAG Bot

New tag: 6.1.51
DISTRIBUTION: unstable
Suggest: synchronizing this PR through rebase #871

@deepin-bot
Copy link
Contributor

deepin-bot bot commented Aug 28, 2025

TAG Bot

New tag: 6.1.52
DISTRIBUTION: unstable
Suggest: synchronizing this PR through rebase #881

@deepin-bot
Copy link
Contributor

deepin-bot bot commented Sep 4, 2025

TAG Bot

New tag: 6.1.53
DISTRIBUTION: unstable
Suggest: synchronizing this PR through rebase #888

@mhduiy mhduiy closed this Sep 11, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants