Commit 003b261d authored by Frank Scholz's avatar Frank Scholz
Browse files

some Maemo adjustments

parent dd4f9500
#!/usr/bin/python
# -*- coding: utf-8 -*-
import os
import os, platform
import random
# Twisted
......@@ -45,7 +45,7 @@ class MainBackground(object):
else:
self.background.fill((0, 0, 0)) # black
def clearScreen(self):
def clear_screen(self):
self.screen.blit(self.background, (0, 0))
def clear_part(self, rect):
......@@ -56,15 +56,17 @@ class MediaRenderer(object):
def __init__(self, fullscreen=1):
pygame.init()
bestdepth = pygame.display.mode_ok(SCREENRECT.size, fullscreen, SCREENDEPTH)
self.screen = pygame.display.set_mode(SCREENRECT.size, fullscreen, bestdepth)
#pygame.mouse.set_visible(False)
self.fullscreen = fullscreen
self.bestdepth = pygame.display.mode_ok(SCREENRECT.size, fullscreen, SCREENDEPTH)
self.screen = pygame.display.set_mode(SCREENRECT.size, fullscreen, self.bestdepth)
pygame.mouse.set_visible(False)
# decorate the game window
pygame.display.set_caption('Coherence MediaRenderer')
self.mainbg = MainBackground(self.screen, SCREENRECT)
self.mainbg.clearScreen()
self.mainbg.clear_screen()
config = {}
config['logmode'] = 'info'
......@@ -83,8 +85,20 @@ class MediaRenderer(object):
self.container_watch = []
self.image_index = 0
self.displaying = None
self.current_image = None
self.client = {}
def toggle_fullscreen(self):
if self.fullscreen == 1:
self.fullscreen = FULLSCREEN
else:
self.fullscreen = 1
self.screen = pygame.display.set_mode(SCREENRECT.size, self.fullscreen, self.bestdepth)
self.mainbg.clear_screen()
self.displaying = self.current_image.get_rect(center=((self.screen.get_width()/2)-1,(self.screen.get_height()/2)-1))
self.screen.blit(self.current_image,self.displaying)
pygame.display.flip()
def proceed_to_next_image(self):
if len(self.images)>0:
try:
......@@ -103,14 +117,14 @@ class MediaRenderer(object):
import StringIO
im = Image.open(StringIO.StringIO(result))
size = im.size
flickr_image = pygame.image.frombuffer( im.tostring("raw","RGB"), im.size, "RGB")
self.current_image = pygame.image.frombuffer( im.tostring("raw","RGB"), im.size, "RGB")
except ImportError:
import tempfile
tmp_fp, tmp_path = tempfile.mkstemp()
os.write(tmp_fp,result)
os.close(tmp_fp)
flickr_image = pygame.image.load(tmp_path).convert()
size = flickr_image.get_size()
self.current_image = pygame.image.load(tmp_path).convert()
size = self.current_image.get_size()
os.unlink(tmp_path)
if self.displaying is not None:
......@@ -132,9 +146,9 @@ class MediaRenderer(object):
new_width = int(float(size[0]) * relation)
transform =(new_width,new_height)
if transform is not None:
flickr_image = pygame.transform.scale(flickr_image, transform)
self.displaying = flickr_image.get_rect(center=((self.screen.get_width()/2)-1,(self.screen.get_height()/2)-1))
self.screen.blit(flickr_image,self.displaying)
self.current_image = pygame.transform.scale(flickr_image, transform)
self.displaying = self.current_image.get_rect(center=((self.screen.get_width()/2)-1,(self.screen.get_height()/2)-1))
self.screen.blit(self.current_image,self.displaying)
pygame.display.flip()
pygame.display.set_caption('Coherence MediaRenderer - %s' % title)
......@@ -212,13 +226,20 @@ class MediaRenderer(object):
for event in pygame.event.get():
#print event
if (event.type == KEYDOWN and event.key == K_F6):
"""switch between fullscreen and app mode """
if((event.type == KEYDOWN and event.key == K_ESCAPE) or
event.type == QUIT):
reactor.stop()
def main():
MediaRenderer()
if platform.uname()[1].startswith('Nokia'):
fullscreen = FULLSCREEN
else:
fullscreen = 1
MediaRenderer(fullscreen=fullscreen)
reactor.run()
if __name__ == '__main__':
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment