summaryrefslogtreecommitdiffstats
path: root/pyanaconda/ui/gui/__init__.py
diff options
context:
space:
mode:
authorMartin Sivak <msivak@redhat.com>2012-10-16 12:58:48 +0200
committerMartin Sivak <msivak@redhat.com>2012-10-16 15:37:37 +0200
commit4738bb9da3f3488ff12ecb702d3b63315e6ade37 (patch)
tree6a5261dc324e6a6c96b2f19d16f833db22930ea3 /pyanaconda/ui/gui/__init__.py
parent8d65f4e89fc4f036be3b283c1b5a2041153593b5 (diff)
downloadanaconda-threading.tar.gz
anaconda-threading.tar.xz
anaconda-threading.zip
Make all Gtk calls from inside of it's main loop (and thread)threading
- Marks all methods containing mostly gtk calls as gtk_thread_wait or gtk_thread_nowait - Uses gtk_call_once instead of GLib.idle_add to make sure the method is called only once (returns False) - Removes some code from the threading locks, because it wasn´t touching Gtk at all This change was discussed in the mailinglist here: https://www.redhat.com/archives/anaconda-devel-list/2012-October/msg00030.html The main point was: According to the Gtk team, the gdk_threads_enter/leave pair should not be used at all (and they have apparently discouraged usage of it since early releases of Gtk2). Moreover in the current Gdk docs (http://developer.gnome.org/gdk3/stable/gdk3-Threads.html) those functions are now marked as deprecated. The preferred way (and now the only way) is to use g_idle_add (GLib.idle_add) with a callback method to schedule GUI changes. The callback method will then get called by the Gtk main loop so no locking is needed (and GLib.idle_add performs none). But that is also the reason why everything Gtk related must be done from the mainloop thread either directly or via idle_add.
Diffstat (limited to 'pyanaconda/ui/gui/__init__.py')
-rw-r--r--pyanaconda/ui/gui/__init__.py47
1 files changed, 23 insertions, 24 deletions
diff --git a/pyanaconda/ui/gui/__init__.py b/pyanaconda/ui/gui/__init__.py
index 638772bdb..fa80e6de7 100644
--- a/pyanaconda/ui/gui/__init__.py
+++ b/pyanaconda/ui/gui/__init__.py
@@ -24,7 +24,7 @@ import meh.ui.gui
from gi.repository import Gdk
from pyanaconda.ui import UserInterface, common
-from pyanaconda.ui.gui.utils import enlightbox, gdk_threaded
+from pyanaconda.ui.gui.utils import enlightbox, gtk_thread_wait
import gettext
_ = lambda x: gettext.ldgettext("anaconda", x)
@@ -117,37 +117,36 @@ class GraphicalUserInterface(UserInterface):
###
### MESSAGE HANDLING METHODS
###
+ @gtk_thread_wait
def showError(self, message):
from gi.repository import AnacondaWidgets, Gtk
-
- with gdk_threaded():
- dlg = Gtk.MessageDialog(flags=Gtk.DialogFlags.MODAL,
- message_type=Gtk.MessageType.ERROR,
- buttons=Gtk.ButtonsType.NONE,
- message_format=message)
- dlg.add_button(_("_Exit Installer"), 0)
-
- with enlightbox(self._actions[0].window, dlg):
- dlg.run()
- dlg.destroy()
-
+ dlg = Gtk.MessageDialog(flags=Gtk.DialogFlags.MODAL,
+ message_type=Gtk.MessageType.ERROR,
+ buttons=Gtk.ButtonsType.NONE,
+ message_format=message)
+ dlg.add_button(_("_Exit Installer"), 0)
+
+ with enlightbox(self._actions[0].window, dlg):
+ dlg.run()
+ dlg.destroy()
+
+ @gtk_thread_wait
def showYesNoQuestion(self, message):
from gi.repository import AnacondaWidgets, Gtk
+ dlg = Gtk.MessageDialog(flags=Gtk.DialogFlags.MODAL,
+ message_type=Gtk.MessageType.QUESTION,
+ buttons=Gtk.ButtonsType.NONE,
+ message_format=message)
+ dlg.add_buttons(_("_No"), 0, _("_Yes"), 1)
+ dlg.set_default_response(1)
- with gdk_threaded():
- dlg = Gtk.MessageDialog(flags=Gtk.DialogFlags.MODAL,
- message_type=Gtk.MessageType.QUESTION,
- buttons=Gtk.ButtonsType.NONE,
- message_format=message)
- dlg.add_buttons(_("_No"), 0, _("_Yes"), 1)
- dlg.set_default_response(1)
-
- with enlightbox(self._actions[0].window, dlg):
- rc = dlg.run()
- dlg.destroy()
+ with enlightbox(self._actions[0].window, dlg):
+ rc = dlg.run()
+ dlg.destroy()
return bool(rc)
+
def mainExceptionWindow(self, text, exn_file, *args, **kwargs):
from gi.repository import Gtk, AnacondaWidgets