Skip to content

Commit

Permalink
#2290 remove gobject from gobject_compat module
Browse files Browse the repository at this point in the history
git-svn-id: https://xpra.org/svn/Xpra/trunk@23804 3bb7dfac-3a0b-4e04-842a-767bc560f471
  • Loading branch information
totaam committed Sep 18, 2019
1 parent 19d367a commit d467f29
Show file tree
Hide file tree
Showing 29 changed files with 166 additions and 324 deletions.
8 changes: 3 additions & 5 deletions src/xpra/client/gobject_client_base.py
Expand Up @@ -6,6 +6,7 @@

import sys
from gi.repository import GLib
from gi.repository import GObject

from xpra.util import (
nonl, sorted_nicely, print_nested_dict, envint, flatten_dict,
Expand All @@ -17,13 +18,10 @@
EXIT_OK, EXIT_CONNECTION_LOST, EXIT_TIMEOUT, EXIT_INTERNAL_ERROR,
EXIT_FAILURE, EXIT_UNSUPPORTED, EXIT_REMOTE_ERROR, EXIT_FILE_TOO_BIG,
)
from xpra.gtk_common.gobject_compat import import_gobject
from xpra.log import Logger

log = Logger("gobject", "client")

gobject = import_gobject()

FLATTEN_INFO = envint("XPRA_FLATTEN_INFO", 1)


Expand All @@ -35,7 +33,7 @@ def errwrite(msg):
pass


class GObjectXpraClient(gobject.GObject, XpraClientBase):
class GObjectXpraClient(GObject.GObject, XpraClientBase):
"""
Utility superclass for GObject clients
"""
Expand All @@ -45,7 +43,7 @@ def __init__(self):
self.idle_add = GLib.idle_add
self.timeout_add = GLib.timeout_add
self.source_remove = GLib.source_remove
gobject.GObject.__init__(self)
GObject.GObject.__init__(self)
XpraClientBase.__init__(self)

def init(self, opts):
Expand Down
7 changes: 3 additions & 4 deletions src/xpra/client/gtk_base/client_launcher.py
Expand Up @@ -15,9 +15,11 @@
import os.path
import sys
import traceback
from gi.repository import Pango
from gi.repository import GLib

from xpra.gtk_common.gobject_compat import (
import_gtk, import_gdk, import_gobject,
import_gtk, import_gdk,
register_os_signals,
)
from xpra.scripts.config import read_config, make_defaults_struct, validate_config, save_config
Expand Down Expand Up @@ -45,11 +47,8 @@

log = Logger("launcher")

gobject = import_gobject()
gtk = import_gtk()
gdk = import_gdk()
from gi.repository import Pango
from gi.repository import GLib

#what we save in the config file:
SAVED_FIELDS = [
Expand Down
3 changes: 1 addition & 2 deletions src/xpra/client/gtk_base/gtk_client_base.py
Expand Up @@ -8,7 +8,7 @@
import os
import weakref

from xpra.gtk_common.gobject_compat import import_gobject, import_gtk, import_gdk
from xpra.gtk_common.gobject_compat import import_gtk, import_gdk
from xpra.client.gtk_base.gtk_client_window_base import HAS_X11_BINDINGS, XSHAPE
from xpra.gtk_common.quit import gtk_main_quit_really, gtk_main_quit_on_fatal_exceptions_enable
from xpra.util import (
Expand Down Expand Up @@ -49,7 +49,6 @@
)
from xpra.log import Logger

gobject = import_gobject()
gtk = import_gtk()
gdk = import_gdk()

Expand Down
3 changes: 1 addition & 2 deletions src/xpra/client/gtk_base/start_new_command.py
Expand Up @@ -13,7 +13,7 @@
window_defaults, WIN_POS_CENTER,
)
from xpra.gtk_common.gobject_compat import (
import_gtk, import_gdk, import_gobject,
import_gtk, import_gdk,
register_os_signals,
)
from xpra.platform.paths import get_icon_dir
Expand All @@ -24,7 +24,6 @@

gtk = import_gtk()
gdk = import_gdk()
gobject = import_gobject()


_instance = None
Expand Down
11 changes: 0 additions & 11 deletions src/xpra/gtk_common/gobject_compat.py
Expand Up @@ -8,7 +8,6 @@
import sys

__all__ = [
"import_gobject",
"import_gtk",
"import_gdk",
]
Expand Down Expand Up @@ -39,16 +38,6 @@ def try_import_GdkX11():
return None


def import_gobject():
from gi.repository import GObject #@UnresolvedImport
#silence a GTK3 warning about threads_init not beeing needed:
v = getattr(GObject, "pygobject_version", (0))
if v>=(3,10):
def noop(*_args):
pass
GObject.threads_init = noop
return GObject

def import_gtk():
gi_gtk()
from gi.repository import Gtk #@UnresolvedImport
Expand Down
13 changes: 4 additions & 9 deletions src/xpra/gtk_common/gobject_util.py
@@ -1,19 +1,14 @@
# This file is part of Xpra.
# Copyright (C) 2008, 2009 Nathaniel Smith <njs@pobox.com>
# Copyright (C) 2013 Antoine Martin <antoine@xpra.org>
# Copyright (C) 2013-2019 Antoine Martin <antoine@xpra.org>
# Xpra is released under the terms of the GNU GPL v2, or, at your option, any
# later version. See the file COPYING for details.


