2009-07-29 14:42:43 +02:00
|
|
|
# Copyright (C) 2009, Aleksey Lim
|
|
|
|
#
|
2009-07-10 05:58:13 +02:00
|
|
|
# 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.
|
|
|
|
|
2011-11-15 19:29:07 +01:00
|
|
|
from gi.repository import Gtk
|
|
|
|
from gi.repository import GObject
|
2009-07-10 05:58:13 +02:00
|
|
|
|
2011-10-29 10:44:18 +02:00
|
|
|
from sugar3.graphics import style
|
|
|
|
from sugar3.graphics.palette import PaletteWindow, ToolInvoker
|
|
|
|
from sugar3.graphics.toolbutton import ToolButton
|
|
|
|
from sugar3.graphics import palettegroup
|
2009-07-10 05:58:13 +02:00
|
|
|
|
2009-08-25 21:12:40 +02:00
|
|
|
|
2009-07-10 05:58:13 +02:00
|
|
|
class ToolbarButton(ToolButton):
|
2009-08-25 21:12:40 +02:00
|
|
|
|
2009-08-01 13:23:06 +02:00
|
|
|
def __init__(self, page=None, **kwargs):
|
2009-07-12 03:42:23 +02:00
|
|
|
ToolButton.__init__(self, **kwargs)
|
2009-08-25 19:55:48 +02:00
|
|
|
|
2009-08-24 15:09:02 +02:00
|
|
|
self.page_widget = None
|
2009-07-10 05:58:13 +02:00
|
|
|
|
2009-08-01 13:23:06 +02:00
|
|
|
self.set_page(page)
|
2009-07-10 05:58:13 +02:00
|
|
|
|
|
|
|
self.connect('clicked',
|
2009-07-31 09:10:17 +02:00
|
|
|
lambda widget: self.set_expanded(not self.is_expanded()))
|
2009-07-10 05:58:13 +02:00
|
|
|
|
2011-07-12 21:15:24 +02:00
|
|
|
self.connect('hierarchy-changed', self.__hierarchy_changed_cb)
|
|
|
|
|
|
|
|
def __hierarchy_changed_cb(self, tool_button, previous_toplevel):
|
2011-11-15 21:32:03 +01:00
|
|
|
parent = self.get_parent()
|
|
|
|
if hasattr(parent, 'owner'):
|
2011-09-07 18:20:01 +02:00
|
|
|
if self.page_widget and previous_toplevel is None:
|
2011-07-12 21:15:24 +02:00
|
|
|
self._unparent()
|
2011-11-15 21:32:03 +01:00
|
|
|
parent.owner.pack_start(self.page_widget, True, True, 0)
|
2011-07-12 21:15:24 +02:00
|
|
|
self.set_expanded(False)
|
|
|
|
|
2009-07-31 05:49:05 +02:00
|
|
|
def get_toolbar_box(self):
|
2011-11-15 21:32:03 +01:00
|
|
|
parent = self.get_parent()
|
|
|
|
if not hasattr(parent, 'owner'):
|
2009-07-12 03:42:23 +02:00
|
|
|
return None
|
2011-11-15 21:32:03 +01:00
|
|
|
return parent.owner
|
2009-07-12 03:42:23 +02:00
|
|
|
|
2009-07-31 05:49:05 +02:00
|
|
|
toolbar_box = property(get_toolbar_box)
|
2009-07-12 03:42:23 +02:00
|
|
|
|
|
|
|
def get_page(self):
|
2009-07-31 09:10:17 +02:00
|
|
|
if self.page_widget is None:
|
|
|
|
return None
|
2009-09-18 15:18:46 +02:00
|
|
|
return _get_embedded_page(self.page_widget)
|
2009-07-12 03:42:23 +02:00
|
|
|
|
|
|
|
def set_page(self, page):
|
2009-08-01 13:23:06 +02:00
|
|
|
if page is None:
|
|
|
|
self.page_widget = None
|
|
|
|
return
|
2009-09-18 14:24:48 +02:00
|
|
|
self.page_widget, alignment_ = _embed_page(_Box, page)
|
2009-09-09 10:54:08 +02:00
|
|
|
self.page_widget.set_size_request(-1, style.GRID_CELL_SIZE)
|
2009-07-12 03:42:23 +02:00
|
|
|
page.show()
|
2009-08-01 13:23:06 +02:00
|
|
|
if self.props.palette is None:
|
|
|
|
self.props.palette = _ToolbarPalette(invoker=ToolInvoker(self))
|
|
|
|
self._move_page_to_palette()
|
2009-07-12 03:42:23 +02:00
|
|
|
|
2011-11-15 19:29:07 +01:00
|
|
|
page = GObject.property(type=object, getter=get_page, setter=set_page)
|
2009-07-10 05:58:13 +02:00
|
|
|
|
2009-09-18 15:18:46 +02:00
|
|
|
def is_in_palette(self):
|
2009-09-18 14:24:48 +02:00
|
|
|
return self.page is not None and \
|
2011-11-15 21:32:03 +01:00
|
|
|
self.page_widget.get_parent() == self.props.palette
|
2009-08-01 13:23:06 +02:00
|
|
|
|
2009-07-31 09:10:17 +02:00
|
|
|
def is_expanded(self):
|
2009-09-18 14:24:48 +02:00
|
|
|
return self.page is not None and \
|
2009-09-18 15:18:46 +02:00
|
|
|
not self.is_in_palette()
|
2009-07-12 03:42:23 +02:00
|
|
|
|
2009-07-31 09:10:17 +02:00
|
|
|
def popdown(self):
|
2009-09-09 10:54:08 +02:00
|
|
|
if self.props.palette is not None:
|
|
|
|
self.props.palette.popdown(immediate=True)
|
2009-07-12 03:42:23 +02:00
|
|
|
|
2009-07-31 09:10:17 +02:00
|
|
|
def set_expanded(self, expanded):
|
|
|
|
self.popdown()
|
|
|
|
|
2009-09-18 14:24:48 +02:00
|
|
|
if self.page is None or self.is_expanded() == expanded:
|
2009-07-31 09:10:17 +02:00
|
|
|
return
|
2009-07-12 03:42:23 +02:00
|
|
|
|
2009-07-31 09:10:17 +02:00
|
|
|
if not expanded:
|
2009-08-01 13:23:06 +02:00
|
|
|
self._move_page_to_palette()
|
2009-07-31 09:10:17 +02:00
|
|
|
return
|
2009-07-12 03:42:23 +02:00
|
|
|
|
2009-09-18 13:25:32 +02:00
|
|
|
box = self.toolbar_box
|
|
|
|
|
2009-07-31 09:10:17 +02:00
|
|
|
if box.expanded_button is not None:
|
2011-11-15 21:32:03 +01:00
|
|
|
button_window = box.expanded_button.get_window()
|
|
|
|
if button_window is not None:
|
2009-09-18 13:25:32 +02:00
|
|
|
# need to redraw it to erase arrow
|
2011-11-15 21:32:03 +01:00
|
|
|
button_window.invalidate_rect(None, True)
|
2009-07-31 09:10:17 +02:00
|
|
|
box.expanded_button.set_expanded(False)
|
2009-09-18 13:25:32 +02:00
|
|
|
box.expanded_button = self
|
2009-07-12 03:42:23 +02:00
|
|
|
|
2009-09-18 14:24:48 +02:00
|
|
|
self._unparent()
|
2009-07-10 05:58:13 +02:00
|
|
|
|
2011-11-15 19:29:07 +01:00
|
|
|
self.modify_bg(Gtk.StateType.NORMAL, box.background)
|
2009-07-31 09:10:17 +02:00
|
|
|
_setup_page(self.page_widget, box.background, box.props.padding)
|
2011-11-15 19:29:07 +01:00
|
|
|
box.pack_start(self.page_widget, True, True, 0)
|
2009-07-10 05:58:13 +02:00
|
|
|
|
2009-09-18 14:24:48 +02:00
|
|
|
def _move_page_to_palette(self):
|
2009-09-18 15:18:46 +02:00
|
|
|
if self.is_in_palette():
|
2009-09-18 14:24:48 +02:00
|
|
|
return
|
|
|
|
|
|
|
|
self._unparent()
|
|
|
|
|
|
|
|
if isinstance(self.props.palette, _ToolbarPalette):
|
|
|
|
self.props.palette.add(self.page_widget)
|
|
|
|
|
|
|
|
def _unparent(self):
|
2011-11-15 21:32:03 +01:00
|
|
|
page_parent = self.page_widget.get_parent()
|
|
|
|
if page_parent is None:
|
2009-09-18 14:24:48 +02:00
|
|
|
return
|
2011-11-15 21:32:03 +01:00
|
|
|
page_parent.remove(self.page_widget)
|
2009-09-18 14:24:48 +02:00
|
|
|
|
2009-07-10 05:58:13 +02:00
|
|
|
def do_expose_event(self, event):
|
2009-08-01 13:23:06 +02:00
|
|
|
if not self.is_expanded() or self.props.palette is not None and \
|
|
|
|
self.props.palette.is_up():
|
2009-07-10 05:58:13 +02:00
|
|
|
ToolButton.do_expose_event(self, event)
|
2011-11-15 19:29:07 +01:00
|
|
|
_paint_arrow(self, event, Gtk.ArrowType.DOWN)
|
2009-07-10 05:58:13 +02:00
|
|
|
return
|
|
|
|
|
2009-07-12 06:32:51 +02:00
|
|
|
alloc = self.allocation
|
|
|
|
|
2009-07-10 05:58:13 +02:00
|
|
|
self.get_style().paint_box(event.window,
|
2011-11-15 19:29:07 +01:00
|
|
|
Gtk.StateType.NORMAL, Gtk.ShadowType.IN, event.area, self,
|
2009-07-12 03:42:23 +02:00
|
|
|
'palette-invoker', alloc.x, 0,
|
2009-08-01 13:27:56 +02:00
|
|
|
alloc.width, alloc.height + style.FOCUS_LINE_WIDTH)
|
2009-07-10 05:58:13 +02:00
|
|
|
|
2011-11-15 19:29:07 +01:00
|
|
|
if self.get_child().state != Gtk.StateType.PRELIGHT:
|
2009-07-10 05:58:13 +02:00
|
|
|
self.get_style().paint_box(event.window,
|
2011-11-15 19:29:07 +01:00
|
|
|
Gtk.StateType.NORMAL, Gtk.ShadowType.NONE, event.area, self, None,
|
2009-08-01 13:27:56 +02:00
|
|
|
alloc.x + style.FOCUS_LINE_WIDTH, style.FOCUS_LINE_WIDTH,
|
2009-08-01 13:34:45 +02:00
|
|
|
alloc.width - style.FOCUS_LINE_WIDTH * 2, alloc.height)
|
2009-07-10 05:58:13 +02:00
|
|
|
|
2011-11-15 19:29:07 +01:00
|
|
|
Gtk.ToolButton.do_expose_event(self, event)
|
|
|
|
_paint_arrow(self, event, Gtk.ArrowType.UP)
|
2009-07-10 05:58:13 +02:00
|
|
|
|
2009-08-25 21:12:40 +02:00
|
|
|
|
2011-11-15 19:29:07 +01:00
|
|
|
class ToolbarBox(Gtk.VBox):
|
2009-08-25 21:12:40 +02:00
|
|
|
|
2009-07-12 06:32:51 +02:00
|
|
|
def __init__(self, padding=style.TOOLBOX_HORIZONTAL_PADDING):
|
2011-11-15 19:29:07 +01:00
|
|
|
GObject.GObject.__init__(self)
|
2009-09-18 13:25:32 +02:00
|
|
|
self._expanded_button_index = -1
|
2009-08-01 13:27:56 +02:00
|
|
|
self.background = None
|
2009-07-10 05:58:13 +02:00
|
|
|
|
2011-11-15 19:29:07 +01:00
|
|
|
self._toolbar = Gtk.Toolbar()
|
2009-07-31 12:25:01 +02:00
|
|
|
self._toolbar.owner = self
|
|
|
|
self._toolbar.connect('remove', self.__remove_cb)
|
2009-07-12 03:42:23 +02:00
|
|
|
|
2009-09-18 14:24:48 +02:00
|
|
|
self._toolbar_widget, self._toolbar_alignment = \
|
2011-11-15 19:29:07 +01:00
|
|
|
_embed_page(Gtk.EventBox, self._toolbar)
|
|
|
|
self.pack_start(self._toolbar_widget, True, True, 0)
|
2009-07-12 06:32:51 +02:00
|
|
|
|
|
|
|
self.props.padding = padding
|
2011-11-15 19:29:07 +01:00
|
|
|
self.modify_bg(Gtk.StateType.NORMAL,
|
2009-07-12 03:42:23 +02:00
|
|
|
style.COLOR_TOOLBAR_GREY.get_gdk_color())
|
2009-07-10 05:58:13 +02:00
|
|
|
|
2009-09-18 14:24:48 +02:00
|
|
|
def get_toolbar(self):
|
|
|
|
return self._toolbar
|
|
|
|
|
|
|
|
toolbar = property(get_toolbar)
|
|
|
|
|
2009-09-18 13:25:32 +02:00
|
|
|
def get_expanded_button(self):
|
|
|
|
if self._expanded_button_index == -1:
|
|
|
|
return None
|
2009-09-18 14:24:48 +02:00
|
|
|
return self.toolbar.get_nth_item(self._expanded_button_index)
|
2009-09-18 13:25:32 +02:00
|
|
|
|
|
|
|
def set_expanded_button(self, button):
|
2009-09-18 14:24:48 +02:00
|
|
|
if not button in self.toolbar:
|
2009-09-18 13:25:32 +02:00
|
|
|
self._expanded_button_index = -1
|
|
|
|
return
|
2009-09-18 14:24:48 +02:00
|
|
|
self._expanded_button_index = self.toolbar.get_item_index(button)
|
2009-09-18 13:25:32 +02:00
|
|
|
|
|
|
|
expanded_button = property(get_expanded_button, set_expanded_button)
|
|
|
|
|
2009-07-12 06:32:51 +02:00
|
|
|
def get_padding(self):
|
2009-09-18 14:24:48 +02:00
|
|
|
return self._toolbar_alignment.props.left_padding
|
2009-07-12 06:32:51 +02:00
|
|
|
|
|
|
|
def set_padding(self, pad):
|
2009-09-18 14:24:48 +02:00
|
|
|
self._toolbar_alignment.set_padding(0, 0, pad, pad)
|
2009-07-12 06:32:51 +02:00
|
|
|
|
2011-11-15 19:29:07 +01:00
|
|
|
padding = GObject.property(type=object,
|
2009-07-12 06:32:51 +02:00
|
|
|
getter=get_padding, setter=set_padding)
|
|
|
|
|
2009-07-12 03:42:23 +02:00
|
|
|
def modify_bg(self, state, color):
|
2011-11-15 19:29:07 +01:00
|
|
|
if state == Gtk.StateType.NORMAL:
|
2009-07-31 09:10:17 +02:00
|
|
|
self.background = color
|
2009-09-18 14:24:48 +02:00
|
|
|
self._toolbar_widget.modify_bg(state, color)
|
2009-07-30 18:25:04 +02:00
|
|
|
self.toolbar.modify_bg(state, color)
|
2009-07-10 05:58:13 +02:00
|
|
|
|
2009-09-18 14:24:48 +02:00
|
|
|
def __remove_cb(self, sender, button):
|
|
|
|
if not isinstance(button, ToolbarButton):
|
|
|
|
return
|
|
|
|
button.popdown()
|
|
|
|
if button == self.expanded_button:
|
|
|
|
self.remove(button.page_widget)
|
|
|
|
self._expanded_button_index = -1
|
|
|
|
|
2009-08-25 21:12:40 +02:00
|
|
|
|
2009-08-01 13:23:06 +02:00
|
|
|
class _ToolbarPalette(PaletteWindow):
|
2009-08-25 21:12:40 +02:00
|
|
|
|
2009-08-01 13:23:06 +02:00
|
|
|
def __init__(self, **kwargs):
|
|
|
|
PaletteWindow.__init__(self, **kwargs)
|
|
|
|
self.set_border_width(0)
|
2009-09-09 19:11:58 +02:00
|
|
|
self._has_focus = False
|
2009-07-31 22:43:35 +02:00
|
|
|
|
|
|
|
group = palettegroup.get_group('default')
|
|
|
|
group.connect('popdown', self.__group_popdown_cb)
|
2009-09-18 13:25:32 +02:00
|
|
|
self.set_group_id('toolbarbox')
|
|
|
|
|
|
|
|
def get_expanded_button(self):
|
2011-11-15 21:32:03 +01:00
|
|
|
return self.invoker.get_parent()
|
2009-09-18 13:25:32 +02:00
|
|
|
|
|
|
|
expanded_button = property(get_expanded_button)
|
2009-07-31 22:43:35 +02:00
|
|
|
|
|
|
|
def on_invoker_enter(self):
|
|
|
|
PaletteWindow.on_invoker_enter(self)
|
2009-09-09 19:11:58 +02:00
|
|
|
self._set_focus(True)
|
2009-07-31 22:43:35 +02:00
|
|
|
|
|
|
|
def on_invoker_leave(self):
|
|
|
|
PaletteWindow.on_invoker_leave(self)
|
2009-09-09 19:11:58 +02:00
|
|
|
self._set_focus(False)
|
2009-07-31 22:43:35 +02:00
|
|
|
|
|
|
|
def on_enter(self, event):
|
|
|
|
PaletteWindow.on_enter(self, event)
|
2009-09-09 19:11:58 +02:00
|
|
|
self._set_focus(True)
|
2009-07-31 22:43:35 +02:00
|
|
|
|
|
|
|
def on_leave(self, event):
|
|
|
|
PaletteWindow.on_enter(self, event)
|
2009-09-09 19:11:58 +02:00
|
|
|
self._set_focus(False)
|
2009-07-31 22:43:35 +02:00
|
|
|
|
2009-09-09 19:11:58 +02:00
|
|
|
def _set_focus(self, new_focus):
|
|
|
|
self._has_focus = new_focus
|
|
|
|
if not self._has_focus:
|
2009-07-31 22:43:35 +02:00
|
|
|
group = palettegroup.get_group('default')
|
|
|
|
if not group.is_up():
|
|
|
|
self.popdown()
|
2009-08-01 13:23:06 +02:00
|
|
|
|
|
|
|
def do_size_request(self, requisition):
|
2011-11-15 19:29:07 +01:00
|
|
|
Gtk.Window.do_size_request(self, requisition)
|
2009-08-01 13:23:06 +02:00
|
|
|
requisition.width = max(requisition.width,
|
2011-11-15 19:29:07 +01:00
|
|
|
Gdk.Screen.width())
|
2009-08-01 13:23:06 +02:00
|
|
|
|
2009-08-01 15:34:42 +02:00
|
|
|
def popup(self, immediate=False):
|
2009-09-18 13:25:32 +02:00
|
|
|
button = self.expanded_button
|
2009-08-01 13:23:06 +02:00
|
|
|
if button.is_expanded():
|
|
|
|
return
|
|
|
|
box = button.toolbar_box
|
|
|
|
_setup_page(button.page_widget, style.COLOR_BLACK.get_gdk_color(),
|
|
|
|
box.props.padding)
|
2009-08-01 15:34:42 +02:00
|
|
|
PaletteWindow.popup(self, immediate)
|
2009-07-31 22:43:35 +02:00
|
|
|
|
|
|
|
def __group_popdown_cb(self, group):
|
2009-09-09 19:11:58 +02:00
|
|
|
if not self._has_focus:
|
2009-07-31 22:43:35 +02:00
|
|
|
self.popdown(immediate=True)
|
2009-08-01 13:23:06 +02:00
|
|
|
|
2009-08-25 21:12:40 +02:00
|
|
|
|
2011-11-15 19:29:07 +01:00
|
|
|
class _Box(Gtk.EventBox):
|
2009-08-25 21:12:40 +02:00
|
|
|
|
2009-07-10 05:58:13 +02:00
|
|
|
def __init__(self):
|
2011-11-15 19:29:07 +01:00
|
|
|
GObject.GObject.__init__(self)
|
2009-07-10 05:58:13 +02:00
|
|
|
self.connect('expose-event', self.do_expose_event)
|
|
|
|
self.set_app_paintable(True)
|
|
|
|
|
|
|
|
def do_expose_event(self, widget, event):
|
2011-11-15 21:32:03 +01:00
|
|
|
expanded_button = self.get_parent().expanded_button
|
|
|
|
if expanded_button is None:
|
2009-09-18 13:25:32 +02:00
|
|
|
return
|
2011-11-15 21:32:03 +01:00
|
|
|
alloc = expanded_button.allocation
|
2009-07-10 05:58:13 +02:00
|
|
|
self.get_style().paint_box(event.window,
|
2011-11-15 19:29:07 +01:00
|
|
|
Gtk.StateType.NORMAL, Gtk.ShadowType.IN, event.area, self,
|
2009-08-01 13:34:45 +02:00
|
|
|
'palette-invoker', -style.FOCUS_LINE_WIDTH, 0,
|
|
|
|
self.allocation.width + style.FOCUS_LINE_WIDTH * 2,
|
|
|
|
self.allocation.height + style.FOCUS_LINE_WIDTH)
|
2009-07-10 05:58:13 +02:00
|
|
|
self.get_style().paint_box(event.window,
|
2011-11-15 19:29:07 +01:00
|
|
|
Gtk.StateType.NORMAL, Gtk.ShadowType.NONE, event.area, self, None,
|
2009-08-01 13:34:45 +02:00
|
|
|
alloc.x + style.FOCUS_LINE_WIDTH, 0,
|
|
|
|
alloc.width - style.FOCUS_LINE_WIDTH * 2,
|
|
|
|
style.FOCUS_LINE_WIDTH)
|
2009-07-10 05:58:13 +02:00
|
|
|
|
2009-08-25 21:12:40 +02:00
|
|
|
|
2009-07-31 22:05:40 +02:00
|
|
|
def _setup_page(page_widget, color, hpad):
|
2009-08-01 13:34:45 +02:00
|
|
|
vpad = style.FOCUS_LINE_WIDTH
|
2011-11-15 19:29:07 +01:00
|
|
|
page_widget.get_child().set_padding(vpad, vpad, hpad, hpad)
|
2009-07-31 22:05:40 +02:00
|
|
|
|
2009-09-18 15:18:46 +02:00
|
|
|
page = _get_embedded_page(page_widget)
|
2011-11-15 19:29:07 +01:00
|
|
|
page.modify_bg(Gtk.StateType.NORMAL, color)
|
|
|
|
if isinstance(page, Gtk.Container):
|
2009-07-31 22:05:40 +02:00
|
|
|
for i in page.get_children():
|
2011-11-15 19:29:07 +01:00
|
|
|
i.modify_bg(Gtk.StateType.INSENSITIVE, color)
|
2009-07-31 22:05:40 +02:00
|
|
|
|
2011-11-15 19:29:07 +01:00
|
|
|
page_widget.modify_bg(Gtk.StateType.NORMAL, color)
|
|
|
|
page_widget.modify_bg(Gtk.StateType.PRELIGHT, color)
|
2009-07-10 05:58:13 +02:00
|
|
|
|
2009-08-25 21:12:40 +02:00
|
|
|
|
2009-09-18 14:24:48 +02:00
|
|
|
def _embed_page(box_class, page):
|
2009-09-18 13:25:32 +02:00
|
|
|
page.show()
|
|
|
|
|
2011-10-30 14:54:53 +01:00
|
|
|
alignment = Gtk.Alignment(xscale=1.0, yscale=1.0)
|
2009-09-18 13:25:32 +02:00
|
|
|
alignment.add(page)
|
2009-07-12 06:32:51 +02:00
|
|
|
alignment.show()
|
2009-09-18 13:25:32 +02:00
|
|
|
|
|
|
|
page_widget = box_class()
|
2011-11-15 19:29:07 +01:00
|
|
|
page_widget.modify_bg(Gtk.StateType.ACTIVE,
|
2009-09-18 13:25:32 +02:00
|
|
|
style.COLOR_BUTTON_GREY.get_gdk_color())
|
|
|
|
page_widget.add(alignment)
|
|
|
|
page_widget.show()
|
|
|
|
|
2009-09-18 14:24:48 +02:00
|
|
|
return (page_widget, alignment)
|
|
|
|
|
|
|
|
|
2009-09-18 15:18:46 +02:00
|
|
|
def _get_embedded_page(page_widget):
|
2011-11-15 21:32:03 +01:00
|
|
|
return page_widget.get_child().get_child()
|
2009-07-10 05:58:13 +02:00
|
|
|
|
2009-08-25 21:12:40 +02:00
|
|
|
|
2009-08-01 13:27:56 +02:00
|
|
|
def _paint_arrow(widget, event, arrow_type):
|
2009-07-30 13:29:52 +02:00
|
|
|
alloc = widget.allocation
|
|
|
|
x = alloc.x + alloc.width / 2 - style.TOOLBAR_ARROW_SIZE / 2
|
|
|
|
y = alloc.y + alloc.height - int(style.TOOLBAR_ARROW_SIZE * .85)
|
|
|
|
|
2009-07-10 05:58:13 +02:00
|
|
|
widget.get_style().paint_arrow(event.window,
|
2011-11-15 19:29:07 +01:00
|
|
|
Gtk.StateType.NORMAL, Gtk.ShadowType.NONE, event.area, widget,
|
2009-08-01 13:27:56 +02:00
|
|
|
None, arrow_type, True,
|
2009-07-30 13:29:52 +02:00
|
|
|
x, y, style.TOOLBAR_ARROW_SIZE, style.TOOLBAR_ARROW_SIZE)
|