Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/palettes.py
blob: e1ba9a7d9f1f95c734f68a525c519f384ed1d353 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
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