092efd0ada4933eaa1ab9013ca09eb4ea805ac19
[watersofshiloah] / src / imagestore.py
1 import os
2
3 import cairo
4 import gtk
5
6
7 class ImageStore(object):
8
9         STORE_LOOKUP = {
10                 "next": "next.png",
11                 "prev": "prev.png",
12                 "pause": "pause.png",
13                 "play": "play.png",
14                 "stop": "stop.png",
15                 "loading": "loading.gif",
16
17                 "radio_header": "radio_header.png",
18                 "conference_background": "conference_bg.png",
19                 "magazine_background": "magazine_bg.png",
20                 "scriptures_background": "scripture_bg.png",
21
22                 "conferences": "conference.png",
23                 "magazines": "magazines.png",
24                 "more": "more.png",
25                 "mormonmessages": "mormonmessages.png",
26                 "radio": "radio.png",
27                 "scriptures": "scriptures.png",
28                 "icon": "icon.png",
29         }
30
31         def __init__(self, storePath, cachePath):
32                 self._storePath = storePath
33                 self._cachePath = cachePath
34
35         def get_surface_from_store(self, image):
36                 path = os.path.join(self._storePath, image)
37                 image = cairo.ImageSurface.create_from_png(path)
38                 return image
39
40         def get_image_from_store(self, image):
41                 path = os.path.join(self._storePath, image)
42                 image = gtk.Image()
43                 image.set_from_file(path)
44                 return image
45
46         def get_pixbuf_from_store(self, image):
47                 path = os.path.join(self._storePath, image)
48                 return gtk.gdk.pixbuf_new_from_file(path)
49
50         def get_pixbuf_animation_from_store(self, image):
51                 path = os.path.join(self._storePath, image)
52                 return gtk.gdk.PixbufAnimation(path)