Remove Canvas* widgets and other hippo-canvas using parts

hippo-canvas isn't available in the GTK3 world, so we need to remove
anything that depends on it. Activities that still use it will need replace
hippo-canvas based widgets with native GTK ones before they can be ported to
GTK3.

[replaced description]
Signed-off-by: Sascha Silbe <silbe@activitycentral.com>
This commit is contained in:
Simon Schampijer 2011-10-29 10:58:15 +02:00
parent 1edc6ca1b1
commit 9cb18cdcf3
7 changed files with 0 additions and 699 deletions

View File

@ -2,10 +2,8 @@ sugardir = $(pythondir)/sugar3/graphics
sugar_PYTHON = \
alert.py \
animator.py \
canvastextview.py \
colorbutton.py \
combobox.py \
entry.py \
iconentry.py \
icon.py \
__init__.py \
@ -18,7 +16,6 @@ sugar_PYTHON = \
panel.py \
radiopalette.py \
radiotoolbutton.py \
roundbox.py \
style.py \
toggletoolbutton.py \
toolbarbox.py \

View File

@ -1,41 +0,0 @@
# Copyright (C) 2008 One Laptop Per Child
#
# 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 gtk
import hippo
from sugar3.graphics import style
class CanvasTextView(hippo.CanvasWidget):
def __init__(self, text, **kwargs):
hippo.CanvasWidget.__init__(self, **kwargs)
self.text_view_widget = gtk.TextView()
self.text_view_widget.props.buffer.props.text = text
self.text_view_widget.props.left_margin = style.DEFAULT_SPACING
self.text_view_widget.props.right_margin = style.DEFAULT_SPACING
self.text_view_widget.props.wrap_mode = gtk.WRAP_WORD
self.text_view_widget.show()
# TODO: These fields should expand vertically instead of scrolling
scrolled_window = gtk.ScrolledWindow()
scrolled_window.set_shadow_type(gtk.SHADOW_OUT)
scrolled_window.set_policy(gtk.POLICY_NEVER, gtk.POLICY_AUTOMATIC)
scrolled_window.add(self.text_view_widget)
self.props.widget = scrolled_window

View File

@ -1,41 +0,0 @@
# Copyright (C) 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.
"""
STABLE.
"""
import gtk
import hippo
class CanvasEntry(hippo.CanvasEntry):
def set_background(self, color_spec):
"""
Parameters
----------
color_spec :
Returns
-------
None
"""
color = gtk.gdk.color_parse(color_spec)
self.props.widget.modify_bg(gtk.STATE_INSENSITIVE, color)
self.props.widget.modify_base(gtk.STATE_INSENSITIVE, color)

View File

