~and471/software-center/software-store-andrew

« back to all changes in this revision

Viewing changes to softwarecenter/view/widgets/animatedimage.py

  • Committer: rugby471
  • Date: 2009-11-22 07:34:57 UTC
  • Revision ID: rugby471@gmail.com-20091122073457-gdpnaaziylzs8o9v
putting progress icons in one file, adding code to work like the imagedialog.py does with process-working
cleanup of code in imagedialog.py
(last commit, I removed the progress bar from imagedialog.py, we already had two methods of showing progress, only one is needed)

Show diffs side-by-side

added added

removed removed

Lines of Context:
27
27
    
28
28
    FPS = 20.0
29
29
 
30
 
    def __init__(self, globexp):
 
30
    def __init__(self, icon):
31
31
        """ Animate a gtk.Image
32
32
    
33
33
        Keywords:
36
36
        """
37
37
        super(AnimatedImage, self).__init__()
38
38
        self._progressN = 0
39
 
        if isinstance(globexp, gtk.gdk.Pixbuf):
40
 
            self.images = [globexp]
41
 
            self.set_from_pixbuf(globexp)
42
 
        elif isinstance(globexp, str):
43
 
            self._imagefiles = sorted(glob.glob(globexp))
 
39
        if isinstance(icon, gtk.gdk.Pixbuf):
 
40
            self.images = [icon]
 
41
            self.set_from_pixbuf(icon)
 
42
        elif isinstance(icon, str):
 
43
            self._imagefiles = icon
44
44
            self.images = []
45
45
            if not self._imagefiles:
46
 
                raise IOError, "no images for the animation found in '%s'" % globexp
47
 
            for f in self._imagefiles:
48
 
                self.images.append(gtk.gdk.pixbuf_new_from_file(f))
 
46
                raise IOError, "no images for the animation found in '%s'" % icon
 
47
                
 
48
            pixbuf_orig = gtk.gdk.pixbuf_new_from_file(icon)
 
49
            x = 0
 
50
            y = 0
 
51
            pixbuf_buffer = pixbuf_orig.copy()
 
52
 
 
53
            for f in range((pixbuf_orig.get_width() / 24) * (pixbuf_orig.get_height() / 24)):
 
54
                pixbuf_buffer = pixbuf_orig.subpixbuf(x, y, 24, 24)
 
55
                self.images.append(pixbuf_buffer)
 
56
                if x == pixbuf_orig.get_width() - 24:
 
57
                    x = 0
 
58
                    y += 24
 
59
                    if y == 72:
 
60
                        x = 0
 
61
                        y = 0
 
62
                else:
 
63
                    x += 24
 
64
 
49
65
            self.set_from_pixbuf(self.images[self._progressN])
50
66
            self.connect("show", self.start)
51
67
            self.connect("hide", self.stop)
117
133
    elif os.path.exists("./data"):
118
134
        datadir = "./data"
119
135
    else:
120
 
        datadir = "/usr/share/software-center"
 
136
        datadir = "/usr/share/software-center/data"
121
137
 
122
 
    image = AnimatedImage(datadir+"/icons/32x32/status/software-center-progress-*.png")
123
 
    image1 = AnimatedImage(datadir+"/icons/32x32/status/software-center-progress-*.png")
 
138
    image = AnimatedImage(datadir+"/icons/24x24/status/softwarecenter-progress.png")
 
139
    image1 = AnimatedImage(datadir+"/icons/24x24/status/softwarecenter-progress.png")
124
140
    image1.start()
125
 
    image2 = AnimatedImage(datadir+"/icons/32x32/status/software-center-progress-01.png")
126
 
    pixbuf = gtk.gdk.pixbuf_new_from_file(datadir+"/icons/32x32/status/software-center-progress-07.png")
 
141
    image2 = AnimatedImage(datadir+"/icons/24x24/status/softwarecenter-progress.png")
 
142
    pixbuf = gtk.gdk.pixbuf_new_from_file(datadir+"/icons/24x24/status/softwarecenter-progress.png")
127
143
    image3 = AnimatedImage(pixbuf)
128
144
    image3.show()
129
145