New invoker, TreeViewInvoker
This new invoker is able to handle all the palettes on a treeview, removing the need of one invoker per cell renderer (CellRendererInvoker). This simplifies the code and makes it more efficient. Also removes the logic from the CellRendererIcon, which should only care about drawing itself. [1] Is important to note than in Gtk3 a CellRenderer is not a GtkWidget then can't know when the mouse is over it or have the usual events used by other invokers, making the implementation CellRendererInvoker very complicate. This commit also removes the invoker of CellRendererIcon. The ScrollingDetector logic is simplified too, because now there are only one invoker instead of one by renderer and the example code updated. [1] https://developer.gnome.org/gtk3/stable/GtkCellRenderer.html
This commit is contained in:
@@ -18,11 +18,12 @@
|
||||
from gi.repository import GObject
|
||||
from gi.repository import GLib
|
||||
|
||||
from sugar3.graphics.icon import CellRendererIcon
|
||||
|
||||
|
||||
class ScrollingDetector(GObject.GObject):
|
||||
"""
|
||||
ScollingDetector emit signals when a ScrolledWindow starts and
|
||||
finish scrolling. Other widets can use that information to
|
||||
avoid do performance expensive operations.
|
||||
"""
|
||||
|
||||
scroll_start_signal = GObject.Signal('scroll-start')
|
||||
@@ -58,15 +59,3 @@ class ScrollingDetector(GObject.GObject):
|
||||
self.scroll_start_signal.emit()
|
||||
self._prev_value = adj.props.value
|
||||
GLib.timeout_add(self._timeout, self._check_scroll_cb, adj)
|
||||
|
||||
def connect_treeview(self, treeview):
|
||||
"""
|
||||
treeview -- Gtk.TreeView: a TreeView with CellRendererIcons already
|
||||
added.
|
||||
This method need be executed after all the columns and renderers
|
||||
were added to the treeview.
|
||||
"""
|
||||
for column in treeview.get_columns():
|
||||
for cell_renderer in column.get_cells():
|
||||
if isinstance(cell_renderer, CellRendererIcon):
|
||||
cell_renderer.connect_to_scroller(self)
|
||||
|
||||
Reference in New Issue
Block a user