Esempio n. 1
0
    def _make_actions(self, vs):
        items = []
        if self.manager.controller.task.window is not None:
            application = self.manager.controller.task.window.application
            added = []
            for vi in application.windows + vs:
                if hasattr(vi, 'active_task'):
                    if vi.active_task:
                        if not vi.active_task.id in added:
                            checked = vi == application.active_window
                            items.append(
                                ActionItem(action=RaiseAction(
                                    window=vi,
                                    checked=checked,
                                    name=vi.active_task.name)))
                            added.append(vi.active_task.id)
                else:
                    items.append(
                        ActionItem(action=RaiseUIAction(
                            name=vi.title or vi.id,
                            ui=vi,
                            checked=checked,
                        )))

        return items
 def _get_items(self):
     items = []
     for window in self.application.windows:
         active = window == self.application.active_window
         action = TaskWindowToggleAction(window=window, checked=active)
         items.append(ActionItem(action=action))
     return items
Esempio n. 3
0
 def _get_items(self):
     items = []
     for i, task in enumerate(self.window.tasks):
         action = TaskToggleAction(task=task,
                                   accelerator='Ctrl+{}'.format(i + 1))
         items.append(ActionItem(action=action))
     return items
Esempio n. 4
0
 def _get_items(self):
     items = []
     if len(self.window.tasks) > 1:
         # at least two tasks, so something to toggle
         items = [
             ActionItem(action=TaskToggleAction(task=task))
             for task in self.window.tasks
         ]
     return items
    def _items_default(self):
        manager = self
        while isinstance(manager, Group):
            manager = manager.parent
        application = manager.controller.task.window.application

        items = []
        for factory in application.task_factories:
            action = TaskWindowLaunchAction(task_id=factory.id)
            items.append(ActionItem(action=action))
        return items
Esempio n. 6
0
    def _get_items(self, event_data=None):
        items = []
        recent_files = self.application.get_plugin_data('open_recent')
        log.debug("GET ITEMS: recent_files=%s, storage=%s" %
                  (recent_files, recent_files.storage))
        if recent_files is not None:
            for uri in recent_files.iter_items():
                action = OpenRecentAction(uri=uri)
                items.append(ActionItem(action=action))

        return items
Esempio n. 7
0
    def _get_items(self, event_data=None):
        items = []
        if event_data is not None:
            for i, segment in enumerate(event_data):
                if is_valid_level_segment(segment):
                    action = UseLevelAction(segment=segment,
                                            segment_number=i,
                                            task=self.task,
                                            checked=False)
                    log.debug("LevelListGroup: created %s for %s, num=%d" %
                              (action, str(segment), i))
                    items.append(ActionItem(action=action, parent=self))

        if not items:
            action = UseLevelAction(segment="<no valid levels>",
                                    segment_number=0,
                                    task=self.task,
                                    checked=False,
                                    enabled=False)
            log.debug("LevelListGroup: created empty menu")
            items.append(ActionItem(action=action, parent=self))

        return items
Esempio n. 8
0
    def _items_default(self):
        """ Create a DockPaneToggleAction for each dock pane.
        """
        manager = self
        while isinstance(manager, Group):
            manager = manager.parent
        task = manager.controller.task

        items = []
        for dock_pane in task.window.get_dock_panes(task):
            action = DockPaneToggleAction(dock_pane=dock_pane)
            items.append(ActionItem(action=action))
        items.sort(key=lambda item: item.action.name)
        return items
Esempio n. 9
0
    def _view_groups(self):
        def groupfunc(task_factory):
            gid = 0
            if hasattr(task_factory, 'task_group'):
                gid = task_factory.task_group
                if gid:
                    gid = ('hardware', 'experiment').index(gid) + 1
                else:
                    gid = 0

            return gid

        application = self.window.application
        groups = []
        for _, factories in groupby(sorted(application.task_factories,
                                           key=groupfunc),
                                    key=groupfunc):
            items = []
            for factory in factories:
                for win in application.windows:
                    if win.active_task:
                        if win.active_task.id == factory.id:
                            checked = True
                            break
                else:
                    checked = False

                action = myTaskWindowLaunchAction(task_id=factory.id,
                                                  checked=checked)
                # if hasattr(factory, 'size'):
                # action.size = factory.size

                if hasattr(factory, 'accelerator'):
                    action.accelerator = factory.accelerator
                add = True
                if hasattr(factory, 'include_view_menu'):
                    add = factory.include_view_menu

                if hasattr(factory, 'image'):
                    if factory.image:
                        action.image = icon(factory.image)

                if add:
                    items.append(ActionItem(action=action))

            groups.append(TaskGroup(items=items))

        # groups.append(DockPaneToggleGroup())
        return groups
Esempio n. 10
0
    def _dock_panes_updated(self):
        """Recreate the group items when dock panes have been added/removed.
        """

        # Remove the previous group items.
        self.destroy()

        items = []
        for dock_pane in self.dock_panes:
            action = DockPaneToggleAction(dock_pane=dock_pane)
            items.append(ActionItem(action=action))

        items.sort(key=lambda item: item.action.name)
        self.items = items

        # Inform the parent menu manager.
        manager = self.get_manager()
        manager.changed = True
Esempio n. 11
0
 def _get_items(self):
     items = []
     for task in self.window.tasks:
         action = TaskToggleAction(task=task)
         items.append(ActionItem(action=action))
     return items