Commit 8760eb62 authored by Alexandru Băluț's avatar Alexandru Băluț

system: Reuse the system object

Differential Revision: https://phabricator.freedesktop.org/D981
parent 920d44a0
......@@ -63,6 +63,7 @@ class Pitivi(Gtk.Application, Loggable):
gui (MainWindow): The main window of the app.
project_manager (ProjectManager): The holder of the current project.
settings (GlobalSettings): The application-wide settings.
system (pitivi.utils.system.System): The system running the app.
"""
__gsignals__ = {
......
......@@ -31,7 +31,6 @@ from pitivi.configure import get_audiopresets_dir
from pitivi.configure import get_renderpresets_dir
from pitivi.configure import get_videopresets_dir
from pitivi.settings import xdg_data_home
from pitivi.utils import system
from pitivi.utils.loggable import Loggable
......@@ -64,7 +63,7 @@ class PresetManager(GObject.Object, Loggable):
"preset-loaded": (GObject.SignalFlags.RUN_LAST, None, ()),
}
def __init__(self, default_path, user_path):
def __init__(self, default_path, user_path, system):
GObject.Object.__init__(self)
Loggable.__init__(self)
......@@ -77,7 +76,7 @@ class PresetManager(GObject.Object, Loggable):
self.cur_preset = None
# Whether to ignore the updateValue calls.
self.ignore_update_requests = False
self.system = system.getSystem()
self.system = system
def setupUi(self, combo, button):
self.combo = combo
......@@ -420,10 +419,10 @@ class PresetManager(GObject.Object, Loggable):
class VideoPresetManager(PresetManager):
def __init__(self):
def __init__(self, system):
default_path = get_videopresets_dir()
user_path = os.path.join(xdg_data_home(), 'video_presets')
PresetManager.__init__(self, default_path, user_path)
PresetManager.__init__(self, default_path, user_path, system)
def _deserializePreset(self, parser):
width = parser["width"]
......@@ -464,10 +463,10 @@ class VideoPresetManager(PresetManager):
class AudioPresetManager(PresetManager):
def __init__(self):
def __init__(self, system):
default_path = get_audiopresets_dir()
user_path = os.path.join(xdg_data_home(), 'audio_presets')
PresetManager.__init__(self, default_path, user_path)
PresetManager.__init__(self, default_path, user_path, system)
def _deserializePreset(self, parser):
channels = parser["channels"]
......@@ -492,10 +491,10 @@ class AudioPresetManager(PresetManager):
class RenderPresetManager(PresetManager):
def __init__(self):
def __init__(self, system):
default_path = get_renderpresets_dir()
user_path = os.path.join(xdg_data_home(), 'render_presets')
PresetManager.__init__(self, default_path, user_path)
PresetManager.__init__(self, default_path, user_path, system)
def _deserializePreset(self, parser):
container = parser["container"]
......
......@@ -1496,13 +1496,14 @@ class ProjectSettingsDialog(object):
Attributes:
project (Project): The project who's settings are displayed.
app (pitivi.application.Pitivi): The current app.
"""
def __init__(self, parent_window, project, app):
self.app = app
self.project = project
self.audio_presets = AudioPresetManager()
self.video_presets = VideoPresetManager()
self.audio_presets = AudioPresetManager(app.system)
self.video_presets = VideoPresetManager(app.system)
self._createUi()
self.window.set_transient_for(parent_window)
self._setupUiConstraints()
......
......@@ -355,7 +355,7 @@ class RenderDialog(Loggable):
# {object: sigId}
self._gstSigId = {}
self.render_presets = RenderPresetManager()
self.render_presets = RenderPresetManager(self.app.system)
self.render_presets.loadAll()
self._createUi()
......
......@@ -24,9 +24,9 @@ from gi.repository import Gdk
from gi.repository import GES
from gi.repository import Gtk
from pitivi.utils.loggable import Loggable
from pitivi.viewer.move_scale_overlay import MoveScaleOverlay
from pitivi.viewer.title_overlay import TitleOverlay
from pitivi.utils.loggable import Loggable
class OverlayStack(Gtk.Overlay, Loggable):
......
......@@ -28,12 +28,13 @@ from unittest import TestCase
from pitivi.preset import AudioPresetManager
from pitivi.preset import PresetManager
from pitivi.utils.system import System
class FakePresetManager(PresetManager):
def __init__(self, default_path):
PresetManager.__init__(self, default_path, tempfile.mkdtemp())
PresetManager.__init__(self, default_path, tempfile.mkdtemp(), System())
def _serializePreset(self, preset):
return dict(preset.items())
......@@ -121,14 +122,14 @@ class TestPresetBasics(TestCase):
class TestAudioPresetsIO(TestCase):
def setUp(self):
self.manager = AudioPresetManager()
self.manager = AudioPresetManager(System())
self.manager.user_path = tempfile.mkdtemp()
def tearDown(self):
clearPresetManagerPaths(self.manager)
def createOtherManager(self):
other_manager = AudioPresetManager()
other_manager = AudioPresetManager(System())
other_manager.user_path = self.manager.user_path
return other_manager
......@@ -192,7 +193,7 @@ class TestAudioPresetsIO(TestCase):
self.manager.removeCurrentPreset()
# Check that the files have not been deleted or changed.
other_manager = AudioPresetManager()
other_manager = AudioPresetManager(System())
other_manager.user_path = "/pitivi/non/existing/directory"
other_manager.loadAll()
for preset_name in system_presets:
......@@ -215,7 +216,7 @@ class TestAudioPresetsIO(TestCase):
self.manager.saveCurrentPreset(new_name)
# Check that the files have not been deleted or changed.
other_manager = AudioPresetManager()
other_manager = AudioPresetManager(System())
other_manager.user_path = "/pitivi/non/existing/directory"
other_manager.loadAll()
for preset_name in system_presets:
......
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