Merge branch 'master' of git+ssh://dev.laptop.org/git/sugar
This commit is contained in:
commit
cb6a808832
@ -22,6 +22,7 @@ from sugar.graphics import units
|
||||
class PanelWindow(gtk.Window):
|
||||
def __init__(self, orientation):
|
||||
gtk.Window.__init__(self)
|
||||
self._orientation = orientation
|
||||
|
||||
self.set_decorated(False)
|
||||
self.connect('realize', self._realize_cb)
|
||||
@ -29,28 +30,16 @@ class PanelWindow(gtk.Window):
|
||||
self._canvas = hippo.Canvas()
|
||||
|
||||
self._bg = hippo.CanvasBox(background_color=0x414141ff,
|
||||
orientation=orientation)
|
||||
|
||||
padding = units.grid_to_pixels(1)
|
||||
if orientation == hippo.ORIENTATION_HORIZONTAL:
|
||||
self._bg.props.padding_left = padding
|
||||
self._bg.props.padding_right = padding
|
||||
|
||||
width = gtk.gdk.screen_width()
|
||||
height = units.grid_to_pixels(1)
|
||||
else:
|
||||
self._bg.props.padding_top = padding
|
||||
self._bg.props.padding_bottom = padding
|
||||
|
||||
width = units.grid_to_pixels(1)
|
||||
height = gtk.gdk.screen_height()
|
||||
orientation=self._orientation)
|
||||
|
||||
self._update_size()
|
||||
self._canvas.set_root(self._bg)
|
||||
|
||||
self.add(self._canvas)
|
||||
self._canvas.show()
|
||||
|
||||
self.resize(width, height)
|
||||
screen = gtk.gdk.screen_get_default()
|
||||
screen.connect('size-changed', self._size_changed_cb)
|
||||
|
||||
def get_root(self):
|
||||
return self._bg
|
||||
@ -58,6 +47,29 @@ class PanelWindow(gtk.Window):
|
||||
def get_canvas(self):
|
||||
return self._canvas
|
||||
|
||||
def _update_size(self):
|
||||
padding = units.grid_to_pixels(1)
|
||||
if self._orientation == hippo.ORIENTATION_HORIZONTAL:
|
||||
self._bg.props.padding_left = padding
|
||||
self._bg.props.padding_right = padding
|
||||
self._bg.props.padding_top = 0
|
||||
self._bg.props.padding_bottom = 0
|
||||
|
||||
width = gtk.gdk.screen_width()
|
||||
height = units.grid_to_pixels(1)
|
||||
else:
|
||||
self._bg.props.padding_left = 0
|
||||
self._bg.props.padding_right = 0
|
||||
self._bg.props.padding_top = padding
|
||||
self._bg.props.padding_bottom = padding
|
||||
|
||||
width = units.grid_to_pixels(1)
|
||||
height = gtk.gdk.screen_height()
|
||||
self.resize(width, height)
|
||||
|
||||
def _realize_cb(self, widget):
|
||||
self.window.set_type_hint(gtk.gdk.WINDOW_TYPE_HINT_DIALOG)
|
||||
self.window.set_accept_focus(False)
|
||||
|
||||
def _size_changed_cb(self, screen):
|
||||
self._update_size()
|
||||
|
@ -50,6 +50,7 @@ class Frame:
|
||||
self._hover_frame = False
|
||||
self._shell = shell
|
||||
self._mode = Frame.INACTIVE
|
||||
self._current_position = 0
|
||||
|
||||
self._timeline = Timeline(self)
|
||||
self._timeline.add_tag('slide_in', 18, 24)
|
||||
@ -76,6 +77,9 @@ class Frame:
|
||||
shell.get_model().connect('notify::state',
|
||||
self._shell_state_changed_cb)
|
||||
|
||||
screen = gtk.gdk.screen_get_default()
|
||||
screen.connect('size-changed', self._size_changed_cb)
|
||||
|
||||
def _create_top_panel(self):
|
||||
panel = self._create_panel(hippo.ORIENTATION_HORIZONTAL)
|
||||
root = panel.get_root()
|
||||
@ -221,22 +225,26 @@ class Frame:
|
||||
self._timeline.play('before_slide_out', 'slide_out')
|
||||
|
||||
def _move(self, pos):
|
||||
self._current_position = pos
|
||||
self._update_position()
|
||||
|
||||
def _update_position(self):
|
||||
screen_h = gtk.gdk.screen_height()
|
||||
screen_w = gtk.gdk.screen_width()
|
||||
|
||||
self._move_panel(self._top_panel, pos,
|
||||
self._move_panel(self._top_panel, self._current_position,
|
||||
0, units.grid_to_pixels(-1),
|
||||
0, 0)
|
||||
|
||||
self._move_panel(self._bottom_panel, pos,
|
||||
self._move_panel(self._bottom_panel, self._current_position,
|
||||
0, screen_h,
|
||||
0, screen_h - units.grid_to_pixels(1))
|
||||
|
||||
self._move_panel(self._left_panel, pos,
|
||||
self._move_panel(self._left_panel, self._current_position,
|
||||
units.grid_to_pixels(-1), 0,
|
||||
0, 0)
|
||||
|
||||
self._move_panel(self._right_panel, pos,
|
||||
self._move_panel(self._right_panel, self._current_position,
|
||||
screen_w, 0,
|
||||
screen_w - units.grid_to_pixels(1), 0)
|
||||
|
||||
@ -256,6 +264,9 @@ class Frame:
|
||||
if not self._event_frame.is_visible():
|
||||
self._event_frame.show()
|
||||
|
||||
def _size_changed_cb(self, screen):
|
||||
self._update_position()
|
||||
|
||||
def is_visible(self):
|
||||
return self._top_panel.props.visible
|
||||
|
||||
|
@ -355,7 +355,7 @@ class CanvasIcon(hippo.CanvasBox, hippo.CanvasItem):
|
||||
[x, y] = context.translate_to_screen(self)
|
||||
|
||||
# TODO: Any better place to do this?
|
||||
popup.props.box_width = max(popup.props.box_width,
|
||||
popup.props.box_width = max(popup.get_width_request(),
|
||||
self.get_width_request())
|
||||
|
||||
[width, height] = self.get_allocation()
|
||||
|
@ -64,6 +64,8 @@ class OptionMenu(hippo.CanvasBox, hippo.CanvasItem):
|
||||
|
||||
self._round_box = RoundBox()
|
||||
self._round_box.props.border_color = color.FRAME_BORDER.get_int()
|
||||
self._round_box.props.spacing = units.points_to_pixels(3)
|
||||
self._round_box.props.padding = units.points_to_pixels(1)
|
||||
self.append(self._round_box, hippo.PACK_EXPAND)
|
||||
|
||||
self._canvas_text = hippo.CanvasText()
|
||||
@ -111,11 +113,15 @@ class OptionMenu(hippo.CanvasBox, hippo.CanvasItem):
|
||||
[x, y] = context.translate_to_screen(self._round_box)
|
||||
|
||||
# TODO: Any better place to do this?
|
||||
self._menu.props.box_width = self.get_width_request()
|
||||
self._menu.props.box_width = max(self.get_width_request(),
|
||||
self._menu.get_width_request())
|
||||
|
||||
[width, height] = self._round_box.get_allocation()
|
||||
self._menu.popup(x, y + height)
|
||||
|
||||
# Grab the pointer so the menu will popdown on mouse click.
|
||||
self._menu.grab_pointer()
|
||||
|
||||
def _menu_action_cb(self, menu, menu_item):
|
||||
action_id = menu_item.props.action_id
|
||||
label = menu_item.props.label
|
||||
|
@ -46,5 +46,13 @@ class Popup(hippo.CanvasBox, hippo.CanvasItem):
|
||||
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')
|
||||
|
@ -48,7 +48,7 @@ canvas.set_root(vbox)
|
||||
toolbar = Toolbar()
|
||||
vbox.append(toolbar)
|
||||
|
||||
button = IconButton('theme:stock-close')
|
||||
button = IconButton(icon_name='theme:stock-close')
|
||||
toolbar.append(button)
|
||||
|
||||
OPTION_ANYTHING = 1
|
||||
|
Loading…
Reference in New Issue
Block a user