def __init__(self, *args, **kwargs): super().__init__(*args, application_id="easy-ebook-viewer", flags=Gio.ApplicationFlags.HANDLES_COMMAND_LINE, **kwargs) self.window = None self.file_path = None GLib.set_application_name('Easy eBook Viewer') GLib.set_prgname('easy-ebook-viewer') GLib.setenv('PULSE_PROP_application.icon_name', 'easy-ebook-viewer', True)
def main(args=None): GObject.threads_init() if not args: args = sys.argv[1:] parser = optparse.OptionParser() parser.add_option("-i", "--interval", dest="interval", default=60, type=int, help="scraping interval in seconds") parser.add_option("-o", "--output", dest="output", default="", help="output filename. Should be a path to a mp3 file") parser.add_option("-s", "--station", dest="station", default="FIP", help="Radio to tune to.") parser.add_option("-a", "--audio-sink", dest="audiosink", default="autoaudiosink", help="audio sink to use") parser.add_option("-n", "--no-scrobble", action="store_true", default=False, dest="noscrobble", help="disable scrobbling") parser.add_option("-l", "--list-stations", action="store_true", default=False, dest="list_stations", help="display the list of radio stations") parser.add_option("-x", "--headless", action="store_true", default=False, dest="headless", help="disable desktop notifications") (options, args) = parser.parse_args(args) if options.list_stations: from radioplayer.radios import STATIONS print "Supported radio stations:" stations = STATIONS.keys() stations.sort() for name in stations: print "- %s" % name return 0 if args: cfgfile = args[0] else: cfgfile = os.path.expanduser("~/.config/radioplayer.cfg") config = ConfigParser.RawConfigParser() if os.path.exists(cfgfile): config.read(cfgfile) GLib.set_prgname("RadioPlayer") GLib.setenv("PA_PROP_MEDIA_ROLE", "music", True) GLib.setenv("PA_PROP_MEDIA_ICON_NAME", "audio-x-mp3", True) from radioplayer.notifier import Notifier notifier = Notifier(options, config) notifier.run()
def status(self, name, album, title): status = u"♫ %s - %s ♫" % (name, title) if self.notification: self.notification.update(self.station_name, status) if not self.notification.actions: self.notification.add_action("suspend", "Suspend playback", self._suspend_playback_cb) self.notification.icon_name = "media-playback-start-symbolic" self.notification.show() GLib.setenv("PA_PROP_MEDIA_ARTIST", name, True) GLib.setenv("PA_PROP_MEDIA_TITLE", title, True) return "%s: %s" % (self.station_name, status)
def __init__(self, **kwargs): self.ui = None GObject.threads_init() listen() Gtk.Application.__init__(self, application_id='com.github.geigi.cozy') GLib.setenv("PULSE_PROP_media.role", "music", True) import gettext locale.bindtextdomain('cozy', localedir) locale.textdomain('cozy') gettext.install('cozy', localedir)
def __init__(self, application_id): super().__init__(application_id=application_id, flags=Gio.ApplicationFlags.FLAGS_NONE) self.props.resource_base_path = "/org/gnome/Music" GLib.set_application_name(_("Music")) GLib.set_prgname(application_id) GLib.setenv("PULSE_PROP_media.role", "music", True) self._init_style() self._window = None self._application_id = application_id
def __init__(self, IP): global timer1 self.simple_vertex_shader_str_gles2 = RTCvideo.read_shader_fromfile( "vertex_shader.frag") self.distortion_fragment_shader = RTCvideo.read_shader_fromfile( "fragment_shader.frag") Gst.init(sys.argv) glutInit(sys.argv) GLib.setenv("GST_GL_API", "opengl", False) self.PAUSED = False timer1.start() self.DEST = IP
def __init__(self, IP = '127.0.0.1', RTP_RECV_PORT = 5000, RTCP_RECV_PORT = 5001, RTCP_SEND_PORT = 5005, overlay = draw_callback0): # ip и порты по умолчанию Gst.init(sys.argv) # Инициализация компонентов glutInit(sys.argv) GObject.threads_init() GLib.setenv("GST_GL_API", "opengl", False) # включить поддержку старых версий openGL self.VIDEO_CAPS="application/x-rtp,media=(string)video,clock-rate=(int)90000,encoding-name=(string)JPEG,payload=(int)26,ssrc=(uint)1006979985,clock-base=(uint)312170047,seqnum-base=(uint)3174" # caps приема self.IP=IP # ip приема self.RTP_RECV_PORT0=RTP_RECV_PORT # Порты приема self.RTCP_RECV_PORT0=RTCP_RECV_PORT self.RTCP_SEND_PORT0=RTCP_SEND_PORT self.drawcall=overlay # callback функция отрисовки, можно передать свою self.PAUSED=False # Метка паузы, мб потом заменить ее на что-нибудь self.texture0=0
def __init_proxy(self): """ Init proxy setting env """ try: settings = Gio.Settings.new('org.gnome.system.proxy.http') h = settings.get_value('host').get_string() p = settings.get_value('port').get_int32() if h != '' and p != 0: GLib.setenv('http_proxy', "%s:%s" % (h, p), True) GLib.setenv('https_proxy', "%s:%s" % (h, p), True) except: pass
def __init__(self, extension_dir): """ Create application @param extension_dir as str """ # First check WebKit2 version if WebKit2.MINOR_VERSION < 16: exit("You need WebKit2GTK >= 2.16") Gtk.Application.__init__( self, application_id='org.gnome.Eolie', flags=Gio.ApplicationFlags.HANDLES_COMMAND_LINE) self.set_property('register-session', True) # Ideally, we will be able to delete this once Flatpak has a solution # for SSL certificate management inside of applications. if GLib.file_test("/app", GLib.FileTest.EXISTS): paths = [ "/etc/ssl/certs/ca-certificates.crt", "/etc/pki/tls/cert.pem", "/etc/ssl/cert.pem" ] for path in paths: if GLib.file_test(path, GLib.FileTest.EXISTS): GLib.setenv('SSL_CERT_FILE', path, True) break self.sync_worker = None # Not initialised self.__extension_dir = extension_dir self.__windows = [] self.debug = False self.show_tls = False try: self.zoom_levels = load(open(LOCAL_PATH + "/zoom_levels.bin", "rb")) except: self.zoom_levels = {} self.cursors = {} GLib.set_application_name('Eolie') GLib.set_prgname('eolie') self.add_main_option("debug", b'd', GLib.OptionFlags.NONE, GLib.OptionArg.NONE, "Debug Eolie", None) self.add_main_option("private", b'p', GLib.OptionFlags.NONE, GLib.OptionArg.NONE, "Add a private page", None) self.add_main_option("new", b'n', GLib.OptionFlags.NONE, GLib.OptionArg.NONE, "Add a new window", None) self.add_main_option("show-tls", b's', GLib.OptionFlags.NONE, GLib.OptionArg.NONE, "Show TLS info", None) self.connect('activate', self.__on_activate) self.connect('command-line', self.__on_command_line) self.register(None) if self.get_is_remote(): Gdk.notify_startup_complete() self.__listen_to_gnome_sm()
def __init__(self, extensiondir): logger.info('Init') Gtk.Application.__init__( self, application_id='com.github.dyskette.Seneca', resource_base_path='/com/github/dyskette/Seneca', flags=Gio.ApplicationFlags.HANDLES_OPEN) GLib.set_application_name('Seneca') GLib.set_prgname('com.github.dyskette.Seneca') # Set environment variable for webextension pythonloader self.extensiondir = extensiondir GLib.setenv('PYTHONPATH', self.extensiondir, True)
def __on_command_line(self, app, app_cmd_line): """ Handle command line @param app as Gio.Application @param options as Gio.ApplicationCommandLine """ self.__externals_count = 0 args = app_cmd_line.get_arguments() options = app_cmd_line.get_options_dict() if options.contains("debug"): GLib.setenv("WEBKIT_DEBUG", "network", True) self.debug = True if options.contains("show-tls"): self.show_tls = True if options.contains("disable-artwork-cache"): self.art.disable_cache() ephemeral = options.contains("private") if not self.get_windows(): self.__create_initial_windows(len(args) < 2) if options.contains("new"): active_window = self.get_new_window() else: active_window = self.active_window # Open command line args if len(args) > 1: items = [] i = 0 for uri in args[1:]: # Transform path to uri parsed = urlparse(uri) if not parsed.scheme: if uri.startswith('/'): uri = "file://%s" % uri else: uri = "http://%s" % uri loading_type = wanted_loading_type(i) items.append((uri, uri, 0, 0, ephemeral, None, loading_type)) i += 1 active_window.container.add_webviews(items) active_window.present_with_time(Gtk.get_current_event_time()) # Add default start page if not active_window.container.views: active_window.container.add_webview(self.start_page, LoadingType.FOREGROUND, ephemeral) if self.debug: WebKit2.WebContext.get_default().get_plugins( None, self.__on_get_plugins, None) return 0
def __init_proxy(self): """ Init proxy setting env """ try: proxy = Gio.Settings.new("org.gnome.system.proxy") https = Gio.Settings.new("org.gnome.system.proxy.https") mode = proxy.get_value("mode").get_string() if mode != "none": h = https.get_value("host").get_string() p = https.get_value("port").get_int32() GLib.setenv("http_proxy", "http://%s:%s" % (h, p), True) GLib.setenv("https_proxy", "http://%s:%s" % (h, p), True) except Exception as e: print("Application::__init_proxy()", e)
def __init__(self): app_id = 'com.github.wwmm.pulseeffects' app_flags = Gio.ApplicationFlags.HANDLES_COMMAND_LINE GLib.set_application_name('PulseEffects') GLib.setenv('PULSE_PROP_media.role', 'production', True) GLib.setenv('PULSE_PROP_application.icon_name', 'pulseeffects', True) Gtk.Application.__init__(self, application_id=app_id, flags=app_flags) self.add_main_option('no-window', ord('n'), GLib.OptionFlags.NONE, GLib.OptionArg.NONE, 'do not show window', None) self.add_main_option('switch-on-all-apps', ord('s'), GLib.OptionFlags.NONE, GLib.OptionArg.NONE, 'Force effects for all applications', None)
def __init__(self, **kwargs): self.ui = None listen() Gtk.Application.__init__(self, application_id='com.github.geigi.cozy') GLib.setenv("PULSE_PROP_media.role", "music", True) GLib.set_application_name("Cozy") self.old_except_hook = sys.excepthook sys.excepthook = self.handle_exception import gettext locale.bindtextdomain('com.github.geigi.cozy', localedir) locale.textdomain('com.github.geigi.cozy') gettext.install('com.github.geigi.cozy', localedir)
def __init_proxy(self): """ Init proxy setting env """ try: proxy = Gio.Settings.new('org.gnome.system.proxy') https = Gio.Settings.new('org.gnome.system.proxy.https') mode = proxy.get_value('mode').get_string() if mode != 'none': h = https.get_value('host').get_string() p = https.get_value('port').get_int32() GLib.setenv('http_proxy', "http://%s:%s" % (h, p), True) GLib.setenv('https_proxy', "http://%s:%s" % (h, p), True) except Exception as e: print("Application::__init_proxy()", e)
def __init__(self, localedir: str, pkgdatadir: str): self.localedir = localedir self.pkgdatadir = pkgdatadir Gtk.Application.__init__(self, application_id='com.github.geigi.cozy') GLib.setenv("PULSE_PROP_media.role", "music", True) GLib.set_application_name("Cozy") self.old_except_hook = sys.excepthook sys.excepthook = self.handle_exception setup_thread_excepthook() import gettext locale.bindtextdomain('com.github.geigi.cozy', localedir) locale.textdomain('com.github.geigi.cozy') gettext.install('com.github.geigi.cozy', localedir)
def __init__(self, application_id): super().__init__(application_id=application_id, flags=Gio.ApplicationFlags.FLAGS_NONE) self.props.resource_base_path = "/org/gnome/Music" GLib.set_application_name(_("Music")) GLib.set_prgname(application_id) GLib.setenv("PULSE_PROP_media.role", "music", True) self._init_style() self._window = None self._settings = Gio.Settings.new('org.gnome.Music') self._player = Player(self) InhibitSuspend(self) PauseOnSuspend(self._player)
def __on_command_line(self, app, app_cmd_line): """ Handle command line @param app as Gio.Application @param options as Gio.ApplicationCommandLine """ self.__externals_count = 0 args = app_cmd_line.get_arguments() options = app_cmd_line.get_options_dict() if options.contains("debug"): GLib.setenv("WEBKIT_DEBUG", "network", True) self.debug = True if options.contains("show-tls"): self.show_tls = True ephemeral = options.contains("private") restored = False if self.settings.get_value("remember-session"): restored = self.__restore_state() if options.contains("new"): active_window = self.get_new_window() else: active_window = self.active_window # Open command line args if len(args) > 1: for uri in args[1:]: # Transform path to uri f = Gio.File.new_for_path(uri) if f.query_exists(): uri = f.get_uri() active_window.container.add_webview(uri, Gdk.WindowType.CHILD, ephemeral) active_window.present_with_time(Gtk.get_current_event_time()) # We already have a window, open a new one elif active_window.container.current: window = self.get_new_window() window.container.add_webview(self.start_page, Gdk.WindowType.CHILD, ephemeral) # Add default start page elif not restored: active_window.container.add_webview(self.start_page, Gdk.WindowType.CHILD, ephemeral) thread = Thread(target=self.__show_plugins) thread.daemon = True thread.start() return 0
def __init__(self, IP, RTP_RECV_PORT, RTCP_RECV_PORT, RTCP_SEND_PORT, overlay=draw_callback0): Gst.init(sys.argv) glutInit(sys.argv) GObject.threads_init() GLib.setenv("GST_GL_API", "opengl", False) self.VIDEO_CAPS="application/x-rtp,media=(string)video,clock-rate=(int)90000,encoding-name=(string)JPEG,payload=(int)26,ssrc=(uint)1006979985,clock-base=(uint)312170047,seqnum-base=(uint)3174" self.IP=IP self.RTP_RECV_PORT0=RTP_RECV_PORT self.RTCP_RECV_PORT0=RTCP_RECV_PORT self.RTCP_SEND_PORT0=RTCP_SEND_PORT self.init_GL_flag=False self.drawcall=overlay self.PAUSED=False self.texture0=0
def __on_command_line(self, app, app_cmd_line): """ Handle command line @param app as Gio.Application @param options as Gio.ApplicationCommandLine """ self.__externals_count = 0 args = app_cmd_line.get_arguments() options = app_cmd_line.get_options_dict() if options.contains("debug"): GLib.setenv("WEBKIT_DEBUG", "network", True) self.debug = True if options.contains("show-tls"): self.show_tls = True if options.contains("disable-artwork-cache"): self.art.disable_cache() ephemeral = options.contains("private") restored = False if self.settings.get_value("remember-session"): restored = self.__restore_state() if options.contains("new"): active_window = self.get_new_window() else: active_window = self.active_window # Open command line args if len(args) > 1: for uri in args[1:]: # Transform path to uri f = Gio.File.new_for_path(uri) if f.query_exists(): uri = f.get_uri() self.__new_or_load(uri, Gdk.WindowType.CHILD, ephemeral) active_window.present_with_time(Gtk.get_current_event_time()) # Add default start page elif not restored: self.active_window.present_with_time(Gtk.get_current_event_time()) self.__new_or_load(self.start_page, Gdk.WindowType.CHILD, ephemeral) if self.debug: WebKit2.WebContext.get_default().get_plugins(None, self.__on_get_plugins, None) return 0
def __init__(self): """ Create application """ Gtk.Application.__init__( self, application_id='org.gnome.Lollypop', flags=Gio.ApplicationFlags.HANDLES_COMMAND_LINE) GLib.setenv('PULSE_PROP_media.role', 'music', True) GLib.setenv('PULSE_PROP_application.icon_name', 'lollypop', True) self.cursors = {} self.window = None self.notify = None self.lastfm = None self.debug = False self.__externals_count = 0 self.__init_proxy() GLib.set_application_name('Lollypop') GLib.set_prgname('lollypop') self.add_main_option("album", b'a', GLib.OptionFlags.NONE, GLib.OptionArg.STRING, "Play album", None) self.add_main_option("debug", b'd', GLib.OptionFlags.NONE, GLib.OptionArg.NONE, "Debug lollypop", None) self.add_main_option("set-rating", b'r', GLib.OptionFlags.NONE, GLib.OptionArg.INT, "Rate the current track", None) self.add_main_option("play-pause", b't', GLib.OptionFlags.NONE, GLib.OptionArg.NONE, "Toggle playback", None) self.add_main_option("next", b'n', GLib.OptionFlags.NONE, GLib.OptionArg.NONE, "Go to next track", None) self.add_main_option("prev", b'p', GLib.OptionFlags.NONE, GLib.OptionArg.NONE, "Go to prev track", None) self.add_main_option("emulate-phone", b'e', GLib.OptionFlags.NONE, GLib.OptionArg.NONE, "Emulate an Android Phone", None) self.connect('command-line', self.__on_command_line) self.connect('activate', self.__on_activate) self.register(None) if self.get_is_remote(): Gdk.notify_startup_complete()
def __init__(self): """ Create application """ Gtk.Application.__init__( self, application_id='org.gnome.Lollypop', flags=Gio.ApplicationFlags.HANDLES_COMMAND_LINE) GLib.setenv('PULSE_PROP_media.role', 'music', True) GLib.setenv('PULSE_PROP_application.icon_name', 'lollypop', True) self.cursors = {} self.window = None self.notify = None self.lastfm = None self.debug = False self.__externals_count = 0 self.__init_proxy() GLib.set_application_name('lollypop') GLib.set_prgname('lollypop') # TODO: Remove this test later if Gtk.get_minor_version() > 12: self.add_main_option("debug", b'd', GLib.OptionFlags.NONE, GLib.OptionArg.NONE, "Debug lollypop", None) self.add_main_option("set-rating", b'r', GLib.OptionFlags.NONE, GLib.OptionArg.INT, "Rate the current track", None) self.add_main_option("play-pause", b't', GLib.OptionFlags.NONE, GLib.OptionArg.NONE, "Toggle playback", None) self.add_main_option("next", b'n', GLib.OptionFlags.NONE, GLib.OptionArg.NONE, "Go to next track", None) self.add_main_option("prev", b'p', GLib.OptionFlags.NONE, GLib.OptionArg.NONE, "Go to prev track", None) self.add_main_option("emulate-phone", b'e', GLib.OptionFlags.NONE, GLib.OptionArg.NONE, "Emulate an Android Phone", None) self.connect('command-line', self.__on_command_line) self.connect('activate', self.__on_activate) self.register(None) if self.get_is_remote(): Gdk.notify_startup_complete()
def __init__(self): app_id = 'com.github.wwmm.pulseeffects' app_flags = Gio.ApplicationFlags.HANDLES_COMMAND_LINE GLib.set_application_name('PulseEffects') GLib.setenv('PULSE_PROP_application.icon_name', 'pulseeffects', True) GLib.setenv('PULSE_PROP_application.id', 'com.github.wwmm.pulseeffects', True) GLib.setenv('PULSE_PROP_application.version', '3.2.1', True) Gtk.Application.__init__(self, application_id=app_id, flags=app_flags) GLib.unix_signal_add(GLib.PRIORITY_DEFAULT, 2, self.quit) # sigint help_msg = _('Quit PulseEffects. Useful when running in service mode.') self.add_main_option('quit', ord('q'), GLib.OptionFlags.NONE, GLib.OptionArg.NONE, help_msg, None) help_msg = _('Show available presets.') self.add_main_option('presets', ord('p'), GLib.OptionFlags.NONE, GLib.OptionArg.NONE, help_msg, None) help_msg = _('Load a preset. Example: pulseeffects -l music') self.add_main_option('load-preset', ord('l'), GLib.OptionFlags.NONE, GLib.OptionArg.STRING, help_msg, None)
def __init__(self, version): """ Create application @param version as str """ Gtk.Application.__init__( self, application_id="org.gnome.Lollypop", flags=Gio.ApplicationFlags.HANDLES_COMMAND_LINE) self.__version = version self.set_property("register-session", True) GLib.setenv("PULSE_PROP_media.role", "music", True) GLib.setenv("PULSE_PROP_application.icon_name", "org.gnome.Lollypop", True) # Ideally, we will be able to delete this once Flatpak has a solution # for SSL certificate management inside of applications. if GLib.file_test("/app", GLib.FileTest.EXISTS): paths = [ "/etc/ssl/certs/ca-certificates.crt", "/etc/pki/tls/cert.pem", "/etc/ssl/cert.pem" ] for path in paths: if GLib.file_test(path, GLib.FileTest.EXISTS): GLib.setenv("SSL_CERT_FILE", path, True) break self.cursors = {} self.window = None self.notify = None self.lastfm = None self.debug = False self.__externals_count = 0 self.__init_proxy() GLib.set_application_name("Lollypop") GLib.set_prgname("lollypop") self.add_main_option("play-ids", b"a", GLib.OptionFlags.NONE, GLib.OptionArg.STRING, "Play ids", None) self.add_main_option("debug", b"d", GLib.OptionFlags.NONE, GLib.OptionArg.NONE, "Debug lollypop", None) self.add_main_option("set-rating", b"r", GLib.OptionFlags.NONE, GLib.OptionArg.INT, "Rate the current track", None) self.add_main_option("play-pause", b"t", GLib.OptionFlags.NONE, GLib.OptionArg.NONE, "Toggle playback", None) self.add_main_option("next", b"n", GLib.OptionFlags.NONE, GLib.OptionArg.NONE, "Go to next track", None) self.add_main_option("prev", b"p", GLib.OptionFlags.NONE, GLib.OptionArg.NONE, "Go to prev track", None) self.add_main_option("emulate-phone", b"e", GLib.OptionFlags.NONE, GLib.OptionArg.NONE, "Emulate an Android Phone", None) self.add_main_option("version", b"V", GLib.OptionFlags.NONE, GLib.OptionArg.NONE, "Lollypop version", None) self.connect("command-line", self.__on_command_line) self.connect("activate", self.__on_activate) self.register(None) if self.get_is_remote(): Gdk.notify_startup_complete() self.__listen_to_gnome_sm()
def __init__(self): """ Create application """ Gtk.Application.__init__( self, application_id='org.gnome.Lollypop', flags=Gio.ApplicationFlags.HANDLES_COMMAND_LINE) self.set_property('register-session', True) GLib.setenv('PULSE_PROP_media.role', 'music', True) GLib.setenv('PULSE_PROP_application.icon_name', 'lollypop', True) # Ideally, we will be able to delete this once Flatpak has a solution # for SSL certificate management inside of applications. if GLib.file_test("/app", GLib.FileTest.EXISTS): paths = ["/etc/ssl/certs/ca-certificates.crt", "/etc/pki/tls/cert.pem", "/etc/ssl/cert.pem"] for path in paths: if GLib.file_test(path, GLib.FileTest.EXISTS): GLib.setenv('SSL_CERT_FILE', path, True) break self.cursors = {} self.window = None self.notify = None self.lastfm = None self.debug = False self.__externals_count = 0 self.__init_proxy() GLib.set_application_name('Lollypop') GLib.set_prgname('lollypop') self.add_main_option("play-ids", b'a', GLib.OptionFlags.NONE, GLib.OptionArg.STRING, "Play ids", None) self.add_main_option("debug", b'd', GLib.OptionFlags.NONE, GLib.OptionArg.NONE, "Debug lollypop", None) self.add_main_option("set-rating", b'r', GLib.OptionFlags.NONE, GLib.OptionArg.INT, "Rate the current track", None) self.add_main_option("play-pause", b't', GLib.OptionFlags.NONE, GLib.OptionArg.NONE, "Toggle playback", None) self.add_main_option("next", b'n', GLib.OptionFlags.NONE, GLib.OptionArg.NONE, "Go to next track", None) self.add_main_option("prev", b'p', GLib.OptionFlags.NONE, GLib.OptionArg.NONE, "Go to prev track", None) self.add_main_option("emulate-phone", b'e', GLib.OptionFlags.NONE, GLib.OptionArg.NONE, "Emulate an Android Phone", None) self.connect('command-line', self.__on_command_line) self.connect('activate', self.__on_activate) self.register(None) if self.get_is_remote(): Gdk.notify_startup_complete() self.__listen_to_gnome_sm()
def __init__(self): app_id = 'com.github.wwmm.pulseeffects' GLib.set_application_name('PulseEffects') GLib.setenv('PULSE_PROP_media.role', 'production', True) GLib.setenv('PULSE_PROP_application.icon_name', 'pulseeffects', True) Gtk.Application.__init__(self, application_id=app_id) self.ui_initialized = False self.generating_test_signal = False self.module_path = os.path.dirname(__file__) log_format = '%(asctime)s.%(msecs)d - %(name)s - %(levelname)s' log_format = log_format + ' - %(message)s' logging.basicConfig(format=log_format, datefmt='%H:%M:%S', level=logging.INFO) self.log = logging.getLogger('PulseEffects') self.settings = Gio.Settings('com.github.wwmm.pulseeffects') # pulseaudio self.pm = PulseManager() # gstreamer audio effects self.gst = GstEffects(self.pm.default_sink_rate) self.gst.set_source_monitor_name(self.pm.sink_monitor_name) self.gst.set_output_sink_name(self.pm.default_sink_name) # creating user presets folder self.user_config_dir = os.path.expanduser('~/.config/PulseEffects') os.makedirs(self.user_config_dir, exist_ok=True)
def main(args=None): '''Entry point function. Since we're often running from within flatpak, make sure to override XDG_DATA_DIRS to include the flatpak exports too, since they don't get included by default. We use GLib.setenv here, since os.environ is only visible to Python code, but setting a variable in os.environ does not actually update the 'environ' global variable on the C side. ''' flatpak_export_share_dirs = [ os.path.join(d, 'exports', 'share') for d in EosCompanionAppService.flatpak_install_dirs() ] GLib.setenv( 'XDG_DATA_DIRS', os.pathsep.join([GLib.getenv('XDG_DATA_DIRS') or ''] + flatpak_export_share_dirs), True) logging.basicConfig( format='CompanionAppService %(levelname)s: %(message)s', level=get_log_level()) CompanionAppApplication().run(args or sys.argv)
def __init__(self): """ Create application """ Gtk.Application.__init__( self, application_id='org.gnome.Lollypop', flags=Gio.ApplicationFlags.HANDLES_COMMAND_LINE) GLib.setenv('PULSE_PROP_media.role', 'music', True) GLib.setenv('PULSE_PROP_application.icon_name', 'lollypop', True) # Ideally, we will be able to delete this once Flatpak has a solution # for SSL certificate management inside of applications. if GLib.file_test("/app", GLib.FileTest.EXISTS): paths = [ "/etc/ssl/certs/ca-certificates.crt", "/etc/pki/tls/cert.pem", "/etc/ssl/cert.pem" ] for path in paths: if GLib.file_test(path, GLib.FileTest.EXISTS): GLib.setenv('SSL_CERT_FILE', path, True) break self.cursors = {} self.window = None self.notify = None self.lastfm = None self.debug = False self.__externals_count = 0 self.__init_proxy() GLib.set_application_name('Lollypop') GLib.set_prgname('lollypop') self.add_main_option("play-ids", b'a', GLib.OptionFlags.NONE, GLib.OptionArg.STRING, "Play ids", None) self.add_main_option("debug", b'd', GLib.OptionFlags.NONE, GLib.OptionArg.NONE, "Debug lollypop", None) self.add_main_option("set-rating", b'r', GLib.OptionFlags.NONE, GLib.OptionArg.INT, "Rate the current track", None) self.add_main_option("play-pause", b't', GLib.OptionFlags.NONE, GLib.OptionArg.NONE, "Toggle playback", None) self.add_main_option("next", b'n', GLib.OptionFlags.NONE, GLib.OptionArg.NONE, "Go to next track", None) self.add_main_option("prev", b'p', GLib.OptionFlags.NONE, GLib.OptionArg.NONE, "Go to prev track", None) self.add_main_option("emulate-phone", b'e', GLib.OptionFlags.NONE, GLib.OptionArg.NONE, "Emulate an Android Phone", None) self.connect('command-line', self.__on_command_line) self.connect('activate', self.__on_activate) self.register(None) if self.get_is_remote(): Gdk.notify_startup_complete()
def __init__(self): app_id = 'com.github.wwmm.pulseeffects' app_flags = Gio.ApplicationFlags.HANDLES_COMMAND_LINE GLib.set_application_name('PulseEffects') GLib.setenv('PULSE_PROP_application.icon_name', 'pulseeffects', True) GLib.setenv('PULSE_PROP_application.id', 'com.github.wwmm.pulseeffects', True) GLib.setenv('PULSE_PROP_application.version', '3.2.0', True) Gtk.Application.__init__(self, application_id=app_id, flags=app_flags) GLib.unix_signal_add(GLib.PRIORITY_DEFAULT, 2, self.quit) # sigint help_msg = 'Exit PulseEffects. Useful when running in service mode.' self.add_main_option('quit', ord('q'), GLib.OptionFlags.NONE, GLib.OptionArg.NONE, help_msg, None)
def __init__(self): app_id = 'com.github.wwmm.pulseeffects' app_flags = Gio.ApplicationFlags.HANDLES_COMMAND_LINE GLib.set_application_name('PulseEffects') GLib.setenv('PULSE_PROP_application.icon_name', 'pulseeffects', True) GLib.setenv('PULSE_PROP_application.id', 'com.github.wwmm.pulseeffects', True) GLib.setenv('PULSE_PROP_application.version', '3.2.3', True) GLib.unix_signal_add(GLib.PRIORITY_DEFAULT, 2, self.quit) # sigint Gtk.Application.__init__(self, application_id=app_id, flags=app_flags) help_msg = _('Quit PulseEffects. Useful when running in service mode.') self.add_main_option('quit', ord('q'), GLib.OptionFlags.NONE, GLib.OptionArg.NONE, help_msg, None) help_msg = _('Show available presets.') self.add_main_option('presets', ord('p'), GLib.OptionFlags.NONE, GLib.OptionArg.NONE, help_msg, None) help_msg = _('Load a preset. Example: pulseeffects -l music') self.add_main_option('load-preset', ord('l'), GLib.OptionFlags.NONE, GLib.OptionArg.STRING, help_msg, None) log_format = '%(asctime)s.%(msecs)d - %(name)s - %(levelname)s' log_format = log_format + ' - %(message)s' logging.basicConfig(format=log_format, datefmt='%H:%M:%S', level=logging.INFO) self.log = logging.getLogger('PulseEffects') self.log_tag = 'MAIN - ' if os.environ.get('PULSEEFFECTS_DEBUG'): self.log.setLevel(logging.DEBUG) self.log.debug(self.log_tag + 'debug logging enabled')
def __on_command_line(self, app, app_cmd_line): """ Handle command line @param app as Gio.Application @param options as Gio.ApplicationCommandLine """ self.__externals_count = 0 args = app_cmd_line.get_arguments() options = app_cmd_line.get_options_dict() if options.contains("debug"): GLib.setenv("LIBGL_DEBUG", "verbose", True) GLib.setenv("WEBKIT_DEBUG", "network", True) GLib.setenv("GST_DEBUG", "webkit*:5", True) self.debug = True private_browsing = options.contains("private") if self.settings.get_value("remember-session"): count = self.__restore_state() else: count = 0 active_window = self.active_window if len(args) > 1: for uri in args[1:]: active_window.container.add_web_view(uri, True, private_browsing) active_window.present() elif count == 0: # We already have a window, open a new one if active_window.container.current: window = self.__get_new_window() window.container.add_web_view(self.start_page, True, private_browsing) else: active_window.container.add_web_view(self.start_page, True, private_browsing) GLib.idle_add(self.__show_plugins) return 0
def init_VARandLIB(self): global appLock global appCond print(appLock) Gtk.init(sys.argv) Gst.init(sys.argv) #GLib.Mutex.init(appLock) print(appLock) #GLib.Cond.init(appCond) glutInit(sys.argv) #initGL() appLock.init() appCond.init() print(appLock) GLib.setenv("GST_GL_API", "opengl", False) self.player = Gst.Pipeline.new("player") if not self.player: print("ERROR: Could not create pipeline.") sys.exit(1) bus = self.player.get_bus() bus.add_signal_watch() bus.connect("message::error", self.on_error) bus.connect("message::eos", self.on_eos) ################ VIDEODEPAY ################################ videodepay0 = Gst.ElementFactory.make('rtpjpegdepay', 'videodepay0') if not videodepay0: print("ERROR: Could not create videodepay0.") sys.exit(1) videodepay1 = Gst.ElementFactory.make('rtpjpegdepay', 'videodepay1') if not videodepay1: print("ERROR: Could not create videodepay1.") sys.exit(1) ################ SOURCE ################################## rtpbin = Gst.ElementFactory.make('rtpbin', 'rtpbin') self.player.add(rtpbin) caps = Gst.caps_from_string(VIDEO_CAPS) def pad_added_cb(rtpbin, new_pad, depay): sinkpad = Gst.Element.get_static_pad(depay, 'sink') lres = Gst.Pad.link(new_pad, sinkpad) rtpsrc0 = Gst.ElementFactory.make('udpsrc', 'rtpsrc0') rtpsrc0.set_property('port', RTP_RECV_PORT0) # we need to set caps on the udpsrc for the RTP data rtpsrc0.set_property('caps', caps) rtcpsrc0 = Gst.ElementFactory.make('udpsrc', 'rtcpsrc0') rtcpsrc0.set_property('port', RTCP_RECV_PORT0) rtcpsink0 = Gst.ElementFactory.make('udpsink', 'rtcpsink0') rtcpsink0.set_property('port', RTCP_SEND_PORT0) rtcpsink0.set_property('host', DEST) # no need for synchronisation or preroll on the RTCP sink rtcpsink0.set_property('async', False) rtcpsink0.set_property('sync', False) self.player.add(rtpsrc0, rtcpsrc0, rtcpsink0) srcpad0 = Gst.Element.get_static_pad(rtpsrc0, 'src') sinkpad0 = Gst.Element.get_request_pad(rtpbin, 'recv_rtp_sink_0') lres0 = Gst.Pad.link(srcpad0, sinkpad0) # get an RTCP sinkpad in session 0 srcpad0 = Gst.Element.get_static_pad(rtcpsrc0, 'src') sinkpad0 = Gst.Element.get_request_pad(rtpbin, 'recv_rtcp_sink_0') lres0 = Gst.Pad.link(srcpad0, sinkpad0) # get an RTCP srcpad for sending RTCP back to the sender srcpad0 = Gst.Element.get_request_pad(rtpbin, 'send_rtcp_src_0') sinkpad0 = Gst.Element.get_static_pad(rtcpsink0, 'sink') lres0 = Gst.Pad.link(srcpad0, sinkpad0) ###################### SECOND ################################ rtpbin.connect('pad-added', pad_added_cb, videodepay0) ############### DECODER ###################################### decoder0 = Gst.ElementFactory.make('jpegdec', "decoder0") if not decoder0: print("ERROR: Could not create decoder0.") sys.exit(1) ######################### GLUPLOAD ########################### glupload0 = Gst.ElementFactory.make('glupload', "glupload0") if not glupload0: print("ERROR: Could not create glupload0.") sys.exit(1) ######################## GLCOLORCONVERT ############################ glcolorconvert0 = Gst.ElementFactory.make("glcolorconvert", "glcolorconvert0") if not glcolorconvert0: print("ERROR: Could not create glcolorconvert0.") sys.exit(1) ######################### CAPS AND SINK ########################### sink = Gst.ElementFactory.make('glimagesink', "video-output") if not sink: print("ERROR: Could not create sink.") sys.exit(1) ########################### FILTER ################################### ######################### VIDEOMIXER ################################## videomixer = Gst.ElementFactory.make("glvideomixer", "videomixer") if not videomixer: print("ERROR: Could not create videomixer.") sys.exit(1) videomixer.set_property("background", 1) videomixer.set_property("async-handling", 1) videomixer.set_property("message-forward", 1) mixer_sink_pad0 = videomixer.get_request_pad("sink_%u") mixer_sink_pad0.set_property("xpos", 1280) mixer_sink_pad0.set_property("ypos", 0) mixer_sink_pad0.set_property("width", 1280) ########################## SHADER ##################################### glshader = Gst.ElementFactory.make("glshader", "glshader") glshader.set_property("vertex", simple_vertex_shader_str_gles2) glshader.set_property("fragment", distortion_fragment_shader) ####################### FILTERAPP #################################### glfilterapp0 = Gst.ElementFactory.make("glfilterapp", "glfilterapp0") glfilterapp0.connect("client-draw", draw_callback0) ################################################################## self.player.add(videodepay0) self.player.add(decoder0) self.player.add(glupload0) self.player.add(glcolorconvert0) self.player.add(glfilterapp0) self.player.add(videomixer) self.player.add(glshader) self.player.add(sink) link_ok = videodepay0.link(decoder0) if not link_ok: print("ERROR: Could not link videodepay0 with decoder0.") sys.exit(1) link_ok = decoder0.link(glupload0) if not link_ok: print("ERROR: Could not link decoder0 with glupload0.") sys.exit(1) link_ok = glupload0.link(glcolorconvert0) if not link_ok: print("ERROR: Could not link glupload0 with glcolorconvert0.") sys.exit(1) link_ok = glcolorconvert0.link(glfilterapp0) if not link_ok: print("ERROR: Could not link glcolorconvert0 with glfilterapp0.") sys.exit(1) source0_src_pad = glfilterapp0.get_static_pad("src") link_ok = source0_src_pad.link(mixer_sink_pad0) print(link_ok) link_ok = videomixer.link(glshader) if not link_ok: print("ERROR: Could not link videomixer with glshader.") sys.exit(1) link_ok = glshader.link(sink) if not link_ok: print("ERROR: Could not link glshader with sink.") sys.exit(1)
def __init__(self, version): """ Create application @param version as str """ Gtk.Application.__init__( self, application_id="org.gnome.Lollypop", flags=Gio.ApplicationFlags.HANDLES_COMMAND_LINE) self.__version = version self.set_property("register-session", True) signal(SIGINT, lambda a, b: self.quit()) signal(SIGTERM, lambda a, b: self.quit()) # Set main thread name # We force it to current python 3.6 name, to be sure in case of # change in python current_thread().setName("MainThread") set_proxy_from_gnome() GLib.setenv("PULSE_PROP_media.role", "music", True) GLib.setenv("PULSE_PROP_application.icon_name", "org.gnome.Lollypop", True) # Fix proxy for python proxy = GLib.environ_getenv(GLib.get_environ(), "all_proxy") if proxy is not None and proxy.startswith("socks://"): proxy = proxy.replace("socks://", "socks4://") from os import environ environ["all_proxy"] = proxy environ["ALL_PROXY"] = proxy # Ideally, we will be able to delete this once Flatpak has a solution # for SSL certificate management inside of applications. if GLib.file_test("/app", GLib.FileTest.EXISTS): paths = [ "/etc/ssl/certs/ca-certificates.crt", "/etc/pki/tls/cert.pem", "/etc/ssl/cert.pem" ] for path in paths: if GLib.file_test(path, GLib.FileTest.EXISTS): GLib.setenv("SSL_CERT_FILE", path, True) break self.cursors = {} self.notify = None self.scrobblers = [] self.debug = False self.shown_sidebar_tooltip = False self.__window = None self.__fs_window = None self.__scanner_timeout_id = None self.__scanner_uris = [] GLib.set_application_name("Lollypop") GLib.set_prgname("lollypop") self.add_main_option("play-ids", b"a", GLib.OptionFlags.NONE, GLib.OptionArg.STRING, "Play ids", None) self.add_main_option("debug", b"d", GLib.OptionFlags.NONE, GLib.OptionArg.NONE, "Debug Lollypop", None) self.add_main_option("set-rating", b"r", GLib.OptionFlags.NONE, GLib.OptionArg.STRING, "Rate the current track", None) self.add_main_option("play-pause", b"t", GLib.OptionFlags.NONE, GLib.OptionArg.NONE, "Toggle playback", None) self.add_main_option("stop", b"s", GLib.OptionFlags.NONE, GLib.OptionArg.NONE, "Stop playback", None) self.add_main_option("next", b"n", GLib.OptionFlags.NONE, GLib.OptionArg.NONE, "Go to next track", None) self.add_main_option("prev", b"p", GLib.OptionFlags.NONE, GLib.OptionArg.NONE, "Go to prev track", None) ## anhsirk0 edits self.add_main_option("set-next", b"m", GLib.OptionFlags.NONE, GLib.OptionArg.NONE, "Set next track by track id", None) ## anhsirk0 edits ends self.add_main_option("emulate-phone", b"e", GLib.OptionFlags.NONE, GLib.OptionArg.NONE, "Emulate a Librem phone", None) self.add_main_option("version", b"v", GLib.OptionFlags.NONE, GLib.OptionArg.NONE, "Lollypop version", None) self.connect("command-line", self.__on_command_line) self.connect("handle-local-options", self.__on_handle_local_options) self.connect("activate", self.__on_activate) self.connect("shutdown", lambda a: self.__save_state()) self.register(None) if self.get_is_remote(): Gdk.notify_startup_complete()
def __init(self): """ Init main application """ self.settings = Settings.new() # Init extensions GLib.setenv('PYTHONPATH', self.__extension_dir, True) # Create favicon path d = Gio.File.new_for_path(self.__FAVICONS_PATH) if not d.query_exists(): d.make_directory_with_parents() # Setup default context context = WebKit2.WebContext.get_default() Context(context) # Setup ephemeral context self.__ephemeral_context = WebKit2.WebContext.new_ephemeral() Context(self.__ephemeral_context) # Add a global DBus helper self.helper = DBusHelper() # First init sync worker try: from eolie.mozilla_sync import SyncWorker self.sync_worker = SyncWorker() # Run a first sync in 10 seconds, speed up app start GLib.timeout_add_seconds(10, self.sync_worker.sync, False) # Then run a sync every hour GLib.timeout_add_seconds(3600, self.sync_worker.sync, True) except Exception as e: print("Application::init():", e) self.sync_worker = None if self.prefers_app_menu(): menu = self.get_app_menu() self.set_app_menu(menu) cssProviderFile = Gio.File.new_for_uri( 'resource:///org/gnome/Eolie/application.css') cssProvider = Gtk.CssProvider() cssProvider.load_from_file(cssProviderFile) screen = Gdk.Screen.get_default() styleContext = Gtk.StyleContext() styleContext.add_provider_for_screen(screen, cssProvider, Gtk.STYLE_PROVIDER_PRIORITY_USER) self.history = DatabaseHistory() self.bookmarks = DatabaseBookmarks() # We store cursors for main thread SqlCursor.add(self.history) SqlCursor.add(self.bookmarks) self.websettings = DatabaseSettings() self.adblock = DatabaseAdblock() self.adblock.update() self.phishing = DatabasePhishing() self.adblock_exceptions = DatabaseExceptions("adblock") self.popup_exceptions = DatabaseExceptions("popup") self.image_exceptions = DatabaseExceptions("image") if self.settings.get_user_value("jsblock") is not None: self.js_exceptions = DatabaseExceptions("js") else: self.js_exceptions = None self.phishing.update() self.art = Art() self.search = Search() self.download_manager = DownloadManager() self.pages_menu = PagesMenu() shortcut_action = Gio.SimpleAction.new('shortcut', GLib.VariantType.new('s')) shortcut_action.connect('activate', self.__on_shortcut_action) self.add_action(shortcut_action) self.set_accels_for_action("win.shortcut::expose", ["<Alt>e"]) self.set_accels_for_action("win.exceptions::site", ["<Control>e"]) self.set_accels_for_action("win.shortcut::show_left_panel", ["F9"]) self.set_accels_for_action("win.shortcut::uri", ["<Control>l", "<Control>b"]) self.set_accels_for_action("win.shortcut::new_page", ["<Control>t"]) self.set_accels_for_action("win.shortcut::last_page", ["<Control><Shift>t"]) self.set_accels_for_action("app.shortcut::new_window", ["<Control>n"]) self.set_accels_for_action("win.shortcut::private", ["<Control><Shift>p"]) self.set_accels_for_action("win.shortcut::close_page", ["<Control>w"]) self.set_accels_for_action("win.shortcut::quit", ["<Control>q"]) self.set_accels_for_action("win.shortcut::save", ["<Control>s"]) self.set_accels_for_action("win.shortcut::filter", ["<Control>i"]) self.set_accels_for_action("win.shortcut::reload", ["<Control>r", "F5"]) self.set_accels_for_action("win.shortcut::find", ["<Control>f"]) self.set_accels_for_action("win.shortcut::print", ["<Control>p"]) self.set_accels_for_action("win.shortcut::source", ["<Control><Shift>c"]) self.set_accels_for_action("win.shortcut::history", ["<Control>h"]) self.set_accels_for_action("win.shortcut::search", ["<Control>k"]) self.set_accels_for_action("win.shortcut::fullscreen", ["F11"]) self.set_accels_for_action("app.settings", ["<Control><Shift>s"]) self.set_accels_for_action("win.shortcut::backward", ["<Alt>Left", "XF86Back"]) self.set_accels_for_action("win.shortcut::forward", ["<Alt>Right", "XF86Forward"]) self.set_accels_for_action("win.shortcut::next", ["<Control>Tab", "<Control>Page_Down"]) self.set_accels_for_action("win.shortcut::previous", ["<Control><Shift>Tab", "<Control>Page_Up"]) self.set_accels_for_action("win.shortcut::zoom_in", ["<Control>KP_Add", "<Control>plus", "<Control>equal"]) self.set_accels_for_action("win.shortcut::zoom_out", ["<Control>KP_Subtract", "<Control>minus"]) self.set_accels_for_action("win.shortcut::zoom_default", ["<Control>KP_0", "<Control>0"])
def __gdk_window_set_cb(self, object, pspec): window = object.get_window() if type(window) != GdkX11.X11Window: return s = '%u' % GdkX11.X11Window.get_xid(window) GLib.setenv('IBUS_SETUP_XID', s, True)
def __gdk_window_set_cb(self, object, pspec): str = '%u' % GdkX11.X11Window.get_xid(object.get_window()) GLib.setenv('IBUS_SETUP_XID', str, True)