Commit d30f7e00 authored by Alexandru Băluț's avatar Alexandru Băluț

system: Fix detection of Mac and Windows

Differential Revision:
parent 3ca75f01
......@@ -47,7 +47,7 @@ from pitivi.utils.loggable import Loggable
from pitivi.utils.misc import path_from_uri
from pitivi.utils.misc import quote_uri
from pitivi.utils.proxy import ProxyManager
from pitivi.utils.system import getSystem
from pitivi.utils.system import get_system
from pitivi.utils.threads import ThreadMaster
from pitivi.utils.timeline import Zoomable
......@@ -143,7 +143,7 @@ class Pitivi(Gtk.Application, Loggable):
self.threads = ThreadMaster()
self.effects = EffectsManager()
self.proxy_manager = ProxyManager(self)
self.system = getSystem()
self.system = get_system()
"new-project-loading", self._newProjectLoadingCb)
......@@ -20,6 +20,7 @@ import datetime
import multiprocessing
import os
import resource
import sys
from gi.repository import GObject
......@@ -209,6 +210,8 @@ class GnomeSystem(FreedesktopOrgSystem):
def __init__(self):
import dbus
self.bus = dbus.Bus(dbus.Bus.TYPE_SESSION)
# connect to gnome sessionmanager
......@@ -221,12 +224,6 @@ class GnomeSystem(FreedesktopOrgSystem):
self.connect('update-power-inhibition', self._updatePowerInhibitionCb)
def screensaver_is_blockable(self):
return True
def sleep_is_blockable(self):
return True
def _updatePowerInhibitionCb(self, unused_system):
# there are two states we want the program to be in, with regards to
# power saving, the screen saver is inhibited when the viewer is watched.
......@@ -271,34 +268,39 @@ class GnomeSystem(FreedesktopOrgSystem):
self.debug("already uninhibited")
system_ = None
class DarwinSystem(System):
"""Apple OS X"""
def __init__(self):
# attempts to identify the System, import dependencies and overide system_
if == 'posix':
if 'GNOME_DESKTOP_SESSION_ID' in os.environ:
import dbus
system_ = GnomeSystem
class WindowsSystem(System):
if system_ is None:
system_ = FreedesktopOrgSystem
elif == 'nt':
elif == 'mac':
"""Microsoft Windows"""
def __init__(self):
def getSystem():
system = None
if system_ is not None:
system = system_()
if system is None:
system = System()
def get_system():
Create a System object.
return system
System: A System object.
if == 'posix':
if sys.platform == 'darwin':
return DarwinSystem()
if 'GNOME_DESKTOP_SESSION_ID' in os.environ:
return GnomeSystem()
return FreedesktopOrgSystem()
if == 'nt':
return WindowsSystem()
return System()
class CPUUsageTracker(object):
......@@ -21,7 +21,7 @@
# Boston, MA 02110-1301, USA.
from unittest import TestCase
from pitivi.utils.system import getSystem
from pitivi.utils.system import get_system
from pitivi.utils.system import GnomeSystem
from pitivi.utils.system import INHIBIT_LOGOUT
from pitivi.utils.system import INHIBIT_SESSION_IDLE
......@@ -92,7 +92,7 @@ class TestSystem(TestCase):
class TestGnomeSystem(TestCase):
def setUp(self):
self.system = getSystem()
self.system = get_system()
def testPowerInhibition(self):
if not isinstance(self.system, GnomeSystem):
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment