Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/tautils.py
diff options
context:
space:
mode:
authorWalter Bender <walter@walter-laptop.(none)>2010-02-03 15:54:47 (GMT)
committer Walter Bender <walter@walter-laptop.(none)>2010-02-03 15:54:47 (GMT)
commit2573df3606380970efb3a106bff10dba0437b6be (patch)
treeaea4a88d7ba34af4a6d6278617b48909835cc809 /tautils.py
parent7ae60da4a97263c7f2d95cdc934f1e3c0a62f45d (diff)
fixed boolean problem
Diffstat (limited to 'tautils.py')
-rw-r--r--tautils.py35
1 files changed, 35 insertions, 0 deletions
diff --git a/tautils.py b/tautils.py
index 0471421..77536b0 100644
--- a/tautils.py
+++ b/tautils.py
@@ -139,3 +139,38 @@ def save_picture(canvas, fname):
0, 0, 0, 0, canvas.width, canvas.height)
pixbuf.save(fname, 'png')
+
+def get_pixbuf_from_journal(dsobject, w, h):
+ try:
+ pixbuf = gtk.gdk.pixbuf_new_from_file_at_size(dsobject.file_path,
+ int(w),int(h))
+ except:
+ try:
+ pixbufloader = \
+ gtk.gdk.pixbuf_loader_new_with_mime_type('image/png')
+ pixbufloader.set_size(min(300,int(w)),min(225,int(h)))
+ pixbufloader.write(dsobject.metadata['preview'])
+ pixbufloader.close()
+ pixbuf = pixbufloader.get_pixbuf()
+ except:
+ pixbuf = None
+ return pixbuf
+
+def movie_media_type(suffix):
+ if suffix.replace('.','') in ['ogv','vob','mp4','wmv','mov', 'mpeg']:
+ return True
+ return False
+
+def audio_media_type(suffix):
+ if suffix.replace('.','') in ['ogg', 'oga', 'm4a']:
+ return True
+ return False
+
+def round_int(n):
+ if int(float(n)) == n:
+ return int(n)
+ else:
+ nn = int(float(n+0.05)*10)/10.
+ if int(float(nn)) == nn:
+ return int(nn)
+ return nn