sugar-toolkit-gtk3/sugar/graphics/popup.py

50 lines
1.6 KiB
Python
Raw Normal View History

2007-02-20 16:38:25 +01:00
# 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 sys
import logging
import gobject
import gtk
import hippo
2007-02-21 10:16:03 +01:00
class Popup(hippo.CanvasBox, hippo.CanvasItem):
__gtype_name__ = 'SugarPopup'
2007-02-20 16:38:25 +01:00
__gsignals__ = {
'action-completed': (gobject.SIGNAL_RUN_FIRST, gobject.TYPE_NONE, ([]))
}
2007-02-21 17:05:41 +01:00
def __init__(self):
2007-02-20 16:38:25 +01:00
hippo.CanvasBox.__init__(self)
self._window = None
2007-02-21 17:05:41 +01:00
self.connect('button-press-event', self._button_press_event_cb)
2007-02-20 16:38:25 +01:00
def popup(self, x, y):
if not self._window:
self._window = hippo.CanvasWindow(gtk.WINDOW_POPUP)
self._window.move(x, y)
self._window.set_root(self)
self._window.show()
def popdown(self):
if self._window:
self._window.destroy()
self._window = None
2007-02-21 17:05:41 +01:00
def _button_press_event_cb(self, menu, event):
2007-02-20 16:38:25 +01:00
self.emit('action-completed')