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