From 29ccfcf9b35d0f545ca63b23c12664c397ae97f5 Mon Sep 17 00:00:00 2001 From: Tomeu Vizoso Date: Sun, 01 Jul 2007 11:05:06 +0000 Subject: Remove old popup classes. --- (limited to 'sugar') diff --git a/sugar/graphics/Makefile.am b/sugar/graphics/Makefile.am index b671749..303a9b9 100644 --- a/sugar/graphics/Makefile.am +++ b/sugar/graphics/Makefile.am @@ -10,16 +10,12 @@ sugar_PYTHON = \ combobox.py \ font.py \ frame.py \ - menu.py \ - menushell.py \ notebook.py \ objectchooser.py \ radiotoolbutton.py \ roundbox.py \ palette.py \ panel.py \ - popup.py \ - popupcontext.py \ snowflakebox.py \ spreadbox.py \ toggletoolbutton.py \ diff --git a/sugar/graphics/menu.py b/sugar/graphics/menu.py deleted file mode 100644 index 8aa0a64..0000000 --- a/sugar/graphics/menu.py +++ /dev/null @@ -1,136 +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. - -# -# DEPRECATED. Do not use in new code. We will reimplement it in gtk -# - -import sys - -import gtk -import hippo -import gobject - -from sugar.graphics.canvasicon import CanvasIcon -from sugar.graphics.popup import Popup -from sugar.graphics.roundbox import RoundBox -from sugar.graphics import color -from sugar.graphics import font -from sugar.graphics import units - -class MenuItem(hippo.CanvasBox): - __gtype_name__ = 'SugarMenuItem' - - __gproperties__ = { - 'action-id': (object, None, None, - gobject.PARAM_READWRITE), - 'label' : (str, None, None, None, - gobject.PARAM_READWRITE) - } - - def __init__(self, action_id, label, icon_name=None, icon_color=None): - hippo.CanvasBox.__init__(self, orientation=hippo.ORIENTATION_HORIZONTAL) - - self._action_id = action_id - self.props.spacing = units.points_to_pixels(2) - self.props.padding = units.points_to_pixels(2) - - if icon_name: - icon = CanvasIcon(icon_name=icon_name, - scale=units.SMALL_ICON_SCALE, - box_width=units.microgrid_to_pixels(2), - box_height=units.microgrid_to_pixels(2)) - if icon_color: - icon.props.xo_color = icon_color - self.append(icon) - - self._canvas_text = hippo.CanvasText(text=label) - self._canvas_text.props.color = color.LABEL_TEXT.get_int() - self._canvas_text.props.font_desc = font.DEFAULT.get_pango_desc() - self.append(self._canvas_text) - - self.connect('motion-notify-event', self._motion_notify_event_cb) - - def _motion_notify_event_cb(self, menu_item, event): - if event.detail == hippo.MOTION_DETAIL_ENTER: - self.props.background_color = color.MENU_BACKGROUND_HOVER.get_int() - elif event.detail == hippo.MOTION_DETAIL_LEAVE: - self.props.background_color = color.MENU_BACKGROUND.get_int() - - def do_set_property(self, pspec, value): - if pspec.name == 'action-id': - self._action_id = value - elif pspec.name == 'label': - self._canvas_text.props.text = value - else: - hippo.CanvasBox.do_set_property(self, pspec, value) - - def do_get_property(self, pspec): - if pspec.name == 'action-id': - return self._action_id - elif pspec.name == 'label': - return self._canvas_text.props.text - else: - return hippo.CanvasBox.do_get_property(self, pspec) - -class Menu(Popup): - __gtype_name__ = 'SugarCanvasMenu' - - __gsignals__ = { - 'action': (gobject.SIGNAL_RUN_FIRST, gobject.TYPE_NONE, ([object])) - } - - def __init__(self, title=None): - Popup.__init__(self) - - self.props.background_color = color.MENU_BACKGROUND.get_int() - self.props.border_color = color.MENU_BORDER.get_int() - self.props.border = units.points_to_pixels(1) - - self._title_item = None - if title: - self._title_item = hippo.CanvasText(text=title) - self._title_item.props.color = color.LABEL_TEXT.get_int() - self._title_item.props.font_desc = font.DEFAULT.get_pango_desc() - self._title_item.props.padding = units.points_to_pixels(2) - self.append(self._title_item) - self.add_separator() - - def add_item(self, item): - item.connect('button-press-event', self._item_button_press_event_cb) - self.append(item) - - def remove_item(self, item): - self.remove(item) - - def add_separator(self): - box = hippo.CanvasBox() - box.props.padding = units.points_to_pixels(2) - self.append(box) - - separator = hippo.CanvasBox() - separator.props.background_color = color.MENU_SEPARATOR.get_int() - separator.props.box_height = units.points_to_pixels(1) - box.append(separator) - - def _item_button_press_event_cb(self, menu_item, event): - self.emit('action', menu_item) - - def set_title(self, title): - # FIXME: allow adding a title after __init__ when hippo support is complete - if self._title_item: - self._title_item.props.text = title diff --git a/sugar/graphics/menushell.py b/sugar/graphics/menushell.py deleted file mode 100644 index f2ff9fa..0000000 --- a/sugar/graphics/menushell.py +++ /dev/null @@ -1,101 +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 gobject -import gtk - -class MenuShell(gobject.GObject): - __gsignals__ = { - 'activated': (gobject.SIGNAL_RUN_FIRST, - gobject.TYPE_NONE, ([])), - 'deactivated': (gobject.SIGNAL_RUN_FIRST, - gobject.TYPE_NONE, ([])), - } - - AUTO = 0 - LEFT = 1 - RIGHT = 2 - TOP = 3 - BOTTOM = 4 - - def __init__(self, parent_canvas): - gobject.GObject.__init__(self) - - self._parent_canvas = parent_canvas - self._menu_controller = None - self._position = MenuShell.AUTO - - def set_position(self, position): - self._position = position - - def is_active(self): - return (self._menu_controller != None) - - def set_active(self, controller): - if controller == None: - self.emit('deactivated') - else: - self.emit('activated') - - if self._menu_controller: - self._menu_controller.popdown() - self._menu_controller = controller - - def _get_item_rect(self, item): - [x, y] = item.get_context().translate_to_widget(item) - - [origin_x, origin_y] = self._parent_canvas.window.get_origin() - x += origin_x - y += origin_y - - [w, h] = item.get_allocation() - - return [x, y, w, h] - - def get_position(self, menu, item): - [item_x, item_y, item_w, item_h] = self._get_item_rect(item) - [menu_w, menu_h] = menu.size_request() - - left_x = item_x - menu_w - left_y = item_y - right_x = item_x + item_w - right_y = item_y - top_x = item_x - top_y = item_y - menu_h - bottom_x = item_x - bottom_y = item_y + item_h - - if self._position == MenuShell.LEFT: - [x, y] = [left_x, left_y] - elif self._position == MenuShell.RIGHT: - [x, y] = [right_x, right_y] - elif self._position == MenuShell.TOP: - [x, y] = [top_x, top_y] - elif self._position == MenuShell.BOTTOM: - [x, y] = [bottom_x, bottom_y] - elif self._position == MenuShell.AUTO: - [x, y] = [right_x, right_y] - if x + menu_w > gtk.gdk.screen_width(): - [x, y] = [left_x, left_y] - - x = min(x, gtk.gdk.screen_width() - menu_w) - x = max(0, x) - - y = min(y, gtk.gdk.screen_height() - menu_h) - y = max(0, y) - - return [x, y] diff --git a/sugar/graphics/popup.py b/sugar/graphics/popup.py deleted file mode 100644 index e617c22..0000000 --- a/sugar/graphics/popup.py +++ /dev/null @@ -1,63 +0,0 @@ -# Copyright (C) 2007, 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. - -# -# DEPRECATED. Do not use in new code. We will reimplement it in gtk -# - -import sys -import logging - -import gobject -import gtk -import hippo - -class Popup(hippo.CanvasBox, hippo.CanvasItem): - __gtype_name__ = 'SugarPopup' - - __gsignals__ = { - 'action-completed': (gobject.SIGNAL_RUN_FIRST, gobject.TYPE_NONE, ([])) - } - - def __init__(self): - hippo.CanvasBox.__init__(self) - self._visible = False - self._window = hippo.CanvasWindow(gtk.WINDOW_POPUP) - self._window.set_root(self) - self.connect('button-press-event', self._button_press_event_cb) - - def popup(self, x, y): - if not self._visible: - self._window.move(x, y) - self._window.show() - self._visible = True - - def popdown(self): - if self._visible: - self._window.hide() - self._visible = False - - def grab_pointer(self): - gtk.gdk.pointer_grab(self._window.window, owner_events=False, - event_mask=gtk.gdk.BUTTON_PRESS_MASK | - gtk.gdk.BUTTON_RELEASE_MASK | - gtk.gdk.ENTER_NOTIFY_MASK | - gtk.gdk.LEAVE_NOTIFY_MASK | - gtk.gdk.POINTER_MOTION_MASK) - - def _button_press_event_cb(self, menu, event): - self.emit('action-completed') diff --git a/sugar/graphics/popupcontext.py b/sugar/graphics/popupcontext.py deleted file mode 100644 index 44654a3..0000000 --- a/sugar/graphics/popupcontext.py +++ /dev/null @@ -1,47 +0,0 @@ -# Copyright (C) 2007, 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 gobject - -class PopupContext(gobject.GObject): - __gtype_name__ = 'SugarPopupContext' - - __gsignals__ = { - 'activated': (gobject.SIGNAL_RUN_FIRST, gobject.TYPE_NONE, ([])), - 'deactivated': (gobject.SIGNAL_RUN_FIRST, gobject.TYPE_NONE, ([])) - } - - def __init__(self): - self._active_control = None - gobject.GObject.__init__(self) - - def popped_up(self, control): - if self._active_control and self._active_control != control: - self._active_control.popdown() - self._active_control = control - self.emit('activated') - - def popped_down(self, control): - if self._active_control == control: - self._active_control = None - self.emit('deactivated') - - def is_active(self): - return self._active_control != None - - def get_position(self, control, popup): - raise NotImplementedError -- cgit v0.9.1