1
# -*- coding: utf-8 -*-
3
# Copyright 2012 Canonical Ltd.
5
# This program is free software: you can redistribute it and/or modify it
6
# under the terms of the GNU General Public License version 3, as published
7
# by the Free Software Foundation.
9
# This program is distributed in the hope that it will be useful, but
10
# WITHOUT ANY WARRANTY; without even the implied warranties of
11
# MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
12
# PURPOSE. See the GNU General Public License for more details.
14
# You should have received a copy of the GNU General Public License along
15
# with this program. If not, see <http://www.gnu.org/licenses/>.
17
# In addition, as a special exception, the copyright holders give
18
# permission to link the code of portions of this program with the
19
# OpenSSL library under certain conditions as described in each
20
# individual source file, and distribute linked combinations
22
# You must obey the GNU General Public License in all respects
23
# for all of the code used other than OpenSSL. If you modify
24
# file(s) with this exception, you may extend this exception to your
25
# version of the file(s), but you are not obligated to do so. If you
26
# do not wish to do so, delete this exception statement from your
27
# version. If you delete this exception statement from all source
28
# files in the program, then also delete it here.
29
"""GLib main loop runner."""
31
# pylint: disable=E0611,F0401
33
# pylint: disable=W0621
34
import dbus.mainloop.glib
35
# pylint: enable=W0621
37
from gi.repository import GLib, Gdk, Gtk
40
def timeout_func(*a, **kw):
41
"""Delay import of dynamic bindings to avoid crashes."""
42
return GLib.timeout_add(*a, **kw)
45
def shutdown_func(*a, **kw):
46
"""Delay import of dynamic bindings to avoid crashes."""
51
"""Delay import of dynamic bindings to avoid crashes."""
56
"""Setup the env to run the service."""
57
dbus.mainloop.glib.threads_init()
59
dbus.mainloop.glib.DBusGMainLoop(set_as_default=True)