Move code to use style instead font.py (removed)

This commit is contained in:
Eduardo Silva 2007-07-09 10:09:24 -04:00
parent 40ed24f0fe
commit aa6a024368
7 changed files with 14 additions and 55 deletions

View File

@ -26,7 +26,7 @@ from ConfigParser import ConfigParser
from sugar import env
from sugar.graphics import units
from sugar.graphics import font
from sugar.graphics import style
from sugar.graphics import color
from sugar.graphics import iconbutton
@ -101,7 +101,7 @@ class VideoBox(hippo.CanvasBox, hippo.CanvasItem):
xalign=hippo.ALIGNMENT_START,
padding_right=units.grid_to_pixels(0.5))
self._label.props.color = color.LABEL_TEXT.get_int()
self._label.props.font_desc = font.DEFAULT.get_pango_desc()
self._label.props.font_desc = style.FONT_NORMAL.get_pango_desc()
self.append(self._label)
# check for camera and if not generate a .jpg
@ -181,7 +181,7 @@ class EntryBox(hippo.CanvasBox, hippo.CanvasItem):
xalign=hippo.ALIGNMENT_START,
padding_right=units.grid_to_pixels(0.5))
self._label.props.color = color.LABEL_TEXT.get_int()
self._label.props.font_desc = font.DEFAULT.get_pango_desc()
self._label.props.font_desc = style.FONT_NORMAL.get_pango_desc()
self.append(self._label)
self._entry = gtk.Entry()
@ -225,7 +225,7 @@ class ColorBox(hippo.CanvasBox, hippo.CanvasItem):
xalign=hippo.ALIGNMENT_START,
padding_right=units.grid_to_pixels(0.5))
self._label.props.color = color.LABEL_TEXT.get_int()
self._label.props.font_desc = font.DEFAULT.get_pango_desc()
self._label.props.font_desc = style.FONT_NORMAL.get_pango_desc()
self.append(self._label)
self._cp = colorpicker.ColorPicker()

View File

@ -26,7 +26,7 @@ import hippo
from sugar.graphics.palette import Palette
from sugar.graphics.canvasicon import CanvasIcon
from sugar.graphics import color
from sugar.graphics import font
from sugar.graphics import style
from sugar.activity import activityfactory
from sugar.activity.bundle import Bundle
from sugar.clipboard import clipboardservice
@ -60,7 +60,8 @@ class ClipboardMenu(Palette):
self._preview_text = hippo.CanvasText(text=preview,
size_mode=hippo.CANVAS_SIZE_WRAP_WORD)
self._preview_text.props.color = color.LABEL_TEXT.get_int()
self._preview_text.props.font_desc = font.DEFAULT.get_pango_desc()
self._preview_text.props.font_desc = \
style.FONT_NORMAL.get_pango_desc()
self.append(self._preview_text)
"""

View File

@ -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 \

View File

@ -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

View File

@ -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')

View File

@ -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)

View File

@ -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())