Merge lp:~noskcaj/ubuntu/wily/redshift/merge2 into lp:ubuntu/wily/redshift
- Wily (15.10)
- merge2
- Merge into wily
Proposed by
Jackson Doak
Status: | Merged |
---|---|
Approved by: | Michael Terry |
Approved revision: | 22 |
Merge reported by: | Michael Terry |
Merged at revision: | not available |
Proposed branch: | lp:~noskcaj/ubuntu/wily/redshift/merge2 |
Merge into: | lp:ubuntu/wily/redshift |
Diff against target: |
1046 lines (+108/-795) 16 files modified
.pc/applied-patches (+0/-2) .pc/remove_autostart.patch/src/redshift-gtk/statusicon.py (+0/-520) .pc/retry-geoclue.patch/src/location-geoclue.c (+0/-217) debian/README.Debian (+0/-24) debian/changelog (+36/-0) debian/control (+1/-1) debian/gbp.conf (+2/-0) debian/patches/add-desktop-file.patch (+34/-0) debian/patches/retry-geoclue.patch (+8/-6) debian/patches/series (+1/-1) debian/redshift-gtk.docs (+0/-1) debian/redshift-gtk.install (+2/-1) debian/redshift.install (+1/-0) debian/rules (+3/-2) src/location-geoclue.c (+8/-20) src/redshift-gtk/statusicon.py (+12/-0) |
To merge this branch: | bzr merge lp:~noskcaj/ubuntu/wily/redshift/merge2 |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Michael Terry | Approve | ||
Review via email: mp+274448@code.launchpad.net |
Commit message
Description of the change
Merge from debian. package is currently broken in wily, this merge is required for it to work as intended
To post a comment you must log in.
Revision history for this message
Michael Terry (mterry) wrote : | # |
Only change was I also fixed the typo in the changelog (rues to rules)
Preview Diff
[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1 | === removed file '.pc/applied-patches' | |||
2 | --- .pc/applied-patches 2014-11-01 17:06:15 +0000 | |||
3 | +++ .pc/applied-patches 1970-01-01 00:00:00 +0000 | |||
4 | @@ -1,2 +0,0 @@ | |||
5 | 1 | remove_autostart.patch | ||
6 | 2 | retry-geoclue.patch | ||
7 | 3 | 0 | ||
8 | === removed directory '.pc/remove_autostart.patch' | |||
9 | === removed directory '.pc/remove_autostart.patch/src' | |||
10 | === removed directory '.pc/remove_autostart.patch/src/redshift-gtk' | |||
11 | === removed file '.pc/remove_autostart.patch/src/redshift-gtk/statusicon.py' | |||
12 | --- .pc/remove_autostart.patch/src/redshift-gtk/statusicon.py 2015-05-24 16:48:08 +0000 | |||
13 | +++ .pc/remove_autostart.patch/src/redshift-gtk/statusicon.py 1970-01-01 00:00:00 +0000 | |||
14 | @@ -1,520 +0,0 @@ | |||
15 | 1 | # statusicon.py -- GUI status icon source | ||
16 | 2 | # This file is part of Redshift. | ||
17 | 3 | |||
18 | 4 | # Redshift is free software: you can redistribute it and/or modify | ||
19 | 5 | # it under the terms of the GNU General Public License as published by | ||
20 | 6 | # the Free Software Foundation, either version 3 of the License, or | ||
21 | 7 | # (at your option) any later version. | ||
22 | 8 | |||
23 | 9 | # Redshift is distributed in the hope that it will be useful, | ||
24 | 10 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
25 | 11 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
26 | 12 | # GNU General Public License for more details. | ||
27 | 13 | |||
28 | 14 | # You should have received a copy of the GNU General Public License | ||
29 | 15 | # along with Redshift. If not, see <http://www.gnu.org/licenses/>. | ||
30 | 16 | |||
31 | 17 | # Copyright (c) 2013-2014 Jon Lund Steffensen <jonlst@gmail.com> | ||
32 | 18 | |||
33 | 19 | |||
34 | 20 | '''GUI status icon for Redshift. | ||
35 | 21 | |||
36 | 22 | The run method will try to start an appindicator for Redshift. If the | ||
37 | 23 | appindicator module isn't present it will fall back to a GTK status icon. | ||
38 | 24 | ''' | ||
39 | 25 | |||
40 | 26 | import sys, os | ||
41 | 27 | import fcntl | ||
42 | 28 | import signal | ||
43 | 29 | import re | ||
44 | 30 | import gettext | ||
45 | 31 | |||
46 | 32 | from gi.repository import Gtk, GLib, GObject | ||
47 | 33 | |||
48 | 34 | try: | ||
49 | 35 | from gi.repository import AppIndicator3 as appindicator | ||
50 | 36 | except ImportError: | ||
51 | 37 | appindicator = None | ||
52 | 38 | |||
53 | 39 | from . import defs | ||
54 | 40 | from . import utils | ||
55 | 41 | |||
56 | 42 | _ = gettext.gettext | ||
57 | 43 | |||
58 | 44 | |||
59 | 45 | class RedshiftController(GObject.GObject): | ||
60 | 46 | '''A GObject wrapper around the child process''' | ||
61 | 47 | |||
62 | 48 | __gsignals__ = { | ||
63 | 49 | 'inhibit-changed': (GObject.SIGNAL_RUN_FIRST, None, (bool,)), | ||
64 | 50 | 'temperature-changed': (GObject.SIGNAL_RUN_FIRST, None, (int,)), | ||
65 | 51 | 'period-changed': (GObject.SIGNAL_RUN_FIRST, None, (str,)), | ||
66 | 52 | 'location-changed': (GObject.SIGNAL_RUN_FIRST, None, (float, float)), | ||
67 | 53 | 'error-occured': (GObject.SIGNAL_RUN_FIRST, None, (str,)) | ||
68 | 54 | } | ||
69 | 55 | |||
70 | 56 | def __init__(self, args): | ||
71 | 57 | '''Initialize controller and start child process | ||
72 | 58 | |||
73 | 59 | The parameter args is a list of command line arguments to pass on to | ||
74 | 60 | the child process. The "-v" argument is automatically added.''' | ||
75 | 61 | |||
76 | 62 | GObject.GObject.__init__(self) | ||
77 | 63 | |||
78 | 64 | # Initialize state variables | ||
79 | 65 | self._inhibited = False | ||
80 | 66 | self._temperature = 0 | ||
81 | 67 | self._period = 'Unknown' | ||
82 | 68 | self._location = (0.0, 0.0) | ||
83 | 69 | |||
84 | 70 | # Start redshift with arguments | ||
85 | 71 | args.insert(0, os.path.join(defs.BINDIR, 'redshift')) | ||
86 | 72 | if '-v' not in args: | ||
87 | 73 | args.insert(1, '-v') | ||
88 | 74 | |||
89 | 75 | # Start child process with C locale so we can parse the output | ||
90 | 76 | env = os.environ.copy() | ||
91 | 77 | env['LANG'] = env['LANGUAGE'] = env['LC_ALL'] = env['LC_MESSAGES'] = 'C' | ||
92 | 78 | self._process = GLib.spawn_async(args, envp=['{}={}'.format(k,v) for k, v in env.items()], | ||
93 | 79 | flags=GLib.SPAWN_DO_NOT_REAP_CHILD, | ||
94 | 80 | standard_output=True, standard_error=True) | ||
95 | 81 | |||
96 | 82 | # Wrap remaining contructor in try..except to avoid that the child | ||
97 | 83 | # process is not closed properly. | ||
98 | 84 | try: | ||
99 | 85 | # Handle child input | ||
100 | 86 | # The buffer is encapsulated in a class so we | ||
101 | 87 | # can pass an instance to the child callback. | ||
102 | 88 | class InputBuffer(object): | ||
103 | 89 | buf = '' | ||
104 | 90 | |||
105 | 91 | self._input_buffer = InputBuffer() | ||
106 | 92 | self._error_buffer = InputBuffer() | ||
107 | 93 | self._errors = '' | ||
108 | 94 | |||
109 | 95 | # Set non blocking | ||
110 | 96 | fcntl.fcntl(self._process[2], fcntl.F_SETFL, | ||
111 | 97 | fcntl.fcntl(self._process[2], fcntl.F_GETFL) | os.O_NONBLOCK) | ||
112 | 98 | |||
113 | 99 | # Add watch on child process | ||
114 | 100 | GLib.child_watch_add(GLib.PRIORITY_DEFAULT, self._process[0], self._child_cb) | ||
115 | 101 | GLib.io_add_watch(self._process[2], GLib.PRIORITY_DEFAULT, GLib.IO_IN, | ||
116 | 102 | self._child_data_cb, (True, self._input_buffer)) | ||
117 | 103 | GLib.io_add_watch(self._process[3], GLib.PRIORITY_DEFAULT, GLib.IO_IN, | ||
118 | 104 | self._child_data_cb, (False, self._error_buffer)) | ||
119 | 105 | |||
120 | 106 | # Signal handler to relay USR1 signal to redshift process | ||
121 | 107 | def relay_signal_handler(signal): | ||
122 | 108 | os.kill(self._process[0], signal) | ||
123 | 109 | return True | ||
124 | 110 | |||
125 | 111 | GLib.unix_signal_add(GLib.PRIORITY_DEFAULT, signal.SIGUSR1, | ||
126 | 112 | relay_signal_handler, signal.SIGUSR1) | ||
127 | 113 | except: | ||
128 | 114 | self.termwait() | ||
129 | 115 | raise | ||
130 | 116 | |||
131 | 117 | @property | ||
132 | 118 | def inhibited(self): | ||
133 | 119 | '''Current inhibition state''' | ||
134 | 120 | return self._inhibited | ||
135 | 121 | |||
136 | 122 | @property | ||
137 | 123 | def temperature(self): | ||
138 | 124 | '''Current screen temperature''' | ||
139 | 125 | return self._temperature | ||
140 | 126 | |||
141 | 127 | @property | ||
142 | 128 | def period(self): | ||
143 | 129 | '''Current period of day''' | ||
144 | 130 | return self._period | ||
145 | 131 | |||
146 | 132 | @property | ||
147 | 133 | def location(self): | ||
148 | 134 | '''Current location''' | ||
149 | 135 | return self._location | ||
150 | 136 | |||
151 | 137 | def set_inhibit(self, inhibit): | ||
152 | 138 | '''Set inhibition state''' | ||
153 | 139 | if inhibit != self._inhibited: | ||
154 | 140 | self._child_toggle_inhibit() | ||
155 | 141 | |||
156 | 142 | def _child_toggle_inhibit(self): | ||
157 | 143 | '''Sends a request to the child process to toggle state''' | ||
158 | 144 | os.kill(self._process[0], signal.SIGUSR1) | ||
159 | 145 | |||
160 | 146 | def _child_cb(self, pid, status, data=None): | ||
161 | 147 | '''Called when the child process exists''' | ||
162 | 148 | |||
163 | 149 | # Empty stdout and stderr | ||
164 | 150 | for f in (self._process[2], self._process[3]): | ||
165 | 151 | while True: | ||
166 | 152 | buf = os.read(f, 256).decode('utf-8') | ||
167 | 153 | if buf == '': | ||
168 | 154 | break | ||
169 | 155 | if f == self._process[3]: # stderr | ||
170 | 156 | self._errors += buf | ||
171 | 157 | |||
172 | 158 | # Check exit status of child | ||
173 | 159 | report_errors = False | ||
174 | 160 | try: | ||
175 | 161 | GLib.spawn_check_exit_status(status) | ||
176 | 162 | Gtk.main_quit() | ||
177 | 163 | except GLib.GError: | ||
178 | 164 | report_errors = True | ||
179 | 165 | |||
180 | 166 | if report_errors: | ||
181 | 167 | self.emit('error-occured', self._errors) | ||
182 | 168 | |||
183 | 169 | def _child_key_change_cb(self, key, value): | ||
184 | 170 | '''Called when the child process reports a change of internal state''' | ||
185 | 171 | |||
186 | 172 | def parse_coord(s): | ||
187 | 173 | '''Parse coordinate like `42.0 N` or `91.5 W`''' | ||
188 | 174 | v, d = s.split(' ') | ||
189 | 175 | return float(v) * (1 if d in 'NE' else -1) | ||
190 | 176 | |||
191 | 177 | if key == 'Status': | ||
192 | 178 | new_inhibited = value != 'Enabled' | ||
193 | 179 | if new_inhibited != self._inhibited: | ||
194 | 180 | self._inhibited = new_inhibited | ||
195 | 181 | self.emit('inhibit-changed', new_inhibited) | ||
196 | 182 | elif key == 'Color temperature': | ||
197 | 183 | new_temperature = int(value.rstrip('K'), 10) | ||
198 | 184 | if new_temperature != self._temperature: | ||
199 | 185 | self._temperature = new_temperature | ||
200 | 186 | self.emit('temperature-changed', new_temperature) | ||
201 | 187 | elif key == 'Period': | ||
202 | 188 | new_period = value | ||
203 | 189 | if new_period != self._period: | ||
204 | 190 | self._period = new_period | ||
205 | 191 | self.emit('period-changed', new_period) | ||
206 | 192 | elif key == 'Location': | ||
207 | 193 | new_location = tuple(parse_coord(x) for x in value.split(', ')) | ||
208 | 194 | if new_location != self._location: | ||
209 | 195 | self._location = new_location | ||
210 | 196 | self.emit('location-changed', *new_location) | ||
211 | 197 | |||
212 | 198 | def _child_stdout_line_cb(self, line): | ||
213 | 199 | '''Called when the child process outputs a line to stdout''' | ||
214 | 200 | if line: | ||
215 | 201 | m = re.match(r'([\w ]+): (.+)', line) | ||
216 | 202 | if m: | ||
217 | 203 | key = m.group(1) | ||
218 | 204 | value = m.group(2) | ||
219 | 205 | self._child_key_change_cb(key, value) | ||
220 | 206 | |||
221 | 207 | def _child_data_cb(self, f, cond, data): | ||
222 | 208 | '''Called when the child process has new data on stdout/stderr''' | ||
223 | 209 | |||
224 | 210 | stdout, ib = data | ||
225 | 211 | ib.buf += os.read(f, 256).decode('utf-8') | ||
226 | 212 | |||
227 | 213 | # Split input at line break | ||
228 | 214 | while True: | ||
229 | 215 | first, sep, last = ib.buf.partition('\n') | ||
230 | 216 | if sep == '': | ||
231 | 217 | break | ||
232 | 218 | ib.buf = last | ||
233 | 219 | if stdout: | ||
234 | 220 | self._child_stdout_line_cb(first) | ||
235 | 221 | else: | ||
236 | 222 | self._errors += first + '\n' | ||
237 | 223 | |||
238 | 224 | return True | ||
239 | 225 | |||
240 | 226 | def termwait(self): | ||
241 | 227 | '''Send SIGINT and wait for the child process to quit''' | ||
242 | 228 | try: | ||
243 | 229 | os.kill(self._process[0], signal.SIGINT) | ||
244 | 230 | os.waitpid(self._process[0], 0) | ||
245 | 231 | except ProcessLookupError: | ||
246 | 232 | # Process has apparently already disappeared | ||
247 | 233 | pass | ||
248 | 234 | |||
249 | 235 | |||
250 | 236 | class RedshiftStatusIcon(object): | ||
251 | 237 | '''The status icon tracking the RedshiftController''' | ||
252 | 238 | |||
253 | 239 | def __init__(self, controller): | ||
254 | 240 | '''Creates a new instance of the status icon''' | ||
255 | 241 | |||
256 | 242 | self._controller = controller | ||
257 | 243 | |||
258 | 244 | if appindicator: | ||
259 | 245 | # Create indicator | ||
260 | 246 | self.indicator = appindicator.Indicator.new('redshift', | ||
261 | 247 | 'redshift-status-on', | ||
262 | 248 | appindicator.IndicatorCategory.APPLICATION_STATUS) | ||
263 | 249 | self.indicator.set_status(appindicator.IndicatorStatus.ACTIVE) | ||
264 | 250 | else: | ||
265 | 251 | # Create status icon | ||
266 | 252 | self.status_icon = Gtk.StatusIcon() | ||
267 | 253 | self.status_icon.set_from_icon_name('redshift-status-on') | ||
268 | 254 | self.status_icon.set_tooltip_text('Redshift') | ||
269 | 255 | |||
270 | 256 | # Create popup menu | ||
271 | 257 | self.status_menu = Gtk.Menu() | ||
272 | 258 | |||
273 | 259 | # Add toggle action | ||
274 | 260 | self.toggle_item = Gtk.CheckMenuItem.new_with_label(_('Enabled')) | ||
275 | 261 | self.toggle_item.connect('activate', self.toggle_item_cb) | ||
276 | 262 | self.status_menu.append(self.toggle_item) | ||
277 | 263 | |||
278 | 264 | # Add suspend menu | ||
279 | 265 | suspend_menu_item = Gtk.MenuItem.new_with_label(_('Suspend for')) | ||
280 | 266 | suspend_menu = Gtk.Menu() | ||
281 | 267 | for minutes, label in [(30, _('30 minutes')), | ||
282 | 268 | (60, _('1 hour')), | ||
283 | 269 | (120, _('2 hours'))]: | ||
284 | 270 | suspend_item = Gtk.MenuItem.new_with_label(label) | ||
285 | 271 | suspend_item.connect('activate', self.suspend_cb, minutes) | ||
286 | 272 | suspend_menu.append(suspend_item) | ||
287 | 273 | suspend_menu_item.set_submenu(suspend_menu) | ||
288 | 274 | self.status_menu.append(suspend_menu_item) | ||
289 | 275 | |||
290 | 276 | # Add autostart option | ||
291 | 277 | autostart_item = Gtk.CheckMenuItem.new_with_label(_('Autostart')) | ||
292 | 278 | try: | ||
293 | 279 | autostart_item.set_active(utils.get_autostart()) | ||
294 | 280 | except IOError as strerror: | ||
295 | 281 | print(strerror) | ||
296 | 282 | autostart_item.set_property('sensitive', False) | ||
297 | 283 | else: | ||
298 | 284 | autostart_item.connect('toggled', self.autostart_cb) | ||
299 | 285 | finally: | ||
300 | 286 | self.status_menu.append(autostart_item) | ||
301 | 287 | |||
302 | 288 | # Add info action | ||
303 | 289 | info_item = Gtk.MenuItem.new_with_label(_('Info')) | ||
304 | 290 | info_item.connect('activate', self.show_info_cb) | ||
305 | 291 | self.status_menu.append(info_item) | ||
306 | 292 | |||
307 | 293 | # Add quit action | ||
308 | 294 | quit_item = Gtk.ImageMenuItem.new_with_label(_('Quit')) | ||
309 | 295 | quit_item.connect('activate', self.destroy_cb) | ||
310 | 296 | self.status_menu.append(quit_item) | ||
311 | 297 | |||
312 | 298 | # Create info dialog | ||
313 | 299 | self.info_dialog = Gtk.Dialog() | ||
314 | 300 | self.info_dialog.set_title(_('Info')) | ||
315 | 301 | self.info_dialog.add_button(_('Close'), Gtk.ButtonsType.CLOSE) | ||
316 | 302 | self.info_dialog.set_resizable(False) | ||
317 | 303 | self.info_dialog.set_property('border-width', 6) | ||
318 | 304 | |||
319 | 305 | self.status_label = Gtk.Label() | ||
320 | 306 | self.status_label.set_alignment(0.0, 0.5) | ||
321 | 307 | self.status_label.set_padding(6, 6) | ||
322 | 308 | self.info_dialog.get_content_area().pack_start(self.status_label, True, True, 0) | ||
323 | 309 | self.status_label.show() | ||
324 | 310 | |||
325 | 311 | self.location_label = Gtk.Label() | ||
326 | 312 | self.location_label.set_alignment(0.0, 0.5) | ||
327 | 313 | self.location_label.set_padding(6, 6) | ||
328 | 314 | self.info_dialog.get_content_area().pack_start(self.location_label, True, True, 0) | ||
329 | 315 | self.location_label.show() | ||
330 | 316 | |||
331 | 317 | self.temperature_label = Gtk.Label() | ||
332 | 318 | self.temperature_label.set_alignment(0.0, 0.5) | ||
333 | 319 | self.temperature_label.set_padding(6, 6) | ||
334 | 320 | self.info_dialog.get_content_area().pack_start(self.temperature_label, True, True, 0) | ||
335 | 321 | self.temperature_label.show() | ||
336 | 322 | |||
337 | 323 | self.period_label = Gtk.Label() | ||
338 | 324 | self.period_label.set_alignment(0.0, 0.5) | ||
339 | 325 | self.period_label.set_padding(6, 6) | ||
340 | 326 | self.info_dialog.get_content_area().pack_start(self.period_label, True, True, 0) | ||
341 | 327 | self.period_label.show() | ||
342 | 328 | |||
343 | 329 | self.info_dialog.connect('response', self.response_info_cb) | ||
344 | 330 | |||
345 | 331 | # Setup signals to property changes | ||
346 | 332 | self._controller.connect('inhibit-changed', self.inhibit_change_cb) | ||
347 | 333 | self._controller.connect('period-changed', self.period_change_cb) | ||
348 | 334 | self._controller.connect('temperature-changed', self.temperature_change_cb) | ||
349 | 335 | self._controller.connect('location-changed', self.location_change_cb) | ||
350 | 336 | self._controller.connect('error-occured', self.error_occured_cb) | ||
351 | 337 | |||
352 | 338 | # Set info box text | ||
353 | 339 | self.change_inhibited(self._controller.inhibited) | ||
354 | 340 | self.change_period(self._controller.period) | ||
355 | 341 | self.change_temperature(self._controller.temperature) | ||
356 | 342 | self.change_location(self._controller.location) | ||
357 | 343 | |||
358 | 344 | if appindicator: | ||
359 | 345 | self.status_menu.show_all() | ||
360 | 346 | |||
361 | 347 | # Set the menu | ||
362 | 348 | self.indicator.set_menu(self.status_menu) | ||
363 | 349 | else: | ||
364 | 350 | # Connect signals for status icon and show | ||
365 | 351 | self.status_icon.connect('activate', self.toggle_cb) | ||
366 | 352 | self.status_icon.connect('popup-menu', self.popup_menu_cb) | ||
367 | 353 | self.status_icon.set_visible(True) | ||
368 | 354 | |||
369 | 355 | # Initialize suspend timer | ||
370 | 356 | self.suspend_timer = None | ||
371 | 357 | |||
372 | 358 | def remove_suspend_timer(self): | ||
373 | 359 | '''Disable any previously set suspend timer''' | ||
374 | 360 | if self.suspend_timer is not None: | ||
375 | 361 | GLib.source_remove(self.suspend_timer) | ||
376 | 362 | self.suspend_timer = None | ||
377 | 363 | |||
378 | 364 | def suspend_cb(self, item, minutes): | ||
379 | 365 | '''Callback that handles activation of a suspend timer | ||
380 | 366 | |||
381 | 367 | The minutes parameter is the number of minutes to suspend. Even if redshift | ||
382 | 368 | is not disabled when called, it will still set a suspend timer and | ||
383 | 369 | reactive redshift when the timer is up.''' | ||
384 | 370 | |||
385 | 371 | # Inhibit | ||
386 | 372 | self._controller.set_inhibit(True) | ||
387 | 373 | |||
388 | 374 | # If "suspend" is clicked while redshift is disabled, we reenable | ||
389 | 375 | # it after the last selected timespan is over. | ||
390 | 376 | self.remove_suspend_timer() | ||
391 | 377 | |||
392 | 378 | # If redshift was already disabled we reenable it nonetheless. | ||
393 | 379 | self.suspend_timer = GLib.timeout_add_seconds(minutes * 60, self.reenable_cb) | ||
394 | 380 | |||
395 | 381 | def reenable_cb(self): | ||
396 | 382 | '''Callback to reenable redshift when a suspend timer expires''' | ||
397 | 383 | self._controller.set_inhibit(False) | ||
398 | 384 | |||
399 | 385 | def popup_menu_cb(self, widget, button, time, data=None): | ||
400 | 386 | '''Callback when the popup menu on the status icon has to open''' | ||
401 | 387 | self.status_menu.show_all() | ||
402 | 388 | self.status_menu.popup(None, None, Gtk.StatusIcon.position_menu, | ||
403 | 389 | self.status_icon, button, time) | ||
404 | 390 | |||
405 | 391 | def toggle_cb(self, widget, data=None): | ||
406 | 392 | '''Callback when a request to toggle redshift was made''' | ||
407 | 393 | self.remove_suspend_timer() | ||
408 | 394 | self._controller.set_inhibit(not self._controller.inhibited) | ||
409 | 395 | |||
410 | 396 | def toggle_item_cb(self, widget, data=None): | ||
411 | 397 | '''Callback then a request to toggle redshift was made from a toggle item | ||
412 | 398 | |||
413 | 399 | This ensures that the state of redshift is synchronised with | ||
414 | 400 | the toggle state of the widget (e.g. Gtk.CheckMenuItem).''' | ||
415 | 401 | |||
416 | 402 | active = not self._controller.inhibited | ||
417 | 403 | if active != widget.get_active(): | ||
418 | 404 | self.remove_suspend_timer() | ||
419 | 405 | self._controller.set_inhibit(not self._controller.inhibited) | ||
420 | 406 | |||
421 | 407 | # Info dialog callbacks | ||
422 | 408 | def show_info_cb(self, widget, data=None): | ||
423 | 409 | '''Callback when the info dialog should be presented''' | ||
424 | 410 | self.info_dialog.show() | ||
425 | 411 | |||
426 | 412 | def response_info_cb(self, widget, data=None): | ||
427 | 413 | '''Callback when a button in the info dialog was activated''' | ||
428 | 414 | self.info_dialog.hide() | ||
429 | 415 | |||
430 | 416 | def update_status_icon(self): | ||
431 | 417 | '''Update the status icon according to the internally recorded state | ||
432 | 418 | |||
433 | 419 | This should be called whenever the internally recorded state | ||
434 | 420 | might have changed.''' | ||
435 | 421 | |||
436 | 422 | # Update status icon | ||
437 | 423 | if appindicator: | ||
438 | 424 | if not self._controller.inhibited: | ||
439 | 425 | self.indicator.set_icon('redshift-status-on') | ||
440 | 426 | else: | ||
441 | 427 | self.indicator.set_icon('redshift-status-off') | ||
442 | 428 | else: | ||
443 | 429 | if not self._controller.inhibited: | ||
444 | 430 | self.status_icon.set_from_icon_name('redshift-status-on') | ||
445 | 431 | else: | ||
446 | 432 | self.status_icon.set_from_icon_name('redshift-status-off') | ||
447 | 433 | |||
448 | 434 | # State update functions | ||
449 | 435 | def inhibit_change_cb(self, controller, inhibit): | ||
450 | 436 | '''Callback when controller changes inhibition status''' | ||
451 | 437 | self.change_inhibited(inhibit) | ||
452 | 438 | |||
453 | 439 | def period_change_cb(self, controller, period): | ||
454 | 440 | '''Callback when controller changes period''' | ||
455 | 441 | self.change_period(period) | ||
456 | 442 | |||
457 | 443 | def temperature_change_cb(self, controller, temperature): | ||
458 | 444 | '''Callback when controller changes temperature''' | ||
459 | 445 | self.change_temperature(temperature) | ||
460 | 446 | |||
461 | 447 | def location_change_cb(self, controller, lat, lon): | ||
462 | 448 | '''Callback when controlled changes location''' | ||
463 | 449 | self.change_location((lat, lon)) | ||
464 | 450 | |||
465 | 451 | def error_occured_cb(self, controller, error): | ||
466 | 452 | '''Callback when an error occurs in the controller''' | ||
467 | 453 | error_dialog = Gtk.MessageDialog(None, Gtk.DialogFlags.MODAL, Gtk.MessageType.ERROR, | ||
468 | 454 | Gtk.ButtonsType.CLOSE, '') | ||
469 | 455 | error_dialog.set_markup('<b>Failed to run Redshift</b>\n<i>' + error + '</i>') | ||
470 | 456 | error_dialog.run() | ||
471 | 457 | |||
472 | 458 | # Quit when the model dialog is closed | ||
473 | 459 | sys.exit(-1) | ||
474 | 460 | |||
475 | 461 | # Update interface | ||
476 | 462 | def change_inhibited(self, inhibited): | ||
477 | 463 | '''Change interface to new inhibition status''' | ||
478 | 464 | self.update_status_icon() | ||
479 | 465 | self.toggle_item.set_active(not inhibited) | ||
480 | 466 | self.status_label.set_markup(_('<b>Status:</b> {}').format(_('Disabled') if inhibited else _('Enabled'))) | ||
481 | 467 | |||
482 | 468 | def change_temperature(self, temperature): | ||
483 | 469 | '''Change interface to new temperature''' | ||
484 | 470 | self.temperature_label.set_markup('<b>{}:</b> {}K'.format(_('Color temperature'), temperature)) | ||
485 | 471 | |||
486 | 472 | def change_period(self, period): | ||
487 | 473 | '''Change interface to new period''' | ||
488 | 474 | self.period_label.set_markup('<b>{}:</b> {}'.format(_('Period'), period)) | ||
489 | 475 | |||
490 | 476 | def change_location(self, location): | ||
491 | 477 | '''Change interface to new location''' | ||
492 | 478 | self.location_label.set_markup('<b>{}:</b> {}, {}'.format(_('Location'), *location)) | ||
493 | 479 | |||
494 | 480 | |||
495 | 481 | def autostart_cb(self, widget, data=None): | ||
496 | 482 | '''Callback when a request to toggle autostart is made''' | ||
497 | 483 | utils.set_autostart(widget.get_active()) | ||
498 | 484 | |||
499 | 485 | def destroy_cb(self, widget, data=None): | ||
500 | 486 | '''Callback when a request to quit the application is made''' | ||
501 | 487 | if not appindicator: | ||
502 | 488 | self.status_icon.set_visible(False) | ||
503 | 489 | Gtk.main_quit() | ||
504 | 490 | return False | ||
505 | 491 | |||
506 | 492 | |||
507 | 493 | def sigterm_handler(data=None): | ||
508 | 494 | sys.exit(0) | ||
509 | 495 | |||
510 | 496 | |||
511 | 497 | def run(): | ||
512 | 498 | utils.setproctitle('redshift-gtk') | ||
513 | 499 | |||
514 | 500 | # Install TERM signal handler | ||
515 | 501 | GLib.unix_signal_add(GLib.PRIORITY_DEFAULT, signal.SIGTERM, | ||
516 | 502 | sigterm_handler, None) | ||
517 | 503 | GLib.unix_signal_add(GLib.PRIORITY_DEFAULT, signal.SIGINT, | ||
518 | 504 | sigterm_handler, None) | ||
519 | 505 | |||
520 | 506 | # Internationalisation | ||
521 | 507 | gettext.bindtextdomain('redshift', defs.LOCALEDIR) | ||
522 | 508 | gettext.textdomain('redshift') | ||
523 | 509 | |||
524 | 510 | # Create redshift child process controller | ||
525 | 511 | c = RedshiftController(sys.argv[1:]) | ||
526 | 512 | try: | ||
527 | 513 | # Create status icon | ||
528 | 514 | s = RedshiftStatusIcon(c) | ||
529 | 515 | |||
530 | 516 | # Run main loop | ||
531 | 517 | Gtk.main() | ||
532 | 518 | finally: | ||
533 | 519 | # Always make sure that the child process is closed | ||
534 | 520 | c.termwait() | ||
535 | 521 | 0 | ||
536 | === removed directory '.pc/retry-geoclue.patch' | |||
537 | === removed directory '.pc/retry-geoclue.patch/src' | |||
538 | === removed file '.pc/retry-geoclue.patch/src/location-geoclue.c' | |||
539 | --- .pc/retry-geoclue.patch/src/location-geoclue.c 2015-06-28 09:25:43 +0000 | |||
540 | +++ .pc/retry-geoclue.patch/src/location-geoclue.c 1970-01-01 00:00:00 +0000 | |||
541 | @@ -1,217 +0,0 @@ | |||
542 | 1 | /* location-geoclue.c -- Geoclue location provider source | ||
543 | 2 | This file is part of Redshift. | ||
544 | 3 | |||
545 | 4 | Redshift is free software: you can redistribute it and/or modify | ||
546 | 5 | it under the terms of the GNU General Public License as published by | ||
547 | 6 | the Free Software Foundation, either version 3 of the License, or | ||
548 | 7 | (at your option) any later version. | ||
549 | 8 | |||
550 | 9 | Redshift is distributed in the hope that it will be useful, | ||
551 | 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
552 | 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
553 | 12 | GNU General Public License for more details. | ||
554 | 13 | |||
555 | 14 | You should have received a copy of the GNU General Public License | ||
556 | 15 | along with Redshift. If not, see <http://www.gnu.org/licenses/>. | ||
557 | 16 | |||
558 | 17 | Copyright (c) 2010 Mathieu Trudel-Lapierre <mathieu-tl@ubuntu.com> | ||
559 | 18 | */ | ||
560 | 19 | |||
561 | 20 | #include <stdio.h> | ||
562 | 21 | #include <stdlib.h> | ||
563 | 22 | #include <string.h> | ||
564 | 23 | |||
565 | 24 | #include <geoclue/geoclue-master.h> | ||
566 | 25 | #include <geoclue/geoclue-position.h> | ||
567 | 26 | |||
568 | 27 | #include <glib.h> | ||
569 | 28 | #include <glib-object.h> | ||
570 | 29 | |||
571 | 30 | #include "location-geoclue.h" | ||
572 | 31 | |||
573 | 32 | #ifdef ENABLE_NLS | ||
574 | 33 | # include <libintl.h> | ||
575 | 34 | # define _(s) gettext(s) | ||
576 | 35 | #else | ||
577 | 36 | # define _(s) s | ||
578 | 37 | #endif | ||
579 | 38 | |||
580 | 39 | #define DEFAULT_PROVIDER "org.freedesktop.Geoclue.Providers.UbuntuGeoIP" | ||
581 | 40 | #define DEFAULT_PROVIDER_PATH "/org/freedesktop/Geoclue/Providers/UbuntuGeoIP" | ||
582 | 41 | |||
583 | 42 | int | ||
584 | 43 | location_geoclue_init(location_geoclue_state_t *state) | ||
585 | 44 | { | ||
586 | 45 | #if !GLIB_CHECK_VERSION(2, 35, 0) | ||
587 | 46 | g_type_init(); | ||
588 | 47 | #endif | ||
589 | 48 | |||
590 | 49 | state->position = NULL; | ||
591 | 50 | state->provider = NULL; | ||
592 | 51 | state->provider_path = NULL; | ||
593 | 52 | |||
594 | 53 | return 0; | ||
595 | 54 | } | ||
596 | 55 | |||
597 | 56 | int | ||
598 | 57 | location_geoclue_start(location_geoclue_state_t *state) | ||
599 | 58 | { | ||
600 | 59 | if (state->provider && state->provider_path) { | ||
601 | 60 | state->position = geoclue_position_new(state->provider, | ||
602 | 61 | state->provider_path); | ||
603 | 62 | } else { | ||
604 | 63 | if (getenv("DISPLAY") == NULL || *getenv("DISPLAY") == '\0') { | ||
605 | 64 | /* TODO This (hack) should be removed when GeoClue has been patched. */ | ||
606 | 65 | putenv("DISPLAY=:0"); | ||
607 | 66 | } | ||
608 | 67 | GError *error = NULL; | ||
609 | 68 | GeoclueMaster *master = geoclue_master_get_default(); | ||
610 | 69 | GeoclueMasterClient *client = geoclue_master_create_client(master, | ||
611 | 70 | NULL, &error); | ||
612 | 71 | g_object_unref(master); | ||
613 | 72 | |||
614 | 73 | if (client == NULL) { | ||
615 | 74 | if (error != NULL) { | ||
616 | 75 | g_printerr(_("Unable to obtain master client: %s\n"), | ||
617 | 76 | error->message); | ||
618 | 77 | g_error_free(error); | ||
619 | 78 | } else { | ||
620 | 79 | g_printerr(_("Unable to obtain master client\n")); | ||
621 | 80 | } | ||
622 | 81 | return -1; | ||
623 | 82 | } | ||
624 | 83 | |||
625 | 84 | if (!geoclue_master_client_set_requirements(client, | ||
626 | 85 | GEOCLUE_ACCURACY_LEVEL_REGION, | ||
627 | 86 | 0, FALSE, | ||
628 | 87 | GEOCLUE_RESOURCE_NETWORK, | ||
629 | 88 | &error)) { | ||
630 | 89 | if (error != NULL) { | ||
631 | 90 | g_printerr(_("Can't set requirements for master: %s\n"), | ||
632 | 91 | error->message); | ||
633 | 92 | g_error_free(error); | ||
634 | 93 | } else { | ||
635 | 94 | g_printerr(_("Can't set requirements for master\n")); | ||
636 | 95 | } | ||
637 | 96 | g_object_unref(client); | ||
638 | 97 | |||
639 | 98 | return -1; | ||
640 | 99 | } | ||
641 | 100 | |||
642 | 101 | state->position = geoclue_master_client_create_position(client, NULL); | ||
643 | 102 | |||
644 | 103 | g_object_unref(client); | ||
645 | 104 | } | ||
646 | 105 | |||
647 | 106 | gchar *name = NULL; | ||
648 | 107 | |||
649 | 108 | if (geoclue_provider_get_provider_info(GEOCLUE_PROVIDER(state->position), | ||
650 | 109 | &name, NULL, NULL)) { | ||
651 | 110 | fprintf(stdout, _("Started Geoclue provider `%s'.\n"), name); | ||
652 | 111 | g_free(name); | ||
653 | 112 | } else { | ||
654 | 113 | fputs(_("Could not find a usable Geoclue provider.\n"), stderr); | ||
655 | 114 | fputs(_("Try setting name and path to specify which to use.\n"), stderr); | ||
656 | 115 | return -1; | ||
657 | 116 | } | ||
658 | 117 | |||
659 | 118 | return 0; | ||
660 | 119 | } | ||
661 | 120 | |||
662 | 121 | void | ||
663 | 122 | location_geoclue_free(location_geoclue_state_t *state) | ||
664 | 123 | { | ||
665 | 124 | if (state->position != NULL) g_object_unref(state->position); | ||
666 | 125 | if (state->provider != NULL) free(state->provider); | ||
667 | 126 | if (state->provider_path != NULL) free(state->provider_path); | ||
668 | 127 | } | ||
669 | 128 | |||
670 | 129 | void | ||
671 | 130 | location_geoclue_print_help(FILE *f) | ||
672 | 131 | { | ||
673 | 132 | fputs(_("Use the location as discovered by a Geoclue provider.\n"), f); | ||
674 | 133 | fputs("\n", f); | ||
675 | 134 | |||
676 | 135 | /* TRANSLATORS: Geoclue help output | ||
677 | 136 | left column must not be translated */ | ||
678 | 137 | fputs(_(" name=N\tName of Geoclue provider (or `default')\n" | ||
679 | 138 | " path=N\tPath of Geoclue provider (or `default')\n"), f); | ||
680 | 139 | fputs("\n", f); | ||
681 | 140 | fprintf(f, _("NOTE: currently Redshift doesn't recheck %s once started,\n" | ||
682 | 141 | "which means it has to be restarted to take notice after travel.\n"), | ||
683 | 142 | "GeoClue"); | ||
684 | 143 | fputs("\n", f); | ||
685 | 144 | } | ||
686 | 145 | |||
687 | 146 | int | ||
688 | 147 | location_geoclue_set_option(location_geoclue_state_t *state, | ||
689 | 148 | const char *key, const char *value) | ||
690 | 149 | { | ||
691 | 150 | const char *provider = NULL; | ||
692 | 151 | const char *path = NULL; | ||
693 | 152 | |||
694 | 153 | /* Parse string value */ | ||
695 | 154 | if (strcasecmp(key, "name") == 0) { | ||
696 | 155 | if (strcasecmp(value, "default") == 0) { | ||
697 | 156 | provider = DEFAULT_PROVIDER; | ||
698 | 157 | } else { | ||
699 | 158 | provider = value; | ||
700 | 159 | } | ||
701 | 160 | |||
702 | 161 | state->provider = strdup(provider); | ||
703 | 162 | if (state->provider == NULL) { | ||
704 | 163 | perror("strdup"); | ||
705 | 164 | return -1; | ||
706 | 165 | } | ||
707 | 166 | } else if (strcasecmp(key, "path") == 0) { | ||
708 | 167 | if (value != NULL && strcasecmp(value, "default") == 0) { | ||
709 | 168 | path = DEFAULT_PROVIDER_PATH; | ||
710 | 169 | } else { | ||
711 | 170 | path = value; | ||
712 | 171 | } | ||
713 | 172 | |||
714 | 173 | state->provider_path = strdup(path); | ||
715 | 174 | if (state->provider_path == NULL) { | ||
716 | 175 | perror("strdup"); | ||
717 | 176 | return -1; | ||
718 | 177 | } | ||
719 | 178 | } else { | ||
720 | 179 | fprintf(stderr, _("Unknown method parameter: `%s'.\n"), key); | ||
721 | 180 | return -1; | ||
722 | 181 | } | ||
723 | 182 | |||
724 | 183 | return 0; | ||
725 | 184 | } | ||
726 | 185 | |||
727 | 186 | int | ||
728 | 187 | location_geoclue_get_location(location_geoclue_state_t *state, | ||
729 | 188 | float *lat, float *lon) | ||
730 | 189 | { | ||
731 | 190 | GeocluePositionFields fields; | ||
732 | 191 | GError *error = NULL; | ||
733 | 192 | double latitude = 0, longitude = 0; | ||
734 | 193 | |||
735 | 194 | fields = geoclue_position_get_position(state->position, NULL, | ||
736 | 195 | &latitude, &longitude, NULL, | ||
737 | 196 | NULL, &error); | ||
738 | 197 | if (error) { | ||
739 | 198 | g_printerr(_("Could not get location: %s.\n"), error->message); | ||
740 | 199 | g_error_free(error); | ||
741 | 200 | return -1; | ||
742 | 201 | } | ||
743 | 202 | |||
744 | 203 | if (fields & GEOCLUE_POSITION_FIELDS_LATITUDE && | ||
745 | 204 | fields & GEOCLUE_POSITION_FIELDS_LONGITUDE) { | ||
746 | 205 | fprintf(stdout, _("According to the geoclue provider" | ||
747 | 206 | " we're at: %.2f, %.2f\n"), | ||
748 | 207 | latitude, longitude); | ||
749 | 208 | } else { | ||
750 | 209 | g_warning(_("Provider does not have a valid location available.")); | ||
751 | 210 | return -1; | ||
752 | 211 | } | ||
753 | 212 | |||
754 | 213 | *lat = latitude; | ||
755 | 214 | *lon = longitude; | ||
756 | 215 | |||
757 | 216 | return 0; | ||
758 | 217 | } | ||
759 | 218 | 0 | ||
760 | === removed file 'debian/README.Debian' | |||
761 | --- debian/README.Debian 2015-05-26 14:55:19 +0000 | |||
762 | +++ debian/README.Debian 1970-01-01 00:00:00 +0000 | |||
763 | @@ -1,24 +0,0 @@ | |||
764 | 1 | Geoclue 2 | ||
765 | 2 | --------- | ||
766 | 3 | |||
767 | 4 | Starting with version 1.10, redshift has support for Geoclue 2. | ||
768 | 5 | By default, geoclue will not allow access to redshift. | ||
769 | 6 | |||
770 | 7 | To make geoclue accept requests from redshift, add the following to | ||
771 | 8 | /etc/geoclue/geoclue.conf | ||
772 | 9 | |||
773 | 10 | [redshift] | ||
774 | 11 | allowed=true | ||
775 | 12 | system=false | ||
776 | 13 | users= | ||
777 | 14 | |||
778 | 15 | |||
779 | 16 | Autostart of gtk-redshift | ||
780 | 17 | ------------------------- | ||
781 | 18 | |||
782 | 19 | Autostart was removed from Debian package because of violation of 'Desktop Application | ||
783 | 20 | Autostart Specification' (see bug #619699). If you want gtk-redshift autostarted please | ||
784 | 21 | configure this in your specific desktop environment (e.g. by placing | ||
785 | 22 | /usr/share/applications/gtk-redshift.desktop in | ||
786 | 23 | $HOME/$XDG_CONFIG_HOME/autostart/ | ||
787 | 24 | (usually defaults to $HOME/.config/autostart). | ||
788 | 25 | 0 | ||
789 | === modified file 'debian/changelog' | |||
790 | --- debian/changelog 2015-06-28 09:25:43 +0000 | |||
791 | +++ debian/changelog 2015-10-14 19:20:52 +0000 | |||
792 | @@ -1,3 +1,39 @@ | |||
793 | 1 | redshift (1.10-5ubuntu1) wily; urgency=medium | ||
794 | 2 | |||
795 | 3 | * Merge from Debian. (LP: #1485153) Remaining changes: | ||
796 | 4 | - debian/rues: Add --enable-ubuntu | ||
797 | 5 | - debian/patches/retry-geoclue.patch: Retry geoclue a few times so | ||
798 | 6 | redshift does not explode at startup. | ||
799 | 7 | |||
800 | 8 | -- Jackson Doak <noskcaj@ubuntu.com> Thu, 15 Oct 2015 06:10:29 +1100 | ||
801 | 9 | |||
802 | 10 | redshift (1.10-5) unstable; urgency=medium | ||
803 | 11 | |||
804 | 12 | * [8a88246] Add some changes from Laurent Bigonville | ||
805 | 13 | * [ca45b49] Drop README.Debian | ||
806 | 14 | * [4b34f2c] Add header to quilt patch | ||
807 | 15 | * [9e854c4] Add debian/gbp.conf | ||
808 | 16 | |||
809 | 17 | -- Ritesh Raj Sarraf <rrs@debian.org> Thu, 27 Aug 2015 17:05:00 +0530 | ||
810 | 18 | |||
811 | 19 | redshift (1.10-4) unstable; urgency=medium | ||
812 | 20 | |||
813 | 21 | * [c3cdd0e] Drop patch remove_autostart.patch (Closes: #791598) | ||
814 | 22 | * [47e94ba] Ship appdata file in redshift-gtk. | ||
815 | 23 | Thanks to Laurent Bigonville (Closes: #791600) | ||
816 | 24 | * [3a6b76d] Fix reference to correct name. | ||
817 | 25 | Thanks to Torquil Macdonal Sorensen (Closes: #795502) | ||
818 | 26 | * [26605bd] Add redshift.desktop file entry. Needed for GeoClue activation. | ||
819 | 27 | Thanks to Laurent Bigonville (Closes: #789883) | ||
820 | 28 | * [536ef7e] Add dh-autoreconf to build. Drop autotools_dev from build. | ||
821 | 29 | Call intltoolize to update po/ files | ||
822 | 30 | * [4983734] Ship redshift.desktop file | ||
823 | 31 | * [a1397f2] Add configure flag for systemd user unit dir | ||
824 | 32 | * [fb6fb18] Add redshift-gtk.desktop file that got dropped off mistakenly | ||
825 | 33 | in the redshift.desktop patch | ||
826 | 34 | |||
827 | 35 | -- Ritesh Raj Sarraf <rrs@debian.org> Sat, 15 Aug 2015 16:46:00 +0200 | ||
828 | 36 | |||
829 | 1 | redshift (1.10-3ubuntu1) wily; urgency=medium | 37 | redshift (1.10-3ubuntu1) wily; urgency=medium |
830 | 2 | 38 | ||
831 | 3 | * Merge from Debian. Remaining changes: | 39 | * Merge from Debian. Remaining changes: |
832 | 4 | 40 | ||
833 | === modified file 'debian/control' | |||
834 | --- debian/control 2015-06-28 09:25:43 +0000 | |||
835 | +++ debian/control 2015-10-14 19:20:52 +0000 | |||
836 | @@ -4,7 +4,7 @@ | |||
837 | 4 | Maintainer: Ubuntu Developers <ubuntu-devel-discuss@lists.ubuntu.com> | 4 | Maintainer: Ubuntu Developers <ubuntu-devel-discuss@lists.ubuntu.com> |
838 | 5 | XSBC-Original-Maintainer: Ritesh Raj Sarraf <rrs@debian.org> | 5 | XSBC-Original-Maintainer: Ritesh Raj Sarraf <rrs@debian.org> |
839 | 6 | Uploaders: Franziska Lichtblau <rhalina@old-forest.org> | 6 | Uploaders: Franziska Lichtblau <rhalina@old-forest.org> |
841 | 7 | Build-Depends: debhelper (>= 9), autotools-dev (>= 20100122.1~), pkg-config (>= 0.25), dpkg-dev (>= 1.16.1~), libxcb-randr0-dev, libxxf86vm-dev, libgconf2-dev, python3, libxext-dev, libgeoclue-dev, libdrm-dev, intltool, dh-python | 7 | Build-Depends: debhelper (>= 9), autotools-dev (>= 20100122.1~), pkg-config (>= 0.25), dpkg-dev (>= 1.16.1~), libxcb-randr0-dev, libxxf86vm-dev, libgconf2-dev, python3, libxext-dev, libdrm-dev, intltool, dh-python, dh-autoreconf |
842 | 8 | X-Python3-Version: >= 3.2 | 8 | X-Python3-Version: >= 3.2 |
843 | 9 | Standards-Version: 3.9.3 | 9 | Standards-Version: 3.9.3 |
844 | 10 | Vcs-Git: git://anonscm.debian.org/users/rhalina-guest/redshift.git | 10 | Vcs-Git: git://anonscm.debian.org/users/rhalina-guest/redshift.git |
845 | 11 | 11 | ||
846 | === added file 'debian/gbp.conf' | |||
847 | --- debian/gbp.conf 1970-01-01 00:00:00 +0000 | |||
848 | +++ debian/gbp.conf 2015-10-14 19:20:52 +0000 | |||
849 | @@ -0,0 +1,2 @@ | |||
850 | 1 | [DEFAULT] | ||
851 | 2 | pristine-tar = True | ||
852 | 0 | 3 | ||
853 | === added file 'debian/patches/add-desktop-file.patch' | |||
854 | --- debian/patches/add-desktop-file.patch 1970-01-01 00:00:00 +0000 | |||
855 | +++ debian/patches/add-desktop-file.patch 2015-10-14 19:20:52 +0000 | |||
856 | @@ -0,0 +1,34 @@ | |||
857 | 1 | Add .desktop file until next release, when we can then drop it | ||
858 | 2 | --- a/Makefile.am | ||
859 | 3 | +++ b/Makefile.am | ||
860 | 4 | @@ -28,6 +28,7 @@ | ||
861 | 5 | data/icons/ubuntu-mono-light/scalable/apps/redshift-status-off.svg | ||
862 | 6 | |||
863 | 7 | DESKTOP_IN_FILES = \ | ||
864 | 8 | + data/applications/redshift.desktop.in \ | ||
865 | 9 | data/applications/redshift-gtk.desktop.in | ||
866 | 10 | |||
867 | 11 | SYSTEMD_USER_UNIT_IN_FILES = \ | ||
868 | 12 | --- /dev/null | ||
869 | 13 | +++ b/data/applications/redshift.desktop.in | ||
870 | 14 | @@ -0,0 +1,10 @@ | ||
871 | 15 | +[Desktop Entry] | ||
872 | 16 | +Version=1.0 | ||
873 | 17 | +_Name=Redshift | ||
874 | 18 | +_GenericName=Color temperature adjustment | ||
875 | 19 | +_Comment=Color temperature adjustment tool | ||
876 | 20 | +Exec=redshift | ||
877 | 21 | +Icon=redshift | ||
878 | 22 | +Terminal=true | ||
879 | 23 | +Type=Application | ||
880 | 24 | +NoDisplay=true | ||
881 | 25 | --- a/po/POTFILES.in | ||
882 | 26 | +++ b/po/POTFILES.in | ||
883 | 27 | @@ -1,6 +1,7 @@ | ||
884 | 28 | # List of source files containing translatable strings | ||
885 | 29 | |||
886 | 30 | data/appdata/redshift-gtk.appdata.xml.in | ||
887 | 31 | +data/applications/redshift.desktop.in | ||
888 | 32 | data/applications/redshift-gtk.desktop.in | ||
889 | 33 | |||
890 | 34 | src/redshift.c | ||
891 | 0 | 35 | ||
892 | === modified file 'debian/patches/retry-geoclue.patch' | |||
893 | --- debian/patches/retry-geoclue.patch 2014-11-01 17:06:15 +0000 | |||
894 | +++ debian/patches/retry-geoclue.patch 2015-10-14 19:20:52 +0000 | |||
895 | @@ -2,11 +2,13 @@ | |||
896 | 2 | Author: Clint Byrum <clint@ubuntu.com> | 2 | Author: Clint Byrum <clint@ubuntu.com> |
897 | 3 | Bug-Ubuntu: https://bugs.launchpad.net/ubuntu/+source/redshift/+bug/868904 | 3 | Bug-Ubuntu: https://bugs.launchpad.net/ubuntu/+source/redshift/+bug/868904 |
898 | 4 | 4 | ||
904 | 5 | Index: redshift/src/location-geoclue.c | 5 | --- |
905 | 6 | =================================================================== | 6 | src/location-geoclue.c | 28 ++++++++++++++++++++-------- |
906 | 7 | --- redshift.orig/src/location-geoclue.c 2012-03-02 17:45:30.000000000 -0800 | 7 | 1 file changed, 20 insertions(+), 8 deletions(-) |
907 | 8 | +++ redshift/src/location-geoclue.c 2012-03-02 19:06:32.854211600 -0800 | 8 | |
908 | 9 | @@ -19,6 +19,7 @@ | 9 | --- a/src/location-geoclue.c |
909 | 10 | +++ b/src/location-geoclue.c | ||
910 | 11 | @@ -20,6 +20,7 @@ | ||
911 | 10 | #include <stdio.h> | 12 | #include <stdio.h> |
912 | 11 | #include <stdlib.h> | 13 | #include <stdlib.h> |
913 | 12 | #include <string.h> | 14 | #include <string.h> |
914 | @@ -14,7 +16,7 @@ | |||
915 | 14 | 16 | ||
916 | 15 | #include <geoclue/geoclue-master.h> | 17 | #include <geoclue/geoclue-master.h> |
917 | 16 | #include <geoclue/geoclue-position.h> | 18 | #include <geoclue/geoclue-position.h> |
919 | 17 | @@ -160,17 +161,28 @@ | 19 | @@ -191,17 +192,28 @@ location_geoclue_get_location(location_g |
920 | 18 | GError *error = NULL; | 20 | GError *error = NULL; |
921 | 19 | double latitude = 0, longitude = 0; | 21 | double latitude = 0, longitude = 0; |
922 | 20 | 22 | ||
923 | 21 | 23 | ||
924 | === modified file 'debian/patches/series' | |||
925 | --- debian/patches/series 2014-11-01 17:06:15 +0000 | |||
926 | +++ debian/patches/series 2015-10-14 19:20:52 +0000 | |||
927 | @@ -1,2 +1,2 @@ | |||
929 | 1 | remove_autostart.patch | 1 | add-desktop-file.patch |
930 | 2 | retry-geoclue.patch | 2 | retry-geoclue.patch |
931 | 3 | 3 | ||
932 | === modified file 'debian/redshift-gtk.docs' | |||
933 | --- debian/redshift-gtk.docs 2015-06-28 09:25:43 +0000 | |||
934 | +++ debian/redshift-gtk.docs 2015-10-14 19:20:52 +0000 | |||
935 | @@ -1,2 +1,1 @@ | |||
936 | 1 | README | 1 | README |
937 | 2 | debian/README.Debian | ||
938 | 3 | 2 | ||
939 | === modified file 'debian/redshift-gtk.install' | |||
940 | --- debian/redshift-gtk.install 2015-06-28 09:25:43 +0000 | |||
941 | +++ debian/redshift-gtk.install 2015-10-14 19:20:52 +0000 | |||
942 | @@ -1,4 +1,5 @@ | |||
943 | 1 | usr/bin/redshift-gtk | 1 | usr/bin/redshift-gtk |
944 | 2 | usr/lib/python* | 2 | usr/lib/python* |
945 | 3 | usr/share/icons | 3 | usr/share/icons |
947 | 4 | usr/share/applications/ | 4 | usr/share/appdata/redshift-gtk.appdata.xml |
948 | 5 | usr/share/applications/redshift-gtk.desktop | ||
949 | 5 | 6 | ||
950 | === modified file 'debian/redshift.install' | |||
951 | --- debian/redshift.install 2010-02-18 09:58:46 +0000 | |||
952 | +++ debian/redshift.install 2015-10-14 19:20:52 +0000 | |||
953 | @@ -1,2 +1,3 @@ | |||
954 | 1 | usr/bin/redshift | 1 | usr/bin/redshift |
955 | 2 | usr/share/locale | 2 | usr/share/locale |
956 | 3 | usr/share/applications/redshift.desktop | ||
957 | 3 | 4 | ||
958 | === modified file 'debian/rules' | |||
959 | --- debian/rules 2015-06-28 09:25:43 +0000 | |||
960 | +++ debian/rules 2015-10-14 19:20:52 +0000 | |||
961 | @@ -6,10 +6,11 @@ | |||
962 | 6 | include /usr/share/dpkg/buildflags.mk | 6 | include /usr/share/dpkg/buildflags.mk |
963 | 7 | 7 | ||
964 | 8 | %: | 8 | %: |
966 | 9 | dh $@ --with autotools_dev,python3 | 9 | dh $@ --with python3,autoreconf |
967 | 10 | 10 | ||
968 | 11 | override_dh_auto_configure: | 11 | override_dh_auto_configure: |
970 | 12 | dh_auto_configure -- --enable-randr --enable-vidmode --enable-geoclue2 --disable-geoclue --enable-ubuntu | 12 | intltoolize --force |
971 | 13 | dh_auto_configure -- --enable-randr --enable-vidmode --enable-geoclue2 --disable-geoclue --with-systemduserunitdir=/usr/lib/systemd/user/ --enable-ubuntu | ||
972 | 13 | 14 | ||
973 | 14 | override_dh_installchangelogs: | 15 | override_dh_installchangelogs: |
974 | 15 | dh_installchangelogs NEWS | 16 | dh_installchangelogs NEWS |
975 | 16 | 17 | ||
976 | === modified file 'src/location-geoclue.c' | |||
977 | --- src/location-geoclue.c 2015-06-28 09:25:43 +0000 | |||
978 | +++ src/location-geoclue.c 2015-10-14 19:20:52 +0000 | |||
979 | @@ -20,7 +20,6 @@ | |||
980 | 20 | #include <stdio.h> | 20 | #include <stdio.h> |
981 | 21 | #include <stdlib.h> | 21 | #include <stdlib.h> |
982 | 22 | #include <string.h> | 22 | #include <string.h> |
983 | 23 | #include <unistd.h> | ||
984 | 24 | 23 | ||
985 | 25 | #include <geoclue/geoclue-master.h> | 24 | #include <geoclue/geoclue-master.h> |
986 | 26 | #include <geoclue/geoclue-position.h> | 25 | #include <geoclue/geoclue-position.h> |
987 | @@ -192,28 +191,17 @@ | |||
988 | 192 | GError *error = NULL; | 191 | GError *error = NULL; |
989 | 193 | double latitude = 0, longitude = 0; | 192 | double latitude = 0, longitude = 0; |
990 | 194 | 193 | ||
1009 | 195 | /* Retry 3 times because this seems to timeout quite a bit */ | 194 | fields = geoclue_position_get_position(state->position, NULL, |
1010 | 196 | int retries = 4; | 195 | &latitude, &longitude, NULL, |
1011 | 197 | while(--retries) { | 196 | NULL, &error); |
1012 | 198 | fields = geoclue_position_get_position(state->position, NULL, | 197 | if (error) { |
1013 | 199 | &latitude, &longitude, NULL, | 198 | g_printerr(_("Could not get location: %s.\n"), error->message); |
1014 | 200 | NULL, &error); | 199 | g_error_free(error); |
1015 | 201 | if (error) { | 200 | return -1; |
998 | 202 | g_printerr(_("Could not get location (%d retries left): %s.\n"), retries, error->message); | ||
999 | 203 | g_error_free(error); | ||
1000 | 204 | return -1; | ||
1001 | 205 | } | ||
1002 | 206 | if (fields & GEOCLUE_POSITION_FIELDS_LATITUDE && | ||
1003 | 207 | fields & GEOCLUE_POSITION_FIELDS_LONGITUDE) { | ||
1004 | 208 | break; | ||
1005 | 209 | } | ||
1006 | 210 | g_warning(_("Could not get location, %d retries left.\n"), retries); | ||
1007 | 211 | /* Sleep for a while to let */ | ||
1008 | 212 | usleep(1000000); | ||
1016 | 213 | } | 201 | } |
1017 | 214 | 202 | ||
1018 | 215 | if (fields & GEOCLUE_POSITION_FIELDS_LATITUDE && | 203 | if (fields & GEOCLUE_POSITION_FIELDS_LATITUDE && |
1020 | 216 | fields & GEOCLUE_POSITION_FIELDS_LONGITUDE) { | 204 | fields & GEOCLUE_POSITION_FIELDS_LONGITUDE) { |
1021 | 217 | fprintf(stdout, _("According to the geoclue provider" | 205 | fprintf(stdout, _("According to the geoclue provider" |
1022 | 218 | " we're at: %.2f, %.2f\n"), | 206 | " we're at: %.2f, %.2f\n"), |
1023 | 219 | latitude, longitude); | 207 | latitude, longitude); |
1024 | 220 | 208 | ||
1025 | === modified file 'src/redshift-gtk/statusicon.py' | |||
1026 | --- src/redshift-gtk/statusicon.py 2015-06-28 09:25:43 +0000 | |||
1027 | +++ src/redshift-gtk/statusicon.py 2015-10-14 19:20:52 +0000 | |||
1028 | @@ -273,6 +273,18 @@ | |||
1029 | 273 | suspend_menu_item.set_submenu(suspend_menu) | 273 | suspend_menu_item.set_submenu(suspend_menu) |
1030 | 274 | self.status_menu.append(suspend_menu_item) | 274 | self.status_menu.append(suspend_menu_item) |
1031 | 275 | 275 | ||
1032 | 276 | # Add autostart option | ||
1033 | 277 | autostart_item = Gtk.CheckMenuItem.new_with_label(_('Autostart')) | ||
1034 | 278 | try: | ||
1035 | 279 | autostart_item.set_active(utils.get_autostart()) | ||
1036 | 280 | except IOError as strerror: | ||
1037 | 281 | print(strerror) | ||
1038 | 282 | autostart_item.set_property('sensitive', False) | ||
1039 | 283 | else: | ||
1040 | 284 | autostart_item.connect('toggled', self.autostart_cb) | ||
1041 | 285 | finally: | ||
1042 | 286 | self.status_menu.append(autostart_item) | ||
1043 | 287 | |||
1044 | 276 | # Add info action | 288 | # Add info action |
1045 | 277 | info_item = Gtk.MenuItem.new_with_label(_('Info')) | 289 | info_item = Gtk.MenuItem.new_with_label(_('Info')) |
1046 | 278 | info_item.connect('activate', self.show_info_cb) | 290 | info_item.connect('activate', self.show_info_cb) |
Looks good, thanks! Uploaded to wily.