9ca9964cf3c53bd74bc04a9897a462f7534ca55a
[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                 "home": "home.png",
16
17                 "small_next": "small_next.png",
18                 "small_prev": "small_prev.png",
19                 "small_pause": "small_pause.png",
20                 "small_play": "small_play.png",
21                 "small_stop": "small_stop.png",
22                 "small_home": "small_home.png",
23
24                 "loading": "loading.gif",
25
26                 "radio_header": "radio_header.png",
27                 "conference_background": "conference_bg.png",
28                 "magazine_background": "magazine_bg.png",
29                 "scriptures_background": "scripture_bg.png",
30
31                 "conferences": "conference.png",
32                 "magazines": "magazines.png",
33                 "more": "more.png",
34                 "mormonmessages": "mormonmessages.png",
35                 "radio": "radio.png",
36                 "scriptures": "scriptures.png",
37                 "icon": "icon.png",
38         }
39
40         def __init__(self, storePath, cachePath):
41                 self._storePath = storePath
42                 self._cachePath = cachePath
43
44         def get_surface_from_store(self, imageName):
45                 path = os.path.join(self._storePath, imageName)
46                 image = cairo.ImageSurface.create_from_png(path)
47                 return image
48
49         def get_image_from_store(self, imageName):
50                 path = os.path.join(self._storePath, imageName)
51                 image = gtk.Image()
52                 image.set_from_file(path)
53                 return image
54
55         def set_image_from_store(self, image, imageName):
56                 path = os.path.join(self._storePath, imageName)
57                 image.set_from_file(path)
58                 return image
59
60         def get_pixbuf_from_store(self, imageName):
61                 path = os.path.join(self._storePath, imageName)
62                 return gtk.gdk.pixbuf_new_from_file(path)
63
64         def get_pixbuf_animation_from_store(self, imageName):
65                 path = os.path.join(self._storePath, imageName)
66                 return gtk.gdk.PixbufAnimation(path)