[PATCH] Fix ransom notes cycling.

Chris Lumens clumens at redhat.com
Tue Sep 11 15:17:49 UTC 2012


Instead of constantly creating new Images and shoving them into a spot in
the notebook, I'm now just putting each rnote on its own page.  Whether
it's better or not is up for debate, but at least this way works.
---
 pyanaconda/ui/gui/TODO                |  1 -
 pyanaconda/ui/gui/hubs/progress.glade | 16 ----------------
 pyanaconda/ui/gui/hubs/progress.py    | 35 +++++++++++++++++++++++++----------
 3 files changed, 25 insertions(+), 27 deletions(-)

diff --git a/pyanaconda/ui/gui/TODO b/pyanaconda/ui/gui/TODO
index 9338654..c47f990 100644
--- a/pyanaconda/ui/gui/TODO
+++ b/pyanaconda/ui/gui/TODO
@@ -5,7 +5,6 @@ Fedora 18
 - Can the entry next to "Closest Mirror" be filled in with something to make it look less weird?
 - Disk tug-o-war needs to be written.
 - Do the really slow redraws happen on real hardware, or just virt?
-- Fix ransom notes cycling.
 - Fix retranslating once a different language is selected.
 - Fix the big pause between leaving the storage spoke and displaying the hub (needs error handling
   pushed first).
diff --git a/pyanaconda/ui/gui/hubs/progress.glade b/pyanaconda/ui/gui/hubs/progress.glade
index 1eb32c9..036fcb4 100644
--- a/pyanaconda/ui/gui/hubs/progress.glade
+++ b/pyanaconda/ui/gui/hubs/progress.glade
@@ -111,16 +111,6 @@
                         <property name="show_tabs">False</property>
                         <property name="show_border">False</property>
                         <child>
-                          <object class="GtkImage" id="ransomNotesImage">
-                            <property name="visible">True</property>
-                            <property name="can_focus">False</property>
-                            <property name="stock">gtk-missing-image</property>
-                          </object>
-                        </child>
-                        <child type="tab">
-                          <placeholder/>
-                        </child>
-                        <child>
                           <object class="GtkGrid" id="rebootGrid">
                             <property name="visible">True</property>
                             <property name="can_focus">False</property>
@@ -175,12 +165,6 @@ for you to use!  Go ahead and reboot to start using it!</property>
                         <child type="tab">
                           <placeholder/>
                         </child>
-                        <child>
-                          <placeholder/>
-                        </child>
-                        <child type="tab">
-                          <placeholder/>
-                        </child>
                       </object>
                       <packing>
                         <property name="expand">False</property>
diff --git a/pyanaconda/ui/gui/hubs/progress.py b/pyanaconda/ui/gui/hubs/progress.py
index 13d1811..a4c6f2c 100644
--- a/pyanaconda/ui/gui/hubs/progress.py
+++ b/pyanaconda/ui/gui/hubs/progress.py
@@ -24,7 +24,7 @@ from __future__ import division
 import gettext
 _ = lambda x: gettext.ldgettext("anaconda", x)
 
-from gi.repository import GLib
+from gi.repository import GLib, Gtk
 
 import itertools
 import os
@@ -50,8 +50,6 @@ class ProgressHub(Hub):
         self._totalSteps = 0
         self._currentStep = 0
 
-        self._rnotes = itertools.cycle(self._get_rnotes())
-
     def _update_progress(self):
         from pyanaconda import progress
         import Queue
@@ -82,7 +80,7 @@ class ProgressHub(Hub):
 
                 GLib.source_remove(self._rnotes_id)
 
-                self._progressNotebook.next_page()
+                self._progressNotebook.set_current_page(0)
 
                 # kickstart install, continue automatically if reboot or shutdown selected
                 if flags.automatedInstall and self.data.reboot.action in [KS_REBOOT, KS_SHUTDOWN]:
@@ -113,22 +111,21 @@ class ProgressHub(Hub):
 
     def _cycle_rnotes(self):
         # Change the ransom notes image every minute by grabbing the next
-        # image's filename.  Note that self._rnotes is an infinite list, so
-        # this will cycle through the images indefinitely.
+        # image's filename.  Note that self._rnotesPages is an infinite list,
+        # so this will cycle through the images indefinitely.
         try:
-            nxt = self._rnotes.next()
+            nxt = self._rnotesPages.next()
         except StopIteration:
             # there are no rnotes
             pass
         else:
-            self._rnotesImage.set_from_file(nxt)
+            self._progressNotebook.set_current_page(nxt)
+
         return True
 
     def initialize(self):
         Hub.initialize(self)
 
-        self._rnotesImage = self.builder.get_object("ransomNotesImage")
-
         self._progressBar = self.builder.get_object("progressBar")
         self._progressLabel = self.builder.get_object("progressLabel")
         self._progressNotebook = self.builder.get_object("progressNotebook")
@@ -136,6 +133,24 @@ class ProgressHub(Hub):
         lbl = self.builder.get_object("rebootLabel")
         lbl.set_text(lbl.get_text() % productName)
 
+        rnotes = self._get_rnotes()
+        if rnotes:
+            # Add a new page in the notebook for each ransom note image.
+            for f in rnotes:
+                img = Gtk.Image.new_from_file(f)
+                img.show()
+                self._progressNotebook.append_page(img, None)
+
+            # An infinite list of the page numbers containing ransom notes images.
+            self._rnotesPages = itertools.cycle(range(1, self._progressNotebook.get_n_pages()-1))
+        else:
+            # Add a blank page to the notebook and we'll just cycle to that
+            # over and over again.
+            blank = Gtk.Box()
+            blank.show()
+            self._progressNotebook.append_page(blank, None)
+            self._rnotesPages = itertools.cycle([1])
+
     def refresh(self):
         from pyanaconda.install import doInstall
         from pyanaconda.threads import threadMgr, AnacondaThread
-- 
1.7.11.2



More information about the anaconda-patches mailing list