Package list lightdm-gtk-greeter-settings / c266251
BaseEntry - replacing widgets_to_disable.append() by add_controlled_by_state_widget() Andrew P. 7 years ago
2 changed file(s) with 25 addition(s) and 22 deletion(s). Raw diff Collapse all Expand all
4747 self._image = widgets['image']
4848 self._button = widgets['button']
4949 self._button.props.popup = Gtk.Menu()
50 self._widgets_to_disable.append(self._button)
5150 self._icon_dialog = None
5251 self._path_dialog = None
5352 self._current_item = None
53
54 self._add_controlled_by_state_widget(self._button)
5455
5556 self._items = []
5657 for priority, (update, ask) in self._get_items():
4848 def __init__(self, widgets):
4949 super().__init__()
5050 self._widgets = widgets
51 self._widgets_to_disable = []
51 self.__widgets_to_disable = []
5252
5353 self.__use = widgets['use']
5454 if self.__use:
5555 self.__use.connect('notify::active', self.__on_use_toggled)
5656
57 label_holder = widgets['label_holder']
58 if label_holder:
59 label_holder.connect('button-press-event', self.__on_label_clicked)
60
6157 self.__error = widgets['error']
58
59 self._add_label_widget(widgets['label_holder'])
6260
6361 @property
6462 def value(self):
142140 def _set_enabled(self, value):
143141 if self.__use:
144142 self.__use.set_active(value)
145 if self._widgets_to_disable:
146 for widget in self._widgets_to_disable:
147 widget.props.sensitive = value
143 for widget in self.__widgets_to_disable:
144 widget.props.sensitive = value
148145 self._emit_changed()
146
147 def _add_label_widget(self, *widgets):
148 for widget in widgets:
149 if widget:
150 widget.connect('button-press-event', self.__on_label_clicked)
151
152 def _add_controlled_by_state_widget(self, *widgets):
153 self.__widgets_to_disable += widgets
149154
150155 def _show_menu(self):
151156 self.__on_label_clicked()
167172 super().__init__(widgets)
168173 self._value = widgets['value']
169174 self._value.connect('notify::active', self._emit_changed)
170 self._widgets_to_disable.append(self._value)
175 self._add_controlled_by_state_widget(self._value)
171176
172177 def _get_value(self):
173178 return bool2string(self._value.props.active)
193198 def __init__(self, widgets):
194199 super().__init__(widgets)
195200 self._value = widgets['value']
196 self._widgets_to_disable.append(self._value)
201 self._add_controlled_by_state_widget(self._value)
197202 if isinstance(self._value.props.parent, Gtk.ComboBox):
198 self._widgets_to_disable += [self._value.props.parent]
203 self._add_controlled_by_state_widget(self._value.props.parent)
199204 self._value.connect('changed', self._emit_changed)
200205
201206 def _get_value(self):
220225 super().__init__(widgets)
221226
222227 self._file_dialog = None
223
224228 self._combo = widgets['combo']
225229 self._entry = widgets['entry']
226 self._widgets_to_disable.append(self._combo)
227230 self._filters = ()
231 self._add_controlled_by_state_widget(self._combo)
228232
229233 self._entry.connect('changed', self._emit_changed)
230234 self._combo.connect('format-entry-text', self._on_combobox_format)
276280 def __init__(self, widgets):
277281 super().__init__(widgets)
278282 self._value = widgets['adjustment']
283 self._value.connect('value-changed', self._emit_changed)
279284 self._view = widgets['view']
280 self._widgets_to_disable.append(self._view)
281 self._value.connect('value-changed', self._emit_changed)
285 self._add_controlled_by_state_widget(self._view)
282286
283287 def _get_value(self):
284288 return str(self._value.props.value)
295299 def __init__(self, widgets):
296300 super().__init__(widgets)
297301 self._value = widgets['value']
298 self._widgets_to_disable.append(self._value)
299302 self._value.connect('changed', self._emit_changed)
303 self._add_controlled_by_state_widget(self._value)
300304
301305 def _get_value(self):
302306 return self._value.props.active_id
327331 self._image_value = widgets['image_value']
328332 self._color_value = widgets['color_value']
329333
330 self._widgets_to_disable.append(self._image_choice)
331 self._widgets_to_disable.append(self._color_choice)
332 self._widgets_to_disable.append(self._image_value)
333 self._widgets_to_disable.append(self._color_value)
334 self._add_controlled_by_state_widget(self._image_choice, self._color_choice,
335 self._image_value, self._color_value)
334336
335337 self._on_choice_id = self._color_choice.connect('toggled', self._on_color_choice_toggled)
336338 self._color_value.connect('color-set', self._on_color_set)
387389 def __init__(self, widgets):
388390 super().__init__(widgets)
389391 self._value = widgets['value']
390 self._widgets_to_disable.append(self._value)
391392 self._value.connect('font-set', self._emit_changed)
393 self._add_controlled_by_state_widget(self._value)
392394
393395 def _get_value(self):
394396 return self._value.get_font_name()