[PATCH 5/7] Replace placeholders with the strings from python

David Shea dshea at redhat.com
Tue Oct 15 18:16:04 UTC 2013


For strings that had keyboard accelerators defined in python but not in
glade, replace the glade placeholder with a non-translatable version of
the python string.

Split the labels on buttons and radio buttons into explicit children in
order to set the necessary markup attributes on the label. This also
cleans up some of that get_children mess we have with builder objects.
---
 pyanaconda/ui/gui/spokes/custom.glade  | 10 ++++++++-
 pyanaconda/ui/gui/spokes/custom.py     |  8 +++----
 pyanaconda/ui/gui/spokes/filter.glade  | 10 ++++++++-
 pyanaconda/ui/gui/spokes/filter.py     |  3 +--
 pyanaconda/ui/gui/spokes/storage.glade | 39 ++++++++++++++++++++++++++++------
 pyanaconda/ui/gui/spokes/storage.py    | 15 ++++++-------
 6 files changed, 61 insertions(+), 24 deletions(-)

diff --git a/pyanaconda/ui/gui/spokes/custom.glade b/pyanaconda/ui/gui/spokes/custom.glade
index fbf416c..f8004c2 100644
--- a/pyanaconda/ui/gui/spokes/custom.glade
+++ b/pyanaconda/ui/gui/spokes/custom.glade
@@ -1846,7 +1846,6 @@ until you click on the main menu's 'Begin Installation' button.</property>
                     </child>
                     <child>
                       <object class="GtkButton" id="summary_button">
-                        <property name="label" translatable="yes">summary</property>
                         <property name="visible">True</property>
                         <property name="can_focus">True</property>
                         <property name="receives_default">True</property>
@@ -1856,6 +1855,15 @@ until you click on the main menu's 'Begin Installation' button.</property>
                         <property name="focus_on_click">False</property>
                         <property name="xalign">0</property>
                         <signal name="clicked" handler="on_summary_clicked" swapped="no"/>
+                        <child>
+                          <object class="GtkLabel" id="summary_label">
+                            <property name="visible">True</property>
+                            <property name="can_focus">False</property>
+                            <property name="label">%d _storage devices selected</property>
+                            <property name="use_markup">True</property>
+                            <property name="use_underline">True</property>
+                          </object>
+                        </child>
                       </object>
                       <packing>
                         <property name="left_attach">0</property>
diff --git a/pyanaconda/ui/gui/spokes/custom.py b/pyanaconda/ui/gui/spokes/custom.py
index bb32c60..beb4549 100644
--- a/pyanaconda/ui/gui/spokes/custom.py
+++ b/pyanaconda/ui/gui/spokes/custom.py
@@ -705,7 +705,7 @@ class CustomPartitioningSpoke(NormalSpoke, StorageChecker):
 
         self._availableSpaceLabel = self.builder.get_object("availableSpaceLabel")
         self._totalSpaceLabel = self.builder.get_object("totalSpaceLabel")
-        self._summaryButton = self.builder.get_object("summary_button")
+        self._summaryLabel = self.builder.get_object("summary_label")
 
         # Buttons
         self._addButton = self.builder.get_object("addButton")
@@ -839,15 +839,13 @@ class CustomPartitioningSpoke(NormalSpoke, StorageChecker):
         self._availableSpaceLabel.set_text(str(self._free_space))
         self._totalSpaceLabel.set_text(str(self._currentTotalSpace()))
 
-        summaryLabel = self._summaryButton.get_children()[0]
         count = len(self.data.clearpart.drives)
         summary = P_("%d _storage device selected",
                      "%d _storage devices selected",
                      count) % count
 
-        summaryLabel.set_use_markup(True)
-        summaryLabel.set_markup("<span foreground='blue'><u>%s</u></span>" % summary)
-        summaryLabel.set_use_underline(True)
+        self._summaryLabel.set_markup("<span foreground='blue'><u>%s</u></span>" % summary)
+        self._summaryLabel.set_use_underline(True)
 
     def _reset_storage(self):
         self.__storage = self.storage.copy()
