Exemple #1
0
    def _create_default_config(self, child_name):
        """Creates default settings to save the state of a detachable widget."""
        try:
            GlobalSettings.add_config_section(child_name)
        except ConfigError:
            self.info("Section %s already exists", child_name)
            return

        GlobalSettings.add_config_option(child_name + "docked",
                                         section=child_name,
                                         key="docked",
                                         default=True)
        GlobalSettings.add_config_option(child_name + "width",
                                         section=child_name,
                                         key="width",
                                         default=320)
        GlobalSettings.add_config_option(child_name + "height",
                                         section=child_name,
                                         key="height",
                                         default=400)
        GlobalSettings.add_config_option(child_name + "x",
                                         section=child_name,
                                         key="x",
                                         default=0)
        GlobalSettings.add_config_option(child_name + "y",
                                         section=child_name,
                                         key="y",
                                         default=0)

        self.settings.read_setting_section_from_file(child_name)
    def test_add_config_option(self):
        def add_option():
            GlobalSettings.add_config_option("optionA1",
                                             section="section-a",
                                             key="option-a-1",
                                             default=False)

        # "section-a" does not exist.
        with self.assertRaises(ConfigError):
            add_option()

        GlobalSettings.add_config_section("section-a")
        add_option()
        self.assertFalse(GlobalSettings.optionA1)
        with self.assertRaises(ConfigError):
            add_option()
    def test_write_config_file(self):
        GlobalSettings.add_config_section("section-new")
        GlobalSettings.add_config_option("sectionNewOptionA",
                                         section="section-new",
                                         key="option-a",
                                         default="elmo")
        GlobalSettings.add_config_option("sectionNewOptionB",
                                         section="section-new",
                                         key="option-b",
                                         default=["foo"])

        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.sectionNewOptionB = []
            settings1.store_settings()

            settings2 = GlobalSettings()
            self.assertEqual(settings2.sectionNewOptionA, "kermit")
            self.assertEqual(settings2.sectionNewOptionB, [])
Exemple #4
0
from pitivi.utils.misc import asset_get_duration
# Remove check when we depend on Gst >= 1.20
HAS_GST_1_19 = GstDependency("Gst", apiversion="1.0",
                             version_required="1.19").check()

# Make sure gst knowns about our own GstPresets
Gst.preset_set_app_dir(get_gstpresets_dir())


class ProxyingStrategy:
    AUTOMATIC = "automatic"
    ALL = "all"
    NOTHING = "nothing"


GlobalSettings.add_config_section("proxy")
GlobalSettings.add_config_option('proxying_strategy',
                                 section='proxy',
                                 key='proxying-strategy',
                                 default=ProxyingStrategy.AUTOMATIC)

GlobalSettings.add_config_option('num_transcoding_jobs',
                                 section='proxy',
                                 key='num-proxying-jobs',
                                 default=4,
                                 notify=True)
