Browse Source

update default theme to use theme_utils for its clock. This closes #83

sisyphus
Dustin Falgout 8 years ago
parent
commit
1569a80607
  1. 39
      src/gresource/js/GreeterConfig.js
  2. 2
      src/gresource/js/ThemeUtils.js
  3. 8
      themes/antergos/js/greeter.js

39
src/gresource/js/GreeterConfig.js

@ -30,6 +30,19 @@ let _branding = null,
_greeter = null; _greeter = null;
function set_values( defaults, target_obj, method ) {
let keys = Object.keys(defaults);
keys.forEach( prop => {
try {
target_obj[prop] = method( 'greeter', prop );
} catch(err) {
target_obj[prop] = defaults[prop];
}
});
}
/** /**
* Provides theme authors with a way to retrieve values from the greeter's config * Provides theme authors with a way to retrieve values from the greeter's config
* file located at `/etc/lightdm/lightdm-webkit2-greeter.conf`. The greeter will * file located at `/etc/lightdm/lightdm-webkit2-greeter.conf`. The greeter will
@ -50,10 +63,17 @@ class GreeterConfig {
* @readonly * @readonly
*/ */
get branding() { get branding() {
let props = ['background_images', 'logo', 'user_image'];
if ( null === _branding ) { if ( null === _branding ) {
props.forEach( prop => _branding[prop] = this.get_str( 'branding', prop ) ); let theme_dir = '/usr/share/lightdm-webkit/themes/antergos',
props = {
'background_images': '/usr/share/backgrounds',
'logo': `${theme_dir}/img/antergos-logo-user.png`,
'user_image': `${theme_dir}/img/antergos.png`
};
_branding = {};
set_values( props, _branding, this.get_str );
} }
return _branding; return _branding;
@ -73,15 +93,16 @@ class GreeterConfig {
* @readonly * @readonly
*/ */
get greeter() { get greeter() {
let bools = ['debug_mode', 'secure_mode'],
strings = ['time_format', 'time_language', 'webkit_theme'];
if ( null === _greeter ) { if ( null === _greeter ) {
let bools = {'debug_mode': true, 'secure_mode': true},
strings = {'time_format': 'LT', 'time_language': 'auto', 'webkit_theme': 'antergos'},
numbers = {'screensaver_timeout': 30};
_greeter = {}; _greeter = {};
_greeter.screensaver_timeout = this.get_num( 'greeter', 'screensaver_timeout' );
bools.forEach( prop => _greeter[prop] = this.get_bool( 'greeter', prop ) ); set_values( bools, _greeter, this.get_bool );
strings.forEach( prop => _greeter[prop] = this.get_str( 'greeter', prop ) ); set_values( strings, _greeter, this.get_str );
set_values( numbers, _greeter, this.get_num );
} }
return _greeter; return _greeter;

2
src/gresource/js/ThemeUtils.js

@ -125,7 +125,7 @@ const ThemeUtils = {
} }
} }
let local_time = moment().format( format ); let local_time = moment().format( time_format );
if ( local_time === localized_invalid_date ) { if ( local_time === localized_invalid_date ) {
local_time = moment().format( 'LT' ); local_time = moment().format( 'LT' );

8
themes/antergos/js/greeter.js

@ -588,14 +588,10 @@ class AntergosTheme {
* Setup the clock widget. * Setup the clock widget.
*/ */
initialize_clock() { initialize_clock() {
var saved_format = _util.cache_get( 'clock', 'time_format' ), this.$clock.html( theme_utils.get_current_localized_time() );
format = (null !== saved_format) ? saved_format : 'LT';
moment.locale( window.navigator.languages );
this.$clock.html( moment().format( format ) );
setInterval( () => { setInterval( () => {
_self.$clock.html( moment().format( format ) ); _self.$clock.html( theme_utils.get_current_localized_time() );
}, 60000 ); }, 60000 );
} }

Loading…
Cancel
Save