Remove CellRendererInvoker

This invoker is not used anymore, now is replaced by TreeViewInvoker.
This commit is contained in:
Gonzalo Odiard 2014-11-17 06:19:15 -03:00
parent 49365e132c
commit 7a9510a187
2 changed files with 3 additions and 159 deletions

View File

@ -827,6 +827,9 @@ class CellRendererIcon(Gtk.CellRenderer):
def __init__(self, treeview=None):
# treeview is not used anymore, is here just to not break the API
if treeview is not None:
logging.warning('CellRendererIcon: treeview parameter in '
'constructor is deprecated')
self._buffer = _IconBuffer()
self._buffer.cache = True
self._xo_color = None

View File

@ -1373,165 +1373,6 @@ class ToolInvoker(WidgetInvoker):
self._widget.emit('clicked')
class CellRendererInvoker(Invoker):
def __init__(self):
Invoker.__init__(self)
self._position_hint = self.AT_CURSOR
self._tree_view = None
self._cell_renderer = None
self._motion_hid = None
self._leave_hid = None
self._release_hid = None
self._long_pressed_hid = None
self.path = None
self._long_pressed_controller = SugarGestures.LongPressController()
def attach_cell_renderer(self, tree_view, cell_renderer):
self._tree_view = tree_view
self._cell_renderer = cell_renderer
self._motion_hid = tree_view.connect('motion-notify-event',
self.__motion_notify_event_cb)
self._leave_hid = tree_view.connect('leave-notify-event',
self.__leave_notify_event_cb)
self._release_hid = tree_view.connect('button-release-event',
self.__button_release_event_cb)
self._long_pressed_hid = self._long_pressed_controller.connect(
'pressed', self.__long_pressed_event_cb, tree_view)
self._long_pressed_controller.attach(
tree_view,
SugarGestures.EventControllerFlags.NONE)
Invoker.attach(self, cell_renderer)
def detach(self):
Invoker.detach(self)
self._tree_view.disconnect(self._motion_hid)
self._tree_view.disconnect(self._leave_hid)
self._tree_view.disconnect(self._release_hid)
self._long_pressed_controller.detach(self._tree_view)
self._long_pressed_controller.disconnect(self._long_pressed_hid)
def get_rect(self):
allocation = self._tree_view.get_allocation()
window = self._tree_view.get_window()
if window is not None:
res, x, y = window.get_origin()
else:
logging.warning(
"Trying to position palette with invoker that's not realized.")
x = 0
y = 0
rect = Gdk.Rectangle()
rect.x = x + allocation.x
rect.y = y + allocation.y
rect.width = allocation.width
rect.height = allocation.height
return rect
def __motion_notify_event_cb(self, widget, event):
if event.window != widget.get_bin_window():
return
if self.point_in_cell_renderer(event.x, event.y):
tree_view = self._tree_view
path, column_, x_, y_ = tree_view.get_path_at_pos(int(event.x),
int(event.y))
if path != self.path:
if self.path is not None:
self._redraw_path(self.path)
if path is not None:
self._redraw_path(path)
if self.palette is not None:
self.palette.popdown(immediate=True)
self.palette = None
self.path = path
if event.get_source_device().get_source() == \
Gdk.InputSource.TOUCHSCREEN:
return False
self.notify_mouse_enter()
else:
if self.path is not None:
self._redraw_path(self.path)
self.path = None
if event.get_source_device().get_source() == \
Gdk.InputSource.TOUCHSCREEN:
return False
self.notify_mouse_leave()
def _redraw_path(self, path):
column = None
for column in self._tree_view.get_columns():
if self._cell_renderer in column.get_cells():
break
assert column is not None
area = self._tree_view.get_background_area(path, column)
x, y = \
self._tree_view.convert_bin_window_to_widget_coords(area.x, area.y)
self._tree_view.queue_draw_area(x, y, area.width, area.height)
def __leave_notify_event_cb(self, widget, event):
if event.mode == Gdk.CrossingMode.NORMAL:
self.notify_mouse_leave()
return False
def __button_release_event_cb(self, widget, event):
if event.button == 1 and self.point_in_cell_renderer(event.x,
event.y):
tree_view = self._tree_view
path, column_, x_, y_ = tree_view.get_path_at_pos(int(event.x),
int(event.y))
self._cell_renderer.emit('clicked', path)
# So the treeview receives it and knows a drag isn't going on
return False
if event.button == 3 and self.point_in_cell_renderer(event.x,
event.y):
self.notify_right_click()
return True
else:
return False
def __long_pressed_event_cb(self, controller, x, y, widget):
if self.point_in_cell_renderer(x, y):
self.notify_right_click()
def point_in_cell_renderer(self, event_x, event_y):
pos = self._tree_view.get_path_at_pos(int(event_x), int(event_y))
if pos is None:
return False
path_, column, x, y_ = pos
for cell_renderer in column.get_cells():
if cell_renderer == self._cell_renderer:
cell_x, cell_width = column.cell_get_position(cell_renderer)
if x > cell_x and x < (cell_x + cell_width):
return True
return False
return False
def get_toplevel(self):
return self._tree_view.get_toplevel()
def notify_popup(self):
Invoker.notify_popup(self)
def notify_popdown(self):
Invoker.notify_popdown(self)
self.palette = None
def get_default_position(self):
return self.AT_CURSOR
class TreeViewInvoker(Invoker):
def __init__(self):
Invoker.__init__(self)