def test_gobject_inheritance(self): # GObject.Object is a class hierarchy as follows: # overrides.Object -> introspection.Object -> static.GObject GIObjectModule = get_introspection_module('GObject') self.assertTrue(issubclass(GObject.Object, GIObjectModule.Object)) self.assertTrue(issubclass(GIObjectModule.Object, _gobject.GObject)) self.assertEqual(_gobject.GObject.__gtype__, GObject.TYPE_OBJECT) self.assertEqual(GIObjectModule.Object.__gtype__, GObject.TYPE_OBJECT) self.assertEqual(GObject.Object.__gtype__, GObject.TYPE_OBJECT) # The pytype wrapper should hold the outer most Object class from overrides. self.assertEqual(GObject.TYPE_OBJECT.pytype, GObject.Object)
def test_gobject_inheritance(self): # GObject.Object is a class hierarchy as follows: # overrides.Object -> introspection.Object -> static.GObject GIObjectModule = get_introspection_module('GObject') self.assertTrue(issubclass(GObject.Object, GIObjectModule.Object)) self.assertTrue(issubclass(GIObjectModule.Object, _gi.GObject)) self.assertEqual(_gi.GObject.__gtype__, GObject.TYPE_OBJECT) self.assertEqual(GIObjectModule.Object.__gtype__, GObject.TYPE_OBJECT) self.assertEqual(GObject.Object.__gtype__, GObject.TYPE_OBJECT) # The pytype wrapper should hold the outer most Object class from overrides. self.assertEqual(GObject.TYPE_OBJECT.pytype, GObject.Object)
def _import_external_modules(): global _import_external_modules_done, bus, Gio, GLib, Variant if _import_external_modules_done: return _import_external_modules_done = True # Required for Gio.Cancellable. # See https://lazka.github.io/pgi-docs/Gio-2.0/classes/Cancellable.html#Gio.Cancellable from gi.module import get_introspection_module Gio = get_introspection_module('Gio') from gi.repository import GLib as glib_module GLib = glib_module from pydbus import SystemBus, Variant bus = SystemBus() from pydbus import Variant as variant_class Variant = variant_class
from gi.module import get_introspection_module from gi.repository import Gdk, GLib, GObject, Pango from meld.style import colour_lookup_with_fallback from meld.treehelpers import SearchableTreeStore from meld.vc._vc import ( # noqa: F401 CONFLICT_BASE, CONFLICT_LOCAL, CONFLICT_MERGED, CONFLICT_OTHER, CONFLICT_REMOTE, CONFLICT_THIS, STATE_CONFLICT, STATE_EMPTY, STATE_ERROR, STATE_IGNORED, STATE_MAX, STATE_MISSING, STATE_MODIFIED, STATE_NEW, STATE_NOCHANGE, STATE_NONE, STATE_NONEXIST, STATE_NORMAL, STATE_REMOVED, ) _GIGtk = None try: _GIGtk = get_introspection_module('Gtk') except Exception: pass COL_PATH, COL_STATE, COL_TEXT, COL_ICON, COL_TINT, COL_FG, COL_STYLE, \ COL_WEIGHT, COL_STRIKE, COL_END = list(range(10)) COL_TYPES = (str, str, str, str, Gdk.RGBA, Gdk.RGBA, Pango.Style, Pango.Weight, bool) class DiffTreeStore(SearchableTreeStore): def __init__(self, ntree, types): full_types = [] for col_type in (COL_TYPES + tuple(types)): full_types.extend([col_type] * ntree)
from gi.repository import GObject from gi.repository import Pango from meld.misc import colour_lookup_with_fallback from meld.treehelpers import SearchableTreeStore from meld.vc._vc import ( # noqa: F401 CONFLICT_BASE, CONFLICT_LOCAL, CONFLICT_MERGED, CONFLICT_OTHER, CONFLICT_REMOTE, CONFLICT_THIS, STATE_CONFLICT, STATE_EMPTY, STATE_ERROR, STATE_IGNORED, STATE_MAX, STATE_MISSING, STATE_MODIFIED, STATE_NEW, STATE_NOCHANGE, STATE_NONE, STATE_NONEXIST, STATE_NORMAL, STATE_REMOVED, ) _GIGtk = None try: _GIGtk = get_introspection_module('Gtk') except Exception: pass COL_PATH, COL_STATE, COL_TEXT, COL_ICON, COL_TINT, COL_FG, COL_STYLE, \ COL_WEIGHT, COL_STRIKE, COL_END = list(range(10)) COL_TYPES = (str, str, str, str, Gdk.RGBA, Gdk.RGBA, Pango.Style, Pango.Weight, bool) class DiffTreeStore(SearchableTreeStore): def __init__(self, ntree, types): full_types = [] for col_type in (COL_TYPES + tuple(types)):
from collections import namedtuple from contextlib import suppress from datetime import datetime from enum import Enum from json import loads, dumps from os import linesep from struct import pack, unpack from subprocess import DEVNULL, CalledProcessError, check_output from sys import stdin, stdout, exit from threading import Thread from time import sleep from gi import require_version require_version('Gdk', '3.0') from gi.module import get_introspection_module get_introspection_module('Gdk').set_allowed_backends('x11') from gi.repository import Gdk, GdkX11 PROC_NAME = 'firefox' INTERVAL = 1 # Interval in seconds for continuous decoration. CONTINUOUS = False # Flag for continuous decorations (experimental). LOGFILE = '/tmp/hide-ff-title-bar.log' LOGGING = False # Enable for debugging only! Window = namedtuple('Window', ('id', 'desktop', 'pid', 'machine', 'title')) class EmptyMessage(Exception): """Indicates that a message of size zero was received on stdin.""" pass
import sys from gi.repository import GObject from gi.overrides import override from gi.module import get_introspection_module Gwy = get_introspection_module('Gwy') __all__ = [] def match_signature(args, types): if len(args) != len(types): return False for pair in zip(args, types): if not issubclass(pair[0], pair[1]): return False return True class Unit(Gwy.Unit): def __nonzero__(self): return not self.is_empty() Unit = override(Unit) __all__.append('Unit')