Package list lightdm-gtk-greeter-settings / f5842f8
"show-ndocators" => "indicators"; "timeout" layout changed; shorter name in .desktop file Andrew P. 8 years ago
3 changed file(s) with 82 addition(s) and 20 deletion(s). Raw diff Collapse all Expand all
14351435 </packing>
14361436 </child>
14371437 <child>
1438 <object class="GtkScale" id="timeout_view">
1439 <property name="visible">True</property>
1440 <property name="can_focus">True</property>
1438 <object class="GtkBox" id="box3">
1439 <property name="visible">True</property>
1440 <property name="can_focus">False</property>
14411441 <property name="margin_left">24</property>
1442 <property name="adjustment">timeout_adjustment</property>
1443 <property name="fill_level">10000</property>
1444 <property name="round_digits">1</property>
1445 <property name="digits">0</property>
1446 <property name="value_pos">bottom</property>
1447 <signal name="format-value" handler="on_format_time_scale" swapped="no"/>
1442 <property name="spacing">6</property>
1443 <child>
1444 <object class="GtkLabel" id="label5">
1445 <property name="visible">True</property>
1446 <property name="can_focus">False</property>
1447 <property name="valign">start</property>
1448 <property name="label" translatable="yes">Never</property>
1449 </object>
1450 <packing>
1451 <property name="expand">False</property>
1452 <property name="fill">True</property>
1453 <property name="position">0</property>
1454 </packing>
1455 </child>
1456 <child>
1457 <object class="GtkScale" id="timeout_view">
1458 <property name="visible">True</property>
1459 <property name="can_focus">True</property>
1460 <property name="adjustment">timeout_adjustment</property>
1461 <property name="fill_level">10000</property>
1462 <property name="round_digits">1</property>
1463 <property name="digits">0</property>
1464 <property name="value_pos">bottom</property>
1465 <signal name="format-value" handler="on_format_timeout_scale" swapped="no"/>
1466 </object>
1467 <packing>
1468 <property name="expand">True</property>
1469 <property name="fill">True</property>
1470 <property name="position">1</property>
1471 </packing>
1472 </child>
1473 <child>
1474 <object class="GtkLabel" id="timeout_end_label">
1475 <property name="visible">True</property>
1476 <property name="can_focus">False</property>
1477 <property name="valign">start</property>
1478 <property name="label" translatable="yes">label</property>
1479 </object>
1480 <packing>
1481 <property name="expand">False</property>
1482 <property name="fill">True</property>
1483 <property name="position">2</property>
1484 </packing>
1485 </child>
14481486 </object>
14491487 <packing>
14501488 <property name="left_attach">0</property>
15151553 </child>
15161554 <child>
15171555 <object class="GtkButton" id="reset_button">
1518 <property name="label">Reread</property>
1556 <property name="label">Reload</property>
15191557 <property name="visible">True</property>
15201558 <property name="can_focus">True</property>
15211559 <property name="receives_default">True</property>
1560 <property name="tooltip_text" translatable="yes">Read configuration file</property>
15221561 <property name="image">icon_reset</property>
15231562 <signal name="clicked" handler="on_reset_clicked" swapped="no"/>
15241563 </object>
00 [Desktop Entry]
1 _Name=LightDM GTK+ Greeter settings editor
1 _Name=LightDM GTK+ Greeter settings
22 Categories=GNOME;GTK;Settings;Utility;
33 Keywords=Configuration;Utility;
44 Exec=lightdm-gtk-greeter-settings
1717 BindingValue = namedtuple('BindingValue', ('option', 'default', 'changed_handler'))
1818 InitialValue = namedtuple('InitialValue', ('value', 'state'))
1919
20
21 GREETER_SECTION = 'greeter'
2022
2123 OPTIONS_BINDINGS = \
2224 {
3739 # Panel
3840 'show-clock': (OptionEntry.BooleanEntry, 'show_clock', False),
3941 'clock-format': (OptionEntry.ClockFormatEntry, 'clock_format', '%a, %H:%M'),
40 'show-indicators': (OptionEntry.IndicatorsEntry, 'indicators', None),
42 'indicators': (OptionEntry.IndicatorsEntry, 'indicators', None),
4143 # Position
4244 'position': (OptionEntry.PositionEntry, 'position', '50%,center'),
4345 # Misc
6163 __gtype_name__ = 'GtkGreeterSettingsWindow'
6264
6365 BUILDER_WIDGETS = ('apply_button',
64 'gtk_theme_values', 'icons_theme_values')
66 'gtk_theme_values', 'icons_theme_values',
67 'timeout_view', 'timeout_adjustment', 'timeout_end_label')
6568
6669 def __new__(cls):
6770 builder = Gtk.Builder()
8992 %s\n\nTry to run this program using "sudo" or "pkexec"') % self._config_path,
9093 message_type=Gtk.MessageType.WARNING)
9194
92 self._configure_special_options()
95 self._configure_special_entries()
9396 self._config = configparser.RawConfigParser(strict=False)
9497 self._read()
9598
96 def _configure_special_options(self):
99 def _configure_special_entries(self):
100 # theme-name
97101 for theme in iglob(os.path.join(sys.prefix, 'share', 'themes', '*', 'gtk-3.0')):
98102 self._gtk_theme_values.append_text(theme.split(os.path.sep)[-2])
99
103 # icon-theme-name
100104 for theme in iglob(os.path.join(sys.prefix, 'share', 'icons', '*', 'index.theme')):
101105 self._icons_theme_values.append_text(theme.split(os.path.sep)[-2])
106 # screensaver-timeout
107 step = 60
108 lower = int(self._timeout_adjustment.props.lower) // step
109 upper = int(self._timeout_adjustment.props.upper) // step
110 for value in range(lower * step, (upper + 1) * step, step):
111 self._timeout_view.add_mark(value, Gtk.PositionType.BOTTOM, None)
112 self._timeout_end_label.props.label = _('%d min') % upper
102113
103114 def _has_access_to_write(self, path):
104115 if os.path.exists(path) and os.access(self._config_path, os.W_OK):
111122 return BindingValue(option, default, changed_id)
112123
113124 def _read(self):
125 self._config.clear()
114126 try:
115127 if not self._config.read(self._config_path):
116128 helpers.show_message(text=_('Failed to read configuration file: %s') % self._config_path,
117129 message_type=Gtk.MessageType.ERROR)
118130 except (configparser.DuplicateSectionError, configparser.MissingSectionHeaderError):
119131 pass
132
133 if not self._config.has_option(GREETER_SECTION, 'indicators'):
134 try:
135 value = self._config.get(GREETER_SECTION, 'show-indicators')
136 except (configparser.NoOptionError, configparser.NoSectionError):
137 pass
138 else:
139 if value:
140 self._config.set(GREETER_SECTION, 'indicators', value)
141 self._config.remove_option(GREETER_SECTION, 'show-indicators')
120142
121143 for section, keys in self._bindings.items():
122144 for key, binding in keys.items():
159181 self._changed_values.discard(option)
160182 self._apply_button.props.sensitive = self._allow_edit and self._changed_values
161183
162 def on_format_time_scale(self, scale, value):
163 value = int(value)
164 if value > 0:
184 def on_format_timeout_scale(self, scale, value):
185 if value != self._timeout_adjustment.props.lower and \
186 value != self._timeout_adjustment.props.upper:
187 value = int(value)
165188 return '%02d:%02d' % (value // 60, value % 60)
166189 else:
167 return _('Never')
190 return ''
168191
169192 def on_destroy(self, *args):
170193 Gtk.main_quit()