diff --git a/data/GtkGreeterSettingsWindow.ui b/data/GtkGreeterSettingsWindow.ui index dccfa0e..c84a46d 100644 --- a/data/GtkGreeterSettingsWindow.ui +++ b/data/GtkGreeterSettingsWindow.ui @@ -1436,16 +1436,54 @@ - - True - True + + True + False 24 - timeout_adjustment - 10000 - 1 - 0 - bottom - + 6 + + + True + False + start + Never + + + False + True + 0 + + + + + True + True + timeout_adjustment + 10000 + 1 + 0 + bottom + + + + True + True + 1 + + + + + True + False + start + label + + + False + True + 2 + + 0 @@ -1516,10 +1554,11 @@ - Reread + Reload True True True + Read configuration file icon_reset diff --git a/lightdm-gtk-greeter-settings.desktop.in b/lightdm-gtk-greeter-settings.desktop.in index ac8aef7..352d653 100644 --- a/lightdm-gtk-greeter-settings.desktop.in +++ b/lightdm-gtk-greeter-settings.desktop.in @@ -1,5 +1,5 @@ [Desktop Entry] -_Name=LightDM GTK+ Greeter settings editor +_Name=LightDM GTK+ Greeter settings Categories=GNOME;GTK;Settings;Utility; Keywords=Configuration;Utility; Exec=lightdm-gtk-greeter-settings diff --git a/lightdm_gtk_greeter_settings/GtkGreeterSettingsWindow.py b/lightdm_gtk_greeter_settings/GtkGreeterSettingsWindow.py index 40c4291..c2405e8 100644 --- a/lightdm_gtk_greeter_settings/GtkGreeterSettingsWindow.py +++ b/lightdm_gtk_greeter_settings/GtkGreeterSettingsWindow.py @@ -18,6 +18,8 @@ BindingValue = namedtuple('BindingValue', ('option', 'default', 'changed_handler')) InitialValue = namedtuple('InitialValue', ('value', 'state')) + +GREETER_SECTION = 'greeter' OPTIONS_BINDINGS = \ { @@ -38,7 +40,7 @@ # Panel 'show-clock': (OptionEntry.BooleanEntry, 'show_clock', False), 'clock-format': (OptionEntry.ClockFormatEntry, 'clock_format', '%a, %H:%M'), - 'show-indicators': (OptionEntry.IndicatorsEntry, 'indicators', None), + 'indicators': (OptionEntry.IndicatorsEntry, 'indicators', None), # Position 'position': (OptionEntry.PositionEntry, 'position', '50%,center'), # Misc @@ -62,7 +64,8 @@ __gtype_name__ = 'GtkGreeterSettingsWindow' BUILDER_WIDGETS = ('apply_button', - 'gtk_theme_values', 'icons_theme_values') + 'gtk_theme_values', 'icons_theme_values', + 'timeout_view', 'timeout_adjustment', 'timeout_end_label') def __new__(cls): builder = Gtk.Builder() @@ -90,16 +93,24 @@ %s\n\nTry to run this program using "sudo" or "pkexec"') % self._config_path, message_type=Gtk.MessageType.WARNING) - self._configure_special_options() + self._configure_special_entries() self._config = configparser.RawConfigParser(strict=False) self._read() - def _configure_special_options(self): + def _configure_special_entries(self): + # theme-name for theme in iglob(os.path.join(sys.prefix, 'share', 'themes', '*', 'gtk-3.0')): self._gtk_theme_values.append_text(theme.split(os.path.sep)[-2]) - + # icon-theme-name for theme in iglob(os.path.join(sys.prefix, 'share', 'icons', '*', 'index.theme')): self._icons_theme_values.append_text(theme.split(os.path.sep)[-2]) + # screensaver-timeout + step = 60 + lower = int(self._timeout_adjustment.props.lower) // step + upper = int(self._timeout_adjustment.props.upper) // step + for value in range(lower * step, (upper + 1) * step, step): + self._timeout_view.add_mark(value, Gtk.PositionType.BOTTOM, None) + self._timeout_end_label.props.label = _('%d min') % upper def _has_access_to_write(self, path): if os.path.exists(path) and os.access(self._config_path, os.W_OK): @@ -112,12 +123,23 @@ return BindingValue(option, default, changed_id) def _read(self): + self._config.clear() try: if not self._config.read(self._config_path): helpers.show_message(text=_('Failed to read configuration file: %s') % self._config_path, message_type=Gtk.MessageType.ERROR) except (configparser.DuplicateSectionError, configparser.MissingSectionHeaderError): pass + + if not self._config.has_option(GREETER_SECTION, 'indicators'): + try: + value = self._config.get(GREETER_SECTION, 'show-indicators') + except (configparser.NoOptionError, configparser.NoSectionError): + pass + else: + if value: + self._config.set(GREETER_SECTION, 'indicators', value) + self._config.remove_option(GREETER_SECTION, 'show-indicators') for section, keys in self._bindings.items(): for key, binding in keys.items(): @@ -160,12 +182,13 @@ self._changed_values.discard(option) self._apply_button.props.sensitive = self._allow_edit and self._changed_values - def on_format_time_scale(self, scale, value): - value = int(value) - if value > 0: + def on_format_timeout_scale(self, scale, value): + if value != self._timeout_adjustment.props.lower and \ + value != self._timeout_adjustment.props.upper: + value = int(value) return '%02d:%02d' % (value // 60, value % 60) else: - return _('Never') + return '' def on_destroy(self, *args): Gtk.main_quit()