Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Expose clock format as granite setting #528

Open
wants to merge 14 commits into
base: master
Choose a base branch
from

Conversation

jhaygood86
Copy link
Contributor

This builds on #527 , but also solves some needs in #525

This:

  • exposes the clock format as setting in Granite.Settings, including listening from updates, using the portal. This also allows applications to notify on the update even inside a flatpak'ed application
  • updates internal APIs and widgets to use the new setting, including listening on updates. This magically makes applications work inside flatpak as well as makes them more dynamic (i.e., when the system setting is changed, reflect that change instantly)
  • adds a new API to format a GLib.DateTime directly using the existing APIs and the system settings so that applications don't have to duplicate the format logic everywhere.

Use portal instead of GSettings for clock-format
Also, updates time picker to dynamically re-render using that setting
Adds API to format a GLib.DateTime using system settings so that end user applications don't have to all carry the same code.
@cassidyjames cassidyjames requested review from a team September 17, 2021 03:36
@cassidyjames cassidyjames added the Needs Design Waiting for input from the UX team label Sep 17, 2021
1. Use new format_time method in get_relative_datetime
2. Fall back to GLib.Settings if we can't connect to desktop portal
@danirabbit
Copy link
Member

@jhaygood86 is this still necessary after the other datetime/portals stuff was merged? If so, can you resolve conflicts?

@jhaygood86
Copy link
Contributor Author

Rebase onto changes from portal refactoring

@jhaygood86
Copy link
Contributor Author

@danrabbit It'll still be useful. I've adjusted to account for the new Portal.Settings class being available.

if (_clock_format == null) {
setup_clock_format ();
}
return _clock_format;
Copy link
Member

@tintou tintou Dec 9, 2021

Choose a reason for hiding this comment

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

Suggested change
return _clock_format;
return _clock_format;

_clock_format might be null, so we need to explicitly do/
return _clock_format ?? ClockFormat.24H

setup_portal ();

var clock_format_variant = portal.read (GNOME_DESKTOP_INTERFACE, CLOCK_FORMAT_KEY).get_variant ();
var format = clock_format_variant.get_string ();
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
var format = clock_format_variant.get_string ();
unowned var format = clock_format_variant.get_string ();


portal.setting_changed.connect ((@namespace, key, @value) => {
if (@namespace == GNOME_DESKTOP_INTERFACE && key == CLOCK_FORMAT_KEY) {
var updated_format = @value.get_string ();
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
var updated_format = @value.get_string ();
unowned var updated_format = @value.get_string ();

Reverse order of enum so that 24H is the default
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Needs Design Waiting for input from the UX team
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants