def _check_required_deps(): error_message = 'Gajim needs %s to run. Quitting… (Error: %s)' try: import nbxmpp except ImportError as error: sys.exit(error_message % ('python-nbxmpp', error)) try: import gi except ImportError as error: sys.exit(error_message % ('pygobject', error)) try: gi.require_versions({ 'GLib': '2.0', 'Gio': '2.0', 'Gtk': '3.0', 'GObject': '2.0', 'Pango': '1.0', 'Soup': '2.4' }) except ValueError as error: sys.exit('Missing dependency: %s' % error) try: import cairo except ImportError as error: sys.exit(error_message % ('python-cairo', error)) from gi.repository import Gtk gtk_ver = '%s.%s.%s' % (Gtk.get_major_version(), Gtk.get_minor_version(), Gtk.get_micro_version()) from gi.repository import GLib glib_ver = '.'.join( map(str, [GLib.MAJOR_VERSION, GLib.MINOR_VERSION, GLib.MICRO_VERSION])) check_version('python-nbxmpp', nbxmpp.__version__, _MIN_NBXMPP_VER) check_version('pygobject', gi.__version__, _MIN_PYGOBJECT_VER) check_version('libcairo', cairo.cairo_version_string(), _MIN_CAIRO_VER) check_version('python-cairo', cairo.version, _MIN_CAIRO_VER) check_version('gtk3', gtk_ver, _MIN_GTK_VER) check_version('glib', glib_ver, _MIN_GLIB_VER)
# https://developer.gnome.org/pygobject/stable/ # https://readthedocs.org/docs/python-gtk-3-tutorial/en/latest/index.html # https://wiki.ubuntu.com/DesktopExperienceTeam/ApplicationIndicators # https://github.com/canonical-web-and-design/older-apis import subprocess import os import os.path as osp import signal import sys import time import gi gi.require_versions({ 'AppIndicator3': '0.1', 'Gio': '2.0', 'GLib': '2.0', 'Gtk': '3.0', }) from gi.repository import ( AppIndicator3 as AppIndicator, Gio, GLib, Gtk, ) __all__ = ['SSHReverseTunnelIndicator'] __title__ = 'ssh-reverse-tunnel' __appname__ = 'SSH Reverse Tunnel Indicator' __version__ = '1.0' __appdesc__ = 'App Indicator for creating reverse SSH tunnels' __author__ = 'Rodrigo Silva'
# The following additional terms are in effect as per Section 7 of the license: # # The preservation of all legal notices and author attributions in # the material or in the Appropriate Legal Notices displayed # by works containing it is required. # # You should have received a copy of the GNU General Public License # along with whither; If not, see <http://www.gnu.org/licenses/>. """ Wrapper for GtkWindow """ # Standard Lib # 3rd-Party Libs import gi gi.require_versions({'Gtk': '3.0', 'Gdk': '3.0'}) from gi.repository import ( Gdk, Gtk, ) # This Library from whither.base.objects import Window WINDOW_STATES = { 'NORMAL': 0, 'MINIMIZED': Gdk.WindowState.ICONIFIED, 'MAXIMIZED': Gdk.WindowState.MAXIMIZED, 'FULLSCREEN': Gdk.WindowState.FULLSCREEN, }
THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. Right-click menus for various widgets. """ import asyncio import logging import gi gi.require_versions({'Gtk': '3.0', 'Pango': '1.0'}) from gi.repository import Gtk, GLib class UserRowMenu(Gtk.Popover): def __init__(self, room, row): super().__init__() self.log = logging.getLogger('ad1459.user-row-menu') self.user = '' self.room = room self.row = row self.nick = self.room.network.nickname self.userop = False if self.nick in self.room.ops:
import gi gi.require_versions({ 'Gtk': '3.0', }) from gi.repository import ( Gtk, Gdk, GObject, ) from .controller import GTKController
# This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see <http://www.gnu.org/licenses/>. # import gi import os import json import threading gi.require_versions({ 'Ide': '1.0', }) from gi.repository import GLib from gi.repository import GObject from gi.repository import Gio from gi.repository import Ide SYMBOL_PARAM_FLAGS=flags = GObject.ParamFlags.CONSTRUCT_ONLY | GObject.ParamFlags.READWRITE class JsSymbolNode(Ide.SymbolNode): file = GObject.Property(type=Ide.File, flags=SYMBOL_PARAM_FLAGS) line = GObject.Property(type=int, flags=SYMBOL_PARAM_FLAGS) col = GObject.Property(type=int, flags=SYMBOL_PARAM_FLAGS)
child_dict = { "child": Gtk.Widget, "child_name": str, "icon": Gtk.Image, "header_child": Gtk.Widget or None, "provider": Aduct.Provider } Here only ``header_child`` key is optional. """ import gi gi.require_versions({"Gtk": "3.0"}) from gi.repository import Gtk class Element(Gtk.Bin): __gsignals__ = { "action-clicked": (2, None, (Gtk.Button, int)), "child-added": (2, None, ()), "child-cleared": (2, None, ()), "child-removed": (2, None, ()), } def __init__(self, child_dict=None, use_action_button=True, pack_type=0, **kwargs): """
# Copyright 2020 NXP Semiconductors # SPDX-License-Identifier: BSD-3-Clause import os import subprocess import threading import gi gi.require_versions({'GdkPixbuf': '2.0', 'Gtk': '3.0'}) from gi.repository import GdkPixbuf, Gtk, GLib from eiq.apps import config from eiq.apps.utils import convert_image_to_png class MLPlayer(Gtk.Window): def __init__(self): Gtk.Window.__init__(self, title=config.MAIN_WINDOW_TITLE) self.set_default_size(640, 480) self.set_position(Gtk.WindowPosition.CENTER) self.demo_to_run = None self.demos_list = self.get_demos() self.description = Gtk.Label.new(config.DEFAULT_DEMOS_DESCRIPTION) self.image = config.DEFAULT_IMAGE self.displayed_image = Gtk.Image() self.grid = Gtk.Grid( row_spacing = 10, column_spacing = 10, border_width = 18, expand=True )
# GNU General Public License for more details. # # You should have received a copy of the GNU General Public License along # with GNOME Music; if not, write to the Free Software Foundation, Inc., # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. # # The GNOME Music authors hereby grant permission for non-GPL compatible # GStreamer plugins to be used and distributed together with GStreamer # and GNOME Music. This permission is above and beyond the permissions # granted by the GPL license by which GNOME Music is covered. If you # modify this code, you may extend this exception to your version of the # code, but you are not obligated to do so. If you do not wish to do so, # delete this exception statement from your version. import gi gi.require_versions({"Gfm": "0.1", "Grl": "0.3", 'Tracker': "2.0"}) from gi.repository import Gfm, Grl, GLib, GObject, Tracker from gnomemusic.corealbum import CoreAlbum from gnomemusic.coreartist import CoreArtist from gnomemusic.coredisc import CoreDisc from gnomemusic.coresong import CoreSong from gnomemusic.grilowrappers.grltrackerplaylists import GrlTrackerPlaylists class GrlTrackerWrapper(GObject.GObject): """Wrapper for the Grilo Tracker source. """ METADATA_KEYS = [ Grl.METADATA_KEY_ALBUM, Grl.METADATA_KEY_ALBUM_ARTIST,
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. """ GI_VERSIONS = { 'Gio': '2.0', 'GLib': '2.0', 'GObject': '2.0', 'Gtk': '3.0', } import gi gi.require_versions(GI_VERSIONS) from .application import Application from .toggles import file_toggle def run(id='in.donotspellitgav.ToggleDarkly'): pass
def init_test_environ(): set_dll_search_path() def dbus_launch_session(): if os.name == "nt" or sys.platform == "darwin": return (-1, "") try: out = subprocess.check_output([ "dbus-daemon", "--session", "--fork", "--print-address=1", "--print-pid=1" ]) except (subprocess.CalledProcessError, OSError): return (-1, "") else: out = out.decode("utf-8") addr, pid = out.splitlines() return int(pid), addr pid, addr = dbus_launch_session() if pid >= 0: os.environ["DBUS_SESSION_BUS_ADDRESS"] = addr atexit.register(os.kill, pid, signal.SIGKILL) else: os.environ["DBUS_SESSION_BUS_ADDRESS"] = "." tests_builddir = os.path.abspath( os.environ.get('TESTS_BUILDDIR', os.path.dirname(__file__))) builddir = os.path.dirname(tests_builddir) tests_srcdir = os.path.abspath(os.path.dirname(__file__)) srcdir = os.path.dirname(tests_srcdir) sys.path.insert(0, os.path.join(builddir, 'gi')) sys.path.insert(0, tests_srcdir) sys.path.insert(0, srcdir) sys.path.insert(0, tests_builddir) sys.path.insert(0, builddir) # force untranslated messages, as we check for them in some tests os.environ['LC_MESSAGES'] = 'C' os.environ['G_DEBUG'] = 'fatal-warnings fatal-criticals' if sys.platform == "darwin" or os.name == "nt": # gtk 3.22 has warnings and ciriticals on OS X, ignore for now. # On Windows glib will create an error dialog which will block tests # so it's never a good idea there to make things fatal. os.environ['G_DEBUG'] = '' # make Gio able to find our gschemas.compiled in tests/. This needs to be set # before importing Gio. Support a separate build tree, so look in build dir # first. os.environ['GSETTINGS_BACKEND'] = 'memory' os.environ['GSETTINGS_SCHEMA_DIR'] = tests_builddir os.environ['G_FILENAME_ENCODING'] = 'UTF-8' # Avoid accessibility dbus warnings os.environ['NO_AT_BRIDGE'] = '1' # A workaround for https://gitlab.gnome.org/GNOME/glib/-/issues/2251 # The gtk4 a11y stack calls get_dbus_object_path() on the default app os.environ['GTK_A11Y'] = 'none' # Force the default theme so broken themes don't affect the tests os.environ['GTK_THEME'] = 'Adwaita' import gi gi.require_version("GIRepository", "2.0") from gi.repository import GIRepository repo = GIRepository.Repository.get_default() repo.prepend_library_path(os.path.join(tests_builddir)) repo.prepend_search_path(tests_builddir) def try_require_version(namespace, version): try: gi.require_version(namespace, version) except ValueError: # prevent tests from running with the wrong version sys.modules["gi.repository." + namespace] = None # Optional try_require_version("Gtk", os.environ.get("TEST_GTK_VERSION", "3.0")) try_require_version("Gdk", os.environ.get("TEST_GTK_VERSION", "3.0")) try_require_version("GdkPixbuf", "2.0") try_require_version("Pango", "1.0") try_require_version("PangoCairo", "1.0") try_require_version("Atk", "1.0") # Required gi.require_versions({ "GIMarshallingTests": "1.0", "Regress": "1.0", "GLib": "2.0", "Gio": "2.0", "GObject": "2.0", }) # It's disabled for stable releases by default, this makes sure it's # always on for the tests. warnings.simplefilter('default', gi.PyGIDeprecationWarning) # Otherwise we crash on the first gtk use when e.g. DISPLAY isn't set try: from gi.repository import Gtk except ImportError: pass else: if Gtk._version == "4.0": res = Gtk.init_check() else: res = Gtk.init_check([])[0] if not res: raise RuntimeError("Gtk available, but Gtk.init_check() failed")
# GNU General Public License for more details. # # You should have received a copy of the GNU General Public License along # with GNOME Music; if not, write to the Free Software Foundation, Inc., # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. # # The GNOME Music authors hereby grant permission for non-GPL compatible # GStreamer plugins to be used and distributed together with GStreamer # and GNOME Music. This permission is above and beyond the permissions # granted by the GPL license by which GNOME Music is covered. If you # modify this code, you may extend this exception to your version of the # code, but you are not obligated to do so. If you do not wish to do so, # delete this exception statement from your version. import gi gi.require_versions({"MediaArt": "2.0", "Soup": "2.4"}) from gi.repository import Gio, GLib, GObject, MediaArt, Soup from gnomemusic.musiclogger import MusicLogger from gnomemusic.coreartist import CoreArtist from gnomemusic.corealbum import CoreAlbum from gnomemusic.coresong import CoreSong class StoreArt(GObject.Object): """Stores Art in the MediaArt cache. """ def __init__(self, coreobject, uri): """Initialize StoreArtistArt :param coreobject: The CoreArtist or CoreAlbum to store art for
import time import argparse import logging # This xinit import must happen before any GUI libraries are initialized. # pylint: disable=wrong-import-position,wrong-import-order,ungrouped-imports,unused-import import gi gi.require_versions({'Gtk': '3.0', 'Keybinder': '3.0'}) # pylint: disable=wrong-import-position from gi.repository import Gio, GLib, Gtk, Keybinder from ulauncher.config import FIRST_RUN from ulauncher.utils.environment import IS_X11 from ulauncher.utils.Settings import Settings from ulauncher.utils.desktop.notification import show_notification from ulauncher.ui.AppIndicator import AppIndicator from ulauncher.ui.windows.PreferencesWindow import PreferencesWindow from ulauncher.ui.windows.UlauncherWindow import UlauncherWindow from ulauncher.modes.extensions.ExtensionRunner import ExtensionRunner from ulauncher.modes.extensions.ExtensionServer import ExtensionServer logger = logging.getLogger() class UlauncherApp(Gtk.Application): # Gtk.Applications check if the app is already registered and if so, # new instances sends the signals to the registered one # So all methods except __init__ runs on the main app settings = Settings.get_instance() window = None # type: UlauncherWindow appindicator = None # type: AppIndicator _current_accel_name = None
def init_test_environ(): # this was renamed in Python 3, provide backwards compatible name if sys.version_info[:2] == (2, 7): unittest.TestCase.assertRaisesRegex = unittest.TestCase.assertRaisesRegexp if sys.version_info[0] == 3: unittest.TestCase.assertRegexpMatches = unittest.TestCase.assertRegex unittest.TestCase.assertRaisesRegexp = unittest.TestCase.assertRaisesRegex def dbus_launch_session(): if os.name == "nt" or sys.platform == "darwin": return (-1, "") try: out = subprocess.check_output([ "dbus-daemon", "--session", "--fork", "--print-address=1", "--print-pid=1"]) except (subprocess.CalledProcessError, OSError): return (-1, "") else: if sys.version_info[0] == 3: out = out.decode("utf-8") addr, pid = out.splitlines() return int(pid), addr pid, addr = dbus_launch_session() if pid >= 0: os.environ["DBUS_SESSION_BUS_ADDRESS"] = addr atexit.register(os.kill, pid, signal.SIGKILL) else: os.environ["DBUS_SESSION_BUS_ADDRESS"] = "." tests_builddir = os.path.abspath(os.environ.get('TESTS_BUILDDIR', os.path.dirname(__file__))) builddir = os.path.dirname(tests_builddir) tests_srcdir = os.path.abspath(os.path.dirname(__file__)) srcdir = os.path.dirname(tests_srcdir) sys.path.insert(0, os.path.join(builddir, 'gi')) sys.path.insert(0, tests_srcdir) sys.path.insert(0, srcdir) sys.path.insert(0, tests_builddir) sys.path.insert(0, builddir) # force untranslated messages, as we check for them in some tests os.environ['LC_MESSAGES'] = 'C' os.environ['G_DEBUG'] = 'fatal-warnings fatal-criticals' if sys.platform == "darwin": # gtk 3.22 has warnings and ciriticals on OS X, ignore for now os.environ['G_DEBUG'] = '' # make Gio able to find our gschemas.compiled in tests/. This needs to be set # before importing Gio. Support a separate build tree, so look in build dir # first. os.environ['GSETTINGS_BACKEND'] = 'memory' os.environ['GSETTINGS_SCHEMA_DIR'] = tests_builddir os.environ['G_FILENAME_ENCODING'] = 'UTF-8' # Force the default theme so broken themes don't affect the tests os.environ['GTK_THEME'] = 'Adwaita' import gi gi.require_version("GIRepository", "2.0") from gi.repository import GIRepository repo = GIRepository.Repository.get_default() repo.prepend_library_path(os.path.join(tests_builddir)) repo.prepend_library_path(os.path.join(tests_builddir, ".libs")) repo.prepend_search_path(tests_builddir) def try_require_version(namespace, version): try: gi.require_version(namespace, version) except ValueError: # prevent tests from running with the wrong version sys.modules["gi.repository." + namespace] = None # Optional try_require_version("Gtk", os.environ.get("TEST_GTK_VERSION", "3.0")) try_require_version("Gdk", os.environ.get("TEST_GTK_VERSION", "3.0")) try_require_version("GdkPixbuf", "2.0") try_require_version("Pango", "1.0") try_require_version("PangoCairo", "1.0") try_require_version("Atk", "1.0") # Required gi.require_versions({ "GIMarshallingTests": "1.0", "Regress": "1.0", "GLib": "2.0", "Gio": "2.0", "GObject": "2.0", }) # It's disabled for stable releases by default, this makes sure it's # always on for the tests. warnings.simplefilter('default', gi.PyGIDeprecationWarning) # Otherwise we crash on the first gtk use when e.g. DISPLAY isn't set try: from gi.repository import Gtk except ImportError: pass else: if Gtk._version == "4.0": res = Gtk.init_check() else: res = Gtk.init_check([])[0] if not res: raise RuntimeError("Gtk available, but Gtk.init_check() failed")
#!/usr/bin/env python3 # Third-Party Library import gi gi.require_versions({"Dazzle": "1.0", "GLib": "2.0", "Gtk": "3.0"}) from gi.repository import Dazzle, GLib, Gtk class Graph(Dazzle.GraphView): def __init__(self, color_1: str, color_2: str): super().__init__() self.model = Dazzle.GraphModel(value_min=0.0, value_max=100.0) self.model.add_column(Dazzle.GraphColumn(name="0", value_type=float)) self.model.add_column(Dazzle.GraphColumn(name="1", value_type=float)) self.add_renderer( Dazzle.GraphLineRenderer(column=0, stroke_color=color_1)) self.add_renderer( Dazzle.GraphLineRenderer(column=1, stroke_color=color_2)) self.set_model(self.model) def add(self, value_1: float, value_2: float): row = self.model.push(GLib.get_monotonic_time()) self.model.iter_set(row, 0, value_1) self.model.iter_set(row, 1, value_2) class VariableGraph(Dazzle.GraphView): def __init__(self, color_1: str, color_2: str):
def test_require_versions(self): import gi gi.require_versions({'GLib': '2.0', 'Gio': '2.0', 'GObject': '2.0'}) from gi.repository import GLib GLib
import gi import os import json import threading gi.require_versions({ 'Ide': '1.0', }) from gi.repository import ( GLib, GObject, Gio, Ide, ) SYMBOL_PARAM_FLAGS=flags = GObject.ParamFlags.CONSTRUCT_ONLY | GObject.ParamFlags.READWRITE class JsSymbolNode(Ide.SymbolNode): file = GObject.Property(type=Ide.File, flags=SYMBOL_PARAM_FLAGS) line = GObject.Property(type=int, flags=SYMBOL_PARAM_FLAGS) col = GObject.Property(type=int, flags=SYMBOL_PARAM_FLAGS) def __init__(self, children, **kwargs): super().__init__(**kwargs) assert self.file is not None self.children = children def do_get_location_async(self, cancellable, callback, user_data=None):
import logging import gi gi.require_versions({ "Gdk": "3.0", "GdkX11": "3.0", "Wnck": "3.0", }) # pylint: disable=wrong-import-position from gi.repository import Gdk, GdkX11, Gio, Wnck logger = logging.getLogger() wnck_screen = Wnck.Screen.get_default() def get_monitor(use_mouse_position=False): """ :rtype: class:Gdk.Monitor """ display = Gdk.Display.get_default() if use_mouse_position: try: x11_display = GdkX11.X11Display.get_default() seat = x11_display.get_default_seat() (_, x, y) = seat.get_pointer().get_position() return display.get_monitor_at_point(x, y) # pylint: disable=broad-except except Exception as e: logger.exception("Unexpected exception: %s", e) return display.get_primary_monitor() or display.get_monitor(0)
# Third-Party Library import gi # Gtk Library gi.require_versions({"Gtk": "3.0", "WebKit2": "4.0"}) from gi.repository import Gtk, WebKit2 class WebRenderer(Gtk.Window): def __init__(self, url): super().__init__() self.connect("destroy", Gtk.main_quit) Web = WebKit2.WebView() Web.load_uri(url) self.add(Web) self.show_all() def open(url): WebRenderer(url) Gtk.main()
import time import unittest from unittest import TestCase import gi from fava_gtk.main import ApplicationWindow gi.require_versions({"GdkPixbuf": "2.0", "Gdk": "3.0", "Gtk": "3.0", "WebKit2": "4.0"}) from gi.repository import Gtk # noqa: E402 def refresh_gui(delay=0): while Gtk.events_pending(): Gtk.main_iteration_do(blocking=False) time.sleep(delay) class ApplicationWindowTest(TestCase): def setUp(self): self.window = ApplicationWindow(None) self.window.connect("destroy", Gtk.main_quit) self.window.show_all() refresh_gui() def test_initial_view(self): """Assert that the placeholder view is initially shown.""" assert self.window.stack.get_visible_child() == self.window.placeholder_view if __name__ == "__main__":
You should have received a copy of the GNU General Public License along with Pop-Transition. If not, see <https://www.gnu.org/licenses/>. pop-transition is a simple app that notifies users if they have debian versions of packages which were transitioned to Flatpak in Pop_OS 20.04. """ import gettext import gi import sys gi.require_versions({ 'Flatpak': '1.0', 'Gdk': '3.0', 'GdkPixbuf': '2.0', 'Gio': '2.0', 'Gtk': '3.0', }) from .application import Notification, Application gettext.bindtextdomain('pop-transition', '/usr/share/pop-transition/po') gettext.textdomain('pop-transition') APPS = { 'android_studio': { 'name': 'Android Studio', 'version': '3.6.3.0', 'icon': 'androidstudio', 'id': 'com.google.AndroidStudio',
#!/usr/bin/env python # -*- coding: utf-8 -*- import gi import sys import sympy import signal from consts import ( TESTING, GI_REQUIREMENTS, ) gi.require_versions(GI_REQUIREMENTS) from gi.repository import Gtk from window import Window from utils import x class Algemite(Gtk.Application): def __init__(self): Gtk.Application.__init__(self) self.window = None def do_startup(self): Gtk.Application.do_startup(self) # TODO: crear acciones
import gi gi.require_versions({"Gtk": "3.0", "GtkSource": "3.0"}) from gi.repository import Gtk, GtkSource class PromptFrame(Gtk.Bin): def __init__(self, number, language): super().__init__() self.__parent = Gtk.Grid(name="promptframe-parent", margin=4, column_spacing=2, row_spacing=2) self.__buf = GtkSource.Buffer(language=language, highlight_syntax=True, highlight_matching_brackets=True) self.__editor = GtkSource.View( name="promptframe-editor", hexpand=True, halign=0, monospace=True, buffer=self.__buf, wrap_mode=3, ) self.__number = number self.make_prompt() def make_prompt(self): prompt_in = Gtk.Label( use_markup=True,
# coding=utf-8 # https://gstreamer.freedesktop.org/documentation/tutorials/basic/concepts.html # thanks to https://github.com/gkralik/python-gst-tutorial """ bunda start butonuna basmak lazım. Ancak her stop startta yeni pencerede oynatıyor... """ import gi # import sys gi.require_versions({'Gtk': '3.0', 'Gst': '1.0'}) from gi.repository import Gst, GObject, GLib, Gtk Gst.init(None) Gst.debug_set_active(True) Gst.debug_set_default_threshold(3) class Main: def __init__(self): window = Gtk.Window(Gtk.WindowType.TOPLEVEL) window.set_title("Videotestsrc-Player") window.set_default_size(300, -1) window.connect("destroy", Gtk.main_quit, "WM destroy") vbox = Gtk.VBox() window.add(vbox) self.button = Gtk.Button("Start") self.button.connect("clicked", self.start_stop) vbox.add(self.button) window.show_all()
#!/usr/bin/env python3 from lib.utils import Utils from os.path import join from shutil import copyfile from platform import system from json import dumps from gi import require_versions require_versions({"Gtk": "4.0", "Adw": "1"}) from gi.repository import Gtk class Preferences(Gtk.Window): def __init__(self, parent): super().__init__(modal=True, transient_for=parent, resizable=False, title="Preferences") # Set up header header = Gtk.HeaderBar() # Set decoration layout if system() == "Darwin": header.set_decoration_layout("close,minimize,maximize:") else: header.set_decoration_layout(":minimize,maximize,close") # Add header self.set_titlebar(header)
import gi gi.require_versions({ "Atspi": "2.0", "Gdk": "3.0", "Gtk": "3.0", "Wnck": "3.0" }) from .application import Application
### This library is free software; you can redistribute it and/or ### modify it under the terms of the GNU General Public License as ### published by the Free Software Foundation; either version 2 of the ### License, or (at your option) any later version. ### ### This library is distributed in the hope that it will be useful, ### but WITHOUT ANY WARRANTY; without even the implied warranty of ### MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ### General Public License for more details. ### ### You should have received a copy of the GNU General Public License ### along with this library; if not, write to the Free Software ### Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 ### USA import gi gi.require_versions({"Gtk": "3.0", "Pango": "1.0"}) from gi.repository import Pango from gi.repository import Gtk from gi.repository import GObject import xml.sax.saxutils from gourmet.gdebug import debug class PangoBuffer (Gtk.TextBuffer): # TODO: Fix this in 2to3 # desc_to_attr_table = { # 'family':[Pango.AttrFamily,""], # 'style':[Pango.AttrStyle,Pango.Style.NORMAL], # 'variant':[Pango.AttrVariant,Pango.VARIANT_NORMAL], # 'weight':[Pango.AttrWeight,Pango.Weight.NORMAL], # 'stretch':[Pango.AttrStretch,Pango.STRETCH_NORMAL], # }
#!/usr/bin/env python3 # Third-Party Library import gi gi.require_versions( { "Gio": "2.0", "Gtk": "3.0" } ) from gi.repository import Gio, Gtk class AppWindow(Gtk.ApplicationWindow): def __init__(self, *args, **kwargs): super().__init__(*args, **kwargs) self.set_border_width(10) self.header = Gtk.VBox() self.main = Gtk.VBox() self.footer = Gtk.VBox() layout = Gtk.VBox() layout.set_spacing(10) layout.pack_start(self.header, False, True, 0) layout.pack_start(self.main, True, True, 0) layout.pack_start(self.footer, False, True, 0) self.add(layout)
# GNU General Public License for more details. # # You should have received a copy of the GNU General Public License along # with GNOME Music; if not, write to the Free Software Foundation, Inc., # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. # # The GNOME Music authors hereby grant permission for non-GPL compatible # GStreamer plugins to be used and distributed together with GStreamer # and GNOME Music. This permission is above and beyond the permissions # granted by the GPL license by which GNOME Music is covered. If you # modify this code, you may extend this exception to your version of the # code, but you are not obligated to do so. If you do not wish to do so, # delete this exception statement from your version. import gi gi.require_versions({"Grl": "0.3"}) from gi.repository import Gfm, Gio, Grl, GObject from gnomemusic.coresong import CoreSong class GrlSearchWrapper(GObject.GObject): METADATA_KEYS = [ Grl.METADATA_KEY_ALBUM, Grl.METADATA_KEY_ALBUM_ARTIST, Grl.METADATA_KEY_ALBUM_DISC_NUMBER, Grl.METADATA_KEY_ARTIST, Grl.METADATA_KEY_CREATION_DATE, Grl.METADATA_KEY_COMPOSER, Grl.METADATA_KEY_DURATION,
def test_require_versions(self): import gi gi.require_versions({'GLib': '2.0', 'Gio': '2.0', 'GObject': '2.0'}) from gi.repository import GLib GLib
def init_test_environ(): # this was renamed in Python 3, provide backwards compatible name if sys.version_info[:2] == (2, 7): unittest.TestCase.assertRaisesRegex = unittest.TestCase.assertRaisesRegexp if sys.version_info[0] == 3: unittest.TestCase.assertRegexpMatches = unittest.TestCase.assertRegex unittest.TestCase.assertRaisesRegexp = unittest.TestCase.assertRaisesRegex def dbus_launch_session(): if os.name == "nt" or sys.platform == "darwin": return (-1, "") try: out = subprocess.check_output([ "dbus-daemon", "--session", "--fork", "--print-address=1", "--print-pid=1" ]) except (subprocess.CalledProcessError, OSError): return (-1, "") else: if sys.version_info[0] == 3: out = out.decode("utf-8") addr, pid = out.splitlines() return int(pid), addr pid, addr = dbus_launch_session() if pid >= 0: os.environ["DBUS_SESSION_BUS_ADDRESS"] = addr atexit.register(os.kill, pid, signal.SIGKILL) else: os.environ["DBUS_SESSION_BUS_ADDRESS"] = "." tests_builddir = os.path.abspath( os.environ.get('TESTS_BUILDDIR', os.path.dirname(__file__))) builddir = os.path.dirname(tests_builddir) tests_srcdir = os.path.abspath(os.path.dirname(__file__)) srcdir = os.path.dirname(tests_srcdir) sys.path.insert(0, os.path.join(builddir, 'gi')) sys.path.insert(0, tests_srcdir) sys.path.insert(0, srcdir) sys.path.insert(0, tests_builddir) sys.path.insert(0, builddir) # force untranslated messages, as we check for them in some tests os.environ['LC_MESSAGES'] = 'C' os.environ['G_DEBUG'] = 'fatal-warnings fatal-criticals' if sys.platform == "darwin": # gtk 3.22 has warnings and ciriticals on OS X, ignore for now os.environ['G_DEBUG'] = '' # make Gio able to find our gschemas.compiled in tests/. This needs to be set # before importing Gio. Support a separate build tree, so look in build dir # first. os.environ['GSETTINGS_BACKEND'] = 'memory' os.environ['GSETTINGS_SCHEMA_DIR'] = tests_builddir os.environ['G_FILENAME_ENCODING'] = 'UTF-8' import gi gi.require_version("GIRepository", "2.0") from gi.repository import GIRepository repo = GIRepository.Repository.get_default() repo.prepend_library_path(os.path.join(tests_builddir)) repo.prepend_library_path(os.path.join(tests_builddir, ".libs")) repo.prepend_search_path(tests_builddir) def try_require_version(namespace, version): try: gi.require_version(namespace, version) except ValueError: # prevent tests from running with the wrong version sys.modules["gi.repository." + namespace] = None # Optional try_require_version("Gtk", os.environ.get("TEST_GTK_VERSION", "3.0")) try_require_version("Gdk", os.environ.get("TEST_GTK_VERSION", "3.0")) try_require_version("GdkPixbuf", "2.0") try_require_version("Pango", "1.0") try_require_version("PangoCairo", "1.0") try_require_version("Atk", "1.0") # Required gi.require_versions({ "GIMarshallingTests": "1.0", "Regress": "1.0", "GLib": "2.0", "Gio": "2.0", "GObject": "2.0", }) # It's disabled for stable releases by default, this makes sure it's # always on for the tests. warnings.simplefilter('default', gi.PyGIDeprecationWarning)
from datetime import datetime from typing import Optional import gi import faulthandler from Xlib import XK from key_binder import KeyBinder from window_manager import WindowManager from windows_switcher import WindowsSwitcher gi.require_versions({"Gtk": "3.0", "Keybinder": "3.0", "Wnck": "3.0"}) # noinspection PyUnresolvedReferences from gi.repository import Gtk, Wnck, GdkX11, Gdk, GLib faulthandler.enable() KEY_BINDINGS = { '<Hyper>w': 'Google-chrome', '<Hyper>t': 'Tilix', '<Hyper>c': 'jetbrains-pycharm-ce', '<Hyper>p': 'okular', } class Sifaka: def __init__(self): self._screen = Wnck.Screen.get_default() self._screen.force_update()
# # You should have received a copy of the GNU General Public License along # with GNOME Music; if not, write to the Free Software Foundation, Inc., # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. # # The GNOME Music authors hereby grant permission for non-GPL compatible # GStreamer plugins to be used and distributed together with GStreamer # and GNOME Music. This permission is above and beyond the permissions # granted by the GPL license by which GNOME Music is covered. If you # modify this code, you may extend this exception to your version of the # code, but you are not obligated to do so. If you do not wish to do so, # delete this exception statement from your version. import gi gi.require_versions({"Gfm": "0.1", "Grl": "0.3"}) from gi.repository import Gfm, Gio, Grl, GObject import gnomemusic.utils as utils from gnomemusic.albumart import AlbumArt class CoreAlbum(GObject.GObject): """Exposes a Grl.Media with relevant data as properties """ artist = GObject.Property(type=str) composer = GObject.Property(type=str, default=None) duration = GObject.Property(type=int, default=0) media = GObject.Property(type=Grl.Media)
""" This file is a part of Openbox Key Editor Code under GPL (originally MIT) from version 1.3 - 2018. See Licenses information in ../obkey . """ try: import gi gi.require_versions({'Gtk': '3.0', 'GLib': '2.0', 'Gio': '2.0'}) from gi.repository import Gtk,Gdk from gi.repository.GObject import (TYPE_UINT, TYPE_INT, TYPE_BOOLEAN, TYPE_PYOBJECT, TYPE_STRING) from gi.repository.Gtk import AttachOptions, PolicyType (NEVER, AUTOMATIC, FILL, EXPAND) = ( PolicyType.NEVER, PolicyType.AUTOMATIC, AttachOptions.FILL, AttachOptions.EXPAND) except ImportError: print("Gtk 3.0 is required to run obkey.") exit # ========================================================= # This is the uber cool switchers/conditions(sensors) system. # Helps a lot with widgets sensitivity. # ========================================================= class SensCondition: