-
-
Notifications
You must be signed in to change notification settings - Fork 40
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
Support dark mode #684
Draft
lenemter
wants to merge
22
commits into
master
Choose a base branch
from
lenemter/support-dark-mode
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Support dark mode #684
Changes from 20 commits
Commits
Show all changes
22 commits
Select commit
Hold shift + click to select a range
155ccb5
Support dark mode
lenemter 0e29187
Merge branch 'master' into lenemter/support-dark-mode
lenemter 55f4d46
Merge branch 'master' into lenemter/support-dark-mode
lenemter bb95147
Avoid loading lighdm_act many times
lenemter dada4a6
Fix lint
lenemter 7c5fcfe
Merge branch 'master' into lenemter/support-dark-mode
danirabbit b01ac4b
Simplify last coordinates
lenemter 825b0a3
Fix settings
lenemter 6da7d4a
Merge branch 'master' into lenemter/support-dark-mode
lenemter 29e535d
Merge branch 'master' into lenemter/support-dark-mode
lenemter 2844ca2
Merge branch 'master' into lenemter/support-dark-mode
danirabbit 5d93138
Remove bad merge line
danirabbit a6a63aa
Merge branch 'master' into lenemter/support-dark-mode
danirabbit 6c5998d
Merge branch 'master' into lenemter/support-dark-mode
danirabbit 0ec938f
Merge branch 'master' into lenemter/support-dark-mode
zeebok e279b07
Merge branch 'master' into lenemter/support-dark-mode
zeebok 971d451
Merge branch 'master' into lenemter/support-dark-mode
zeebok 6b34a15
Merge branch 'master' into lenemter/support-dark-mode
lenemter d37ade6
Merge branch 'master' into lenemter/support-dark-mode
zeebok 143814f
Fix build
lenemter 7a1eeec
Merge branch 'master' into lenemter/support-dark-mode
zeebok 831e723
Merge branch 'master' into lenemter/support-dark-mode
zeebok File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -25,14 +25,38 @@ public int main (string[] args) { | |
Intl.textdomain (Constants.GETTEXT_PACKAGE); | ||
Intl.bindtextdomain (Constants.GETTEXT_PACKAGE, Constants.LOCALE_DIR); | ||
|
||
var settings_daemon = new Greeter.SettingsDaemon (); | ||
settings_daemon.start (); | ||
var gnome_settings_daemon = new Greeter.SettingsDaemon (); | ||
gnome_settings_daemon.start (); | ||
|
||
Greeter.SubprocessSupervisor portals; | ||
Greeter.SubprocessSupervisor settings_daemon; | ||
|
||
Gtk.init (ref args); | ||
|
||
var window = new Greeter.MainWindow (); | ||
window.show_all (); | ||
|
||
try { | ||
portals = new Greeter.SubprocessSupervisor ({"/usr/libexec/xdg-desktop-portal"}); | ||
} catch (Error e) { | ||
critical (e.message); | ||
} | ||
|
||
unowned var gtk_settings = Gtk.Settings.get_default (); | ||
unowned var granite_settings = Granite.Settings.get_default (); | ||
|
||
gtk_settings.gtk_application_prefer_dark_theme = granite_settings.prefers_color_scheme == DARK; | ||
|
||
granite_settings.notify["prefers-color-scheme"].connect (() => { | ||
gtk_settings.gtk_application_prefer_dark_theme = granite_settings.prefers_color_scheme == DARK; | ||
}); | ||
|
||
try { | ||
settings_daemon = new Greeter.SubprocessSupervisor ({"io.elementary.settings-daemon"}); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Also unclear? |
||
} catch (Error e) { | ||
critical (e.message); | ||
} | ||
|
||
Gtk.main (); | ||
|
||
return 0; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -6,6 +6,9 @@ | |||||||||||
*/ | ||||||||||||
|
||||||||||||
public class Greeter.UserCard : Greeter.BaseCard { | ||||||||||||
private static Act.User lightdm_user_act; | ||||||||||||
private static Pantheon.AccountsService lightdm_act; | ||||||||||||
|
||||||||||||
public signal void go_left (); | ||||||||||||
public signal void go_right (); | ||||||||||||
public signal void focus_requested (); | ||||||||||||
|
@@ -24,6 +27,8 @@ public class Greeter.UserCard : Greeter.BaseCard { | |||||||||||
private Pantheon.AccountsService greeter_act; | ||||||||||||
private Pantheon.SettingsDaemon.AccountsService settings_act; | ||||||||||||
|
||||||||||||
private ulong dark_mode_sync_id = 0; | ||||||||||||
|
||||||||||||
private Gtk.GestureMultiPress click_gesture; | ||||||||||||
private Gtk.Revealer form_revealer; | ||||||||||||
private Gtk.Stack login_stack; | ||||||||||||
|
@@ -211,9 +216,17 @@ public class Greeter.UserCard : Greeter.BaseCard { | |||||||||||
act_user = Act.UserManager.get_default ().get_user (lightdm_user.name); | ||||||||||||
act_user.bind_property ("locked", username_label, "sensitive", INVERT_BOOLEAN); | ||||||||||||
act_user.bind_property ("locked", session_button, "visible", INVERT_BOOLEAN); | ||||||||||||
act_user.notify["is-loaded"].connect (on_act_user_loaded); | ||||||||||||
|
||||||||||||
on_act_user_loaded (); | ||||||||||||
if (lightdm_user_act == null) { | ||||||||||||
lightdm_user_act = Act.UserManager.get_default ().get_user (Environment.get_user_name ()); | ||||||||||||
} | ||||||||||||
|
||||||||||||
if (act_user.is_loaded && lightdm_user_act.is_loaded) { | ||||||||||||
on_act_user_loaded (); | ||||||||||||
} else { | ||||||||||||
act_user.notify["is-loaded"].connect (on_act_user_loaded); | ||||||||||||
lightdm_user_act.notify["is-loaded"].connect (on_act_user_loaded); | ||||||||||||
} | ||||||||||||
|
||||||||||||
card_overlay.focus.connect ((direction) => { | ||||||||||||
if (direction == LEFT) { | ||||||||||||
|
@@ -237,6 +250,11 @@ public class Greeter.UserCard : Greeter.BaseCard { | |||||||||||
|
||||||||||||
notify["show-input"].connect (() => { | ||||||||||||
update_collapsed_class (); | ||||||||||||
|
||||||||||||
// Stop settings sync, that starts in `set_settings ()` | ||||||||||||
if (!show_input) { | ||||||||||||
stop_settings_sync (); | ||||||||||||
} | ||||||||||||
}); | ||||||||||||
|
||||||||||||
password_entry.activate.connect (on_login); | ||||||||||||
|
@@ -314,47 +332,59 @@ public class Greeter.UserCard : Greeter.BaseCard { | |||||||||||
} | ||||||||||||
|
||||||||||||
private void on_act_user_loaded () { | ||||||||||||
if (!act_user.is_loaded) { | ||||||||||||
if (!act_user.is_loaded || !lightdm_user_act.is_loaded) { | ||||||||||||
return; | ||||||||||||
} | ||||||||||||
|
||||||||||||
unowned string? act_path = act_user.get_object_path (); | ||||||||||||
if (act_path != null) { | ||||||||||||
try { | ||||||||||||
greeter_act = Bus.get_proxy_sync ( | ||||||||||||
SYSTEM, | ||||||||||||
"org.freedesktop.Accounts", | ||||||||||||
act_path, | ||||||||||||
GET_INVALIDATED_PROPERTIES | ||||||||||||
); | ||||||||||||
if (act_path == null) { | ||||||||||||
critical ("Couldn't load user act"); | ||||||||||||
return; | ||||||||||||
} | ||||||||||||
|
||||||||||||
try { | ||||||||||||
greeter_act = Bus.get_proxy_sync ( | ||||||||||||
SYSTEM, | ||||||||||||
"org.freedesktop.Accounts", | ||||||||||||
act_path, | ||||||||||||
GET_INVALIDATED_PROPERTIES | ||||||||||||
); | ||||||||||||
|
||||||||||||
settings_act = Bus.get_proxy_sync ( | ||||||||||||
SYSTEM, | ||||||||||||
"org.freedesktop.Accounts", | ||||||||||||
act_path, | ||||||||||||
GET_INVALIDATED_PROPERTIES | ||||||||||||
); | ||||||||||||
|
||||||||||||
is_24h = greeter_act.time_format != "12h"; | ||||||||||||
prefers_accent_color = greeter_act.prefers_accent_color; | ||||||||||||
sleep_inactive_ac_timeout = greeter_act.sleep_inactive_ac_timeout; | ||||||||||||
sleep_inactive_ac_type = greeter_act.sleep_inactive_ac_type; | ||||||||||||
sleep_inactive_battery_timeout = greeter_act.sleep_inactive_battery_timeout; | ||||||||||||
sleep_inactive_battery_type = greeter_act.sleep_inactive_battery_type; | ||||||||||||
} catch (Error e) { | ||||||||||||
critical (e.message); | ||||||||||||
return; | ||||||||||||
} | ||||||||||||
|
||||||||||||
if (lightdm_act == null) { | ||||||||||||
unowned string? lightdm_act_path = lightdm_user_act.get_object_path (); | ||||||||||||
if (lightdm_act_path == null) { | ||||||||||||
critical ("Couldn't load lighdm act"); | ||||||||||||
return; | ||||||||||||
} | ||||||||||||
|
||||||||||||
settings_act = Bus.get_proxy_sync ( | ||||||||||||
try { | ||||||||||||
lightdm_act = Bus.get_proxy_sync ( | ||||||||||||
SYSTEM, | ||||||||||||
"org.freedesktop.Accounts", | ||||||||||||
act_path, | ||||||||||||
lightdm_act_path, | ||||||||||||
GET_INVALIDATED_PROPERTIES | ||||||||||||
); | ||||||||||||
|
||||||||||||
is_24h = greeter_act.time_format != "12h"; | ||||||||||||
prefers_accent_color = greeter_act.prefers_accent_color; | ||||||||||||
sleep_inactive_ac_timeout = greeter_act.sleep_inactive_ac_timeout; | ||||||||||||
sleep_inactive_ac_type = greeter_act.sleep_inactive_ac_type; | ||||||||||||
sleep_inactive_battery_timeout = greeter_act.sleep_inactive_battery_timeout; | ||||||||||||
sleep_inactive_battery_type = greeter_act.sleep_inactive_battery_type; | ||||||||||||
|
||||||||||||
((DBusProxy) greeter_act).g_properties_changed.connect ((changed_properties, invalidated_properties) => { | ||||||||||||
string time_format; | ||||||||||||
changed_properties.lookup ("TimeFormat", "s", out time_format); | ||||||||||||
is_24h = time_format != "12h"; | ||||||||||||
|
||||||||||||
changed_properties.lookup ("PrefersAccentColor", "i", out _prefers_accent_color); | ||||||||||||
changed_properties.lookup ("SleepInactiveACTimeout", "i", out _sleep_inactive_ac_timeout); | ||||||||||||
changed_properties.lookup ("SleepInactiveACType", "i", out _sleep_inactive_ac_type); | ||||||||||||
changed_properties.lookup ("SleepInactiveBatteryTimeout", "i", out _sleep_inactive_battery_timeout); | ||||||||||||
changed_properties.lookup ("SleepInactiveBatteryType", "i", out _sleep_inactive_battery_type); | ||||||||||||
}); | ||||||||||||
} catch (Error e) { | ||||||||||||
critical (e.message); | ||||||||||||
return; | ||||||||||||
} | ||||||||||||
} | ||||||||||||
|
||||||||||||
|
@@ -398,16 +428,22 @@ public class Greeter.UserCard : Greeter.BaseCard { | |||||||||||
} | ||||||||||||
|
||||||||||||
public void set_settings () { | ||||||||||||
if (!act_user.is_loaded) { | ||||||||||||
if (!show_input) { | ||||||||||||
return; | ||||||||||||
} | ||||||||||||
|
||||||||||||
if (!act_user.is_loaded || !lightdm_user_act.is_loaded) { | ||||||||||||
needs_settings_set = true; | ||||||||||||
return; | ||||||||||||
} | ||||||||||||
|
||||||||||||
update_style (); | ||||||||||||
set_keyboard_layouts (); | ||||||||||||
set_mouse_touchpad_settings (); | ||||||||||||
set_interface_settings (); | ||||||||||||
set_night_light_settings (); | ||||||||||||
update_style (); | ||||||||||||
|
||||||||||||
start_settings_sync (); | ||||||||||||
} | ||||||||||||
|
||||||||||||
private void set_keyboard_layouts () { | ||||||||||||
|
@@ -477,6 +513,17 @@ public class Greeter.UserCard : Greeter.BaseCard { | |||||||||||
set_or_reset_settings_key (interface_settings, "font-name", settings_act.font_name); | ||||||||||||
set_or_reset_settings_key (interface_settings, "monospace-font-name", settings_act.monospace_font_name); | ||||||||||||
|
||||||||||||
var settings_daemon_settings = new GLib.Settings ("io.elementary.settings-daemon.prefers-color-scheme"); | ||||||||||||
|
||||||||||||
var latitude = new Variant.double (settings_act.last_coordinates.latitude); | ||||||||||||
var longitude = new Variant.double (settings_act.last_coordinates.longitude); | ||||||||||||
var coordinates = new Variant.tuple ({latitude, longitude}); | ||||||||||||
settings_daemon_settings.set_value ("last-coordinates", coordinates); | ||||||||||||
|
||||||||||||
settings_daemon_settings.set_enum ("prefer-dark-schedule", settings_act.prefer_dark_schedule); | ||||||||||||
settings_daemon_settings.set_value ("prefer-dark-schedule-from", settings_act.prefer_dark_schedule_from); | ||||||||||||
settings_daemon_settings.set_value ("prefer-dark-schedule-to", settings_act.prefer_dark_schedule_to); | ||||||||||||
|
||||||||||||
var touchscreen_settings = new GLib.Settings ("org.gnome.settings-daemon.peripherals.touchscreen"); | ||||||||||||
touchscreen_settings.set_boolean ("orientation-lock", settings_act.orientation_lock); | ||||||||||||
|
||||||||||||
|
@@ -495,8 +542,8 @@ public class Greeter.UserCard : Greeter.BaseCard { | |||||||||||
var night_light_settings = new GLib.Settings ("org.gnome.settings-daemon.plugins.color"); | ||||||||||||
night_light_settings.set_value ("night-light-enabled", settings_act.night_light_enabled); | ||||||||||||
|
||||||||||||
var latitude = new Variant.double (settings_act.night_light_last_coordinates.latitude); | ||||||||||||
var longitude = new Variant.double (settings_act.night_light_last_coordinates.longitude); | ||||||||||||
var latitude = new Variant.double (settings_act.last_coordinates.latitude); | ||||||||||||
var longitude = new Variant.double (settings_act.last_coordinates.longitude); | ||||||||||||
var coordinates = new Variant.tuple ({latitude, longitude}); | ||||||||||||
night_light_settings.set_value ("night-light-last-coordinates", coordinates); | ||||||||||||
|
||||||||||||
|
@@ -509,6 +556,23 @@ public class Greeter.UserCard : Greeter.BaseCard { | |||||||||||
private void update_style () { | ||||||||||||
var interface_settings = new GLib.Settings ("org.gnome.desktop.interface"); | ||||||||||||
interface_settings.set_value ("gtk-theme", "io.elementary.stylesheet." + accent_to_string (prefers_accent_color)); | ||||||||||||
lightdm_act.prefers_color_scheme = greeter_act.prefers_color_scheme; | ||||||||||||
} | ||||||||||||
|
||||||||||||
private void start_settings_sync () { | ||||||||||||
debug ("Started settings sync for user %s", lightdm_user.name); | ||||||||||||
|
||||||||||||
dark_mode_sync_id = ((DBusProxy) lightdm_act).g_properties_changed.connect ((changed_properties, invalidated_properties) => { | ||||||||||||
int prefers_color_scheme; | ||||||||||||
changed_properties.lookup ("PrefersColorScheme", "i", out prefers_color_scheme); | ||||||||||||
greeter_act.prefers_color_scheme = prefers_color_scheme; | ||||||||||||
Comment on lines
+567
to
+568
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||||
}); | ||||||||||||
} | ||||||||||||
|
||||||||||||
private void stop_settings_sync () { | ||||||||||||
debug ("Stopped settings sync for user %s", lightdm_user.name); | ||||||||||||
|
||||||||||||
lightdm_act.disconnect (dark_mode_sync_id); | ||||||||||||
} | ||||||||||||
|
||||||||||||
public override void wrong_credentials () { | ||||||||||||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is unclear to me why you need to spawn this?