Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
* use threads_enter / threads_leave in launcher (and make it gtk2 only)
* move code to util class
* make client call gtk.threads_init() and not just gobject.threads_init()

git-svn-id: https://xpra.org/svn/Xpra/trunk@4796 3bb7dfac-3a0b-4e04-842a-767bc560f471
  • Loading branch information
totaam committed Nov 25, 2013
1 parent 7a05cf3 commit 6710af8
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 15 deletions.
7 changes: 3 additions & 4 deletions src/xpra/client/gtk2/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,12 @@
pass
import gtk
from gtk import gdk
gtk.threads_init()

from xpra.platform.ui_thread_watcher import get_UI_watcher
get_UI_watcher(gobject.timeout_add).start()

from xpra.gtk_common.gtk2common import gtk2main
from xpra.client.gtk_base.gtk_client_base import GTKXpraClient, xor_str
from xpra.client.gtk2.tray_menu import GTK2TrayMenu
from xpra.gtk_common.cursor_names import cursor_names
Expand Down Expand Up @@ -64,10 +66,7 @@ def init(self, opts):
log("init(..) ClientWindowClass=%s", self.ClientWindowClass)

def gtk_main(self):
if gtk.main_level()==0:
gtk.threads_enter()
gtk.main()
gtk.threads_leave()
gtk2main()

def client_type(self):
return "Python/Gtk2"
Expand Down
12 changes: 7 additions & 5 deletions src/xpra/client/gtk_base/client_launcher.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,12 @@
import shlex
import signal

from xpra.gtk_common.gobject_compat import import_gtk, import_gdk, import_gobject
gtk = import_gtk()
gdk = import_gdk()
gobject = import_gobject()
import pygtk
pygtk.require('2.0')
import gtk.gdk
import gobject
gobject.threads_init()
gtk.threads_init()
import pango


Expand Down Expand Up @@ -278,7 +279,8 @@ def show(self):
self.window.present()

def run(self):
gtk.main()
from xpra.gtk_common.gtk2common import gtk2main
gtk2main()

def get_icon(self, icon_name):
icon_filename = os.path.join(get_icon_dir(), icon_name)
Expand Down
16 changes: 16 additions & 0 deletions src/xpra/gtk_common/gtk2common.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# coding=utf8
# This file is part of Xpra.
# Copyright (C) 2013 Antoine Martin <antoine@devloop.org.uk>
# Xpra is released under the terms of the GNU GPL v2, or, at your option, any
# later version. See the file COPYING for details.

def gtk2main():
import pygtk
pygtk.require('2.0')
import gtk
if gtk.main_level()==0:
try:
gtk.threads_enter()
gtk.main()
finally:
gtk.threads_leave()
8 changes: 2 additions & 6 deletions src/xpra/server/gtk_server_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
gtk_main_quit_on_fatal_exceptions_enable)
from xpra.server.server_base import ServerBase
from xpra.gtk_common.gtk_util import add_gtk_version_info
from xpra.gtk_common.gtk2common import gtk2main


class GTKServerBase(ServerBase):
Expand All @@ -44,12 +45,7 @@ def do_quit(self):

def do_run(self):
gtk_main_quit_on_fatal_exceptions_enable()
log("calling gtk.main()")
try:
gtk.threads_enter()
gtk.main()
finally:
gtk.threads_leave()
gtk2main()
log("end of gtk.main()")

def add_listen_socket(self, socktype, sock):
Expand Down

0 comments on commit 6710af8

Please sign in to comment.