Move code to use style instead font.py (removed)
This commit is contained in:
parent
40ed24f0fe
commit
aa6a024368
@ -26,7 +26,7 @@ from ConfigParser import ConfigParser
|
|||||||
from sugar import env
|
from sugar import env
|
||||||
|
|
||||||
from sugar.graphics import units
|
from sugar.graphics import units
|
||||||
from sugar.graphics import font
|
from sugar.graphics import style
|
||||||
from sugar.graphics import color
|
from sugar.graphics import color
|
||||||
from sugar.graphics import iconbutton
|
from sugar.graphics import iconbutton
|
||||||
|
|
||||||
@ -101,7 +101,7 @@ class VideoBox(hippo.CanvasBox, hippo.CanvasItem):
|
|||||||
xalign=hippo.ALIGNMENT_START,
|
xalign=hippo.ALIGNMENT_START,
|
||||||
padding_right=units.grid_to_pixels(0.5))
|
padding_right=units.grid_to_pixels(0.5))
|
||||||
self._label.props.color = color.LABEL_TEXT.get_int()
|
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.append(self._label)
|
||||||
|
|
||||||
# check for camera and if not generate a .jpg
|
# check for camera and if not generate a .jpg
|
||||||
@ -181,7 +181,7 @@ class EntryBox(hippo.CanvasBox, hippo.CanvasItem):
|
|||||||
xalign=hippo.ALIGNMENT_START,
|
xalign=hippo.ALIGNMENT_START,
|
||||||
padding_right=units.grid_to_pixels(0.5))
|
padding_right=units.grid_to_pixels(0.5))
|
||||||
self._label.props.color = color.LABEL_TEXT.get_int()
|
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.append(self._label)
|
||||||
|
|
||||||
self._entry = gtk.Entry()
|
self._entry = gtk.Entry()
|
||||||
@ -225,7 +225,7 @@ class ColorBox(hippo.CanvasBox, hippo.CanvasItem):
|
|||||||
xalign=hippo.ALIGNMENT_START,
|
xalign=hippo.ALIGNMENT_START,
|
||||||
padding_right=units.grid_to_pixels(0.5))
|
padding_right=units.grid_to_pixels(0.5))
|
||||||
self._label.props.color = color.LABEL_TEXT.get_int()
|
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.append(self._label)
|
||||||
|
|
||||||
self._cp = colorpicker.ColorPicker()
|
self._cp = colorpicker.ColorPicker()
|
||||||
|
@ -26,7 +26,7 @@ import hippo
|
|||||||
from sugar.graphics.palette import Palette
|
from sugar.graphics.palette import Palette
|
||||||
from sugar.graphics.canvasicon import CanvasIcon
|
from sugar.graphics.canvasicon import CanvasIcon
|
||||||
from sugar.graphics import color
|
from sugar.graphics import color
|
||||||
from sugar.graphics import font
|
from sugar.graphics import style
|
||||||
from sugar.activity import activityfactory
|
from sugar.activity import activityfactory
|
||||||
from sugar.activity.bundle import Bundle
|
from sugar.activity.bundle import Bundle
|
||||||
from sugar.clipboard import clipboardservice
|
from sugar.clipboard import clipboardservice
|
||||||
@ -60,7 +60,8 @@ class ClipboardMenu(Palette):
|
|||||||
self._preview_text = hippo.CanvasText(text=preview,
|
self._preview_text = hippo.CanvasText(text=preview,
|
||||||
size_mode=hippo.CANVAS_SIZE_WRAP_WORD)
|
size_mode=hippo.CANVAS_SIZE_WRAP_WORD)
|
||||||
self._preview_text.props.color = color.LABEL_TEXT.get_int()
|
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)
|
self.append(self._preview_text)
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
@ -8,7 +8,6 @@ sugar_PYTHON = \
|
|||||||
canvasentry.py \
|
canvasentry.py \
|
||||||
color.py \
|
color.py \
|
||||||
combobox.py \
|
combobox.py \
|
||||||
font.py \
|
|
||||||
frame.py \
|
frame.py \
|
||||||
notebook.py \
|
notebook.py \
|
||||||
menuitem.py \
|
menuitem.py \
|
||||||
@ -19,6 +18,7 @@ sugar_PYTHON = \
|
|||||||
palettegroup.py \
|
palettegroup.py \
|
||||||
panel.py \
|
panel.py \
|
||||||
spreadlayout.py \
|
spreadlayout.py \
|
||||||
|
style.py \
|
||||||
toggletoolbutton.py \
|
toggletoolbutton.py \
|
||||||
toolbox.py \
|
toolbox.py \
|
||||||
toolbutton.py \
|
toolbutton.py \
|
||||||
|
@ -27,7 +27,6 @@ import time
|
|||||||
|
|
||||||
from sugar.graphics import color
|
from sugar.graphics import color
|
||||||
from sugar.graphics.xocolor import XoColor
|
from sugar.graphics.xocolor import XoColor
|
||||||
from sugar.graphics import font
|
|
||||||
from sugar.graphics import units
|
from sugar.graphics import units
|
||||||
from sugar.graphics.palette import Palette, CanvasInvoker
|
from sugar.graphics.palette import Palette, CanvasInvoker
|
||||||
|
|
||||||
|
@ -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')
|
|
@ -25,7 +25,7 @@ from sugar.graphics.frame import Frame
|
|||||||
from sugar.activity.bundle import Bundle
|
from sugar.activity.bundle import Bundle
|
||||||
from sugar.date import Date
|
from sugar.date import Date
|
||||||
from sugar.graphics import color
|
from sugar.graphics import color
|
||||||
from sugar.graphics import font
|
from sugar.graphics import style
|
||||||
from sugar.graphics import units
|
from sugar.graphics import units
|
||||||
from sugar.graphics.canvasicon import CanvasIcon
|
from sugar.graphics.canvasicon import CanvasIcon
|
||||||
from sugar.graphics.xocolor import XoColor
|
from sugar.graphics.xocolor import XoColor
|
||||||
@ -111,7 +111,7 @@ class CollapsedEntry(Frame):
|
|||||||
|
|
||||||
date = hippo.CanvasText(text=self._format_date(),
|
date = hippo.CanvasText(text=self._format_date(),
|
||||||
xalign=hippo.ALIGNMENT_START,
|
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)
|
box_width=self._DATE_COL_WIDTH)
|
||||||
self.append(date)
|
self.append(date)
|
||||||
|
|
||||||
@ -122,7 +122,7 @@ class CollapsedEntry(Frame):
|
|||||||
|
|
||||||
title = hippo.CanvasText(text=self._format_title(),
|
title = hippo.CanvasText(text=self._format_title(),
|
||||||
xalign=hippo.ALIGNMENT_START,
|
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)
|
size_mode=hippo.CANVAS_SIZE_WRAP_WORD)
|
||||||
self.append(title)
|
self.append(title)
|
||||||
|
|
||||||
|
@ -16,6 +16,7 @@
|
|||||||
# Boston, MA 02111-1307, USA.
|
# Boston, MA 02111-1307, USA.
|
||||||
|
|
||||||
import gtk
|
import gtk
|
||||||
|
import pango
|
||||||
|
|
||||||
def _compute_zoom_factor():
|
def _compute_zoom_factor():
|
||||||
return gtk.gdk.screen_width() / 1200.0
|
return gtk.gdk.screen_width() / 1200.0
|
||||||
@ -27,8 +28,8 @@ def _compute_font_height(font):
|
|||||||
widget = gtk.Label('')
|
widget = gtk.Label('')
|
||||||
|
|
||||||
context = widget.get_pango_context()
|
context = widget.get_pango_context()
|
||||||
font = context.load_font(font.get_pango_desc())
|
pango_font = context.load_font(font.get_pango_desc())
|
||||||
metrics = font.get_metrics()
|
metrics = pango_font.get_metrics()
|
||||||
|
|
||||||
return pango.PIXELS(metrics.get_ascent() + metrics.get_descent())
|
return pango.PIXELS(metrics.get_ascent() + metrics.get_descent())
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user