Codebase list lightdm-gtk-greeter-settings / 556be22
Value check for "multihead/background" option Andrew P. 9 years ago
2 changed file(s) with 34 addition(s) and 3 deletion(s). Raw diff Collapse all Expand all
5959 <column type="GdkPixbuf"/>
6060 <!-- column-name background-is-color -->
6161 <column type="gboolean"/>
62 <!-- column-name error-visible -->
63 <column type="gboolean"/>
64 <!-- column-name error-text -->
65 <column type="gchararray"/>
6266 </columns>
6367 </object>
6468 <object class="MultiheadSetupDialog" id="multihead_setup_dialog">
167171 </object>
168172 <attributes>
169173 <attribute name="text">0</attribute>
174 </attributes>
175 </child>
176 <child>
177 <object class="GtkCellRendererPixbuf" id="error_renderer">
178 <property name="icon_name">dialog-warning</property>
179 </object>
180 <attributes>
181 <attribute name="visible">8</attribute>
170182 </attributes>
171183 </child>
172184 </object>
1515 # with this program. If not, see <http://www.gnu.org/licenses/>.
1616
1717
18 import os
1819 from builtins import max
1920 from locale import gettext as _
2021 from gi.repository import Gtk, Gdk, GdkPixbuf
2930 ROW = ModelRowEnum('NAME', 'BACKGROUND',
3031 'USER_BG', 'USER_BG_DISABLED',
3132 'LAPTOP', 'LAPTOP_DISABLED',
32 'BACKGROUND_PIXBUF', 'BACKGROUND_IS_COLOR')
33 'BACKGROUND_PIXBUF', 'BACKGROUND_IS_COLOR',
34 'ERROR_VISIBLE', 'ERROR_TEXT')
3335
3436 BG_ROW = ModelRowEnum('TEXT', 'TYPE')
3537
6466 self._invalid_name_dialog = None
6567 self._name_exists_dialog = None
6668
69 self._treeview.props.tooltip_column = ROW.ERROR_TEXT
6770 self._bg_renderer.set_property('placeholder-text',
6871 C_('option|multihead', 'Use default value'))
6972
8689 LAPTOP=entry['laptop'],
8790 LAPTOP_DISABLED=entry['laptop'] is None,
8891 BACKGROUND_PIXBUF=None,
89 BACKGROUND_IS_COLOR=False))
92 BACKGROUND_IS_COLOR=False,
93 ERROR_VISIBLE=False,
94 ERROR_TEXT=None))
9095 self._update_row_appearance(rowiter)
9196 screen = Gdk.Screen.get_default()
9297 self._available_monitors = [screen.get_monitor_plug_name(i)
106111 row = self._model[rowiter]
107112 bg = row[ROW.BACKGROUND]
108113
114 error = None
109115 color = Gdk.color_parse(bg)
110116 if color:
111117 pixbuf = row[ROW.BACKGROUND_PIXBUF]
120126 row[ROW.BACKGROUND_IS_COLOR] = True
121127 else:
122128 row[ROW.BACKGROUND_IS_COLOR] = False
129 if not os.path.exists(bg):
130 error = C_('option|multihead', 'File not found: {path}'.format(path=bg))
131 else:
132 try:
133 if not helpers.file_is_readable_by_greeter(bg):
134 error = C_('option|multihead', 'File may be not readable for greeter: {path}'.format(path=bg))
135 except:
136 error = C_('option|multihead', 'Failed to check permissions for file: {path}'.format(path=bg))
137
138 row[ROW.ERROR_VISIBLE] = error is not None
139 row[ROW.ERROR_TEXT] = error
123140
124141 _TOGGLE_STATES = {None: True, False: None, True: False}
125142
146163 LAPTOP_ENABLED=False,
147164 BACKGROUND='',
148165 BACKGROUND_PIXBUF=None,
149 BACKGROUND_IS_COLOR=False))
166 BACKGROUND_IS_COLOR=False,
167 ERROR_VISIBLE=False,
168 ERROR_TEXT=None))
150169 self._treeview.set_cursor(self._model.get_path(rowiter), self._name_column, True)
151170
152171 def on_monitors_remove_clicked(self, button):