diff options
author | Walter Bender <walter.bender@gmail.com> | 2012-06-26 20:08:49 (GMT) |
---|---|---|
committer | Walter Bender <walter.bender@gmail.com> | 2012-06-26 20:08:49 (GMT) |
commit | 14919a58055cb863deedf405129c16257cb97cdc (patch) | |
tree | 350a768b6b6570063970c91e527a8c967eec01a5 | |
parent | 52f55c1989111d09c963bf069609b4f41244d4d4 (diff) |
add frame to thumbnails
-rw-r--r-- | PortfolioActivity.py | 5 | ||||
-rw-r--r-- | utils.py | 27 |
2 files changed, 31 insertions, 1 deletions
diff --git a/PortfolioActivity.py b/PortfolioActivity.py index 264e3b8..7fc2093 100644 --- a/PortfolioActivity.py +++ b/PortfolioActivity.py @@ -39,7 +39,8 @@ from sugar.graphics.alert import Alert from sprites import Sprites, Sprite from exportpdf import save_pdf from utils import get_path, lighter_color, svg_str_to_pixbuf, \ - play_audio_from_file, get_pixbuf_from_journal, genblank, get_hardware + play_audio_from_file, get_pixbuf_from_journal, genblank, get_hardware, \ + svg_rectangle from toolbar_utils import radio_factory, \ button_factory, separator_factory, combo_factory, label_factory from grecord import Grecord @@ -674,6 +675,8 @@ class PortfolioActivity(activity.Activity): self.colors)) self._thumbs.append([Sprite(self._sprites, x, y, pixbuf_thumb), x, y, self.i]) + self._thumbs[-1][0].set_image(svg_str_to_pixbuf( + svg_rectangle(int(w), int(h), self.colors)), i=1) self._thumbs[-1][0].set_label(str(self.i + 1)) self._thumbs[self.i][0].set_layer(TOP) @@ -95,6 +95,33 @@ def svg_str_to_pixbuf(svg_string): return pixbuf +def svg_rectangle(width, height, colors): + ''' Generate a rectangle frame in two colors ''' + return \ +'<?xml version="1.0" encoding="UTF-8" standalone="no"?>\ +<svg\ + version="1.1"\ + width="%f"\ + height="%f">\ + <g>\ + <rect\ + width="%f"\ + height="%f"\ + x="2.5"\ + y="2.5"\ + style="fill:none;stroke:%s;stroke-width:5;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none" />\ + <rect\ + width="%f"\ + height="%f"\ + x="7.5"\ + y="7.5"\ + style="fill:none;stroke:%s;stroke-width:5;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none" />\ + </g>\ +</svg>' % (width, height, + width - 5, height - 5, colors[1], + width - 15, height - 15, colors[0]) + + def load_svg_from_file(file_path, width, height): '''Create a pixbuf from SVG in a file. ''' return gtk.gdk.pixbuf_new_from_file_at_size(file_path, width, height) |