diff --git a/pyanaconda/ui/gui/spokes/filter.glade b/pyanaconda/ui/gui/spokes/filter.glade
index a96da34..efce5f8 100644
--- a/pyanaconda/ui/gui/spokes/filter.glade
+++ b/pyanaconda/ui/gui/spokes/filter.glade
@@ -1540,7 +1540,6 @@
                 </child>
                 <child>
                   <object class="GtkButton" id="summary_button">
-                    <property name="label" translatable="yes">summary</property>
                     <property name="visible">True</property>
                     <property name="can_focus">True</property>
                     <property name="receives_default">True</property>
@@ -1550,6 +1549,15 @@
                     <property name="focus_on_click">False</property>
                     <property name="xalign">0</property>
                     <signal name="clicked" handler="on_summary_clicked" swapped="no"/>
+                    <child>
+                      <object class="GtkLabel" id="summary_button_label">
+                        <property name="visible">True</property>
+                        <property name="can_focus">False</property>
+                        <property name="label">%d _storage devices selected</property>
+                        <property name="use_markup">True</property>
+                        <property name="use_underline">True</property>
+                      </object>
+                    </child>
                   </object>
                   <packing>
                     <property name="expand">False</property>
diff --git a/pyanaconda/ui/gui/spokes/filter.py b/pyanaconda/ui/gui/spokes/filter.py
index 0c225e2..26d583b 100644
--- a/pyanaconda/ui/gui/spokes/filter.py
+++ b/pyanaconda/ui/gui/spokes/filter.py
@@ -498,7 +498,7 @@ class FilterSpoke(NormalSpoke):
 
     def _update_summary(self):
         summaryButton = self.builder.get_object("summary_button")
-        label = summaryButton.get_children()[0]
+        label = self.builder.get_object("summary_button_label")
 
         # We need to remove ancestor devices from the count.  Otherwise, we'll
         # end up in a situation where selecting one multipath device could
@@ -509,7 +509,6 @@ class FilterSpoke(NormalSpoke):
                      "%d _storage devices selected",
                      count) % count
 
-        label.set_use_markup(True)
         label.set_markup("<span foreground='blue'><u>%s</u></span>" % summary)
         label.set_use_underline(True)
 
diff --git a/pyanaconda/ui/gui/spokes/storage.glade b/pyanaconda/ui/gui/spokes/storage.glade
index a408f44..684f717 100644
--- a/pyanaconda/ui/gui/spokes/storage.glade
+++ b/pyanaconda/ui/gui/spokes/storage.glade
@@ -98,11 +98,9 @@
                 <property name="visible">True</property>
                 <property name="can_focus">False</property>
                 <property name="xalign">0</property>
-                <property name="label">Here we'll describe what your options are.</property>
+                <property name="label">&lt;span font-desc="Cantarell 11"&gt;You have &lt;b&gt;%(freeSpace)s&lt;/b&gt; of free space, which is enough to install %(productName)s.  What would like to do?&lt;/span&gt;</property>
+                <property name="use_markup">True</property>
                 <property name="wrap">True</property>
-                <attributes>
-                  <attribute name="font-desc" value="Cantarell 11"/>
-                </attributes>
               </object>
               <packing>
                 <property name="expand">False</property>
@@ -112,7 +110,6 @@
             </child>
             <child>
               <object class="GtkRadioButton" id="options1_autopart_radio">
-                <property name="label">Here's the autopart label.</property>
                 <property name="visible">True</property>
                 <property name="can_focus">True</property>
                 <property name="receives_default">False</property>
@@ -120,6 +117,16 @@
                 <property name="xalign">0</property>
                 <property name="active">True</property>
                 <property name="draw_indicator">True</property>
+                <child>
+                  <object class="GtkLabel" id="options1_autopart_label">
+                    <property name="visible">True</property>
+                    <property name="can_focus">True</property>
+                    <property name="label">&lt;span font-desc="Cantarell 11"&gt;A_utomatically configure my %(productName)s installation to the disk(s) I selected and return me to the main menu.&lt;/span&gt;</property>
+                    <property name="use_markup">True</property>
+                    <property name="use_underline">True</property>
+                    <property name="wrap">True</property>
+                  </object>
+                </child>
               </object>
               <packing>
                 <property name="expand">False</property>
@@ -129,7 +136,6 @@
             </child>
             <child>
               <object class="GtkRadioButton" id="options1_reclaim_radio">
