I have implemented the following. Before adding the 2nd parameter (‘link_remove’) to Gio.MenuItem.new() the menu item is not greyed-out. After adding the 2nd parameter, the menu item is greyed-out.
Seems to me the 2nd parameter is necessary as an association to SimpleAction().
‘set_enabled’ does not prevent it from being greyed-out.
I have looked at several code examples and cannot find anything that suggests why this is happening. In fact, the examples show the same kind of thing I am doing with the exception that they do not make use of Gio.SimpleAction.activate(). But, removing it or leaving it in makes no difference.
Any ideas?
item = Gio.MenuItem.new('_Remove Link', 'link_remove')
remove_action = Gio.SimpleAction.new('link_remove', None)
# Documentation says this 'set_enabled' has to occur before activation.
remove_action.set_enabled(True) # Makes the menu item sensitive# Documentation says 'activate()' must appear before the activation.
remove_action.activate(None)
# shows that the this menu item is enabled.
logger.debug('Menu: populate_popup(): Remove Link enabled = %s', remove_action.get_enabled())
remove_action.connect('activate', lambda o: self.remove_link(iter=iter))
# This following results in an 'argument must be callable' error. Don't know why??
#action.connect('activate', self.remove_link(iter=iter))
menu_section.prepend_item(item)