controller: Emit signal when stopped
This commit is contained in:
@@ -37,8 +37,9 @@ class RedshiftController(GObject.GObject):
|
|||||||
'temperature-changed': (GObject.SIGNAL_RUN_FIRST, None, (int,)),
|
'temperature-changed': (GObject.SIGNAL_RUN_FIRST, None, (int,)),
|
||||||
'period-changed': (GObject.SIGNAL_RUN_FIRST, None, (str,)),
|
'period-changed': (GObject.SIGNAL_RUN_FIRST, None, (str,)),
|
||||||
'location-changed': (GObject.SIGNAL_RUN_FIRST, None, (float, float)),
|
'location-changed': (GObject.SIGNAL_RUN_FIRST, None, (float, float)),
|
||||||
'error-occured': (GObject.SIGNAL_RUN_FIRST, None, (str,))
|
'error-occured': (GObject.SIGNAL_RUN_FIRST, None, (str,)),
|
||||||
}
|
'stopped': (GObject.SIGNAL_RUN_FIRST, None, ()),
|
||||||
|
}
|
||||||
|
|
||||||
def __init__(self, args):
|
def __init__(self, args):
|
||||||
"""Initialize controller and start child process.
|
"""Initialize controller and start child process.
|
||||||
@@ -159,6 +160,7 @@ class RedshiftController(GObject.GObject):
|
|||||||
self.emit('error-occured', self._errors)
|
self.emit('error-occured', self._errors)
|
||||||
|
|
||||||
GLib.spawn_close_pid(self._process[0])
|
GLib.spawn_close_pid(self._process[0])
|
||||||
|
self.emit('stopped')
|
||||||
|
|
||||||
def _child_key_change_cb(self, key, value):
|
def _child_key_change_cb(self, key, value):
|
||||||
"""Called when the child process reports a change of internal state."""
|
"""Called when the child process reports a change of internal state."""
|
||||||
|
|||||||
@@ -152,6 +152,7 @@ class RedshiftStatusIcon(object):
|
|||||||
'temperature-changed', self.temperature_change_cb)
|
'temperature-changed', self.temperature_change_cb)
|
||||||
self._controller.connect('location-changed', self.location_change_cb)
|
self._controller.connect('location-changed', self.location_change_cb)
|
||||||
self._controller.connect('error-occured', self.error_occured_cb)
|
self._controller.connect('error-occured', self.error_occured_cb)
|
||||||
|
self._controller.connect('stopped', self.controller_stopped_cb)
|
||||||
|
|
||||||
# Set info box text
|
# Set info box text
|
||||||
self.change_inhibited(self._controller.inhibited)
|
self.change_inhibited(self._controller.inhibited)
|
||||||
@@ -278,6 +279,10 @@ class RedshiftStatusIcon(object):
|
|||||||
# Quit when the model dialog is closed
|
# Quit when the model dialog is closed
|
||||||
sys.exit(-1)
|
sys.exit(-1)
|
||||||
|
|
||||||
|
def controller_stopped_cb(self, controller):
|
||||||
|
"""Callback when controlled is stopped successfully."""
|
||||||
|
Gtk.main_quit()
|
||||||
|
|
||||||
# Update interface
|
# Update interface
|
||||||
def change_inhibited(self, inhibited):
|
def change_inhibited(self, inhibited):
|
||||||
"""Change interface to new inhibition status."""
|
"""Change interface to new inhibition status."""
|
||||||
|
|||||||
Reference in New Issue
Block a user