gnome-games r7273 - in trunk/glchess: . src/lib/gtkui



Author: rancell
Date: Sat Jan 26 01:15:48 2008
New Revision: 7273
URL: http://svn.gnome.org/viewvc/gnome-games?rev=7273&view=rev

Log:
handle invalid throbber images


Modified:
   trunk/glchess/ChangeLog
   trunk/glchess/src/lib/gtkui/network.py

Modified: trunk/glchess/src/lib/gtkui/network.py
==============================================================================
--- trunk/glchess/src/lib/gtkui/network.py	(original)
+++ trunk/glchess/src/lib/gtkui/network.py	Sat Jan 26 01:15:48 2008
@@ -158,6 +158,7 @@
             gobject.source_remove(self._throbberTimer)
             self._throbberTimer = None
         
+        # Display animating frames if busy or idle frame if not
         if isBusy:
             self._throbberFrame = 1
             self._throbberTimer = gobject.timeout_add(25, self._updateThrobber)
@@ -334,19 +335,28 @@
         self._throbberTimer = None
         theme = gtk.icon_theme_get_default()
         size = 32
-        icon = theme.load_icon('process-working', size, 0)      
+        icon = theme.load_icon('process-working', size, 0)
         self._throbberFrames = []
         for i in xrange(icon.get_height() / size):
             for j in xrange(icon.get_width() / size):
                 frame = icon.subpixbuf(j * size, i * size, size, size)
                 self._throbberFrames.append(frame)
-        
+                
+        # The throbber image should contain 1 idle image and N animation images.
+        # If the image is invalid (i.e. there is only one 32x32 icon) then duplicate
+        # that image as a 1 frame animation.
+        if len(self._throbberFrames) == 1:
+            self.throbberFrames.append(self._throbberFrames[0])
+
+        # Display idle frame
         self._throbberFrame = 0
         self._updateThrobber()
 
     def _updateThrobber(self):
         widget = self.__gui.get_widget('throbber_image')
         widget.set_from_pixbuf(self._throbberFrames[self._throbberFrame])
+        
+        # Move to next frame restarting animation after idle frame
         self._throbberFrame += 1
         if self._throbberFrame >= len(self._throbberFrames):
             self._throbberFrame = 1



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]