Package list lightdm-gtk-greeter-settings / 82dfb26
Using StringPathEntry for "keyboard" and "reader" options Andrew P. 7 years ago
3 changed file(s) with 174 addition(s) and 51 deletion(s). Raw diff Collapse all Expand all
220220 <property name="can_focus">False</property>
221221 <property name="hexpand">True</property>
222222 <property name="vexpand">True</property>
223 <property name="enable_popup">True</property>
224223 <child>
225224 <object class="GtkGrid" id="appearance_box">
226225 <property name="visible">True</property>
664663 </object>
665664 <packing>
666665 <property name="tab_expand">True</property>
666 <property name="tab_fill">False</property>
667667 </packing>
668668 </child>
669669 <child>
947947 <packing>
948948 <property name="position">1</property>
949949 <property name="tab_expand">True</property>
950 <property name="tab_fill">False</property>
950951 </packing>
951952 </child>
952953 <child>
12341235 <packing>
12351236 <property name="position">2</property>
12361237 <property name="tab_expand">True</property>
1238 <property name="tab_fill">False</property>
12371239 </packing>
12381240 </child>
12391241 <child>
12661268 </packing>
12671269 </child>
12681270 <child>
1269 <object class="GtkLabel" id="greeter_keyboard_label">
1270 <property name="visible">True</property>
1271 <property name="can_focus">False</property>
1272 <property name="halign">start</property>
1273 <property name="hexpand">True</property>
1274 <property name="label" translatable="yes" context="option|keyboard">Onscreen keyboard</property>
1275 <attributes>
1276 <attribute name="weight" value="semibold"/>
1277 </attributes>
1278 </object>
1279 <packing>
1280 <property name="left_attach">0</property>
1281 <property name="top_attach">0</property>
1282 </packing>
1283 </child>
1284 <child>
1285 <object class="GtkComboBoxText" id="greeter_keyboard_values">
1286 <property name="visible">True</property>
1287 <property name="can_focus">False</property>
1288 <property name="margin_left">24</property>
1289 <property name="has_entry">True</property>
1290 <items>
1291 <item>onboard</item>
1292 </items>
1293 <child internal-child="entry">
1294 <object class="GtkEntry" id="greeter_keyboard_value">
1295 <property name="can_focus">True</property>
1296 </object>
1297 </child>
1298 </object>
1299 <packing>
1300 <property name="left_attach">0</property>
1301 <property name="top_attach">1</property>
1302 <property name="width">2</property>
1303 </packing>
1304 </child>
1305 <child>
1306 <object class="GtkSwitch" id="greeter_keyboard_use">
1307 <property name="visible">True</property>
1308 <property name="can_focus">False</property>
1309 <property name="halign">end</property>
1310 </object>
1311 <packing>
1312 <property name="left_attach">1</property>
1313 <property name="top_attach">0</property>
1314 </packing>
1315 </child>
1316 <child>
13171271 <object class="GtkBox" id="greeter_screensaver-timeout_box">
13181272 <property name="visible">True</property>
13191273 <property name="can_focus">False</property>
13651319 <packing>
13661320 <property name="left_attach">0</property>
13671321 <property name="top_attach">3</property>
1322 <property name="width">2</property>
1323 </packing>
1324 </child>
1325 <child>
1326 <object class="GtkLabel" id="label4">
1327 <property name="visible">True</property>
1328 <property name="can_focus">False</property>
1329 <property name="halign">start</property>
1330 <property name="label" translatable="yes">Accessibility</property>
1331 <attributes>
1332 <attribute name="weight" value="semibold"/>
1333 </attributes>
1334 </object>
1335 <packing>
1336 <property name="left_attach">0</property>
1337 <property name="top_attach">0</property>
1338 <property name="width">2</property>
1339 </packing>
1340 </child>
1341 <child>
1342 <object class="GtkGrid" id="grid1">
1343 <property name="visible">True</property>
1344 <property name="can_focus">False</property>
1345 <property name="margin_left">24</property>
1346 <property name="row_spacing">8</property>
1347 <property name="column_spacing">8</property>
1348 <child>
1349 <object class="GtkCheckButton" id="greeter_keyboard_use">
1350 <property name="label" translatable="yes">Keyboard</property>
1351 <property name="visible">True</property>
1352 <property name="can_focus">True</property>
1353 <property name="receives_default">False</property>
1354 <property name="xalign">0</property>
1355 <property name="draw_indicator">True</property>
1356 </object>
1357 <packing>
1358 <property name="left_attach">0</property>
1359 <property name="top_attach">0</property>
1360 </packing>
1361 </child>
1362 <child>
1363 <object class="GtkCheckButton" id="greeter_reader_use">
1364 <property name="label" translatable="yes">Reader</property>
1365 <property name="visible">True</property>
1366 <property name="can_focus">True</property>
1367 <property name="receives_default">False</property>
1368 <property name="xalign">0</property>
1369 <property name="draw_indicator">True</property>
1370 </object>
1371 <packing>
1372 <property name="left_attach">0</property>
1373 <property name="top_attach">1</property>
1374 </packing>
1375 </child>
1376 <child>
1377 <object class="GtkLabel" id="label6">
1378 <property name="visible">True</property>
1379 <property name="can_focus">False</property>
1380 <property name="halign">start</property>
1381 <property name="label" translatable="yes">&lt;i&gt;You can choose accessibility features &lt;a href=""&gt;enabled at start&lt;/a&gt;&lt;/i&gt;</property>
1382 <property name="use_markup">True</property>
1383 </object>
1384 <packing>
1385 <property name="left_attach">0</property>
1386 <property name="top_attach">2</property>
1387 <property name="width">2</property>
1388 </packing>
1389 </child>
1390 <child>
1391 <object class="GtkComboBoxText" id="greeter_reader_combo">
1392 <property name="visible">True</property>
1393 <property name="can_focus">False</property>
1394 <property name="hexpand">True</property>
1395 <property name="has_entry">True</property>
1396 <items>
1397 <item id="select-path" translatable="yes" context="option|greeter|reader">Select path to reader...</item>
1398 <item id="separator">-</item>
1399 <item id="value">orca</item>
1400 </items>
1401 <child internal-child="entry">
1402 <object class="GtkEntry" id="greeter_reader_entry">
1403 <property name="can_focus">True</property>
1404 <property name="placeholder_text" translatable="yes" context="option|greeter|reader">Command to launch screen reader</property>
1405 </object>
1406 </child>
1407 </object>
1408 <packing>
1409 <property name="left_attach">1</property>
1410 <property name="top_attach">1</property>
1411 </packing>
1412 </child>
1413 <child>
1414 <object class="GtkComboBoxText" id="greeter_keyboard_combo">
1415 <property name="visible">True</property>
1416 <property name="can_focus">False</property>
1417 <property name="hexpand">True</property>
1418 <property name="has_entry">True</property>
1419 <items>
1420 <item id="select-path" translatable="yes" context="option|greeter|keyboard">Select path to keyboard...</item>
1421 <item id="separator">-</item>
1422 <item id="value">onboard</item>
1423 </items>
1424 <child internal-child="entry">
1425 <object class="GtkEntry" id="greeter_keyboard_entry">
1426 <property name="can_focus">True</property>
1427 <property name="placeholder_text" translatable="yes" context="option|greeter|keyboard">Command to launch on-screen keyboard</property>
1428 </object>
1429 </child>
1430 </object>
1431 <packing>
1432 <property name="left_attach">1</property>
1433 <property name="top_attach">0</property>
1434 </packing>
1435 </child>
1436 </object>
1437 <packing>
1438 <property name="left_attach">0</property>
1439 <property name="top_attach">1</property>
13681440 <property name="width">2</property>
13691441 </packing>
13701442 </child>
13831455 <packing>
13841456 <property name="position">3</property>
13851457 <property name="tab_expand">True</property>
1458 <property name="tab_fill">False</property>
13861459 </packing>
13871460 </child>
13881461 </object>
9292 'position': (PositionEntry.PositionEntry, '50%,center'),
9393 # Misc
9494 'screensaver-timeout': (OptionEntry.AdjustmentEntry, 60),
95 'keyboard': (OptionEntry.StringEntry, None)
95 'keyboard': (OptionEntry.StringPathEntry, None),
96 'reader': (OptionEntry.StringPathEntry, None)
9697 }),
9798 MonitorsGroup(self._widgets)
9899 )
1616
1717 from builtins import isinstance
1818 from collections import OrderedDict
19 from locale import gettext as _
1920 import os
2021 import time
2122
2829 from lightdm_gtk_greeter_settings.helpers import string2bool, bool2string
2930
3031
31 __all__ = ['BaseEntry', 'BooleanEntry', 'StringEntry', 'ClockFormatEntry',
32 __all__ = ['BaseEntry', 'BooleanEntry', 'StringEntry', 'StringPathEntry', 'ClockFormatEntry',
3233 'BackgroundEntry', 'IconEntry', 'IndicatorsEntry',
3334 'AdjustmentEntry', 'ChoiceEntry']
3435
151152
152153 def _set_enabled(self, value):
153154 self._value.props.sensitive = value
155
156
157 class StringPathEntry(BaseEntry):
158
159 def __init__(self, widgets):
160 super().__init__(widgets)
161
162 self._file_dialog = None
163
164 self._combo = widgets['combo']
165 self._entry = widgets['entry']
166
167 self._entry.connect('changed', self._emit_changed)
168 self._combo.connect('format-entry-text', self._on_combobox_format)
169
170 self._combo.set_row_separator_func(self._row_separator_callback, None)
171
172 def _get_value(self):
173 return self._entry.props.text
174
175 def _set_value(self, value):
176 self._entry.props.text = value or ''
177
178 def _set_enabled(self, value):
179 self._combo.props.sensitive = value
180
181 def _row_separator_callback(self, model, rowiter, data):
182 return model[rowiter][0] == '-'
183
184 def _on_combobox_format(self, combobox, path):
185 value = ''
186 item_id = combobox.get_active_id()
187 if item_id == 'select-path':
188 if not self._file_dialog:
189 self._file_dialog = Gtk.FileChooserDialog(
190 parent=self._combo.get_toplevel(),
191 buttons=(_('_OK'), Gtk.ResponseType.OK,
192 _('_Cancel'), Gtk.ResponseType.CANCEL),
193 title=C_('option|StringPathEntry', 'Select path'))
194 if self._file_dialog.run() == Gtk.ResponseType.OK:
195 value = self._file_dialog.get_filename()
196 else:
197 value = combobox.get_active_text()
198 self._file_dialog.hide()
199 elif item_id == 'value':
200 value = combobox.props.model[path][0]
201 combobox.set_active(-1)
202 return value
154203
155204
156205 class AdjustmentEntry(BaseEntry):