15 | 15 |
# with this program. If not, see <http://www.gnu.org/licenses/>.
|
16 | 16 |
|
17 | 17 |
|
|
18 |
import os
|
18 | 19 |
from builtins import max
|
19 | 20 |
from locale import gettext as _
|
20 | 21 |
from gi.repository import Gtk, Gdk, GdkPixbuf
|
|
29 | 30 |
ROW = ModelRowEnum('NAME', 'BACKGROUND',
|
30 | 31 |
'USER_BG', 'USER_BG_DISABLED',
|
31 | 32 |
'LAPTOP', 'LAPTOP_DISABLED',
|
32 | |
'BACKGROUND_PIXBUF', 'BACKGROUND_IS_COLOR')
|
|
33 |
'BACKGROUND_PIXBUF', 'BACKGROUND_IS_COLOR',
|
|
34 |
'ERROR_VISIBLE', 'ERROR_TEXT')
|
33 | 35 |
|
34 | 36 |
BG_ROW = ModelRowEnum('TEXT', 'TYPE')
|
35 | 37 |
|
|
64 | 66 |
self._invalid_name_dialog = None
|
65 | 67 |
self._name_exists_dialog = None
|
66 | 68 |
|
|
69 |
self._treeview.props.tooltip_column = ROW.ERROR_TEXT
|
67 | 70 |
self._bg_renderer.set_property('placeholder-text',
|
68 | 71 |
C_('option|multihead', 'Use default value'))
|
69 | 72 |
|
|
86 | 89 |
LAPTOP=entry['laptop'],
|
87 | 90 |
LAPTOP_DISABLED=entry['laptop'] is None,
|
88 | 91 |
BACKGROUND_PIXBUF=None,
|
89 | |
BACKGROUND_IS_COLOR=False))
|
|
92 |
BACKGROUND_IS_COLOR=False,
|
|
93 |
ERROR_VISIBLE=False,
|
|
94 |
ERROR_TEXT=None))
|
90 | 95 |
self._update_row_appearance(rowiter)
|
91 | 96 |
screen = Gdk.Screen.get_default()
|
92 | 97 |
self._available_monitors = [screen.get_monitor_plug_name(i)
|
|
106 | 111 |
row = self._model[rowiter]
|
107 | 112 |
bg = row[ROW.BACKGROUND]
|
108 | 113 |
|
|
114 |
error = None
|
109 | 115 |
color = Gdk.color_parse(bg)
|
110 | 116 |
if color:
|
111 | 117 |
pixbuf = row[ROW.BACKGROUND_PIXBUF]
|
|
120 | 126 |
row[ROW.BACKGROUND_IS_COLOR] = True
|
121 | 127 |
else:
|
122 | 128 |
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
|
123 | 140 |
|
124 | 141 |
_TOGGLE_STATES = {None: True, False: None, True: False}
|
125 | 142 |
|
|
146 | 163 |
LAPTOP_ENABLED=False,
|
147 | 164 |
BACKGROUND='',
|
148 | 165 |
BACKGROUND_PIXBUF=None,
|
149 | |
BACKGROUND_IS_COLOR=False))
|
|
166 |
BACKGROUND_IS_COLOR=False,
|
|
167 |
ERROR_VISIBLE=False,
|
|
168 |
ERROR_TEXT=None))
|
150 | 169 |
self._treeview.set_cursor(self._model.get_path(rowiter), self._name_column, True)
|
151 | 170 |
|
152 | 171 |
def on_monitors_remove_clicked(self, button):
|