From ba8a731aa171a47932010abc83fd51adb59de08c Mon Sep 17 00:00:00 2001 From: Marco Pesenti Gritti Date: Thu, 16 Aug 2007 16:46:21 +0200 Subject: [PATCH] Add a border to the frame. --- NEWS | 1 + shell/view/frame/clipboardpanelwindow.py | 4 +- shell/view/frame/frame.py | 17 +++---- shell/view/frame/frameinvoker.py | 2 +- shell/view/frame/framewindow.py | 59 ++++++++++++++++-------- sugar/graphics/style.py | 2 + 6 files changed, 53 insertions(+), 32 deletions(-) diff --git a/NEWS b/NEWS index 58ea6cbf..f7a57938 100644 --- a/NEWS +++ b/NEWS @@ -1,3 +1,4 @@ +* #2669: Add a border to the inner of the frame. (marco) * #2703: Update macedonian translation. (ArangelAngov) * #2543: Offer multiple activities for opening clipboard objects. diff --git a/shell/view/frame/clipboardpanelwindow.py b/shell/view/frame/clipboardpanelwindow.py index 70b87e4d..217096a1 100644 --- a/shell/view/frame/clipboardpanelwindow.py +++ b/shell/view/frame/clipboardpanelwindow.py @@ -36,10 +36,8 @@ class ClipboardPanelWindow(FrameWindow): self._clipboard = gtk.Clipboard() self._clipboard.connect("owner-change", self._owner_change_cb) - root = self.get_root() - self._clipboard_box = ClipboardBox() - root.append(self._clipboard_box) + self.append(self._clipboard_box) # Receiving dnd drops self.drag_dest_set(0, [], 0) diff --git a/shell/view/frame/frame.py b/shell/view/frame/frame.py index 1c4680ed..f4111580 100644 --- a/shell/view/frame/frame.py +++ b/shell/view/frame/frame.py @@ -208,11 +208,10 @@ class Frame(object): self._right_panel.hover) def _create_top_panel(self): - panel = self._create_panel(hippo.ORIENTATION_HORIZONTAL) - root = panel.get_root() + panel = self._create_panel(gtk.POS_TOP) box = ZoomBox(self._shell) - root.append(box) + panel.append(box) #box = OverlayBox(self._shell) #root.append(box, hippo.PACK_END) @@ -220,25 +219,23 @@ class Frame(object): return panel def _create_bottom_panel(self): - panel = self._create_panel(hippo.ORIENTATION_HORIZONTAL) - root = panel.get_root() + panel = self._create_panel(gtk.POS_BOTTOM) box = ActivitiesBox(self._shell) - root.append(box) + panel.append(box) return panel def _create_right_panel(self): - panel = self._create_panel(hippo.ORIENTATION_VERTICAL) - root = panel.get_root() + panel = self._create_panel(gtk.POS_RIGHT) box = FriendsBox(self._shell) - root.append(box) + panel.append(box) return panel def _create_left_panel(self): - panel = ClipboardPanelWindow(self, hippo.ORIENTATION_VERTICAL) + panel = ClipboardPanelWindow(self, gtk.POS_LEFT) self._connect_to_panel(panel) panel.connect('drag-motion', self._drag_motion_cb) diff --git a/shell/view/frame/frameinvoker.py b/shell/view/frame/frameinvoker.py index 1b99d503..e0f2859f 100644 --- a/shell/view/frame/frameinvoker.py +++ b/shell/view/frame/frameinvoker.py @@ -29,7 +29,7 @@ class FrameCanvasInvoker(CanvasInvoker): return Palette.AROUND def get_screen_area(self): - frame_thickness = style.zoom(75) + frame_thickness = style.GRID_CELL_SIZE - style.LINE_WIDTH x = y = frame_thickness width = gtk.gdk.screen_width() - frame_thickness diff --git a/shell/view/frame/framewindow.py b/shell/view/frame/framewindow.py index 469ea65e..82dcb327 100644 --- a/shell/view/frame/framewindow.py +++ b/shell/view/frame/framewindow.py @@ -21,11 +21,12 @@ from sugar.graphics import style class FrameWindow(gtk.Window): __gtype_name__ = 'SugarFrameWindow' - def __init__(self, orientation): + + def __init__(self, position): gtk.Window.__init__(self) self.hover = False - self._orientation = orientation + self._position = position self.set_decorated(False) self.connect('realize', self._realize_cb) @@ -36,33 +37,55 @@ class FrameWindow(gtk.Window): self.add(self._canvas) self._canvas.show() - self._bg = hippo.CanvasBox(orientation=self._orientation) - self._canvas.set_root(self._bg) + box = hippo.CanvasBox() + self._canvas.set_root(box) + + padding = style.GRID_CELL_SIZE + if self._position == gtk.POS_TOP or self._position == gtk.POS_BOTTOM: + box.props.orientation = hippo.ORIENTATION_HORIZONTAL + box.props.padding_left = padding + box.props.padding_right = padding + box.props.padding_top = 0 + box.props.padding_bottom = 0 + else: + box.props.orientation = hippo.ORIENTATION_VERTICAL + box.props.padding_left = 0 + box.props.padding_right = 0 + box.props.padding_top = padding + box.props.padding_bottom = padding + + self._bg = hippo.CanvasBox( + border_color=style.COLOR_BUTTON_GREY.get_int()) + + border = style.LINE_WIDTH + if position == gtk.POS_TOP: + self._bg.props.orientation = hippo.ORIENTATION_HORIZONTAL + self._bg.props.border_bottom = border + elif position == gtk.POS_BOTTOM: + self._bg.props.orientation = hippo.ORIENTATION_HORIZONTAL + self._bg.props.border_top = border + elif position == gtk.POS_LEFT: + self._bg.props.orientation = hippo.ORIENTATION_VERTICAL + self._bg.props.border_right = border + elif position == gtk.POS_RIGHT: + self._bg.props.orientation = hippo.ORIENTATION_VERTICAL + self._bg.props.border_left = border + + box.append(self._bg, hippo.PACK_EXPAND) self._update_size() screen = gtk.gdk.screen_get_default() screen.connect('size-changed', self._size_changed_cb) - def get_root(self): - return self._bg + def append(self, child, flags=0): + self._bg.append(child, flags) def _update_size(self): - padding = style.GRID_CELL_SIZE - 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 - + if self._position == gtk.POS_TOP or self._position == gtk.POS_BOTTOM: width = gtk.gdk.screen_width() height = style.GRID_CELL_SIZE 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 = style.GRID_CELL_SIZE height = gtk.gdk.screen_height() self.resize(width, height) diff --git a/sugar/graphics/style.py b/sugar/graphics/style.py index c0094b6d..9d561eb8 100644 --- a/sugar/graphics/style.py +++ b/sugar/graphics/style.py @@ -128,6 +128,8 @@ COLOR_WHITE = Color('#FFFFFF') COLOR_TRANSPARENT = Color('#FFFFFF', alpha=0.0) COLOR_PANEL_GREY = Color('#C0C0C0') COLOR_SELECTION_GREY = Color('#A6A6A6') +COLOR_TOOLBAR_GREY = Color('#404040') +COLOR_BUTTON_GREY = Color('#808080') COLOR_INACTIVE_FILL = Color('#9D9FA1') COLOR_INACTIVE_STROKE = Color('#757575')