-                <property name="label">Here's the reclaim label.</property>
                 <property name="visible">True</property>
                 <property name="can_focus">True</property>
                 <property name="receives_default">False</property>
@@ -138,6 +144,16 @@
                 <property name="active">True</property>
                 <property name="draw_indicator">True</property>
                 <property name="group">options1_autopart_radio</property>
+                <child>
+                  <object class="GtkLabel" id="options1_reclaim_label">
+                    <property name="visible">True</property>
+                    <property name="can_focus">True</property>
+                    <property name="label">&lt;span font-desc="Cantarell 11"&gt;I want more space. _Guide me through shrinking and/or removing partitions so I can have more space for %(productName)s.&lt;/span&gt;</property>
+                    <property name="use_markup">True</property>
+                    <property name="use_underline">True</property>
+                    <property name="wrap">True</property>
+                  </object>
+                </child>
               </object>
               <packing>
                 <property name="expand">False</property>
@@ -147,7 +163,6 @@
             </child>
             <child>
               <object class="GtkRadioButton" id="options1_custom_radio">
-                <property name="label">Here's the custom label.</property>
                 <property name="visible">True</property>
                 <property name="can_focus">True</property>
                 <property name="receives_default">False</property>
@@ -156,6 +171,16 @@
                 <property name="active">True</property>
                 <property name="draw_indicator">True</property>
                 <property name="group">options1_autopart_radio</property>
+                <child>
+                  <object class="GtkLabel" id="options1_custom_label">
+                    <property name="visible">True</property>
+                    <property name="can_focus">True</property>
+                    <property name="label">&lt;span font-desc="Cantarell 11"&gt;I want to review/_modify my disk partitions before continuing.&lt;/span&gt;</property>
+                    <property name="use_markup">True</property>
+                    <property name="use_underline">True</property>
+                    <property name="wrap">True</property>
+                  </object>
+                </child>
               </object>
               <packing>
                 <property name="expand">False</property>
diff --git a/pyanaconda/ui/gui/spokes/storage.py b/pyanaconda/ui/gui/spokes/storage.py
index 43b1bf6..31f6b1f 100644
--- a/pyanaconda/ui/gui/spokes/storage.py
+++ b/pyanaconda/ui/gui/spokes/storage.py
@@ -123,34 +123,33 @@ class InstallOptions1Dialog(GUIObject):
 
         options_label = self.builder.get_object("options1_label")
 
-        options_text = _("You have <b>%(freeSpace)s</b> of free space, which is "
-                         "enough to install %(productName)s.  What would you "
-                         "like to do?") % {"freeSpace": disk_free, "productName": productName}
+        options_text = _("<span font-desc=\"Cantarell 11\">You have <b>%(freeSpace)s</b> "
+                         "of free space, which is enough to install %(productName)s.  "
+                         "What would you like to do?</span>") %\
+                         {"freeSpace": disk_free, "productName": productName}
         options_label.set_markup(options_text)
 
-        label = self.builder.get_object("options1_autopart_radio").get_children()[0]
+        label = self.builder.get_object("options1_autopart_label")
         label.set_markup(_("<span font-desc=\"Cantarell 11\">A_utomatically "
                            "configure my %(productName)s installation to the "
                            "disk(s) I selected and return me to the main "
                            "menu.</span>") % {"productName": productName})
-        label.set_line_wrap(True)
         label.set_use_underline(True)
 
         radio = self.builder.get_object("options1_reclaim_radio")
         if self.showReclaim:
+            label = self.builder.get_object("options1_reclaim_label")
             label = radio.get_children()[0]
             label.set_markup(_("<span font-desc=\"Cantarell 11\">I want more space. "
                                "_Guide me through shrinking and/or removing partitions "
                                "so I can have more space for %(productName)s.</span>") % {"productName": productName})
-            label.set_line_wrap(True)
             label.set_use_underline(True)
         else:
             radio.hide()
 
-        label = self.builder.get_object("options1_custom_radio").get_children()[0]
+        label = self.builder.get_object("options1_custom_label")
         label.set_markup(_("<span font-desc=\"Cantarell 11\">I want to review/_modify "
                            "my disk partitions before continuing.</span>"))
-        label.set_line_wrap(True)
         label.set_use_underline(True)
 
     @property
-- 
1.8.3.1



More information about the anaconda-patches mailing list