From 283b20114576b1e29d856911d188ce3c73865012 Mon Sep 17 00:00:00 2001 From: Marco Pesenti Gritti Date: Fri, 18 Apr 2008 23:10:48 +0000 Subject: pylint most of sugar.graphics, only palette left --- (limited to 'sugar') diff --git a/sugar/graphics/menuitem.py b/sugar/graphics/menuitem.py index 908cc1f..3d6764b 100644 --- a/sugar/graphics/menuitem.py +++ b/sugar/graphics/menuitem.py @@ -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) diff --git a/sugar/graphics/notebook.py b/sugar/graphics/notebook.py index 2d49b1f..bc6bab5 100644 --- a/sugar/graphics/notebook.py +++ b/sugar/graphics/notebook.py @@ -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() diff --git a/sugar/graphics/objectchooser.py b/sugar/graphics/objectchooser.py index 59f1a8a..51fa3a7 100644 --- a/sugar/graphics/objectchooser.py +++ b/sugar/graphics/objectchooser.py @@ -16,7 +16,6 @@ # Boston, MA 02111-1307, USA. import logging -import time import gobject import gtk diff --git a/sugar/graphics/roundbox.py b/sugar/graphics/roundbox.py index 51b9e7d..573344e 100644 --- a/sugar/graphics/roundbox.py +++ b/sugar/graphics/roundbox.py @@ -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: diff --git a/sugar/graphics/toggletoolbutton.py b/sugar/graphics/toggletoolbutton.py index 3d05cc0..4c59f80 100644 --- a/sugar/graphics/toggletoolbutton.py +++ b/sugar/graphics/toggletoolbutton.py @@ -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) diff --git a/sugar/graphics/toolbox.py b/sugar/graphics/toolbox.py index e5ae141..4897add 100644 --- a/sugar/graphics/toolbox.py +++ b/sugar/graphics/toolbox.py @@ -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) diff --git a/sugar/graphics/toolbutton.py b/sugar/graphics/toolbutton.py index 08bc1f3..236d7ec 100644 --- a/sugar/graphics/toolbutton.py +++ b/sugar/graphics/toolbutton.py @@ -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) diff --git a/sugar/graphics/tray.py b/sugar/graphics/tray.py index 064c3d0..abc8df3 100644 --- a/sugar/graphics/tray.py +++ b/sugar/graphics/tray.py @@ -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] diff --git a/sugar/graphics/window.py b/sugar/graphics/window.py index 3189400..60aa8fd 100644 --- a/sugar/graphics/window.py +++ b/sugar/graphics/window.py @@ -17,7 +17,6 @@ import gobject import gtk -import logging from sugar.graphics.icon import Icon diff --git a/sugar/graphics/xocolor.py b/sugar/graphics/xocolor.py index d37eab1..b2da8e9 100644 --- a/sugar/graphics/xocolor.py +++ b/sugar/graphics/xocolor.py @@ -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 -- cgit v0.9.1