pylint most of sugar.graphics, only palette left
This commit is contained in:
parent
8783d1113d
commit
283b201145
@ -29,5 +29,6 @@ class MenuItem(gtk.ImageMenuItem):
|
||||
icon.show()
|
||||
|
||||
if text_maxlen > 0:
|
||||
self.child.set_ellipsize(pango.ELLIPSIZE_MIDDLE)
|
||||
self.child.set_max_width_chars(text_maxlen)
|
||||
child = self.get_child()
|
||||
child.set_ellipsize(pango.ELLIPSIZE_MIDDLE)
|
||||
child.set_max_width_chars(text_maxlen)
|
||||
|
@ -30,7 +30,8 @@ class Notebook(gtk.Notebook):
|
||||
|
||||
__gproperties__ = {
|
||||
'can-close-tabs': (bool, None, None, False,
|
||||
gobject.PARAM_READWRITE | gobject.PARAM_CONSTRUCT_ONLY)
|
||||
gobject.PARAM_READWRITE |
|
||||
gobject.PARAM_CONSTRUCT_ONLY)
|
||||
}
|
||||
|
||||
def __init__(self, **kwargs):
|
||||
@ -41,7 +42,8 @@ class Notebook(gtk.Notebook):
|
||||
# Set True the scrollable notebook property
|
||||
|
||||
gobject.GObject.__init__(self, **kwargs)
|
||||
gtk.Notebook.__init__(self)
|
||||
|
||||
self._can_close_tabs = None
|
||||
|
||||
self.set_scrollable(True)
|
||||
self.show()
|
||||
@ -59,7 +61,7 @@ class Notebook(gtk.Notebook):
|
||||
gtk.Button.set_relief(button, gtk.RELIEF_NONE)
|
||||
|
||||
settings = gtk.Widget.get_settings(button)
|
||||
(w,h) = gtk.icon_size_lookup_for_settings(settings, gtk.ICON_SIZE_MENU)
|
||||
w, h = gtk.icon_size_lookup_for_settings(settings, gtk.ICON_SIZE_MENU)
|
||||
gtk.Widget.set_size_request(button, w + 4, h + 4)
|
||||
image.show()
|
||||
icon_box.pack_start(image, True, False, 0)
|
||||
@ -77,7 +79,6 @@ class Notebook(gtk.Notebook):
|
||||
|
||||
# Add a picture on a button
|
||||
self._add_icon_to_button(tab_button)
|
||||
icon_box = gtk.HBox(False, 0)
|
||||
|
||||
event_box.show()
|
||||
tab_button.show()
|
||||
|
@ -16,7 +16,6 @@
|
||||
# Boston, MA 02111-1307, USA.
|
||||
|
||||
import logging
|
||||
import time
|
||||
|
||||
import gobject
|
||||
import gtk
|
||||
|
@ -29,7 +29,7 @@ class CanvasRoundBox(hippo.CanvasBox, hippo.CanvasItem):
|
||||
def __init__(self, **kwargs):
|
||||
hippo.CanvasBox.__init__(self, **kwargs)
|
||||
|
||||
# TODO: we should calculate this value depending on the height of the box.
|
||||
# TODO: we should calculate radius depending on the height of the box.
|
||||
self._radius = style.zoom(10)
|
||||
|
||||
self.props.orientation = hippo.ORIENTATION_HORIZONTAL
|
||||
@ -46,18 +46,18 @@ class CanvasRoundBox(hippo.CanvasBox, hippo.CanvasItem):
|
||||
width -= self._BORDER_DEFAULT
|
||||
height -= self._BORDER_DEFAULT
|
||||
|
||||
cr.move_to(x + self._radius, y);
|
||||
cr.move_to(x + self._radius, y)
|
||||
cr.arc(x + width - self._radius, y + self._radius,
|
||||
self._radius, math.pi * 1.5, math.pi * 2);
|
||||
self._radius, math.pi * 1.5, math.pi * 2)
|
||||
cr.arc(x + width - self._radius, x + height - self._radius,
|
||||
self._radius, 0, math.pi * 0.5);
|
||||
self._radius, 0, math.pi * 0.5)
|
||||
cr.arc(x + self._radius, y + height - self._radius,
|
||||
self._radius, math.pi * 0.5, math.pi);
|
||||
self._radius, math.pi * 0.5, math.pi)
|
||||
cr.arc(x + self._radius, y + self._radius, self._radius,
|
||||
math.pi, math.pi * 1.5);
|
||||
math.pi, math.pi * 1.5)
|
||||
|
||||
hippo.cairo_set_source_rgba32(cr, self.props.background_color)
|
||||
cr.fill_preserve();
|
||||
cr.fill_preserve()
|
||||
|
||||
# TODO: we should be more consistent here with the border properties.
|
||||
if self.props.border_color:
|
||||
|
@ -46,17 +46,18 @@ class ToggleToolButton(gtk.ToggleToolButton):
|
||||
self.set_palette(Palette(text))
|
||||
|
||||
def do_expose_event(self, event):
|
||||
allocation = self.get_allocation()
|
||||
child = self.get_child()
|
||||
|
||||
if self._palette and self._palette.is_up():
|
||||
invoker = self._palette.props.invoker
|
||||
invoker.draw_rectangle(event, self._palette)
|
||||
elif self.child.state == gtk.STATE_PRELIGHT:
|
||||
self.child.style.paint_box(event.window, gtk.STATE_PRELIGHT,
|
||||
gtk.SHADOW_NONE, event.area,
|
||||
self.child, "toolbutton-prelight",
|
||||
self.allocation.x,
|
||||
self.allocation.y,
|
||||
self.allocation.width,
|
||||
self.allocation.height)
|
||||
elif child.state == gtk.STATE_PRELIGHT:
|
||||
child.style.paint_box(event.window, gtk.STATE_PRELIGHT,
|
||||
gtk.SHADOW_NONE, event.area,
|
||||
child, "toolbutton-prelight",
|
||||
allocation.x, allocation.y,
|
||||
allocation.width, allocation.height)
|
||||
|
||||
gtk.ToggleToolButton.do_expose_event(self, event)
|
||||
|
||||
|
@ -19,7 +19,6 @@ import gtk
|
||||
import gobject
|
||||
import hippo
|
||||
|
||||
from sugar.graphics.toolbutton import ToolButton
|
||||
from sugar.graphics import style
|
||||
|
||||
class Toolbox(gtk.VBox):
|
||||
@ -60,7 +59,7 @@ class Toolbox(gtk.VBox):
|
||||
|
||||
def add_toolbar(self, name, toolbar):
|
||||
label = gtk.Label(name)
|
||||
width, height = label.size_request()
|
||||
width = label.size_request()[0]
|
||||
label.set_size_request(max(width, style.TOOLBOX_TAB_LABEL_WIDTH), -1)
|
||||
label.set_alignment(0.0, 0.5)
|
||||
|
||||
|
@ -106,20 +106,21 @@ class ToolButton(gtk.ToolButton):
|
||||
self._palette = palette
|
||||
self._palette.props.invoker = ToolInvoker(self)
|
||||
|
||||
palette = gobject.property(type=object, setter=set_palette, getter=get_palette)
|
||||
palette = gobject.property(
|
||||
type=object, setter=set_palette, getter=get_palette)
|
||||
|
||||
def do_expose_event(self, event):
|
||||
child = self.get_child()
|
||||
allocation = self.get_allocation()
|
||||
if self._palette and self._palette.is_up():
|
||||
invoker = self._palette.props.invoker
|
||||
invoker.draw_rectangle(event, self._palette)
|
||||
elif self.child.state == gtk.STATE_PRELIGHT:
|
||||
self.child.style.paint_box(event.window, gtk.STATE_PRELIGHT,
|
||||
gtk.SHADOW_NONE, event.area,
|
||||
self.child, "toolbutton-prelight",
|
||||
self.allocation.x,
|
||||
self.allocation.y,
|
||||
self.allocation.width,
|
||||
self.allocation.height)
|
||||
elif child.state == gtk.STATE_PRELIGHT:
|
||||
child.style.paint_box(event.window, gtk.STATE_PRELIGHT,
|
||||
gtk.SHADOW_NONE, event.area,
|
||||
child, "toolbutton-prelight",
|
||||
allocation.x, allocation.y,
|
||||
allocation.width, allocation.height)
|
||||
|
||||
gtk.ToolButton.do_expose_event(self, event)
|
||||
|
||||
|
@ -68,27 +68,29 @@ class _TrayViewport(gtk.Viewport):
|
||||
self._scroll_next()
|
||||
|
||||
def _scroll_next(self):
|
||||
allocation = self.get_allocation()
|
||||
if self.orientation == gtk.ORIENTATION_HORIZONTAL:
|
||||
adj = self.get_hadjustment()
|
||||
new_value = adj.value + self.allocation.width
|
||||
adj.value = min(new_value, adj.upper - self.allocation.width)
|
||||
new_value = adj.value + allocation.width
|
||||
adj.value = min(new_value, adj.upper - allocation.width)
|
||||
else:
|
||||
adj = self.get_vadjustment()
|
||||
new_value = adj.value + self.allocation.height
|
||||
adj.value = min(new_value, adj.upper - self.allocation.height)
|
||||
new_value = adj.value + allocation.height
|
||||
adj.value = min(new_value, adj.upper - allocation.height)
|
||||
|
||||
def _scroll_previous(self):
|
||||
allocation = self.get_allocation()
|
||||
if self.orientation == gtk.ORIENTATION_HORIZONTAL:
|
||||
adj = self.get_hadjustment()
|
||||
new_value = adj.value - self.allocation.width
|
||||
new_value = adj.value - allocation.width
|
||||
adj.value = max(adj.lower, new_value)
|
||||
else:
|
||||
adj = self.get_vadjustment()
|
||||
new_value = adj.value - self.allocation.height
|
||||
new_value = adj.value - allocation.height
|
||||
adj.value = max(adj.lower, new_value)
|
||||
|
||||
def do_size_request(self, requisition):
|
||||
child_requisition = self.child.size_request()
|
||||
child_requisition = self.get_child().size_request()
|
||||
if self.orientation == gtk.ORIENTATION_HORIZONTAL:
|
||||
requisition[0] = 0
|
||||
requisition[1] = child_requisition[1]
|
||||
|
@ -17,7 +17,6 @@
|
||||
|
||||
import gobject
|
||||
import gtk
|
||||
import logging
|
||||
|
||||
from sugar.graphics.icon import Icon
|
||||
|
||||
|
@ -219,24 +219,24 @@ class XoColor:
|
||||
def __init__(self, color_string=None):
|
||||
if color_string == None or not is_valid(color_string):
|
||||
n = int(random.random() * (len(_colors) - 1))
|
||||
[self._stroke, self._fill] = _colors[n]
|
||||
[self.stroke, self.fill] = _colors[n]
|
||||
else:
|
||||
[self._stroke, self._fill] = _parse_string(color_string)
|
||||
[self.stroke, self.fill] = _parse_string(color_string)
|
||||
|
||||
def __cmp__(self, other):
|
||||
if isinstance(other, XoColor):
|
||||
if self._stroke == other._stroke and self._fill == other._fill:
|
||||
if self.stroke == other.stroke and self.fill == other.fill:
|
||||
return 0
|
||||
return -1
|
||||
|
||||
def get_stroke_color(self):
|
||||
return self._stroke
|
||||
return self.stroke
|
||||
|
||||
def get_fill_color(self):
|
||||
return self._fill
|
||||
return self.fill
|
||||
|
||||
def to_string(self):
|
||||
return '%s,%s' % (self._stroke, self._fill)
|
||||
return '%s,%s' % (self.stroke, self.fill)
|
||||
|
||||
if __name__ == "__main__":
|
||||
import sys
|
||||
|
Loading…
Reference in New Issue
Block a user