PreferencesDialog.add_numeric_preference(
    'num_transcoding_jobs',
    description="",
    section="_proxies",
    label=_("Max number of parallel transcoding jobs"),
Exemple #5
0
from gi.repository import Gtk
from gi.repository import Pango

from pitivi.settings import GlobalSettings
from pitivi.utils.loggable import Loggable
from pitivi.utils.misc import uri_is_valid
from pitivi.utils.pipeline import AssetPipeline
from pitivi.utils.ui import beautify_length
from pitivi.utils.ui import beautify_stream
from pitivi.utils.ui import SPACING
from pitivi.viewer.viewer import ViewerWidget

PREVIEW_WIDTH = 250
PREVIEW_HEIGHT = 100

GlobalSettings.add_config_section('filechooser-preview')
GlobalSettings.add_config_option('FCEnablePreview',
                                 section='filechooser-preview',
                                 key='do-preview-on-clip-import',
                                 default=True)
GlobalSettings.add_config_option('FCpreviewWidth',
                                 section='filechooser-preview',
                                 key='video-preview-width',
                                 default=PREVIEW_WIDTH)
GlobalSettings.add_config_option('FCpreviewHeight',
                                 section='filechooser-preview',
                                 key='video-preview-height',
                                 default=PREVIEW_HEIGHT)

ACCEPTABLE_TAGS = [
    Gst.TAG_ALBUM_ARTIST, Gst.TAG_ARTIST, Gst.TAG_TITLE, Gst.TAG_ALBUM,
                                 section="main-window",
                                 key="Y",
                                 default=0,
                                 type_=int)
GlobalSettings.add_config_option('mainWindowWidth',
                                 section="main-window",
                                 key="width",
                                 default=-1,
                                 type_=int)
GlobalSettings.add_config_option('mainWindowHeight',
                                 section="main-window",
                                 key="height",
                                 default=-1,
                                 type_=int)

GlobalSettings.add_config_section('export')
GlobalSettings.add_config_option('lastExportFolder',
                                 section='export',
                                 key="last-export-folder",
                                 environment="PITIVI_EXPORT_FOLDER",
                                 default=os.path.expanduser("~"))

GlobalSettings.add_config_section("version")
GlobalSettings.add_config_option('displayCounter',
                                 section='version',
                                 key='info-displayed-counter',
                                 default=0)
GlobalSettings.add_config_option('lastCurrentVersion',
                                 section='version',
                                 key='last-current-version',
                                 default='')
Exemple #7
0
from gi.repository import GES
from gi.repository import Gio
from gi.repository import GLib
from gi.repository import GObject
from gi.repository import Gst
from gi.repository import Gtk

from pitivi.settings import GlobalSettings
from pitivi.utils.loggable import Loggable
from pitivi.utils.pipeline import AssetPipeline
from pitivi.utils.ui import SPACING
from pitivi.utils.widgets import TimeWidget
from pitivi.viewer.guidelines import GuidelinesPopover
from pitivi.viewer.overlay_stack import OverlayStack

GlobalSettings.add_config_section("viewer")
GlobalSettings.add_config_option("viewerDocked",
                                 section="viewer",
                                 key="docked",
                                 default=True)
GlobalSettings.add_config_option("viewerWidth",
                                 section="viewer",
                                 key="width",
                                 default=320)
GlobalSettings.add_config_option("viewerHeight",
                                 section="viewer",
                                 key="height",
                                 default=240)
GlobalSettings.add_config_option("viewerX",
                                 section="viewer",
                                 key="x-pos",
Exemple #8
0
from pitivi.medialibrary import MediaLibraryWidget
from pitivi.perspective import Perspective
from pitivi.project import ProjectSettingsDialog
from pitivi.settings import GlobalSettings
from pitivi.tabsmanager import BaseTabs
from pitivi.timeline.previewers import ThumbnailCache
from pitivi.timeline.timeline import TimelineContainer
from pitivi.transitions import TransitionsListWidget
from pitivi.utils.loggable import Loggable
from pitivi.utils.misc import path_from_uri
from pitivi.utils.ui import beautify_time_delta
from pitivi.utils.ui import EDITOR_PERSPECTIVE_CSS
from pitivi.utils.ui import info_name
from pitivi.viewer.viewer import ViewerContainer

GlobalSettings.add_config_section("main-window")
GlobalSettings.add_config_option('mainWindowHPanePosition',
                                 section="main-window",
                                 key="hpane-position",
                                 type_=int)
GlobalSettings.add_config_option('mainWindowMainHPanePosition',
                                 section="main-window",
                                 key="main-hpane-position",
                                 type_=int)
GlobalSettings.add_config_option('mainWindowVPanePosition',
                                 section="main-window",
                                 key="vpane-position",
                                 type_=int)
GlobalSettings.add_config_option('lastProjectFolder',
                                 section="main-window",
                                 key="last-folder",
Exemple #9
0
    "colorconvert",
    "festival",
    "navigationtest",
    "videoanalyse",
    # We prefer to use videocrop, see https://gitlab.gnome.org/GNOME/pitivi/issues/2150
    "videobox",
    "videodetect",
    "volume",
]

HIDDEN_EFFECTS = [
    # Overlaying an image onto a video stream can already be done.
    "gdkpixbufoverlay"
]

GlobalSettings.add_config_section('effect-library')
GlobalSettings.add_config_option('favourite_effects',
                                 section='effect-library',
                                 key='favourite-effects',
                                 default=[])

ICON_WIDTH = 80
ICON_HEIGHT = 45


class EffectInfo:
    """Info for displaying and using an effect.

    Attributes:
        effect_name (str): The bin_description identifying the effect.
    """
Exemple #10
0
# You should have received a copy of the GNU Lesser General Public
# License along with this program; if not, see <http://www.gnu.org/licenses/>.
"""PluginManager for loading Pitivi plugins."""
import os
from enum import IntEnum
from gettext import gettext as _

from gi.repository import GObject
from gi.repository import Peas

from pitivi.configure import get_plugins_dir
from pitivi.configure import get_user_plugins_dir
from pitivi.settings import GlobalSettings
from pitivi.utils.loggable import Loggable

GlobalSettings.add_config_section("plugins")
GlobalSettings.add_config_option("ActivePlugins",
                                 section="plugins",
                                 key="active-plugins",
                                 default=[])


class API(GObject.GObject):
    """Interface that gives access to all the objects inside Pitivi."""
    def __init__(self, app):
        GObject.GObject.__init__(self)
        self.app = app


class PluginType(IntEnum):
    """Types of plugins we support, depending on their directory location."""
Exemple #11
0
from gi.repository import GObject
from gi.repository import Gtk

from pitivi.configure import get_ui_dir
from pitivi.configure import get_user_plugins_dir
from pitivi.pluginmanager import PluginManager
from pitivi.settings import GlobalSettings
from pitivi.utils import widgets
from pitivi.utils.loggable import Loggable
from pitivi.utils.ui import alter_style_class
from pitivi.utils.ui import fix_infobar
from pitivi.utils.ui import PADDING
from pitivi.utils.ui import PREFERENCES_CSS
from pitivi.utils.ui import SPACING

GlobalSettings.add_config_section("user-interface")

GlobalSettings.add_config_option('prefsDialogWidth',
                                 section="user-interface",
                                 key="prefs-dialog-width",
                                 default=600)

GlobalSettings.add_config_option('prefsDialogHeight',
                                 section="user-interface",
                                 key="prefs-dialog-height",
                                 default=400)


class PreferencesDialog(Loggable):
    """Preferences for how the app works."""
    def test_read_config_file(self):
        GlobalSettings.add_config_section("section-1")
        GlobalSettings.add_config_option("section1OptionA",
                                         section="section-1",
                                         key="option-a",
                                         default=50)
        GlobalSettings.add_config_option("section1OptionB",
                                         section="section-1",
                                         key="option-b",
                                         default=False)
        GlobalSettings.add_config_option("section1OptionC",
                                         section="section-1",
                                         key="option-c",
                                         default="")
        GlobalSettings.add_config_option("section1OptionD",
                                         section="section-1",
                                         key="option-d",
                                         default=[])
        GlobalSettings.add_config_option("section1OptionE",
                                         section="section-1",
                                         key="option-e",
                                         default=["foo"])
        GlobalSettings.add_config_option("section1OptionF",
                                         section="section-1",
                                         key="option-f",
                                         default=Gdk.RGBA())

        self.assertEqual(GlobalSettings.section1OptionA, 50)
        self.assertEqual(GlobalSettings.section1OptionB, False)
        self.assertEqual(GlobalSettings.section1OptionC, "")
        self.assertEqual(GlobalSettings.section1OptionD, [])
        self.assertEqual(GlobalSettings.section1OptionE, ["foo"])
        self.assertEqual(GlobalSettings.section1OptionF, Gdk.RGBA())

        self.assertIs(
            GlobalSettings.options["section-1"]["section1OptionA"][0], int)
        self.assertIs(
            GlobalSettings.options["section-1"]["section1OptionB"][0], bool)
        self.assertIs(
            GlobalSettings.options["section-1"]["section1OptionC"][0], str)
        self.assertIs(
            GlobalSettings.options["section-1"]["section1OptionD"][0], list)
        self.assertIs(
            GlobalSettings.options["section-1"]["section1OptionE"][0], list)
        self.assertIs(
            GlobalSettings.options["section-1"]["section1OptionF"][0],
            Gdk.RGBA)

        conf_file_content = ("[section-1]\n"
                             "option-a = 10\n"
                             "option-b = True\n"
                             "option-c = Pigs fly\n"
                             "option-d=\n"
                             "option-e=\n"
                             "     elmo\n"
                             "          knows\n"
                             "     where you live\n"
                             "option-f=rgba(51,102,255,0.4)")

        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")
        self.assertEqual(settings.section1OptionD, [])
        expected_e_value = ["elmo", "knows", "where you live"]
        self.assertEqual(settings.section1OptionE, expected_e_value)
        self.assertEqual(settings.section1OptionF,
                         Gdk.RGBA(0.2, 0.4, 1.0, 0.4))
 def test_add_section(self):
     GlobalSettings.add_config_section("section-a")
     GlobalSettings.add_config_section("section-a")