Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarco Pesenti Gritti <mpg@redhat.com>2007-02-24 19:58:51 (GMT)
committer Marco Pesenti Gritti <mpg@redhat.com>2007-02-24 19:58:51 (GMT)
commitcb6a808832c456840c043f4b06ea55e7b64f2618 (patch)
tree697913162cd25380ed970012a974832820667120
parent39292db23e4b9ba881e9d6e5b5a7924c76e2ddd6 (diff)
parentd7eb3fd73400bef047ba49bf50d8673aa121dab0 (diff)
Merge branch 'master' of git+ssh://dev.laptop.org/git/sugar
-rw-r--r--shell/view/frame/PanelWindow.py40
-rw-r--r--shell/view/frame/frame.py23
-rw-r--r--sugar/graphics/canvasicon.py2
-rw-r--r--sugar/graphics/optionmenu.py8
-rw-r--r--sugar/graphics/popup.py8
-rwxr-xr-xtests/test-option-menu.py2
6 files changed, 60 insertions, 23 deletions
diff --git a/shell/view/frame/PanelWindow.py b/shell/view/frame/PanelWindow.py
index e14f6b4..6edd4bd 100644
--- a/shell/view/frame/PanelWindow.py
+++ b/shell/view/frame/PanelWindow.py
@@ -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,35 +30,46 @@ class PanelWindow(gtk.Window):
self._canvas = hippo.Canvas()
self._bg = hippo.CanvasBox(background_color=0x414141ff,
- orientation=orientation)
+ orientation=self._orientation)
+ 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)
- if orientation == hippo.ORIENTATION_HORIZONTAL:
+ 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._canvas.set_root(self._bg)
-
- self.add(self._canvas)
- self._canvas.show()
-
self.resize(width, height)
- def get_root(self):
- return self._bg
-
- def get_canvas(self):
- return self._canvas
-
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()
diff --git a/shell/view/frame/frame.py b/shell/view/frame/frame.py
index 27658f0..f15bf35 100644
--- a/shell/view/frame/frame.py
+++ b/shell/view/frame/frame.py
@@ -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)
@@ -75,6 +76,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)
@@ -219,24 +223,28 @@ class Frame:
def notify_key_release(self):
if self._mode == Frame.TEMPORARY:
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)
@@ -255,7 +263,10 @@ class Frame:
self._move(0)
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
diff --git a/sugar/graphics/canvasicon.py b/sugar/graphics/canvasicon.py
index 76d29b0..fe04074 100644
--- a/sugar/graphics/canvasicon.py
+++ b/sugar/graphics/canvasicon.py
@@ -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()
diff --git a/sugar/graphics/optionmenu.py b/sugar/graphics/optionmenu.py
index edd1d39..f5a4417 100644
--- a/sugar/graphics/optionmenu.py
+++ b/sugar/graphics/optionmenu.py
@@ -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,10 +113,14 @@ 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
diff --git a/sugar/graphics/popup.py b/sugar/graphics/popup.py
index 5c63b6e..d0bee06 100644
--- a/sugar/graphics/popup.py
+++ b/sugar/graphics/popup.py
@@ -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')
diff --git a/tests/test-option-menu.py b/tests/test-option-menu.py
index bbcc03a..f320afc 100755
--- a/tests/test-option-menu.py
+++ b/tests/test-option-menu.py
@@ -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