summaryrefslogtreecommitdiffstats
path: root/pyanaconda/ui/gui/spokes/datetime_spoke.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/spokes/datetime_spoke.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/spokes/datetime_spoke.py')
-rw-r--r--pyanaconda/ui/gui/spokes/datetime_spoke.py16
1 files changed, 9 insertions, 7 deletions
diff --git a/pyanaconda/ui/gui/spokes/datetime_spoke.py b/pyanaconda/ui/gui/spokes/datetime_spoke.py
index feabeec29..f3249bbcf 100644
--- a/pyanaconda/ui/gui/spokes/datetime_spoke.py
+++ b/pyanaconda/ui/gui/spokes/datetime_spoke.py
@@ -32,7 +32,7 @@ from gi.repository import AnacondaWidgets, GLib, Gtk
from pyanaconda.ui.gui import GUIObject
from pyanaconda.ui.gui.spokes import NormalSpoke
from pyanaconda.ui.gui.categories.localization import LocalizationCategory
-from pyanaconda.ui.gui.utils import enlightbox
+from pyanaconda.ui.gui.utils import enlightbox, gtk_thread_nowait, gtk_call_once
from pyanaconda import timezone
from pyanaconda import iutil
@@ -174,6 +174,7 @@ class NTPconfigDialog(GUIObject):
"""
+ @gtk_thread_nowait
def set_store_value(arg_tuple):
"""
We need a function for this, because this way it can be added to
@@ -200,13 +201,14 @@ class NTPconfigDialog(GUIObject):
if orig_hostname == actual_hostname:
if server_working:
- GLib.idle_add(set_store_value, (self._serversStore,
- itr, 1, SERVER_OK))
+ set_store_value((self._serversStore,
+ itr, 1, SERVER_OK))
else:
- GLib.idle_add(set_store_value, (self._serversStore,
- itr, 1, SERVER_NOK))
+ set_store_value((self._serversStore,
+ itr, 1, SERVER_NOK))
self._epoch_lock.release()
+ @gtk_thread_nowait
def _refresh_server_working(self, itr):
""" Runs a new thread with _set_server_ok_nok(itr) as a taget. """
@@ -229,7 +231,7 @@ class NTPconfigDialog(GUIObject):
self._poolsNote.set_text(POOL_SERVERS_NOTE)
#do not block UI while starting thread (may take some time)
- GLib.idle_add(self._refresh_server_working, itr)
+ self._refresh_server_working(itr)
def on_entry_activated(self, entry, *args):
self._add_server(entry.get_text())
@@ -410,7 +412,7 @@ class DatetimeSpoke(NormalSpoke):
self._show_no_network_warning()
else:
self.window.clear_info()
- GLib.idle_add(self._config_dialog.refresh_servers_state)
+ gtk_call_once(self._config_dialog.refresh_servers_state)
if flags.can_touch_runtime_system("get NTP service state"):
ntp_working = has_active_network and iutil.service_running("chronyd")