text
stringlengths
0
828
_L().debug('`%s`: %s %s %s', signal, group, command, data)
gtk.idle_add(self.emit, command_signal, group, command, data)
menu_item.connect('activate', ft.partial(_callback, 'activate'))
menu_item.connect('button-press-event',
ft.partial(_callback, 'button-press-event'))
if group is not None:
menu_item.set_tooltip_text(group)
menu = gtk.Menu()
# Add menu items/groups for registered global commands.
if self.global_commands:
data = {'event': event.copy()}
command_signal = 'global-command'
for group, commands in self.global_commands.iteritems():
for command, title in commands.iteritems():
menu_item_j = gtk.MenuItem(title)
menu.append(menu_item_j)
_connect_callback(menu_item_j, command_signal, group,
command, data)
# Add menu items/groups for registered electrode commands.
if self.electrode_commands:
separator = gtk.SeparatorMenuItem()
menu.append(separator)
# Add electrode sub-menu.
menu_e = gtk.Menu()
menu_head_e = gtk.MenuItem('_Electrode')
menu_head_e.set_submenu(menu_e)
menu_head_e.set_use_underline(True)
menu.append(menu_head_e)
command_signal = 'electrode-command'
data = {'electrode_id': shape, 'event': event.copy()}
for group, commands in self.electrode_commands.iteritems():
for command, title in commands.iteritems():
menu_item_j = gtk.MenuItem(title)
menu_e.append(menu_item_j)
_connect_callback(menu_item_j, command_signal, group,
command, data)
# Add menu items/groups for registered route commands.
if routes and self.route_commands:
# TODO: Refactor electrode/route command menu code to reduce code
# duplication (i.e., DRY).
separator = gtk.SeparatorMenuItem()
menu.append(separator)
# Add route sub-menu.
menu_r = gtk.Menu()
menu_head_r = gtk.MenuItem('_Route(s)')
menu_head_r.set_submenu(menu_r)
menu_head_r.set_use_underline(True)
menu.append(menu_head_r)
command_signal = 'route-command'
data = {'route_ids': routes, 'event': event.copy()}
for group, commands in self.route_commands.iteritems():
for command, title in commands.iteritems():
menu_item_j = gtk.MenuItem(title)
menu_r.append(menu_item_j)
_connect_callback(menu_item_j, command_signal, group,
command, data)
menu.show_all()
return menu"
4321,"def on_widget__motion_notify_event(self, widget, event):
'''
Called when mouse pointer is moved within drawing area.
.. versionchanged:: 0.11
Do not trigger `route-electrode-added` event if `ALT` key is
pressed.
'''
if self.canvas is None:
# Canvas has not been initialized. Nothing to do.
return
elif event.is_hint:
pointer = event.window.get_pointer()
x, y, mod_type = pointer
else:
x = event.x
y = event.y
shape = self.canvas.find_shape(x, y)
# Grab focus to [enable notification on key press/release events][1].
#
# [1]: http://mailman.daa.com.au/cgi-bin/pipermail/pygtk/2003-August/005770.html
self.widget.grab_focus()
if shape != self.last_hovered:
if self.last_hovered is not None:
# Leaving shape