"show-ndocators" => "indicators"; "timeout" layout changed; shorter name in .desktop file
Andrew P.
10 years ago
1435 | 1435 | </packing> |
1436 | 1436 | </child> |
1437 | 1437 | <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> | |
1441 | 1441 | <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> | |
1448 | 1486 | </object> |
1449 | 1487 | <packing> |
1450 | 1488 | <property name="left_attach">0</property> |
1515 | 1553 | </child> |
1516 | 1554 | <child> |
1517 | 1555 | <object class="GtkButton" id="reset_button"> |
1518 | <property name="label">Reread</property> | |
1556 | <property name="label">Reload</property> | |
1519 | 1557 | <property name="visible">True</property> |
1520 | 1558 | <property name="can_focus">True</property> |
1521 | 1559 | <property name="receives_default">True</property> |
1560 | <property name="tooltip_text" translatable="yes">Read configuration file</property> | |
1522 | 1561 | <property name="image">icon_reset</property> |
1523 | 1562 | <signal name="clicked" handler="on_reset_clicked" swapped="no"/> |
1524 | 1563 | </object> |
0 | 0 | [Desktop Entry] |
1 | _Name=LightDM GTK+ Greeter settings editor | |
1 | _Name=LightDM GTK+ Greeter settings | |
2 | 2 | Categories=GNOME;GTK;Settings;Utility; |
3 | 3 | Keywords=Configuration;Utility; |
4 | 4 | Exec=lightdm-gtk-greeter-settings |
17 | 17 | BindingValue = namedtuple('BindingValue', ('option', 'default', 'changed_handler')) |
18 | 18 | InitialValue = namedtuple('InitialValue', ('value', 'state')) |
19 | 19 | |
20 | ||
21 | GREETER_SECTION = 'greeter' | |
20 | 22 | |
21 | 23 | OPTIONS_BINDINGS = \ |
22 | 24 | { |
37 | 39 | # Panel |
38 | 40 | 'show-clock': (OptionEntry.BooleanEntry, 'show_clock', False), |
39 | 41 | 'clock-format': (OptionEntry.ClockFormatEntry, 'clock_format', '%a, %H:%M'), |
40 | 'show-indicators': (OptionEntry.IndicatorsEntry, 'indicators', None), | |
42 | 'indicators': (OptionEntry.IndicatorsEntry, 'indicators', None), | |
41 | 43 | # Position |
42 | 44 | 'position': (OptionEntry.PositionEntry, 'position', '50%,center'), |
43 | 45 | # Misc |
61 | 63 | __gtype_name__ = 'GtkGreeterSettingsWindow' |
62 | 64 | |
63 | 65 | 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') | |
65 | 68 | |
66 | 69 | def __new__(cls): |
67 | 70 | builder = Gtk.Builder() |
89 | 92 | %s\n\nTry to run this program using "sudo" or "pkexec"') % self._config_path, |
90 | 93 | message_type=Gtk.MessageType.WARNING) |
91 | 94 | |
92 | self._configure_special_options() | |
95 | self._configure_special_entries() | |
93 | 96 | self._config = configparser.RawConfigParser(strict=False) |
94 | 97 | self._read() |
95 | 98 | |
96 | def _configure_special_options(self): | |
99 | def _configure_special_entries(self): | |
100 | # theme-name | |
97 | 101 | for theme in iglob(os.path.join(sys.prefix, 'share', 'themes', '*', 'gtk-3.0')): |
98 | 102 | self._gtk_theme_values.append_text(theme.split(os.path.sep)[-2]) |
99 | ||
103 | # icon-theme-name | |
100 | 104 | for theme in iglob(os.path.join(sys.prefix, 'share', 'icons', '*', 'index.theme')): |
101 | 105 | 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 | |
102 | 113 | |
103 | 114 | def _has_access_to_write(self, path): |
104 | 115 | if os.path.exists(path) and os.access(self._config_path, os.W_OK): |
111 | 122 | return BindingValue(option, default, changed_id) |
112 | 123 | |
113 | 124 | def _read(self): |
125 | self._config.clear() | |
114 | 126 | try: |
115 | 127 | if not self._config.read(self._config_path): |
116 | 128 | helpers.show_message(text=_('Failed to read configuration file: %s') % self._config_path, |
117 | 129 | message_type=Gtk.MessageType.ERROR) |
118 | 130 | except (configparser.DuplicateSectionError, configparser.MissingSectionHeaderError): |
119 | 131 | 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') | |
120 | 142 | |
121 | 143 | for section, keys in self._bindings.items(): |
122 | 144 | for key, binding in keys.items(): |
159 | 181 | self._changed_values.discard(option) |
160 | 182 | self._apply_button.props.sensitive = self._allow_edit and self._changed_values |
161 | 183 | |
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) | |
165 | 188 | return '%02d:%02d' % (value // 60, value % 60) |
166 | 189 | else: |
167 | return _('Never') | |
190 | return '' | |
168 | 191 | |
169 | 192 | def on_destroy(self, *args): |
170 | 193 | Gtk.main_quit() |