本文整理汇总了Python中pitivi.settings.GlobalSettings类的典型用法代码示例。如果您正苦于以下问题:Python GlobalSettings类的具体用法?Python GlobalSettings怎么用?Python GlobalSettings使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了GlobalSettings类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __create_settings
def __create_settings(proxyingStrategy=ProxyingStrategy.NOTHING,
numTranscodingJobs=4,
**additional_settings):
settings = GlobalSettings()
settings.proxyingStrategy = proxyingStrategy
settings.numTranscodingJobs = numTranscodingJobs
for key, value in additional_settings.items():
setattr(settings, key, value)
return settings
示例2: test_add_config_option
def test_add_config_option(self):
def add_option():
GlobalSettings.addConfigOption("optionA1", section="section-a",
key="option-a-1", default=False)
# "section-a" does not exist.
with self.assertRaises(ConfigError):
add_option()
GlobalSettings.addConfigSection("section-a")
add_option()
self.assertFalse(GlobalSettings.optionA1)
with self.assertRaises(ConfigError):
add_option()
示例3: test_read_config_file
def test_read_config_file(self):
GlobalSettings.addConfigSection("section-1")
GlobalSettings.addConfigOption("section1OptionA", section="section-1",
key="option-a", default=50)
GlobalSettings.addConfigOption("section1OptionB", section="section-1",
key="option-b", default=False)
GlobalSettings.addConfigOption("section1OptionC", section="section-1",
key="option-c", default="")
self.assertEqual(GlobalSettings.section1OptionA, 50)
self.assertEqual(GlobalSettings.section1OptionB, False)
self.assertEqual(GlobalSettings.section1OptionC, "")
conf_file_content = ("[section-1]\n"
"option-a = 10\n"
"option-b = True\n"
"option-c = Pigs fly\n")
with mock.patch("pitivi.settings.xdg_config_home") as xdg_config_home,\
tempfile.TemporaryDirectory() as temp_dir:
with open(os.path.join(temp_dir, "pitivi.conf"), "w") as tmp_file:
tmp_file.write(conf_file_content)
xdg_config_home.return_value = temp_dir
settings = GlobalSettings()
self.assertEqual(settings.section1OptionA, 10)
self.assertEqual(settings.section1OptionB, True)
self.assertEqual(settings.section1OptionC, "Pigs fly")
示例4: _startupCb
def _startupCb(self, unused_app):
# Init logging as early as possible so we can log startup code
enable_color = not os.environ.get(
'PITIVI_DEBUG_NO_COLOR', '0') in ('', '1')
# Let's show a human-readable Pitivi debug output by default, and only
# show a crazy unreadable mess when surrounded by gst debug statements.
enable_crack_output = "GST_DEBUG" in os.environ
log.init('PITIVI_DEBUG', enable_color, enable_crack_output)
self.info('starting up')
self.settings = GlobalSettings()
self.threads = ThreadMaster()
self.effects = EffectsManager()
self.system = getSystem()
self.action_log.connect("commit", self._actionLogCommit)
self.action_log.connect("undo", self._actionLogUndo)
self.action_log.connect("redo", self._actionLogRedo)
self.action_log.connect("cleaned", self._actionLogCleaned)
self.timeline_log_observer = TimelineLogObserver(self.action_log)
self.project_log_observer = ProjectLogObserver(self.action_log)
self.project_manager.connect(
"new-project-loading", self._newProjectLoadingCb)
self.project_manager.connect(
"new-project-loaded", self._newProjectLoaded)
self.project_manager.connect("project-closed", self._projectClosed)
self._createActions()
self._checkVersion()
示例5: __init__
def __init__(self):
Loggable.__init__(self)
# Init logging as early as possible so we can log startup code
enable_color = not os.environ.get('PITIVI_DEBUG_NO_COLOR', '0') in ('', '1')
# Let's show a human-readable pitivi debug output by default, and only
# show a crazy unreadable mess when surrounded by gst debug statements.
enable_crack_output = "GST_DEBUG" in os.environ
log.init('PITIVI_DEBUG', enable_color, enable_crack_output)
self.info('starting up')
self.settings = GlobalSettings()
self.threads = ThreadMaster()
self.effects = EffectsHandler()
self.system = getSystem()
self.current_project = None
self.projectManager = ProjectManager(self)
self._connectToProjectManager(self.projectManager)
self.action_log = UndoableActionLog()
self.debug_action_log_observer = DebugActionLogObserver()
self.debug_action_log_observer.startObserving(self.action_log)
# TODO reimplement the observing after GES port
#self.timelineLogObserver = TimelineLogObserver(self.action_log)
self.projectLogObserver = ProjectLogObserver(self.action_log)
self._version_information = {}
self._checkVersion()
示例6: test_write_config_file
def test_write_config_file(self):
GlobalSettings.addConfigSection("section-new")
GlobalSettings.addConfigOption("sectionNewOptionA",
section="section-new", key="option-a",
default="elmo")
with mock.patch("pitivi.settings.xdg_config_home") as xdg_config_home,\
tempfile.TemporaryDirectory() as temp_dir:
xdg_config_home.return_value = temp_dir
settings1 = GlobalSettings()
settings1.sectionNewOptionA = "kermit"
settings1.storeSettings()
settings2 = GlobalSettings()
self.assertEqual(settings2.sectionNewOptionA, "kermit")
示例7: _setup
def _setup(self):
self.settings = GlobalSettings()
self.threads = ThreadMaster()
self.effects = EffectsManager()
self.proxy_manager = ProxyManager(self)
self.system = get_system()
self.project_manager.connect(
"new-project-loading", self._newProjectLoadingCb)
self.project_manager.connect(
"new-project-loaded", self._newProjectLoaded)
self.project_manager.connect("project-closed", self._projectClosed)
self._createActions()
self._syncDoUndo()
示例8: _valueChanged
def _valueChanged(self, fake_widget, real_widget, attrname):
value = getattr(self.settings, attrname)
if attrname not in self.original_values:
self.original_values[attrname] = value
if attrname + "Changed" not in GlobalSettings.get_signals():
self.restart_warning.show()
self.revert_button.set_sensitive(True)
# convert the value of the widget to whatever type it is currently
if value is not None:
value = type(value)(real_widget.getWidgetValue())
setattr(self.settings, attrname, value)
# adjust controls as appropriate
self.resets[attrname].set_sensitive(not self.settings.isDefault(attrname))
self.factory_settings.set_sensitive(True)
示例9: __init__
def __init__(self):
"""
initialize pitivi with the command line arguments
"""
Loggable.__init__(self)
# init logging as early as possible so we can log startup code
enable_color = os.environ.get('PITIVI_DEBUG_NO_COLOR', '0') in ('', '0')
# Let's show a human-readable pitivi debug output by default, and only
# show a crazy unreadable mess when surrounded by gst debug statements.
enable_crack_output = "GST_DEBUG" in os.environ
log.init('PITIVI_DEBUG', enable_color, enable_crack_output)
self.info('starting up')
# store ourself in the instance global
if instance.PiTiVi:
raise RuntimeWarning(_("There is already a %s instance, please inform "
"the developers by filing a bug at "
"http://bugzilla.gnome.org/enter_bug.cgi?product=pitivi")
% APPNAME)
instance.PiTiVi = self
self.current = None
# get settings
self.settings = GlobalSettings()
self.threads = ThreadMaster()
#self.screencast = False
self.effects = EffectsHandler()
self.system = getSystem()
self.projectManager = ProjectManager(self.effects)
self._connectToProjectManager(self.projectManager)
self.action_log = UndoableActionLog()
self.debug_action_log_observer = DebugActionLogObserver()
self.debug_action_log_observer.startObserving(self.action_log)
# TODO reimplement the observing after GES port
#self.timelineLogObserver = TimelineLogObserver(self.action_log)
self.projectLogObserver = ProjectLogObserver(self.action_log)
self.medialibrary_log_observer = MediaLibraryLogObserver(self.action_log)
self.version_information = {}
self._checkVersion()
示例10: _valueChanged
def _valueChanged(self, unused_fake_widget, real_widget, attrname):
# Disable missing docstring
#pylint: disable=C0111
value = getattr(self.settings, attrname)
if attrname not in self.original_values:
self.original_values[attrname] = value
if not GlobalSettings.notifiesConfigOption(attrname):
self.restart_warning.show()
self.revert_button.set_sensitive(True)
# convert the value of the widget to whatever type it is currently
if value is not None:
value = type(value)(real_widget.getWidgetValue())
setattr(self.settings, attrname, value)
# adjust controls as appropriate
self.resets[attrname].set_sensitive(not self.settings.isDefault(attrname))
self.factory_settings.set_sensitive(True)
示例11: __init__
def __init__(self):
"""
initialize pitivi with the command line arguments
"""
Loggable.__init__(self)
# init logging as early as possible so we can log startup code
enable_color = os.environ.get('PITIVI_DEBUG_NO_COLOR', '0') in ('', '0')
log.init('PITIVI_DEBUG', enable_color)
self.info('starting up')
# store ourself in the instance global
if instance.PiTiVi:
raise RuntimeWarning(
_("There is already a %s instance, please inform the developers by filing a bug at http://bugzilla.gnome.org/enter_bug.cgi?product=pitivi")
% APPNAME)
instance.PiTiVi = self
self.projects = []
self.current = None
# get settings
self.settings = GlobalSettings()
self.threads = ThreadMaster()
#self.screencast = False
self.plugin_manager = PluginManager(
self.settings.get_local_plugin_path(),
self.settings.get_plugin_settings_path())
self.effects = Magician()
self.deviceprobe = get_probe()
self.projectManager = ProjectManager()
self._connectToProjectManager(self.projectManager)
self.action_log = UndoableActionLog()
self.debug_action_log_observer = DebugActionLogObserver()
self.debug_action_log_observer.startObserving(self.action_log)
self.timelineLogObserver = TimelineLogObserver(self.action_log)
self.projectLogObserver = ProjectLogObserver(self.action_log)
self.sourcelist_log_observer = SourceListLogObserver(self.action_log)
示例12: Pitivi
class Pitivi(Loggable, Signallable):
"""
Pitivi's main application class.
Signals:
- C{new-project} : A new C{Project} is loaded and ready to use.
- C{new-project-loading} : Pitivi is attempting to load a new project.
- C{new-project-loaded} : A new L{Project} has been loaded, and the UI should refresh it's view.
- C{new-project-failed} : A new L{Project} failed to load.
- C{closing-project} : pitivi would like to close a project. handlers should return false
if they do not want this project to close. by default, assumes
true. This signal should only be used by classes that might want to abort
the closing of a project.
- C{project-closed} : The project is closed, it will be freed when the callback returns.
Classes should connect to this instance when they want to know that
data related to that project is no longer going to be used.
- C{shutdown} : Used internally, do not use this signal.`
@ivar settings: Application-wide settings.
@type settings: L{GlobalSettings}.
@ivar current: Currently used project.
@type current: L{Project}.
"""
__signals__ = {
"new-project": ["project"],
"new-project-loading": ["uri"],
"new-project-created": ["project"],
"new-project-loaded": ["project"],
"new-project-failed": ["uri", "exception"],
"closing-project": ["project"],
"project-closed": ["project"],
"missing-uri": ["formatter", "uri"],
"version-info-received": ["versions"],
"shutdown": None}
def __init__(self):
"""
initialize pitivi with the command line arguments
"""
Loggable.__init__(self)
# init logging as early as possible so we can log startup code
enable_color = os.environ.get('PITIVI_DEBUG_NO_COLOR', '0') in ('', '0')
# Let's show a human-readable pitivi debug output by default, and only
# show a crazy unreadable mess when surrounded by gst debug statements.
enable_crack_output = "GST_DEBUG" in os.environ
log.init('PITIVI_DEBUG', enable_color, enable_crack_output)
self.info('starting up')
# store ourself in the instance global
if instance.PiTiVi:
raise RuntimeWarning(_("There is already a %s instance, please inform "
"the developers by filing a bug at "
"http://bugzilla.gnome.org/enter_bug.cgi?product=pitivi")
% APPNAME)
instance.PiTiVi = self
self.current = None
# get settings
self.settings = GlobalSettings()
self.threads = ThreadMaster()
#self.screencast = False
self.effects = EffectsHandler()
self.system = getSystem()
self.projectManager = ProjectManager(self.effects)
self._connectToProjectManager(self.projectManager)
self.action_log = UndoableActionLog()
self.debug_action_log_observer = DebugActionLogObserver()
self.debug_action_log_observer.startObserving(self.action_log)
# TODO reimplement the observing after GES port
#self.timelineLogObserver = TimelineLogObserver(self.action_log)
self.projectLogObserver = ProjectLogObserver(self.action_log)
self.medialibrary_log_observer = MediaLibraryLogObserver(self.action_log)
self.version_information = {}
self._checkVersion()
def shutdown(self):
"""
Close PiTiVi.
@return: C{True} if PiTiVi was successfully closed, else C{False}.
@rtype: C{bool}
"""
self.debug("shutting down")
# we refuse to close if we're running a user interface and the user
# doesn't want us to close the current project.
if self.current and not self.projectManager.closeRunningProject():
self.warning("Not closing since running project doesn't want to close")
return False
self.threads.stopAllThreads()
self.settings.storeSettings()
self.current = None
#.........这里部分代码省略.........
示例13:
import pitivi.settings as settings
from pitivi.settings import GlobalSettings
from pitivi.configure import get_pixmap_dir
import pitivi.utils as utils
from pitivi.utils.misc import big_to_cairo_alpha_mask, big_to_cairo_red_mask, big_to_cairo_green_mask, big_to_cairo_blue_mask
from pitivi.utils.receiver import receiver, handler
from pitivi.utils.timeline import Zoomable
from pitivi.utils.signal import Signallable
from pitivi.utils.loggable import Loggable
from pitivi.dialogs.prefs import PreferencesDialog
GlobalSettings.addConfigSection("thumbnailing")
GlobalSettings.addConfigOption("thumbnailSpacingHint",
section="thumbnailing",
key="spacing-hint",
default=5,
notify=True)
GlobalSettings.addConfigOption("thumbnailPeriod",
section="thumbnailing",
key="thumbnail-period",
default=gst.SECOND,
notify=True)
PreferencesDialog.addNumericPreference("thumbnailSpacingHint",
section=_("Appearance"),
label=_("Thumbnail gap"),
示例14: PreviewWidget
from pitivi.configure import get_pixmap_dir
from pitivi.settings import GlobalSettings
from pitivi.utils.loggable import Loggable
from pitivi.utils.misc import uri_is_valid
from pitivi.utils.ui import beautify_length, beautify_stream,\
SPACING
from pitivi.viewer import ViewerWidget
DEFAULT_AUDIO_IMAGE = os.path.join(get_pixmap_dir(), "pitivi-sound.png")
PREVIEW_WIDTH = 250
PREVIEW_HEIGHT = 100
GlobalSettings.addConfigSection('filechooser-preview')
GlobalSettings.addConfigOption('FCEnablePreview',
section='filechooser-preview',
key='do-preview-on-clip-import',
default=True)
GlobalSettings.addConfigOption('FCpreviewWidth',
section='filechooser-preview',
key='video-preview-width',
default=PREVIEW_WIDTH)
GlobalSettings.addConfigOption('FCpreviewHeight',
section='filechooser-preview',
key='video-preview-height',
default=PREVIEW_HEIGHT)
class PreviewWidget(gtk.VBox, Loggable):
示例15: Gap
import pitivi.utils as utils
from pitivi.configure import get_pixmap_dir
from pitivi.elements.singledecodebin import SingleDecodeBin
from pitivi.elements.thumbnailsink import CairoSurfaceThumbnailSink
from pitivi.elements.arraysink import ArraySink
from pitivi.signalinterface import Signallable
import pitivi.stream as stream
from pitivi.settings import GlobalSettings
from pitivi.ui.zoominterface import Zoomable
from pitivi.log.loggable import Loggable
from pitivi.factories.file import PictureFileSourceFactory
from pitivi.thumbnailcache import ThumbnailCache
from pitivi.ui.prefs import PreferencesDialog
from pitivi.receiver import receiver, handler
GlobalSettings.addConfigSection("thumbnailing")
GlobalSettings.addConfigOption(
"thumbnailSpacingHint", section="thumbnailing", key="spacing-hint", default=2, notify=True
)
PreferencesDialog.addNumericPreference(
"thumbnailSpacingHint",
section=_("Appearance"),
label=_("Thumbnail Gap (pixels)"),
lower=0,
description=_("The gap between thumbnails"),
)
# this default works out to a maximum of ~ 1.78 MiB per factory, assuming:
# 4:3 aspect ratio
# 4 bytes per pixel