[PATCH 3/3] Make Keboard spoke live-system friendly

Vratislav Podzimek vpodzime at redhat.com
Fri Sep 21 16:29:49 UTC 2012


Signed-off-by: Vratislav Podzimek <vpodzime at redhat.com>
---
 pyanaconda/ui/gui/spokes/keyboard.glade |  6 +++---
 pyanaconda/ui/gui/spokes/keyboard.py    | 25 +++++++++++++++++++++----
 2 files changed, 24 insertions(+), 7 deletions(-)

diff --git a/pyanaconda/ui/gui/spokes/keyboard.glade b/pyanaconda/ui/gui/spokes/keyboard.glade
index a4cd335..ae7a606 100644
--- a/pyanaconda/ui/gui/spokes/keyboard.glade
+++ b/pyanaconda/ui/gui/spokes/keyboard.glade
@@ -387,7 +387,7 @@ any layout to the top of the list to select it as the default.</property>
                         <property name="orientation">vertical</property>
                         <property name="spacing">6</property>
                         <child>
-                          <object class="GtkLabel" id="label2">
+                          <object class="GtkLabel" id="testingLabel">
                             <property name="visible">True</property>
                             <property name="can_focus">False</property>
                             <property name="halign">start</property>
@@ -400,7 +400,7 @@ any layout to the top of the list to select it as the default.</property>
                           </packing>
                         </child>
                         <child>
-                          <object class="GtkScrolledWindow" id="scrolledwindow2">
+                          <object class="GtkScrolledWindow" id="testingWindow">
                             <property name="height_request">100</property>
                             <property name="visible">True</property>
                             <property name="can_focus">True</property>
@@ -420,7 +420,7 @@ any layout to the top of the list to select it as the default.</property>
                           </packing>
                         </child>
                         <child>
-                          <object class="GtkLabel" id="layoutSwitchButton">
+                          <object class="GtkLabel" id="layoutSwitchLabel">
                             <property name="visible">True</property>
                             <property name="can_focus">False</property>
                             <property name="halign">end</property>
diff --git a/pyanaconda/ui/gui/spokes/keyboard.py b/pyanaconda/ui/gui/spokes/keyboard.py
index 899fc96..4f8ae5a 100644
--- a/pyanaconda/ui/gui/spokes/keyboard.py
+++ b/pyanaconda/ui/gui/spokes/keyboard.py
@@ -24,6 +24,7 @@ import gettext
 _ = lambda x: gettext.ldgettext("anaconda", x)
 N_ = lambda x: x
 
+# pylint: disable-msg=E0611
 from gi.repository import GLib, Gkbd, Gtk
 
 from pyanaconda.ui.gui import GUIObject
@@ -31,6 +32,7 @@ from pyanaconda.ui.gui.spokes import NormalSpoke
 from pyanaconda.ui.gui.categories.localization import LocalizationCategory
 from pyanaconda.ui.gui.utils import enlightbox
 from pyanaconda import keyboard
+from pyanaconda import flags
 
 __all__ = ["KeyboardSpoke"]
 
@@ -194,6 +196,17 @@ class KeyboardSpoke(NormalSpoke):
         self._store = self.builder.get_object("addedLayoutStore")
         self._add_data_layouts()
 
+        if not flags.can_touch_live_system("test X layouts"):
+            # Disable area for testing layouts as we cannot make
+            # it work without modifying live system
+
+            widgets = [self.builder.get_object("testingLabel")]
+            widgets.append(self.builder.get_object("testingWindow"))
+            widgets.append(self.builder.get_object("layoutSwitchLabel"))
+
+            for widget in widgets:
+                widget.set_sensitive(False)
+
     def refresh(self):
         NormalSpoke.refresh(self)
 
@@ -219,7 +232,8 @@ class KeyboardSpoke(NormalSpoke):
 
     def _addLayout(self, store, name):
         store.append([name])
-        self._xkl_wrapper.add_layout(name)
+        if flags.can_touch_live_system("add runtime X layout"):
+            self._xkl_wrapper.add_layout(name)
 
     def _removeLayout(self, store, itr):
         """
@@ -228,7 +242,8 @@ class KeyboardSpoke(NormalSpoke):
 
         """
 
-        self._xkl_wrapper.remove_layout(store[itr][0])
+        if flags.can_touch_live_system("remove runtime X layout"):
+            self._xkl_wrapper.remove_layout(store[itr][0])
         store.remove(itr)
 
     # Signal handlers.
@@ -301,7 +316,8 @@ class KeyboardSpoke(NormalSpoke):
             return
 
         store.swap(cur, prev)
-        self._flush_layouts_to_X()
+        if flags.can_touch_live_system("reorder runtime X layouts"):
+            self._flush_layouts_to_X()
         selection.emit("changed")
 
     def on_down_clicked(self, button):
@@ -315,7 +331,8 @@ class KeyboardSpoke(NormalSpoke):
             return
 
         store.swap(cur, nxt)
-        self._flush_layouts_to_X()
+        if flags.can_touch_live_system("reorder runtime X layouts"):
+            self._flush_layouts_to_X()
         selection.emit("changed")
 
     def on_preview_clicked(self, button):
-- 
1.7.11.4



More information about the anaconda-patches mailing list