Adding images, blank though they may be, to magazines
[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                 "scripture_background": "scripture_bg.png",
36
37                 "conferences": "conference.png",
38                 "magazines": "magazines.png",
39                 "mormonmessages": "mormonmessages.png",
40                 "radio": "radio.png",
41                 "scriptures": "scriptures.png",
42
43                 "more": "more.png",
44                 "icon": "icon.png",
45                 "nomagazineimage": "nomagazineimage.png",
46         }
47
48         def __init__(self, storePath, cachePath):
49                 self._storePath = storePath
50                 self._cachePath = cachePath
51
52         def get_surface_from_store(self, imageName):
53                 path = os.path.join(self._storePath, imageName)
54                 image = cairo.ImageSurface.create_from_png(path)
55                 return image
56
57         def get_image_from_store(self, imageName):
58                 path = os.path.join(self._storePath, imageName)
59                 image = gtk.Image()
60                 image.set_from_file(path)
61                 return image
62
63         def set_image_from_store(self, image, imageName):
64                 path = os.path.join(self._storePath, imageName)
65                 image.set_from_file(path)
66                 return image
67
68         def get_pixbuf_from_store(self, imageName):
69                 path = os.path.join(self._storePath, imageName)
70                 return gtk.gdk.pixbuf_new_from_file(path)
71
72         def get_pixbuf_animation_from_store(self, imageName):
73                 path = os.path.join(self._storePath, imageName)
74                 return gtk.gdk.PixbufAnimation(path)