diff options
author | Walter Bender <walter.bender@gmail.com> | 2013-03-12 16:30:28 (GMT) |
---|---|---|
committer | Walter Bender <walter.bender@gmail.com> | 2013-03-12 16:30:28 (GMT) |
commit | d0b549ee9f0731418acbc8fd292fd1cb38ef984f (patch) | |
tree | 41a3c1eeec731a2eb3f5092f8a8283a7a07db85b | |
parent | df07f5d3cbc595a8150de2a1a2ba3a8c3347af6d (diff) |
more backports
-rw-r--r-- | PortfolioActivity.py | 61 | ||||
-rw-r--r-- | exportpdf.py | 11 |
2 files changed, 41 insertions, 31 deletions
diff --git a/PortfolioActivity.py b/PortfolioActivity.py index 80d3295..670751d 100644 --- a/PortfolioActivity.py +++ b/PortfolioActivity.py @@ -204,42 +204,42 @@ class PortfolioActivity(activity.Activity): def _set_xy_wh(self): orientation = self._orientation - self._title_wh = [TITLE[orientation][2] * self._scale, - TITLE[orientation][3] * self._scale] - self._title_xy = [TITLE[orientation][0] * self._scale, - TITLE[orientation][1] * self._scale] + self._title_wh = [int(TITLE[orientation][2] * self._scale), + int(TITLE[orientation][3] * self._scale)] + self._title_xy = [int(TITLE[orientation][0] * self._scale), + int(TITLE[orientation][1] * self._scale)] self._title_xy[0] = int((self._width - self._title_wh[0]) / 2.) - self._preview_wh = [PREVIEW[orientation][2] * self._scale, - PREVIEW[orientation][3] * self._scale] - self._preview_xy = [PREVIEW[orientation][0] * self._scale, - PREVIEW[orientation][1] * self._scale] + self._preview_wh = [int(PREVIEW[orientation][2] * self._scale), + int(PREVIEW[orientation][3] * self._scale)] + self._preview_xy = [int(PREVIEW[orientation][0] * self._scale), + int(PREVIEW[orientation][1] * self._scale)] if orientation == 0: self._preview_xy[0] = self._title_xy[0] else: self._preview_xy[0] = int((self._width - self._preview_wh[0]) / 2.) - self._desc_wh = [DESC[orientation][2] * self._scale, - DESC[orientation][3] * self._scale] + self._desc_wh = [int(DESC[orientation][2] * self._scale), + int(DESC[orientation][3] * self._scale)] if orientation == 0: self._desc_wh[0] = \ self._width - self._preview_wh[0] - 2 * self._title_xy[0] else: self._desc_wh[0] = self._title_wh[0] - self._desc_xy = [DESC[orientation][0] * self._scale, - DESC[orientation][1] * self._scale] + self._desc_xy = [int(DESC[orientation][0] * self._scale), + int(DESC[orientation][1] * self._scale)] if orientation == 0: self._desc_xy[0] = self._preview_wh[0] + self._title_xy[0] else: self._desc_xy[0] = self._title_xy[0] - self._new_comment_wh = [NEW_COMMENT[orientation][2] * self._scale, - NEW_COMMENT[orientation][3] * self._scale] - self._new_comment_xy = [NEW_COMMENT[orientation][0] * self._scale, - NEW_COMMENT[orientation][1] * self._scale] + self._new_comment_wh = [int(NEW_COMMENT[orientation][2] * self._scale), + int(NEW_COMMENT[orientation][3] * self._scale)] + self._new_comment_xy = [int(NEW_COMMENT[orientation][0] * self._scale), + int(NEW_COMMENT[orientation][1] * self._scale)] self._new_comment_xy[0] = self._title_xy[0] self._new_comment_xy[1] = self._desc_xy[1] + self._desc_wh[1] - self._comment_wh = [COMMENTS[orientation][2] * self._scale, - COMMENTS[orientation][3] * self._scale] - self._comment_xy = [COMMENTS[orientation][0] * self._scale, - COMMENTS[orientation][1] * self._scale] + self._comment_wh = [int(COMMENTS[orientation][2] * self._scale), + int(COMMENTS[orientation][3] * self._scale)] + self._comment_xy = [int(COMMENTS[orientation][0] * self._scale), + int(COMMENTS[orientation][1] * self._scale)] self._comment_xy[0] = self._title_xy[0] self._comment_xy[1] = self._new_comment_xy[1] + self._new_comment_wh[1] @@ -289,13 +289,13 @@ class PortfolioActivity(activity.Activity): self._canvas.add_events(gtk.gdk.BUTTON_PRESS_MASK) self._canvas.add_events(gtk.gdk.POINTER_MOTION_MASK) self._canvas.add_events(gtk.gdk.BUTTON_RELEASE_MASK) - self._canvas.add_events(gtk.gdk.KEY_PRESS_MASK) + # self._canvas.add_events(gtk.gdk.KEY_PRESS_MASK) self._canvas.add_events(gtk.gdk.CONFIGURE) self._canvas.connect('expose-event', self._expose_cb) self._canvas.connect('button-press-event', self._button_press_cb) self._canvas.connect('button-release-event', self._button_release_cb) self._canvas.connect('motion-notify-event', self._mouse_move_cb) - self._canvas.connect('key-press-event', self._keypress_cb) + # self._canvas.connect('key-press-event', self._keypress_cb) gtk.gdk.screen_get_default().connect('size-changed', self._configure_cb) self._canvas.grab_focus() @@ -1052,7 +1052,7 @@ class PortfolioActivity(activity.Activity): self._selected_spr.set_label(label) if not hasattr(self, 'desc_entry'): self.desc_entry = gtk.TextView() - # self.desc_entry.set_wrap_mode(Gtk.WrapMode.WORD) + self.desc_entry.set_wrap_mode(gtk.WRAP_WORD) self.desc_entry.set_pixels_above_lines(0) self.desc_entry.set_size_request(self._desc_wh[0], self._desc_wh[1]) @@ -1062,9 +1062,10 @@ class PortfolioActivity(activity.Activity): rgba.alpha = 1. self.desc_entry.override_background_color( gtk.StateFlags.NORMAL, rgba) - ''' font_desc = pango.font_description_from_string( str(self.desc_size)) + ''' + font_desc = pango.FontDescription(str(self.desc_size)) self.desc_entry.modify_font(font_desc) self.fixed.put(self.desc_entry, 0, 0) self.text_entry = self.desc_entry @@ -1079,6 +1080,7 @@ class PortfolioActivity(activity.Activity): return True if not hasattr(self, 'title_entry'): self.title_entry = gtk.TextView() + self.title_entry.set_wrap_mode(gtk.WRAP_WORD) self.title_entry.set_justification(gtk.JUSTIFY_CENTER) self.title_entry.set_pixels_above_lines(1) ''' @@ -1087,9 +1089,10 @@ class PortfolioActivity(activity.Activity): rgba.alpha = 1. self.title_entry.override_background_color( Gtk.StateFlags.NORMAL, rgba) - ''' font_desc = pango.font_description_from_string( str(self.title_size)) + ''' + font_desc = pango.FontDescription(str(self.title_size)) self.title_entry.modify_font(font_desc) self.fixed.put(self.title_entry, 0, 0) self.text_entry = self.title_entry @@ -1101,7 +1104,7 @@ class PortfolioActivity(activity.Activity): self._saved_string = spr.labels[0] if not hasattr(self, 'comment_entry'): self.comment_entry = gtk.TextView() - # self.comment_entry.set_wrap_mode(Gtk.WrapMode.WORD) + self.comment_entry.set_wrap_mode(gtk.WRAP_WORD) self.comment_entry.set_pixels_above_lines(0) self.comment_entry.set_size_request( self._new_comment_wh[0], self._new_comment_wh[1]) @@ -1111,9 +1114,10 @@ class PortfolioActivity(activity.Activity): rgba.alpha = 1. self.comment_entry.override_background_color( Gtk.StateFlags.NORMAL, rgba) - ''' font_desc = pango.font_description_from_string( str(self.desc_size)) + ''' + font_desc = pango.FontDescription(str(self.desc_size)) self.comment_entry.modify_font(font_desc) self.fixed.put(self.comment_entry, 0, 0) self.text_entry = self.comment_entry @@ -1435,8 +1439,8 @@ class PortfolioActivity(activity.Activity): self.add_alert(self._alert) self._alert.show() + ''' def _keypress_cb(self, area, event): - ''' Keyboard ''' keyname = Gdk.keyval_name(event.keyval) keyunicode = Gdk.keyval_to_unicode(event.keyval) if event.get_state() & Gdk.ModifierType.MOD1_MASK: @@ -1465,6 +1469,7 @@ class PortfolioActivity(activity.Activity): elif keyname == 'End': self._last_cb() return True + ''' def _unselect(self): if hasattr(self, 'text_entry'): diff --git a/exportpdf.py b/exportpdf.py index e01a788..75b8eb3 100644 --- a/exportpdf.py +++ b/exportpdf.py @@ -17,12 +17,13 @@ import gtk from glib import GError import os.path import time +import json import cairo import pango import pangocairo from gettext import gettext as _ -from utils import get_pixbuf_from_journal +from utils import get_pixbuf_from_journal, parse_comments HEAD = 32 @@ -87,9 +88,13 @@ def save_pdf(activity, nick, description=None): cr.fill() cr.restore() + text = '' if 'description' in dsobj.metadata: - show_text(cr, fd, dsobj.metadata['description'], BODY, - LEFT_MARGIN, h + 175) + text += dsobj.metadata['description'] + if 'comments' in dsobj.metadata: + text += '\n' + text += parse_comments(json.loads(dsobj.metadata['comments'])) + show_text(cr, fd, text, BODY, LEFT_MARGIN, h + 175) cr.show_page() return tmp_file |