pylint palette, some problems left
This commit is contained in:
parent
283b201145
commit
fa90d50cd9
@ -20,13 +20,13 @@ import logging
|
|||||||
|
|
||||||
import gtk
|
import gtk
|
||||||
import gobject
|
import gobject
|
||||||
import time
|
|
||||||
import hippo
|
import hippo
|
||||||
import pango
|
import pango
|
||||||
|
|
||||||
from sugar.graphics import palettegroup
|
from sugar.graphics import palettegroup
|
||||||
from sugar.graphics import animator
|
from sugar.graphics import animator
|
||||||
from sugar.graphics import style
|
from sugar.graphics import style
|
||||||
|
from sugar.graphics.icon import Icon
|
||||||
from sugar import _sugarext
|
from sugar import _sugarext
|
||||||
|
|
||||||
# Helper function to find the gap position and size of widget a
|
# Helper function to find the gap position and size of widget a
|
||||||
@ -81,10 +81,9 @@ class MouseSpeedDetector(gobject.GObject):
|
|||||||
self._threshold = thresh
|
self._threshold = thresh
|
||||||
self._parent = parent
|
self._parent = parent
|
||||||
self._delay = delay
|
self._delay = delay
|
||||||
|
|
||||||
self._state = None
|
self._state = None
|
||||||
|
|
||||||
self._timeout_hid = None
|
self._timeout_hid = None
|
||||||
|
self._mouse_pos = None
|
||||||
|
|
||||||
def start(self):
|
def start(self):
|
||||||
self._state = None
|
self._state = None
|
||||||
@ -99,8 +98,7 @@ class MouseSpeedDetector(gobject.GObject):
|
|||||||
|
|
||||||
def _get_mouse_position(self):
|
def _get_mouse_position(self):
|
||||||
display = gtk.gdk.display_get_default()
|
display = gtk.gdk.display_get_default()
|
||||||
screen, x, y, mask = display.get_pointer()
|
return display.get_pointer()[1:2]
|
||||||
return (x, y)
|
|
||||||
|
|
||||||
def _detect_motion(self):
|
def _detect_motion(self):
|
||||||
oldx, oldy = self._mouse_pos
|
oldx, oldy = self._mouse_pos
|
||||||
@ -225,7 +223,7 @@ class Palette(gtk.Window):
|
|||||||
self.set_decorated(False)
|
self.set_decorated(False)
|
||||||
self.set_resizable(False)
|
self.set_resizable(False)
|
||||||
# Just assume xthickness and ythickness are the same
|
# Just assume xthickness and ythickness are the same
|
||||||
self.set_border_width(self.style.xthickness)
|
self.set_border_width(self.get_style().xthickness)
|
||||||
|
|
||||||
primary_box.set_size_request(-1, style.zoom(style.GRID_CELL_SIZE)
|
primary_box.set_size_request(-1, style.zoom(style.GRID_CELL_SIZE)
|
||||||
- 2 * self.get_border_width())
|
- 2 * self.get_border_width())
|
||||||
@ -242,7 +240,11 @@ class Palette(gtk.Window):
|
|||||||
self._invoker = None
|
self._invoker = None
|
||||||
self._group_id = None
|
self._group_id = None
|
||||||
self._up = False
|
self._up = False
|
||||||
|
self._menu_box = None
|
||||||
|
self._content = None
|
||||||
self._palette_popup_sid = None
|
self._palette_popup_sid = None
|
||||||
|
self._enter_invoker_hid = None
|
||||||
|
self._leave_invoker_hid = None
|
||||||
|
|
||||||
# we set these for backward compatibility
|
# we set these for backward compatibility
|
||||||
if label is not None:
|
if label is not None:
|
||||||
@ -291,7 +293,7 @@ class Palette(gtk.Window):
|
|||||||
# Prevent a warning from pygtk
|
# Prevent a warning from pygtk
|
||||||
if previous_style is not None:
|
if previous_style is not None:
|
||||||
gtk.Window.do_style_set(self, previous_style)
|
gtk.Window.do_style_set(self, previous_style)
|
||||||
self.set_border_width(self.style.xthickness)
|
self.set_border_width(self.get_style().xthickness)
|
||||||
|
|
||||||
def is_up(self):
|
def is_up(self):
|
||||||
return self._up
|
return self._up
|
||||||
@ -462,19 +464,18 @@ class Palette(gtk.Window):
|
|||||||
else:
|
else:
|
||||||
gap = False
|
gap = False
|
||||||
|
|
||||||
|
allocation = self.get_allocation()
|
||||||
|
wstyle = self.get_style()
|
||||||
|
|
||||||
if gap:
|
if gap:
|
||||||
self.style.paint_box_gap(event.window, gtk.STATE_PRELIGHT,
|
wstyle.paint_box_gap(event.window, gtk.STATE_PRELIGHT,
|
||||||
gtk.SHADOW_IN, event.area, self, "palette",
|
gtk.SHADOW_IN, event.area, self, "palette",
|
||||||
0, 0,
|
0, 0, allocation.width, allocation.height,
|
||||||
self.allocation.width,
|
|
||||||
self.allocation.height,
|
|
||||||
gap[0], gap[1], gap[2])
|
gap[0], gap[1], gap[2])
|
||||||
else:
|
else:
|
||||||
self.style.paint_box(event.window, gtk.STATE_PRELIGHT,
|
wstyle.paint_box(event.window, gtk.STATE_PRELIGHT,
|
||||||
gtk.SHADOW_IN, event.area, self, "palette",
|
gtk.SHADOW_IN, event.area, self, "palette",
|
||||||
0, 0,
|
0, 0, allocation.width, allocation.height)
|
||||||
self.allocation.width,
|
|
||||||
self.allocation.height)
|
|
||||||
|
|
||||||
# Fall trough to the container expose handler.
|
# Fall trough to the container expose handler.
|
||||||
# (Leaving out the window expose handler which redraws everything)
|
# (Leaving out the window expose handler which redraws everything)
|
||||||
@ -633,8 +634,8 @@ class Palette(gtk.Window):
|
|||||||
self.emit('popup')
|
self.emit('popup')
|
||||||
|
|
||||||
class PaletteActionBar(gtk.HButtonBox):
|
class PaletteActionBar(gtk.HButtonBox):
|
||||||
def add_action(label, icon_name=None):
|
def add_action(self, label, icon_name=None):
|
||||||
button = Button(label)
|
button = gtk.Button(label)
|
||||||
|
|
||||||
if icon_name:
|
if icon_name:
|
||||||
icon = Icon(icon_name)
|
icon = Icon(icon_name)
|
||||||
@ -736,7 +737,7 @@ class Invoker(gobject.GObject):
|
|||||||
|
|
||||||
if self._cursor_x == -1 or self._cursor_y == -1:
|
if self._cursor_x == -1 or self._cursor_y == -1:
|
||||||
display = gtk.gdk.display_get_default()
|
display = gtk.gdk.display_get_default()
|
||||||
screen, x, y, mask = display.get_pointer()
|
x, y = display.get_pointer()[1:2]
|
||||||
self._cursor_x = x
|
self._cursor_x = x
|
||||||
self._cursor_y = y
|
self._cursor_y = y
|
||||||
|
|
||||||
@ -897,10 +898,10 @@ class WidgetInvoker(Invoker):
|
|||||||
return True
|
return True
|
||||||
|
|
||||||
def draw_rectangle(self, event, palette):
|
def draw_rectangle(self, event, palette):
|
||||||
style = self._widget.style
|
wstyle = self._widget.get_style()
|
||||||
gap = _calculate_gap(self.get_rect(), palette.get_rect())
|
gap = _calculate_gap(self.get_rect(), palette.get_rect())
|
||||||
if gap:
|
if gap:
|
||||||
style.paint_box_gap(event.window, gtk.STATE_PRELIGHT,
|
wstyle.paint_box_gap(event.window, gtk.STATE_PRELIGHT,
|
||||||
gtk.SHADOW_IN, event.area, self._widget,
|
gtk.SHADOW_IN, event.area, self._widget,
|
||||||
"palette-invoker",
|
"palette-invoker",
|
||||||
self._widget.allocation.x,
|
self._widget.allocation.x,
|
||||||
@ -909,7 +910,7 @@ class WidgetInvoker(Invoker):
|
|||||||
self._widget.allocation.height,
|
self._widget.allocation.height,
|
||||||
gap[0], gap[1], gap[2])
|
gap[0], gap[1], gap[2])
|
||||||
else:
|
else:
|
||||||
style.paint_box(event.window, gtk.STATE_PRELIGHT,
|
wstyle.paint_box(event.window, gtk.STATE_PRELIGHT,
|
||||||
gtk.SHADOW_IN, event.area, self._widget,
|
gtk.SHADOW_IN, event.area, self._widget,
|
||||||
"palette-invoker",
|
"palette-invoker",
|
||||||
self._widget.allocation.x,
|
self._widget.allocation.x,
|
||||||
@ -962,7 +963,6 @@ class CanvasInvoker(Invoker):
|
|||||||
|
|
||||||
def _motion_notify_event_cb(self, button, event):
|
def _motion_notify_event_cb(self, button, event):
|
||||||
if event.detail == hippo.MOTION_DETAIL_ENTER:
|
if event.detail == hippo.MOTION_DETAIL_ENTER:
|
||||||
context = self._item.get_context()
|
|
||||||
self.emit('mouse-enter')
|
self.emit('mouse-enter')
|
||||||
elif event.detail == hippo.MOTION_DETAIL_LEAVE:
|
elif event.detail == hippo.MOTION_DETAIL_LEAVE:
|
||||||
self.emit('mouse-leave')
|
self.emit('mouse-leave')
|
||||||
|
Loading…
Reference in New Issue
Block a user