[PATCH 1/2] Implement and use a function for one-off running Gtk actions
Vratislav Podzimek
vpodzime at redhat.com
Tue Jan 14 17:31:30 UTC 2014
There are cases we don't have a function we would like to decorate with the
@gtk_action_wait decorator. And e.g. the addons may make us of this as well.
Signed-off-by: Vratislav Podzimek <vpodzime at redhat.com>
---
pyanaconda/ui/gui/spokes/custom.py | 10 +++-------
pyanaconda/ui/gui/spokes/source.py | 10 +++-------
pyanaconda/ui/gui/utils.py | 8 ++++++++
3 files changed, 14 insertions(+), 14 deletions(-)
diff --git a/pyanaconda/ui/gui/spokes/custom.py b/pyanaconda/ui/gui/spokes/custom.py
index 0c71d31..b119d82 100644
--- a/pyanaconda/ui/gui/spokes/custom.py
+++ b/pyanaconda/ui/gui/spokes/custom.py
@@ -76,8 +76,8 @@ from pyanaconda.ui.gui.spokes.lib.passphrase import PassphraseDialog
from pyanaconda.ui.gui.spokes.lib.accordion import selectorFromDevice, Accordion, Page, CreateNewPage, UnknownPage
from pyanaconda.ui.gui.spokes.lib.refresh import RefreshDialog
from pyanaconda.ui.gui.spokes.lib.summary import ActionSummaryDialog
-from pyanaconda.ui.gui.utils import setViewportBackground, gtk_action_wait, enlightbox, fancy_set_sensitive, ignoreEscape,\
- really_hide, really_show
+from pyanaconda.ui.gui.utils import setViewportBackground, enlightbox, fancy_set_sensitive, ignoreEscape,\
+ really_hide, really_show, fire_gtk_action
from pyanaconda.ui.gui.categories.system import SystemCategory
from gi.repository import Gdk, Gtk
@@ -813,10 +813,6 @@ class CustomPartitioningSpoke(NormalSpoke, StorageChecker):
threadMgr.add(AnacondaThread(name=THREAD_CUSTOM_STORAGE_INIT, target=self._initialize))
def _initialize(self):
- @gtk_action_wait
- def gtk_action(name):
- self._fsCombo.append_text(name)
-
self._fs_types = []
for cls in device_formats.itervalues():
obj = cls()
@@ -828,7 +824,7 @@ class CustomPartitioningSpoke(NormalSpoke, StorageChecker):
(isinstance(obj, FS) or
obj.type in ["biosboot", "prepboot", "swap"]))
if supported_fs:
- gtk_action(obj.name)
+ fire_gtk_action(self._fsCombo.append_text, obj.name)
self._fs_types.append(obj.name)
@property
diff --git a/pyanaconda/ui/gui/spokes/source.py b/pyanaconda/ui/gui/spokes/source.py
index 66f9639..105479e 100644
--- a/pyanaconda/ui/gui/spokes/source.py
+++ b/pyanaconda/ui/gui/spokes/source.py
@@ -36,7 +36,7 @@ from pyanaconda.ui.communication import hubQ
from pyanaconda.ui.gui import GUIObject
from pyanaconda.ui.gui.spokes import NormalSpoke
from pyanaconda.ui.gui.categories.software import SoftwareCategory
-from pyanaconda.ui.gui.utils import enlightbox, gtk_action_wait
+from pyanaconda.ui.gui.utils import enlightbox, fire_gtk_action
from pyanaconda.iutil import ProxyString, ProxyStringError, cmp_obj_attrs
from pyanaconda.ui.gui.utils import gtk_call_once, really_hide, really_show
from pyanaconda.threads import threadMgr, AnacondaThread
@@ -623,12 +623,8 @@ class SourceSpoke(NormalSpoke):
self._cdrom = opticalInstallMedia(self.storage.devicetree)
if self._cdrom:
- @gtk_action_wait
- def gtk_action_1():
- self._autodetectDeviceLabel.set_text(_("Device: %s") % self._cdrom.name)
- self._autodetectLabel.set_text(_("Label: %s") % (getattr(self._cdrom.format, "label", "") or ""))
-
- gtk_action_1()
+ fire_gtk_action(self._autodetectDeviceLabel.set_text, _("Device: %s") % self._cdrom.name)
+ fire_gtk_action(self._autodetectLabel.set_text, _("Label: %s") % (getattr(self._cdrom.format, "label", "") or ""))
added = True
if self.data.method.method == "harddrive":
diff --git a/pyanaconda/ui/gui/utils.py b/pyanaconda/ui/gui/utils.py
index 89daf2f..ae7eac5 100644
--- a/pyanaconda/ui/gui/utils.py
+++ b/pyanaconda/ui/gui/utils.py
@@ -77,6 +77,14 @@ def gtk_action_wait(func):
return _call_method
+def fire_gtk_action(func, *args):
+ """Run some Gtk action in the main thread and wait for it."""
+
+ @gtk_action_wait
+ def gtk_action():
+ func(*args)
+
+ gtk_action()
def gtk_action_nowait(func):
"""Decorator method which ensures every call of the decorated function to be
--
1.8.4.2
More information about the anaconda-patches
mailing list