Codebase list lightdm-gtk-greeter-settings / df2a618
"greeter/indicators" - revert to 1.9 Andrew P. 9 years ago
5 changed file(s) with 171 addition(s) and 72 deletion(s). Raw diff Collapse all Expand all
00 <?xml version="1.0" encoding="UTF-8"?>
1 <!-- Generated with glade 3.16.1 -->
1 <!-- Generated with glade 3.18.3 -->
22 <interface>
33 <requires lib="gtk+" version="3.8"/>
4 <!-- interface-requires gtk_greeter_settings 1.0 -->
4 <requires lib="gtk_greeter_settings" version="1.0"/>
55 <object class="GtkImage" id="image1">
66 <property name="visible">True</property>
77 <property name="can_focus">False</property>
9292 <property name="margin_bottom">8</property>
9393 <property name="orientation">vertical</property>
9494 <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>
13595 <child internal-child="action_area">
13696 <object class="GtkButtonBox" id="dialog-action_area1">
13797 <property name="can_focus">False</property>
205165 <property name="expand">False</property>
206166 <property name="fill">True</property>
207167 <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>
208208 <property name="position">0</property>
209209 </packing>
210210 </child>
216216 <property name="orientation">vertical</property>
217217 <property name="spacing">4</property>
218218 <child>
219 <object class="GtkGrid" id="grid1">
219 <object class="GtkGrid" id="common_options_box">
220220 <property name="visible">True</property>
221221 <property name="can_focus">False</property>
222222 <property name="row_spacing">8</property>
233233 <packing>
234234 <property name="left_attach">0</property>
235235 <property name="top_attach">0</property>
236 <property name="width">1</property>
237 <property name="height">1</property>
238236 </packing>
239237 </child>
240238 <child>
247245 <packing>
248246 <property name="left_attach">1</property>
249247 <property name="top_attach">0</property>
250 <property name="width">1</property>
251 <property name="height">1</property>
252248 </packing>
253249 </child>
254250 <child>
263259 <packing>
264260 <property name="left_attach">0</property>
265261 <property name="top_attach">1</property>
266 <property name="width">1</property>
267 <property name="height">1</property>
268262 </packing>
269263 </child>
270264 <child>
314308 <packing>
315309 <property name="left_attach">1</property>
316310 <property name="top_attach">1</property>
317 <property name="width">1</property>
318 <property name="height">1</property>
319311 </packing>
320312 </child>
321313 </object>
395387 </packing>
396388 </child>
397389 <child>
398 <object class="GtkBox" id="options_power">
390 <object class="GtkBox" id="custom_options_power">
399391 <property name="can_focus">False</property>
400392 <property name="orientation">vertical</property>
401393 <child>
429421 <property name="tab_fill">False</property>
430422 </packing>
431423 </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>
432470 </object>
433471 <packing>
434472 <property name="expand">False</property>
230230 return
231231
232232 if not self._entry_menu:
233 def new_reset_item():
233 def new_item(activate=None):
234234 item = Gtk.MenuItem('')
235235 item.get_child().props.use_markup = True
236236 item.get_child().props.ellipsize = Pango.EllipsizeMode.END
237237 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
239242 return item
240243
241244 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()
244246 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)
247249
248250 self._entry_menu.append(self._entry_menu_label_item)
249251 self._entry_menu.append(self._entry_menu_separator_item)
251253 self._entry_menu.append(self._entry_menu_default_item)
252254 self._entry_menu.show_all()
253255
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))
255270
256271 if entry in self._changed_entries:
257272 initial = self._initial_values[entry]
258273 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)
260275 self._entry_menu_initial_item._reset_entry_data = entry, None, initial.enabled
261276 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)
266278 self._entry_menu_initial_item._reset_entry_data = entry, initial.value, None
267279
268280 self._entry_menu_initial_item.set_tooltip_markup(value)
274286
275287 default = group.defaults[key]
276288 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)
282290 self._entry_menu_default_item._reset_entry_data = entry, default, None
283291 self._entry_menu_default_item.set_tooltip_markup(value)
284292 self._entry_menu_default_item.props.visible = True
2828 bool2string,
2929 string2bool,
3030 get_data_path,
31 get_greeter_version,
3132 SimpleEnum,
3233 WidgetsEnum,
3334 WidgetsWrapper)
144145 ok = 'ok_button'
145146 infobar = 'infobar'
146147 message = 'message'
148 common_options = 'common_options_box'
147149 custom_options = 'custom_options_box'
148150 path = 'option_path_combo'
149151 path_model = 'option_path_model'
174176 name = Gtk.Buildable.get_name(page)
175177 self._name2page['~' + name.rsplit('_')[-1]] = i
176178
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
177190 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))
179192 self._option_image = IndicatorIconEntry(WidgetsWrapper(self.builder, 'option_image'))
180193 self._option_path = IndicatorPath(WidgetsWrapper(self.builder, 'option_path'))
181194 self._option_hide_disabled = \
2626
2727 from lightdm_gtk_greeter_settings.helpers import (
2828 C_,
29 get_greeter_version,
2930 get_markup_error,
3031 SimpleEnum,
3132 TreeStoreDataWrapper)
172173 def __init__(self, widgets):
173174 super().__init__(widgets)
174175
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
175180 for k, v in self.DefaultOptions.items():
176181 v[Option.Name] = k
177182
258263 items.append(fix_token(name) + ': ' + ', '.join(values))
259264 return '; '.join(items)
260265
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
261285 def _set_value(self, value):
262286 with self._model.handler_block(self._on_row_deleted_id):
263287 self._model.clear()
420444 else:
421445 markup = title
422446
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)
425449 if icon and icon.startswith('#'):
426450 icon = icon[1:]
427451 elif icon:
600624
601625 return True
602626
627 def _on_button_release_19(self, treeview, event):
628 pass
629
603630 def _on_row_menu_reset_clicked(self, item):
604631 model, rowiter = self._selection.get_selected()
605632 if rowiter:
6363 'file_is_readable_by_greeter',
6464 'get_config_path',
6565 'get_data_path',
66 'get_greeter_version'
6667 'get_markup_error',
6768 'get_version',
6869 'ModelRowEnum',
100101
101102 def get_version():
102103 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
103116
104117
105118 def bool2string(value):