@ -27,7 +27,6 @@ import logging
import gobject
import gtk
import hippo
import cairo
from sugar3.graphics.xocolor import XoColor
@ -550,438 +549,6 @@ class Icon(gtk.Image):
type=float, setter=set_scale)
class CanvasIcon(hippo.CanvasBox, hippo.CanvasItem):
__gtype_name__ = 'CanvasIcon'
def __init__(self, **kwargs):
from sugar3.graphics.palette import CanvasInvoker
self._buffer = _IconBuffer()
self._palette_invoker = CanvasInvoker()
self._alpha = 1.0
hippo.CanvasBox.__init__(self, **kwargs)
self._palette_invoker.attach(self)
self.connect('destroy', self.__destroy_cb)
def _emit_paint_needed_icon_area(self):
surface = self._buffer.get_surface()
if surface:
width, height = self.get_allocation()
s_width = surface.get_width()
s_height = surface.get_height()
x = (width - s_width) / 2
y = (height - s_height) / 2
self.emit_paint_needed(x, y, s_width, s_height)
def __destroy_cb(self, icon):
if self._palette_invoker is not None:
self._palette_invoker.detach()
def set_file_name(self, value):
"""
Parameters
----------
value:
Returns
-------
None
\"\"\"
"""
if self._buffer.file_name != value:
self._buffer.file_name = value
self.emit_paint_needed(0, 0, -1, -1)
def get_file_name(self):
"""
Parameters
----------
None
Returns
-------
file name :
"""
return self._buffer.file_name
file_name = gobject.property(
type=object, getter=get_file_name, setter=set_file_name)
def set_icon_name(self, value):
"""
Parameters
----------
value:
Returns
-------
None
"""
if self._buffer.icon_name != value:
self._buffer.icon_name = value
self.emit_paint_needed(0, 0, -1, -1)
def get_icon_name(self):
"""
Parameters
----------
None
Returns
-------
icon name :
"""
return self._buffer.icon_name
icon_name = gobject.property(
type=object, getter=get_icon_name, setter=set_icon_name)
def set_xo_color(self, value):
"""
Parameters
----------
value:
Returns
-------
None
"""
if self._buffer.xo_color != value:
self._buffer.xo_color = value
self._emit_paint_needed_icon_area()
xo_color = gobject.property(
type=object, getter=None, setter=set_xo_color)
def set_fill_color(self, value):
"""
Parameters
----------
value:
Returns
-------
None
"""
if self._buffer.fill_color != value:
self._buffer.fill_color = value
self._emit_paint_needed_icon_area()
def get_fill_color(self):
"""
Parameters
----------
None
Returns
-------
fill color :
"""
return self._buffer.fill_color
fill_color = gobject.property(
type=object, getter=get_fill_color, setter=set_fill_color)
def set_stroke_color(self, value):
"""
Parameters
----------
value:
Returns
-------
None
"""
if self._buffer.stroke_color != value:
self._buffer.stroke_color = value
self._emit_paint_needed_icon_area()
def get_stroke_color(self):
"""
Parameters
----------
None
Returns
-------
stroke color :
"""
return self._buffer.stroke_color
stroke_color = gobject.property(
type=object, getter=get_stroke_color, setter=set_stroke_color)
def set_background_color(self, value):
"""
Parameters
----------
value:
Returns
-------
None
"""
if self._buffer.background_color != value:
self._buffer.background_color = value
self.emit_paint_needed(0, 0, -1, -1)
def get_background_color(self):
"""
Parameters
----------
None
Returns
-------
fill color :
"""
return self._buffer.background_color
background_color = gobject.property(
type=object, getter=get_background_color, setter=set_background_color)
def set_size(self, value):
"""
Parameters
----------
value:
Returns
-------
None
"""
if self._buffer.width != value:
self._buffer.width = value
self._buffer.height = value
self.emit_request_changed()
def get_size(self):
"""
Parameters
----------
None
Returns
-------
size :
"""
return self._buffer.width
size = gobject.property(
type=object, getter=get_size, setter=set_size)
def set_scale(self, value):
"""
Parameters
----------
value:
Returns
-------
None
"""
if self._buffer.scale != value:
self._buffer.scale = value
self.emit_request_changed()
def get_scale(self):
"""
Parameters
----------
None
Returns
-------
scale :
"""
return self._buffer.scale
scale = gobject.property(
type=float, getter=get_scale, setter=set_scale)
def set_alpha(self, alpha):
if self._alpha != alpha:
self._alpha = alpha
self.emit_paint_needed(0, 0, -1, -1)
alpha = gobject.property(
type=float, setter=set_alpha)
def set_cache(self, value):
"""
Parameters
----------
cache
Returns
-------
None
"""
self._buffer.cache = value
def get_cache(self):
"""
Parameters
----------
None
Returns
-------
cache :
"""
return self._buffer.cache
cache = gobject.property(
type=bool, default=False, getter=get_cache, setter=set_cache)
def set_badge_name(self, value):
"""
Parameters
----------
value :
Returns
-------
None
"""
if self._buffer.badge_name != value:
self._buffer.badge_name = value
self.emit_paint_needed(0, 0, -1, -1)
def get_badge_name(self):
"""
Parameters
----------
None
Returns
-------
badge name :
"""
return self._buffer.badge_name
badge_name = gobject.property(
type=object, getter=get_badge_name, setter=set_badge_name)
def do_paint_below_children(self, cr, damaged_box):
"""
Parameters
----------
cr :
damaged_box :
Returns
-------
None
"""
surface = self._buffer.get_surface()
if surface:
width, height = self.get_allocation()
x = (width - surface.get_width()) / 2
y = (height - surface.get_height()) / 2
cr.set_source_surface(surface, x, y)
if self._alpha == 1.0:
cr.paint()
else:
cr.paint_with_alpha(self._alpha)
def do_get_content_width_request(self):
"""
Parameters
----------
None
Returns
-------
width :
"""
surface = self._buffer.get_surface()
if surface:
size = surface.get_width()
elif self._buffer.width:
size = self._buffer.width
else:
size = 0
return size, size
def do_get_content_height_request(self, for_width):
surface = self._buffer.get_surface()
if surface:
size = surface.get_height()
elif self._buffer.height:
size = self._buffer.height
else:
size = 0
return size, size
def do_button_press_event(self, event):
if event.button == 1:
self.emit_activated()
return True
else:
return False
def create_palette(self):
return None
def get_palette(self):
return self._palette_invoker.palette
def set_palette(self, palette):
self._palette_invoker.palette = palette
palette = gobject.property(
type=object, setter=set_palette, getter=get_palette)
def get_palette_invoker(self):
return self._palette_invoker
def set_palette_invoker(self, palette_invoker):
self._palette_invoker.detach()
self._palette_invoker = palette_invoker
palette_invoker = gobject.property(
type=object, setter=set_palette_invoker, getter=get_palette_invoker)
def set_tooltip(self, text):
from sugar3.graphics.palette import Palette
self.set_palette(Palette(text))
class CellRendererIcon(gtk.GenericCellRenderer):
__gtype_name__ = 'SugarCellRendererIcon'

