From 8941e08548b3d4af8b0eeb2d60be4828ce1e8584 Mon Sep 17 00:00:00 2001 From: Walter Bender Date: Tue, 18 Aug 2009 21:22:16 +0000 Subject: hover help --- (limited to 'palettes.py') diff --git a/palettes.py b/palettes.py new file mode 100644 index 0000000..e1ba9a7 --- /dev/null +++ b/palettes.py @@ -0,0 +1,64 @@ +# -*- coding: utf-8 -*- +# Copyright (c) 2009, Raúl Gutiérrez Segalés +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program 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 General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +import os +import tempfile +import urlparse +from gettext import gettext as _ +import gobject + +import gtk + +from sugar.graphics.palette import Palette, Invoker +from sugar.graphics.menuitem import MenuItem +from sugar.graphics.icon import Icon +from sugar import profile +from sugar.activity import activity + + +class ContentInvoker(Invoker): + + def __init__(self, help_message): + Invoker.__init__(self) + self._position_hint = self.AT_CURSOR + self.palette = BlockHelpPalette(help_message) + + def get_default_position(self): + return self.AT_CURSOR + + def get_rect(self): + return gtk.gdk.Rectangle() + + def get_toplevel(self): + return None + + def showPopup(self, data = ""): + if self.palette.is_up() == False: + self.palette.popup() + gobject.timeout_add(1500, self.close_palette, "") + + def close_palette(self, data = ""): + self.palette.popdown() + + +class BlockHelpPalette(Palette): + def __init__(self, help_message): + Palette.__init__(self) + + self._help_message = help_message + + self.props.primary_text = help_message -- cgit v0.9.1