summaryrefslogtreecommitdiffstats
path: root/pyanaconda/ui/gui/hubs
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/hubs
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/hubs')
-rw-r--r--pyanaconda/ui/gui/hubs/progress.py25
1 files changed, 11 insertions, 14 deletions
diff --git a/pyanaconda/ui/gui/hubs/progress.py b/pyanaconda/ui/gui/hubs/progress.py
index 9cb95eb63..d3b6b4147 100644
--- a/pyanaconda/ui/gui/hubs/progress.py
+++ b/pyanaconda/ui/gui/hubs/progress.py
@@ -36,7 +36,7 @@ from pyanaconda.flags import flags
from pykickstart.constants import KS_WAIT, KS_SHUTDOWN, KS_REBOOT
from pyanaconda.ui.gui.hubs import Hub
-from pyanaconda.ui.gui.utils import gdk_threaded
+from pyanaconda.ui.gui.utils import gtk_thread_nowait, gtk_call_once
__all__ = ["ProgressHub"]
@@ -227,29 +227,26 @@ class ProgressHub(Hub):
self._totalSteps = steps
self._currentStep = 0
- with gdk_threaded():
- self._progressBar.set_fraction(0.0)
+ gtk_call_once(self._progressBar.set_fraction, 0.0)
def _step_progress_bar(self):
if not self._totalSteps:
return
- with gdk_threaded():
- self._currentStep += 1
- self._progressBar.set_fraction(self._currentStep/self._totalSteps)
+ self._currentStep += 1
+ gtk_call_once(self._progressBar.set_fraction, self._currentStep/self._totalSteps)
def _update_progress_message(self, message):
if not self._totalSteps:
return
- with gdk_threaded():
- self._progressLabel.set_text(message)
+ gtk_call_once(self._progressLabel.set_text, message)
+ @gtk_thread_nowait
def _progress_bar_complete(self):
- with gdk_threaded():
- self._progressBar.set_fraction(1.0)
- self._progressLabel.set_text(_("Complete!"))
+ self._progressBar.set_fraction(1.0)
+ self._progressLabel.set_text(_("Complete!"))
- spinner = self.builder.get_object("progressSpinner")
- spinner.stop()
- spinner.hide()
+ spinner = self.builder.get_object("progressSpinner")
+ spinner.stop()
+ spinner.hide()