Add a window class to graphics, it contains a canvas.
This commit is contained in:
parent
abf84970b5
commit
b04c19efb4
@ -18,34 +18,27 @@ import gtk
|
||||
import hippo
|
||||
|
||||
from sugar.graphics import units
|
||||
from sugar.graphics.window import Window
|
||||
|
||||
class PanelWindow(gtk.Window):
|
||||
class PanelWindow(Window):
|
||||
def __init__(self, orientation):
|
||||
gtk.Window.__init__(self)
|
||||
Window.__init__(self)
|
||||
self._orientation = orientation
|
||||
|
||||
self.set_decorated(False)
|
||||
self.connect('realize', self._realize_cb)
|
||||
|
||||
self._canvas = hippo.Canvas()
|
||||
|
||||
self._bg = hippo.CanvasBox(background_color=0x414141ff,
|
||||
orientation=self._orientation)
|
||||
self.set_root(self._bg)
|
||||
|
||||
self._update_size()
|
||||
self._canvas.set_root(self._bg)
|
||||
|
||||
self.add(self._canvas)
|
||||
self._canvas.show()
|
||||
|
||||
|
||||
screen = gtk.gdk.screen_get_default()
|
||||
screen.connect('size-changed', self._size_changed_cb)
|
||||
|
||||
def get_root(self):
|
||||
return self._bg
|
||||
|
||||
def get_canvas(self):
|
||||
return self._canvas
|
||||
|
||||
def _update_size(self):
|
||||
padding = units.grid_to_pixels(1)
|
||||
|
@ -33,7 +33,10 @@ class ClipboardPanelWindow(PanelWindow):
|
||||
self.add_events(gtk.gdk.BUTTON_PRESS_MASK |
|
||||
gtk.gdk.POINTER_MOTION_HINT_MASK)
|
||||
self.connect("motion_notify_event", box.motion_notify_event_cb)
|
||||
self.get_canvas().connect("button_press_event", box.button_press_event_cb)
|
||||
|
||||
# FIXME I'm not sure we should expose the canvas in the Window API
|
||||
self._canvas.connect("button_press_event", box.button_press_event_cb)
|
||||
|
||||
self.connect("drag_end", box.drag_end_cb)
|
||||
self.connect("drag_data_get", box.drag_data_get_cb)
|
||||
|
||||
|
@ -22,4 +22,5 @@ sugar_PYTHON = \
|
||||
timeline.py \
|
||||
toolbar.py \
|
||||
units.py \
|
||||
window.py \
|
||||
xocolor.py
|
||||
|
14
sugar/graphics/window.py
Normal file
14
sugar/graphics/window.py
Normal file
@ -0,0 +1,14 @@
|
||||
import hippo
|
||||
import gtk
|
||||
|
||||
class Window(gtk.Window):
|
||||
def __init__(self, window_type=gtk.WINDOW_TOPLEVEL):
|
||||
gtk.Window.__init__(self, window_type)
|
||||
|
||||
self._canvas = hippo.Canvas()
|
||||
self.add(self._canvas)
|
||||
self._canvas.show()
|
||||
|
||||
def set_root(self, root):
|
||||
self._canvas.set_root(root)
|
||||
|
Loading…
Reference in New Issue
Block a user