"greeter/indicators" - revert to 1.9
Andrew P.
9 years ago
0 | 0 | <?xml version="1.0" encoding="UTF-8"?> |
1 | <!-- Generated with glade 3.16.1 --> | |
1 | <!-- Generated with glade 3.18.3 --> | |
2 | 2 | <interface> |
3 | 3 | <requires lib="gtk+" version="3.8"/> |
4 | <!-- interface-requires gtk_greeter_settings 1.0 --> | |
4 | <requires lib="gtk_greeter_settings" version="1.0"/> | |
5 | 5 | <object class="GtkImage" id="image1"> |
6 | 6 | <property name="visible">True</property> |
7 | 7 | <property name="can_focus">False</property> |
92 | 92 | <property name="margin_bottom">8</property> |
93 | 93 | <property name="orientation">vertical</property> |
94 | 94 | <property name="spacing">8</property> |
95 | <child> | |
96 | <object class="GtkBox" id="box2"> | |
97 | <property name="visible">True</property> | |
98 | <property name="can_focus">False</property> | |
99 | <property name="spacing">6</property> | |
100 | <child> | |
101 | <object class="GtkRadioButton" id="option_type_indicator_choice"> | |
102 | <property name="label" translatable="yes" context="option-entry|indicators">Indicator</property> | |
103 | <property name="visible">True</property> | |
104 | <property name="can_focus">True</property> | |
105 | <property name="receives_default">False</property> | |
106 | <property name="xalign">0</property> | |
107 | <property name="active">True</property> | |
108 | <property name="draw_indicator">True</property> | |
109 | </object> | |
110 | <packing> | |
111 | <property name="expand">False</property> | |
112 | <property name="fill">True</property> | |
113 | <property name="position">0</property> | |
114 | </packing> | |
115 | </child> | |
116 | <child> | |
117 | <object class="GtkComboBoxText" id="option_type_types"> | |
118 | <property name="visible">True</property> | |
119 | <property name="can_focus">False</property> | |
120 | <signal name="changed" handler="on_option_type_types_changed" swapped="no"/> | |
121 | </object> | |
122 | <packing> | |
123 | <property name="expand">False</property> | |
124 | <property name="fill">True</property> | |
125 | <property name="position">1</property> | |
126 | </packing> | |
127 | </child> | |
128 | </object> | |
129 | <packing> | |
130 | <property name="expand">False</property> | |
131 | <property name="fill">True</property> | |
132 | <property name="position">0</property> | |
133 | </packing> | |
134 | </child> | |
135 | 95 | <child internal-child="action_area"> |
136 | 96 | <object class="GtkButtonBox" id="dialog-action_area1"> |
137 | 97 | <property name="can_focus">False</property> |
205 | 165 | <property name="expand">False</property> |
206 | 166 | <property name="fill">True</property> |
207 | 167 | <property name="pack_type">end</property> |
168 | <property name="position">0</property> | |
169 | </packing> | |
170 | </child> | |
171 | <child> | |
172 | <object class="GtkBox" id="box2"> | |
173 | <property name="visible">True</property> | |
174 | <property name="can_focus">False</property> | |
175 | <property name="spacing">6</property> | |
176 | <child> | |
177 | <object class="GtkRadioButton" id="option_type_indicator_choice"> | |
178 | <property name="label" translatable="yes" context="option-entry|indicators">Indicator</property> | |
179 | <property name="visible">True</property> | |
180 | <property name="can_focus">True</property> | |
181 | <property name="receives_default">False</property> | |
182 | <property name="xalign">0</property> | |
183 | <property name="active">True</property> | |
184 | <property name="draw_indicator">True</property> | |
185 | </object> | |
186 | <packing> | |
187 | <property name="expand">False</property> | |
188 | <property name="fill">True</property> | |
189 | <property name="position">0</property> | |
190 | </packing> | |
191 | </child> | |
192 | <child> | |
193 | <object class="GtkComboBoxText" id="option_type_types"> | |
194 | <property name="visible">True</property> | |
195 | <property name="can_focus">False</property> | |
196 | <signal name="changed" handler="on_option_type_types_changed" swapped="no"/> | |
197 | </object> | |
198 | <packing> | |
199 | <property name="expand">False</property> | |
200 | <property name="fill">True</property> | |
201 | <property name="position">1</property> | |
202 | </packing> | |
203 | </child> | |
204 | </object> | |
205 | <packing> | |
206 | <property name="expand">False</property> | |
207 | <property name="fill">True</property> | |
208 | 208 | <property name="position">0</property> |
209 | 209 | </packing> |
210 | 210 | </child> |
216 | 216 | <property name="orientation">vertical</property> |
217 | 217 | <property name="spacing">4</property> |
218 | 218 | <child> |
219 | <object class="GtkGrid" id="grid1"> | |
219 | <object class="GtkGrid" id="common_options_box"> | |
220 | 220 | <property name="visible">True</property> |
221 | 221 | <property name="can_focus">False</property> |
222 | 222 | <property name="row_spacing">8</property> |
233 | 233 | <packing> |
234 | 234 | <property name="left_attach">0</property> |
235 | 235 | <property name="top_attach">0</property> |
236 | <property name="width">1</property> | |
237 | <property name="height">1</property> | |
238 | 236 | </packing> |
239 | 237 | </child> |
240 | 238 | <child> |
247 | 245 | <packing> |
248 | 246 | <property name="left_attach">1</property> |
249 | 247 | <property name="top_attach">0</property> |
250 | <property name="width">1</property> | |
251 | <property name="height">1</property> | |
252 | 248 | </packing> |
253 | 249 | </child> |
254 | 250 | <child> |
263 | 259 | <packing> |
264 | 260 | <property name="left_attach">0</property> |
265 | 261 | <property name="top_attach">1</property> |
266 | <property name="width">1</property> | |
267 | <property name="height">1</property> | |
268 | 262 | </packing> |
269 | 263 | </child> |
270 | 264 | <child> |
314 | 308 | <packing> |
315 | 309 | <property name="left_attach">1</property> |
316 | 310 | <property name="top_attach">1</property> |
317 | <property name="width">1</property> | |
318 | <property name="height">1</property> | |
319 | 311 | </packing> |
320 | 312 | </child> |
321 | 313 | </object> |
395 | 387 | </packing> |
396 | 388 | </child> |
397 | 389 | <child> |
398 | <object class="GtkBox" id="options_power"> | |
390 | <object class="GtkBox" id="custom_options_power"> | |
399 | 391 | <property name="can_focus">False</property> |
400 | 392 | <property name="orientation">vertical</property> |
401 | 393 | <child> |
429 | 421 | <property name="tab_fill">False</property> |
430 | 422 | </packing> |
431 | 423 | </child> |
424 | <child> | |
425 | <object class="GtkBox" id="custom_options_text"> | |
426 | <property name="visible">True</property> | |
427 | <property name="can_focus">False</property> | |
428 | <property name="orientation">vertical</property> | |
429 | <property name="spacing">4</property> | |
430 | <child> | |
431 | <object class="GtkLabel" id="label5"> | |
432 | <property name="visible">True</property> | |
433 | <property name="can_focus">False</property> | |
434 | <property name="halign">start</property> | |
435 | <property name="label" translatable="yes" context="option-entry|indicators">Text to display:</property> | |
436 | </object> | |
437 | <packing> | |
438 | <property name="expand">False</property> | |
439 | <property name="fill">True</property> | |
440 | <property name="position">0</property> | |
441 | </packing> | |
442 | </child> | |
443 | <child> | |
444 | <object class="GtkEntry" id="option_text_fallback_value"> | |
445 | <property name="visible">True</property> | |
446 | <property name="can_focus">True</property> | |
447 | </object> | |
448 | <packing> | |
449 | <property name="expand">False</property> | |
450 | <property name="fill">True</property> | |
451 | <property name="position">1</property> | |
452 | </packing> | |
453 | </child> | |
454 | </object> | |
455 | <packing> | |
456 | <property name="position">2</property> | |
457 | </packing> | |
458 | </child> | |
459 | <child type="tab"> | |
460 | <object class="GtkLabel" id="label4"> | |
461 | <property name="visible">True</property> | |
462 | <property name="can_focus">False</property> | |
463 | <property name="label" translatable="yes">page 3</property> | |
464 | </object> | |
465 | <packing> | |
466 | <property name="position">2</property> | |
467 | <property name="tab_fill">False</property> | |
468 | </packing> | |
469 | </child> | |
432 | 470 | </object> |
433 | 471 | <packing> |
434 | 472 | <property name="expand">False</property> |
230 | 230 | return |
231 | 231 | |
232 | 232 | if not self._entry_menu: |
233 | def new_reset_item(): | |
233 | def new_item(activate=None): | |
234 | 234 | item = Gtk.MenuItem('') |
235 | 235 | item.get_child().props.use_markup = True |
236 | 236 | item.get_child().props.ellipsize = Pango.EllipsizeMode.END |
237 | 237 | item.get_child().props.max_width_chars = 90 |
238 | item.connect('activate', self.on_entry_reset_clicked) | |
238 | if activate: | |
239 | item.connect('activate', activate) | |
240 | else: | |
241 | item.props.sensitive = False | |
239 | 242 | return item |
240 | 243 | |
241 | 244 | self._entry_menu = Gtk.Menu() |
242 | self._entry_menu_label_item = Gtk.MenuItem() | |
243 | self._entry_menu_label_item.props.sensitive = False | |
245 | self._entry_menu_label_item = new_item() | |
244 | 246 | self._entry_menu_separator_item = Gtk.SeparatorMenuItem() |
245 | self._entry_menu_initial_item = new_reset_item() | |
246 | self._entry_menu_default_item = new_reset_item() | |
247 | self._entry_menu_initial_item = new_item(self.on_entry_reset_clicked) | |
248 | self._entry_menu_default_item = new_item(self.on_entry_reset_clicked) | |
247 | 249 | |
248 | 250 | self._entry_menu.append(self._entry_menu_label_item) |
249 | 251 | self._entry_menu.append(self._entry_menu_separator_item) |
251 | 253 | self._entry_menu.append(self._entry_menu_default_item) |
252 | 254 | self._entry_menu.show_all() |
253 | 255 | |
254 | self._entry_menu_label_item.props.label = '%s/%s' % (group.name, key) | |
256 | def format_value(value=None, enabled=None): | |
257 | if enabled is not None: | |
258 | return _('<i>enabled</i>') if initial.enabled else _('<i>disabled</i>') | |
259 | if value == '': | |
260 | return _('<i>empty string</i>') | |
261 | elif value is None: | |
262 | return _('<i>None</i>') | |
263 | else: | |
264 | return escape_markup(str(value)) | |
265 | ||
266 | self._entry_menu_label_item.props.label = '{key} = {value}'.format( | |
267 | group=group.name, | |
268 | key=key, | |
269 | value=format_value(value=entry.value)) | |
255 | 270 | |
256 | 271 | if entry in self._changed_entries: |
257 | 272 | initial = self._initial_values[entry] |
258 | 273 | if entry.enabled != initial.enabled and not initial.enabled: |
259 | value = _('<i>enabled</i>') if initial.enabled else _('<i>disabled</i>') | |
274 | value = format_value(enabled=initial.enabled) | |
260 | 275 | self._entry_menu_initial_item._reset_entry_data = entry, None, initial.enabled |
261 | 276 | else: |
262 | if initial.value == '': | |
263 | value = _('<i>empty string</i>') | |
264 | else: | |
265 | value = escape_markup(str(initial.value)) | |
277 | value = format_value(value=initial.value) | |
266 | 278 | self._entry_menu_initial_item._reset_entry_data = entry, initial.value, None |
267 | 279 | |
268 | 280 | self._entry_menu_initial_item.set_tooltip_markup(value) |
274 | 286 | |
275 | 287 | default = group.defaults[key] |
276 | 288 | if default is not None and entry.value != default: |
277 | if default == '': | |
278 | value = _('<i>empty string</i>') | |
279 | else: | |
280 | value = escape_markup(str(default)) | |
281 | ||
289 | value = format_value(value=default) | |
282 | 290 | self._entry_menu_default_item._reset_entry_data = entry, default, None |
283 | 291 | self._entry_menu_default_item.set_tooltip_markup(value) |
284 | 292 | self._entry_menu_default_item.props.visible = True |
28 | 28 | bool2string, |
29 | 29 | string2bool, |
30 | 30 | get_data_path, |
31 | get_greeter_version, | |
31 | 32 | SimpleEnum, |
32 | 33 | WidgetsEnum, |
33 | 34 | WidgetsWrapper) |
144 | 145 | ok = 'ok_button' |
145 | 146 | infobar = 'infobar' |
146 | 147 | message = 'message' |
148 | common_options = 'common_options_box' | |
147 | 149 | custom_options = 'custom_options_box' |
148 | 150 | path = 'option_path_combo' |
149 | 151 | path_model = 'option_path_model' |
174 | 176 | name = Gtk.Buildable.get_name(page) |
175 | 177 | self._name2page['~' + name.rsplit('_')[-1]] = i |
176 | 178 | |
179 | if get_greeter_version() < 0x020100: | |
180 | self._widgets.common_options.props.visible = False | |
181 | ||
182 | self._name2page = { | |
183 | Indicators.External: self._name2page[Indicators.External], | |
184 | Indicators.Text: self._name2page[Indicators.Text]} | |
185 | text_prefix = 'option_text_fallback' | |
186 | else: | |
187 | self._name2page[Indicators.Text] = -1 | |
188 | text_prefix = 'option_text' | |
189 | ||
177 | 190 | self._option_type = IndicatorTypeEntry(WidgetsWrapper(self.builder, 'option_type')) |
178 | self._option_text = OptionEntry.StringEntry(WidgetsWrapper(self.builder, 'option_text')) | |
191 | self._option_text = OptionEntry.StringEntry(WidgetsWrapper(self.builder, text_prefix)) | |
179 | 192 | self._option_image = IndicatorIconEntry(WidgetsWrapper(self.builder, 'option_image')) |
180 | 193 | self._option_path = IndicatorPath(WidgetsWrapper(self.builder, 'option_path')) |
181 | 194 | self._option_hide_disabled = \ |
26 | 26 | |
27 | 27 | from lightdm_gtk_greeter_settings.helpers import ( |
28 | 28 | C_, |
29 | get_greeter_version, | |
29 | 30 | get_markup_error, |
30 | 31 | SimpleEnum, |
31 | 32 | TreeStoreDataWrapper) |
172 | 173 | def __init__(self, widgets): |
173 | 174 | super().__init__(widgets) |
174 | 175 | |
176 | if get_greeter_version() < 0x020100: | |
177 | self._get_value = self._get_value_19 | |
178 | self._on_button_release = self._on_button_release_19 | |
179 | ||
175 | 180 | for k, v in self.DefaultOptions.items(): |
176 | 181 | v[Option.Name] = k |
177 | 182 | |
258 | 263 | items.append(fix_token(name) + ': ' + ', '.join(values)) |
259 | 264 | return '; '.join(items) |
260 | 265 | |
266 | def _get_value_19(self): | |
267 | ||
268 | items = [] | |
269 | for row in self._model: | |
270 | if row[Row.HasState] and not row[Row.State]: | |
271 | continue | |
272 | ||
273 | options = deepcopy(row[Row.Options].data) | |
274 | name = options.pop(Option.Name) | |
275 | ||
276 | # name=~text, text=value -> ~~value | |
277 | if name == Indicators.Text: | |
278 | name = '~~' + (options.pop(Option.Text, None) or '') | |
279 | elif name == Indicators.External: | |
280 | name = options.pop(Option.Path, None) or '' | |
281 | ||
282 | items.append(name) | |
283 | return ';'.join(items) | |
284 | ||
261 | 285 | def _set_value(self, value): |
262 | 286 | with self._model.handler_block(self._on_row_deleted_id): |
263 | 287 | self._model.clear() |
420 | 444 | else: |
421 | 445 | markup = title |
422 | 446 | |
423 | if Option.Image in options: | |
424 | icon = options[Option.Image] | |
447 | if Option.Image in options or get_greeter_version() < 0x020100: | |
448 | icon = options.get(Option.Image) | |
425 | 449 | if icon and icon.startswith('#'): |
426 | 450 | icon = icon[1:] |
427 | 451 | elif icon: |
600 | 624 | |
601 | 625 | return True |
602 | 626 | |
627 | def _on_button_release_19(self, treeview, event): | |
628 | pass | |
629 | ||
603 | 630 | def _on_row_menu_reset_clicked(self, item): |
604 | 631 | model, rowiter = self._selection.get_selected() |
605 | 632 | if rowiter: |
63 | 63 | 'file_is_readable_by_greeter', |
64 | 64 | 'get_config_path', |
65 | 65 | 'get_data_path', |
66 | 'get_greeter_version' | |
66 | 67 | 'get_markup_error', |
67 | 68 | 'get_version', |
68 | 69 | 'ModelRowEnum', |
100 | 101 | |
101 | 102 | def get_version(): |
102 | 103 | return __version__ |
104 | ||
105 | ||
106 | def get_greeter_version(): | |
107 | try: | |
108 | return get_greeter_version._version | |
109 | except AttributeError: | |
110 | try: | |
111 | get_greeter_version._version = int(os.getenv('GTK_GREETER_VERSION', '0x010900'), 16) | |
112 | except ValueError: | |
113 | get_greeter_version._version = 0x010900 | |
114 | ||
115 | return get_greeter_version._version | |
103 | 116 | |
104 | 117 | |
105 | 118 | def bool2string(value): |