diff options
author | Eduardo Silva <edsiper@monotop.(none)> | 2007-07-09 14:09:24 (GMT) |
---|---|---|
committer | Eduardo Silva <edsiper@monotop.(none)> | 2007-07-09 14:09:24 (GMT) |
commit | aa6a02436859df3d2d803d945a94d1cdd4b77772 (patch) | |
tree | adb3b80b6eac8e02390ecf786c1960dcae6c5ed1 /sugar | |
parent | 40ed24f0fe1d34198c105a4c1396282e244fbba9 (diff) |
Move code to use style instead font.py (removed)
Diffstat (limited to 'sugar')
-rw-r--r-- | sugar/graphics/Makefile.am | 2 | ||||
-rw-r--r-- | sugar/graphics/canvasicon.py | 1 | ||||
-rw-r--r-- | sugar/graphics/font.py | 42 | ||||
-rw-r--r-- | sugar/graphics/objectchooser.py | 6 | ||||
-rw-r--r-- | sugar/graphics/style.py | 5 |
5 files changed, 7 insertions, 49 deletions
diff --git a/sugar/graphics/Makefile.am b/sugar/graphics/Makefile.am index b68821b..4892ed9 100644 --- a/sugar/graphics/Makefile.am +++ b/sugar/graphics/Makefile.am @@ -8,7 +8,6 @@ sugar_PYTHON = \ canvasentry.py \ color.py \ combobox.py \ - font.py \ frame.py \ notebook.py \ menuitem.py \ @@ -19,6 +18,7 @@ sugar_PYTHON = \ palettegroup.py \ panel.py \ spreadlayout.py \ + style.py \ toggletoolbutton.py \ toolbox.py \ toolbutton.py \ diff --git a/sugar/graphics/canvasicon.py b/sugar/graphics/canvasicon.py index c7e318b..40d5afa 100644 --- a/sugar/graphics/canvasicon.py +++ b/sugar/graphics/canvasicon.py @@ -27,7 +27,6 @@ import time from sugar.graphics import color from sugar.graphics.xocolor import XoColor -from sugar.graphics import font from sugar.graphics import units from sugar.graphics.palette import Palette, CanvasInvoker diff --git a/sugar/graphics/font.py b/sugar/graphics/font.py deleted file mode 100644 index c05bcd6..0000000 --- a/sugar/graphics/font.py +++ /dev/null @@ -1,42 +0,0 @@ -# Copyright (C) 2006-2007, Red Hat, Inc. -# -# This library is free software; you can redistribute it and/or -# modify it under the terms of the GNU Lesser General Public -# License as published by the Free Software Foundation; either -# version 2 of the License, or (at your option) any later version. -# -# This library is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# Lesser General Public License for more details. -# -# You should have received a copy of the GNU Lesser General Public -# License along with this library; if not, write to the -# Free Software Foundation, Inc., 59 Temple Place - Suite 330, -# Boston, MA 02111-1307, USA. - -import pango - -from sugar.graphics import units - -_system_fonts = { - 'default' : 'Bitstream Vera Sans %d' % units.points_to_device(7), - 'default-bold' : 'Bitstream Vera Sans bold %d' % units.points_to_device(7) -} - -class Font(object): - def __init__(self, desc): - self._desc = desc - - def get_desc(self): - return self._desc - - def get_pango_desc(self): - return pango.FontDescription(self._desc) - -class SystemFont(Font): - def __init__(self, font_id): - Font.__init__(self, _system_fonts[font_id]) - -DEFAULT = SystemFont('default') -DEFAULT_BOLD = SystemFont('default-bold') diff --git a/sugar/graphics/objectchooser.py b/sugar/graphics/objectchooser.py index 6ec165f..0d42a7a 100644 --- a/sugar/graphics/objectchooser.py +++ b/sugar/graphics/objectchooser.py @@ -25,7 +25,7 @@ from sugar.graphics.frame import Frame from sugar.activity.bundle import Bundle from sugar.date import Date from sugar.graphics import color -from sugar.graphics import font +from sugar.graphics import style from sugar.graphics import units from sugar.graphics.canvasicon import CanvasIcon from sugar.graphics.xocolor import XoColor @@ -111,7 +111,7 @@ class CollapsedEntry(Frame): date = hippo.CanvasText(text=self._format_date(), xalign=hippo.ALIGNMENT_START, - font_desc=font.DEFAULT.get_pango_desc(), + font_desc=style.FONT_NORMAL.get_pango_desc(), box_width=self._DATE_COL_WIDTH) self.append(date) @@ -122,7 +122,7 @@ class CollapsedEntry(Frame): title = hippo.CanvasText(text=self._format_title(), xalign=hippo.ALIGNMENT_START, - font_desc=font.DEFAULT_BOLD.get_pango_desc(), + font_desc=style.FONT_BOLD.get_pango_desc(), size_mode=hippo.CANVAS_SIZE_WRAP_WORD) self.append(title) diff --git a/sugar/graphics/style.py b/sugar/graphics/style.py index b26ca56..fedbc9e 100644 --- a/sugar/graphics/style.py +++ b/sugar/graphics/style.py @@ -16,6 +16,7 @@ # Boston, MA 02111-1307, USA. import gtk +import pango def _compute_zoom_factor(): return gtk.gdk.screen_width() / 1200.0 @@ -27,8 +28,8 @@ def _compute_font_height(font): widget = gtk.Label('') context = widget.get_pango_context() - font = context.load_font(font.get_pango_desc()) - metrics = font.get_metrics() + pango_font = context.load_font(font.get_pango_desc()) + metrics = pango_font.get_metrics() return pango.PIXELS(metrics.get_ascent() + metrics.get_descent()) |