from xpra.gtk_common.gobject_compat import import_gobject

gobject = import_gobject()
try:
SIGNAL_RUN_LAST = gobject.SignalFlags.RUN_LAST
except AttributeError:
SIGNAL_RUN_LAST = gobject.SIGNAL_RUN_LAST
from gi.repository import GObject
SIGNAL_RUN_LAST = GObject.SignalFlags.RUN_LAST
def n_arg_signal(n):
return (SIGNAL_RUN_LAST, gobject.TYPE_NONE, (gobject.TYPE_PYOBJECT,) * n)
return (SIGNAL_RUN_LAST, GObject.TYPE_NONE, (GObject.TYPE_PYOBJECT,) * n)
no_arg_signal = n_arg_signal(0)
one_arg_signal = n_arg_signal(1)

Expand Down
15 changes: 7 additions & 8 deletions src/xpra/gtk_common/gtk_util.py
Expand Up @@ -10,6 +10,7 @@
from gi.repository import GLib
from gi.repository import GdkPixbuf #@UnresolvedImport
from gi.repository import Pango
from gi.repository import GObject

from xpra.util import iround, first_time
from xpra.os_util import (
Expand All @@ -18,7 +19,6 @@
)
from xpra.gtk_common.gobject_compat import (
import_gtk, import_gdk,
import_gobject,
)
from xpra.log import Logger

Expand All @@ -29,7 +29,6 @@

gtk = import_gtk()
gdk = import_gdk()
gobject = import_gobject()

SHOW_ALL_VISUALS = False

Expand All @@ -48,15 +47,15 @@ def V(k, module, *fields):
return False

if not GTK_VERSION_INFO:
V("gobject", gobject, "pygobject_version")
V("gobject", GObject, "pygobject_version")

#this isn't the actual version, (only shows as "3.0")
#but still better than nothing:
import gi
V("gi", gi, "__version__")
V("gtk", gtk, "_version")
V("gdk", gdk, "_version")
V("gobject", gobject, "_version")
V("gobject", GObject, "_version")
V("pixbuf", GdkPixbuf, "_version")

av("pygtk", "n/a")
Expand Down Expand Up @@ -464,8 +463,8 @@ def wait_for_contents(clipboard, target):
atom = gdk.Atom.intern(target, False)
return clipboard.wait_for_contents(atom)

PARAM_READABLE = gobject.ParamFlags.READABLE
PARAM_READWRITE = gobject.ParamFlags.READWRITE
PARAM_READABLE = GObject.ParamFlags.READABLE
PARAM_READWRITE = GObject.ParamFlags.READWRITE


#no idea why, but trying to use the threads_init / threads_enter
Expand Down Expand Up @@ -778,8 +777,8 @@ def visual(name, v):
#gtk.settings
def get_setting(key):
#try string first, then int
for t in (gobject.TYPE_STRING, gobject.TYPE_INT):
v = gobject.Value()
for t in (GObject.TYPE_STRING, GObject.TYPE_INT):
v = GObject.Value()
v.init(t)
if screen.get_setting(key, v):
return v.get_value()
Expand Down
5 changes: 2 additions & 3 deletions src/xpra/gtk_common/gtk_view_clipboard.py
Expand Up @@ -5,16 +5,15 @@
import re
import sys
from collections import deque
from gi.repository import Pango

from xpra.gtk_common.gobject_compat import import_gtk, import_gdk, import_gobject
from xpra.gtk_common.gobject_compat import import_gtk, import_gdk
from xpra.gtk_common.gtk_util import TableBuilder, label, get_xwindow, GetClipboard
from xpra.platform.paths import get_icon
from xpra.platform.features import CLIPBOARDS

gtk = import_gtk()
gdk = import_gdk()
gobject = import_gobject()
from gi.repository import Pango


class ClipboardInstance(object):
Expand Down
125 changes: 0 additions & 125 deletions src/xpra/platform/darwin/gdk_bindings.pyx

This file was deleted.

5 changes: 2 additions & 3 deletions src/xpra/platform/win32/gui.py
Expand Up @@ -1210,11 +1210,10 @@ def main():
log.enable_debug()
win32_event_logger.enable_debug()

from xpra.gtk_common.gobject_compat import import_gobject
gobject = import_gobject()
from gi.repository import GLib

log.info("Event loop is running")
loop = gobject.MainLoop()
loop = GLib.MainLoop()

def suspend():
log.info("suspend event")
Expand Down
5 changes: 3 additions & 2 deletions src/xpra/sound/sink.py
Expand Up @@ -7,9 +7,10 @@
import sys
from collections import deque
from threading import Lock
from gi.repository import GObject

from xpra.sound.sound_pipeline import SoundPipeline
from xpra.gtk_common.gobject_util import one_arg_signal, gobject
from xpra.gtk_common.gobject_util import one_arg_signal
from xpra.sound.gstreamer_util import (
plugin_str, get_decoder_elements,
get_queue_time, normv, get_decoders,
Expand Down Expand Up @@ -443,7 +444,7 @@ def push_buffer(self, buf):
return 0
return 1

gobject.type_register(SoundSink)
GObject.type_register(SoundSink)


def main():
Expand Down

0 comments on commit d467f29

Please sign in to comment.