def get_actiongroups(self): """ Return actiongroups to be registered. """ if not hasattr(self, 'actiongroups') or self.actiongroups is None: # construct action groups (requires actions_dict) actiongroups = list() for key, actions in self.actions_dict.iteritems(): ag = gtk.ActionGroup(key) ag.add_actions( uihelper.map_actions(actions, self) ) actiongroups.append(ag) self.actiongroups = actiongroups return self.actiongroups
def _construct_uimanager(self, actiongroups, ui, fix_actions=True): uimanager = gtk.UIManager() # construct action groups from dictionary 'actiongroups' self._actiongroups = {} for (group, group_actions) in actiongroups.iteritems(): ag = gtk.ActionGroup(group) if fix_actions is True: group_actions = uihelper.map_actions(group_actions, self) ag.add_actions(group_actions) self._actiongroups[group] = ag # add action groups to ui manager uimanager = gtk.UIManager() for ag in self._actiongroups.values(): uimanager.insert_action_group(ag, 0) # and build ui uimanager.add_ui_from_string(ui) self.add_accel_group(uimanager.get_accel_group()) return uimanager