diff options
author | Martin Sivak <msivak@redhat.com> | 2012-10-16 12:58:48 +0200 |
---|---|---|
committer | Martin Sivak <msivak@redhat.com> | 2012-10-16 15:37:37 +0200 |
commit | 4738bb9da3f3488ff12ecb702d3b63315e6ade37 (patch) | |
tree | 6a5261dc324e6a6c96b2f19d16f833db22930ea3 /pyanaconda/ui/gui/spokes/storage.py | |
parent | 8d65f4e89fc4f036be3b283c1b5a2041153593b5 (diff) | |
download | anaconda-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/spokes/storage.py')
-rw-r--r-- | pyanaconda/ui/gui/spokes/storage.py | 27 |
1 files changed, 15 insertions, 12 deletions
diff --git a/pyanaconda/ui/gui/spokes/storage.py b/pyanaconda/ui/gui/spokes/storage.py index bffe1d0ca..611f4abf7 100644 --- a/pyanaconda/ui/gui/spokes/storage.py +++ b/pyanaconda/ui/gui/spokes/storage.py @@ -40,7 +40,6 @@ from gi.repository import Gdk, GLib, Gtk from gi.repository import AnacondaWidgets - from pyanaconda.ui.gui import GUIObject, communication from pyanaconda.ui.gui.spokes import NormalSpoke from pyanaconda.ui.gui.spokes.lib.cart import SelectedDisksDialog @@ -48,7 +47,7 @@ from pyanaconda.ui.gui.spokes.lib.passphrase import PassphraseDialog from pyanaconda.ui.gui.spokes.lib.detailederror import DetailedErrorDialog from pyanaconda.ui.gui.spokes.lib.resize import ResizeDialog from pyanaconda.ui.gui.categories.storage import StorageCategory -from pyanaconda.ui.gui.utils import enlightbox, gdk_threaded +from pyanaconda.ui.gui.utils import enlightbox, gtk_thread_wait from pyanaconda.kickstart import doKickstartStorage from pyanaconda.storage.size import Size @@ -516,16 +515,18 @@ class StorageSpoke(NormalSpoke, StorageChecker): if len(self.disks) == 1 and not self.selected_disks: self.data.ignoredisk.onlyuse = [self.disks[0].name] - with gdk_threaded(): - # properties: kind, description, capacity, os, popup-info - for disk in self.disks: - if disk.removable: - kind = "drive-removable-media" - else: - kind = "drive-harddisk" + # properties: kind, description, capacity, os, popup-info + for disk in self.disks: + if disk.removable: + kind = "drive-removable-media" + else: + kind = "drive-harddisk" + + size = size_str(disk.size) + popup_info = "%s | %s" % (disk.name, disk.serial) - size = size_str(disk.size) - popup_info = "%s | %s" % (disk.name, disk.serial) + @gtk_thread_wait + def gtk_action(): overview = AnacondaWidgets.DiskOverview(disk.description, kind, size, @@ -541,8 +542,10 @@ class StorageSpoke(NormalSpoke, StorageChecker): overview.connect("key-release-event", self._on_disk_clicked) overview.show_all() - self._update_summary() + self._update_summary() + gtk_action() + self._ready = True communication.send_ready(self.__class__.__name__) |