Fix review issues

This commit is contained in:
Aleksey Lim
2009-07-29 15:33:02 +00:00
parent 0cf445eb0f
commit 872b18a103
5 changed files with 116 additions and 110 deletions
+28 -28
View File
@@ -1,29 +1,29 @@
sugardir = $(pythondir)/sugar/graphics
sugar_PYTHON = \
__init__.py \
alert.py \
animator.py \
canvastextview.py \
combobox.py \
colorbutton.py \
entry.py \
icon.py \
iconentry.py \
menuitem.py \
notebook.py \
objectchooser.py \
radiotoolbutton.py \
palette.py \
palettegroup.py \
panel.py \
roundbox.py \
style.py \
toggletoolbutton.py \
toolbox.py \
toolbutton.py \
toolcombobox.py \
tray.py \
window.py \
xocolor.py \
toolbar.py \
radiopalette.py
sugar_PYTHON = \
alert.py \
animator.py \
canvastextview.py \
colorbutton.py \
combobox.py \
entry.py \
iconentry.py \
icon.py \
__init__.py \
menuitem.py \
notebook.py \
objectchooser.py \
palettegroup.py \
palette.py \
panel.py \
radiopalette.py \
radiotoolbutton.py \
roundbox.py \
style.py \
toggletoolbutton.py \
toolbar.py \
toolbox.py \
toolbutton.py \
toolcombobox.py \
tray.py \
window.py \
xocolor.py \
+19 -35
View File
@@ -18,21 +18,16 @@
import gtk
import gobject
import logging
from gobject import SIGNAL_RUN_FIRST, TYPE_NONE
from gobject import SIGNAL_RUN_FIRST, TYPE_NONE, TYPE_PYOBJECT
from sugar.graphics import style
from sugar.graphics.toolbutton import ToolButton
from sugar.graphics.palette import Palette
from sugar.graphics.radiotoolbutton import RadioToolButton
ARROW_SIZE = hasattr(style, 'TOOLBAR_ARROW_SIZE') and style.TOOLBAR_ARROW_SIZE \
or 8
class RadioPaletteButton(ToolButton):
def __init__(self, **kwargs):
ToolButton.__init__(self, **kwargs)
self._button_cb = None
self.selected_button = None
if self.props.palette:
self.__palette_cb(None, None)
@@ -44,10 +39,6 @@ class RadioPaletteButton(ToolButton):
return
self.props.palette.update_button()
def _set_current_button(self, button):
self.set_icon(button.rp_icon_name)
self._button_cb = button.rp_toggled_cb
class RadioMenuButton(RadioPaletteButton):
def __init__(self, **kwargs):
RadioPaletteButton.__init__(self, **kwargs)
@@ -75,18 +66,19 @@ class RadioMenuButton(RadioPaletteButton):
self.get_style().paint_arrow(event.window,
gtk.STATE_NORMAL, gtk.SHADOW_IN, event.area, self,
None, type, True,
a.x + a.width/2 - ARROW_SIZE/2,
a.y + a.height - ARROW_SIZE - style._FOCUS_LINE_WIDTH,
ARROW_SIZE, ARROW_SIZE)
a.x + a.width/2 - style.TOOLBAR_ARROW_SIZE/2,
a.y + a.height - style.TOOLBAR_ARROW_SIZE - \
style._FOCUS_LINE_WIDTH,
style.TOOLBAR_ARROW_SIZE, style.TOOLBAR_ARROW_SIZE)
class RadioToolsButton(RadioPaletteButton):
def __init__(self, **kwargs):
RadioPaletteButton.__init__(self, **kwargs)
def do_clicked(self):
if not self._button_cb:
if not self.selected_button:
return
self._button_cb()
self.selected_button.emit('clicked')
class RadioPalette(Palette):
def __init__(self, **kwargs):
@@ -96,39 +88,31 @@ class RadioPalette(Palette):
self.top.show()
self.set_content(self.top)
def append(self, icon_name, tooltip=None, toggled_cb=None):
def append(self, button):
children = self.top.get_children()
button = RadioToolButton(icon_name=icon_name,
group=children and children[0] or None)
button.show()
button.connect('toggled', self.__toggled_cb)
button.connect('clicked', self.__clicked_cb)
self.top.pack_start(button, fill=False)
button.rp_icon_name = icon_name
button.rp_tooltip = tooltip
button.rp_toggled_cb = toggled_cb
if not children:
self.__toggled_cb(button, True)
return button
self.__clicked_cb(button, True)
def update_button(self):
for i in self.top.get_children():
self.__toggled_cb(i, True)
self.__clicked_cb(i, True)
def __toggled_cb(self, button, quiet=False):
def __clicked_cb(self, button, quiet=False):
if not button.get_active():
return
self.set_primary_text(button.rp_tooltip)
self.set_primary_text(button.props.tooltip)
if not quiet:
if button.rp_toggled_cb:
button.rp_toggled_cb()
self.popdown(immediate=True)
if not self.invoker or \
not isinstance(self.invoker.parent, RadioPaletteButton):
parent = self.invoker and self.invoker.parent
if not isinstance(parent, RadioPaletteButton):
return
self.invoker.parent._set_current_button(button)
parent.set_icon(button.props.icon_name)
parent.selected_button = button
+3 -6
View File
@@ -27,9 +27,6 @@ from sugar.graphics.palette import MouseSpeedDetector, Invoker
from sugar.graphics import animator
from sugar.graphics import palettegroup
ARROW_SIZE = hasattr(style, 'TOOLBAR_ARROW_SIZE') and style.TOOLBAR_ARROW_SIZE \
or 8
class ToolbarButton(ToolButton):
def __init__(self, **kwargs):
self._page = None
@@ -401,6 +398,6 @@ def _paint_arrow(widget, event, type):
widget.get_style().paint_arrow(event.window,
gtk.STATE_NORMAL, gtk.SHADOW_IN, event.area, widget,
None, type, True,
a.x + a.width/2 - ARROW_SIZE/2,
a.y + a.height - ARROW_SIZE - style._FOCUS_LINE_WIDTH,
ARROW_SIZE, ARROW_SIZE)
a.x + a.width/2 - style.TOOLBAR_ARROW_SIZE/2,
a.y + a.height - style.TOOLBAR_ARROW_SIZE - style._FOCUS_LINE_WIDTH,
style.TOOLBAR_ARROW_SIZE, style.TOOLBAR_ARROW_SIZE)