Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
import os
# Disable gst-vaapi as it doesn't seem to work with gtksink.
# https://github.com/otsaloma/gaupol/issues/79
os.environ["LIBVA_DRIVER_NAME"] = "null"
os.environ["LIBVA_DRIVERS_PATH"] = "/dev/null"
gi.require_version("Gdk", "3.0")
gi.require_version("Gtk", "3.0")
for module, version in {
"Gst": "1.0",
"GstPbutils": "1.0",
"GstVideo": "1.0",
}.items():
with aeidon.util.silent(Exception):
gi.require_version(module, version)
with aeidon.util.silent(Exception):
from gi.repository import Gst
Gst.init(None)
from gaupol.urls import * # noqa
from gaupol import util # noqa
from gaupol.enums import * # noqa
from gaupol.errors import * # noqa
from gaupol.attrdict import * # noqa
from gaupol.config import ConfigurationStore # noqa
conf = ConfigurationStore()
from gaupol import style # noqa
from gaupol import ruler # noqa
from gaupol.entries import * # noqa
def __init__(self, parent, title, doc):
"""Initialize an :class:`OpenDialog` instance."""
GObject.GObject.__init__(self)
self._use_autodetection = aeidon.util.chardet_available()
self._init_dialog(parent, title)
self._init_extra_widget()
self._init_filters()
self._init_encoding_combo()
self._init_align_combo()
self._init_values(doc)
def _affirm_doable(self, application, page, selected_rows):
aeidon.util.affirm(page is not None)
aeidon.util.affirm(page.project.main_file is not None)
def _populate_store(self, store):
"""Add all available languages to `store`."""
locales = []
with aeidon.util.silent(Exception):
locales = aeidon.SpellChecker.list_languages()
for locale in locales:
with aeidon.util.silent(Exception):
name = aeidon.locales.code_to_name(locale)
store.append((locale, name))
def remove(path):
"""Remove temporary file or directory at `path`."""
if os.path.isfile(path):
with aeidon.util.silent(OSError):
os.remove(path)
if os.path.isdir(path):
for name in os.listdir(path):
remove(os.path.join(path, name))
with aeidon.util.silent(OSError):
os.rmdir(path)
def _init_text_view(self):
"""Initialize the text view."""
self._text_view.set_wrap_mode(Gtk.WrapMode.WORD)
self._text_view.set_editable(False)
self._text_view.set_cursor_visible(False)
self._text_view.set_accepts_tab(False)
self._text_view.set_left_margin(6)
self._text_view.set_right_margin(6)
with aeidon.util.silent(AttributeError):
# Top and bottom margins available since GTK 3.18.
self._text_view.set_top_margin(6)
self._text_view.set_bottom_margin(6)
text_buffer = self._text_view.get_buffer()
text_buffer.create_tag("monospace", family="monospace")
text_buffer.create_tag("bold", weight=Pango.Weight.BOLD)
text_buffer.create_tag("large", scale=1.1)
scroller = Gtk.ScrolledWindow()
scroller.set_policy(*((Gtk.PolicyType.AUTOMATIC,)*2))
scroller.set_shadow_type(Gtk.ShadowType.ETCHED_IN)
scroller.add(self._text_view)
box = self.get_message_area()
gaupol.util.pack_start_expand(box, scroller)
box.show_all()
def _affirm_doable(self, application, page, selected_rows):
aeidon.util.affirm(page is not None)
aeidon.util.affirm(application.pattern)
def __init__(self):
"""Initialize a :class:`IntegerCellRenderer` instance."""
GObject.GObject.__init__(self)
aeidon.util.connect(self, self, "edited")
aeidon.util.connect(self, self, "editing-started")