View File

@ -25,7 +25,6 @@ import logging
import gtk
import gobject
import hippo
from sugar3.graphics import palettegroup
from sugar3.graphics import animator
@ -787,64 +786,6 @@ class WidgetInvoker(Invoker):
widget = gobject.property(type=object, getter=_get_widget, setter=None)
class CanvasInvoker(Invoker):
def __init__(self, parent=None):
Invoker.__init__(self)
self._position_hint = self.AT_CURSOR
self._motion_hid = None
self._release_hid = None
self._item = None
if parent:
self.attach(parent)
def attach(self, parent):
Invoker.attach(self, parent)
self._item = parent
self._motion_hid = self._item.connect('motion-notify-event',
self.__motion_notify_event_cb)
self._release_hid = self._item.connect('button-release-event',
self.__button_release_event_cb)
def detach(self):
Invoker.detach(self)
self._item.disconnect(self._motion_hid)
self._item.disconnect(self._release_hid)
def get_default_position(self):
return self.AT_CURSOR
def get_rect(self):
context = self._item.get_context()
if context:
x, y = context.translate_to_screen(self._item)
width, height = self._item.get_allocation()
return gtk.gdk.Rectangle(x, y, width, height)
else:
return gtk.gdk.Rectangle()
def __motion_notify_event_cb(self, button, event):
if event.detail == hippo.MOTION_DETAIL_ENTER:
self.notify_mouse_enter()
elif event.detail == hippo.MOTION_DETAIL_LEAVE:
self.notify_mouse_leave()
return False
def __button_release_event_cb(self, button, event):
if event.button == 3:
self.notify_right_click()
return True
else:
return False
def get_toplevel(self):
return hippo.get_canvas_for_item(self._item).get_toplevel()
class ToolInvoker(WidgetInvoker):
def __init__(self, parent=None):

View File

@ -1,71 +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.
"""
STABLE.
"""
import math
import hippo
from sugar3.graphics import style
class CanvasRoundBox(hippo.CanvasBox, hippo.CanvasItem):
__gtype_name__ = 'SugarRoundBox'
_BORDER_DEFAULT = style.LINE_WIDTH
def __init__(self, **kwargs):
hippo.CanvasBox.__init__(self, **kwargs)
# TODO: we should calculate radius depending on the height of the box.
self._radius = style.zoom(10)
self.props.orientation = hippo.ORIENTATION_HORIZONTAL
self.props.border = self._BORDER_DEFAULT
self.props.border_left = self._radius
self.props.border_right = self._radius
self.props.border_color = style.COLOR_BLACK.get_int()
def do_paint_background(self, cr, damaged_box):
[width, height] = self.get_allocation()
x = self._BORDER_DEFAULT / 2
y = self._BORDER_DEFAULT / 2
width -= self._BORDER_DEFAULT
height -= self._BORDER_DEFAULT
cr.move_to(x + self._radius, y)
cr.arc(x + width - self._radius, y + self._radius,
self._radius, math.pi * 1.5, math.pi * 2)
cr.arc(x + width - self._radius, x + height - self._radius,
self._radius, 0, math.pi * 0.5)
cr.arc(x + self._radius, y + height - self._radius,
self._radius, math.pi * 0.5, math.pi)
cr.arc(x + self._radius, y + self._radius, self._radius,
math.pi, math.pi * 1.5)
hippo.cairo_set_source_rgba32(cr, self.props.background_color)
cr.fill_preserve()
# TODO: we should be more consistent here with the border properties.
if self.props.border_color:
hippo.cairo_set_source_rgba32(cr, self.props.border_color)
cr.set_line_width(self.props.border_top)
cr.stroke()

View File

@ -1,51 +0,0 @@
import hippo
import gtk
import gobject
from sugar3.graphics.icon import CanvasIcon
from sugar3.graphics.roundbox import CanvasRoundBox
import common
test = common.Test()
canvas = hippo.Canvas()
test.pack_start(canvas)
canvas.show()
scrollbars = hippo.CanvasScrollbars()
canvas.set_root(scrollbars)
box = hippo.CanvasBox(padding=10, spacing=10)
scrollbars.set_root(box)
def idle_cb():
global countdown
for i in range(0, 100):
entry = hippo.CanvasBox(border=2, border_color=0x000000ff,
orientation=hippo.ORIENTATION_HORIZONTAL,
padding=10, spacing=10)
for j in range(0, 3):
icon = CanvasIcon(icon_name='go-left')
entry.append(icon)
for j in range(0, 2):
text = hippo.CanvasText(text='Text %s %s' % (countdown, j))
entry.append(text)
box.append(entry)
countdown -= 1
return countdown > 0
countdown = 1000
gobject.idle_add(idle_cb)
test.show()
if __name__ == '__main__':
common.main(test)