Example #1
0
    def set_parent(self, v, first, type_):

        ans = []
        for i in self.buttons:
            if i[0].target is v and i[0].first == first and i[0].type_ == type_:
                ans.append(i)

        if not ans:
            g.es("Didn't find button")
            return
        elif len(ans) != 1:
            g.es("Note: found multiple %s/first=%s buttons, using first" %
                 (type_, first))

        qmb, b = ans[0]

        # need to set 'parent' key in v.u['quickMove'] list item to gnx of parent

        parents = [[i[0].targetHeadString, False, i[0]] for i in self.buttons
                   if i[0] is not qmb and not i[0].has_parent]

        if not parents:
            g.es("No suitable Move buttons found")
            return

        ld = ListDialog(None, 'Pick parent', 'Pick parent', parents)
        ld.exec_()

        if ld.result() == QtGui.QDialog.Rejected:
            return

        for i in parents:
            if i[1]:
                parent = i[2].target
                break
        else:
            return

        if 'quickMove' not in v.u or 'buttons' not in v.u['quickMove']:
            # make button permanent first
            self.permanentButton(v=v, type_=type_, first=first)

        for i in v.u['quickMove']['buttons']:
            if i['type'] == qmb.type_ and i['first'] == qmb.first:
                i['parent'] = parent.gnx
                break
        else:
            v.u['quickMove']['buttons'].append({
                'type': qmb.type_,
                'first': qmb.first,
                'parent': parent.gnx
            })

        self.addButton(qmb.first, qmb.type_, v=qmb.target, parent=parent.gnx)
        self.buttons = [i for i in self.buttons if i[0] is not qmb]
        print(b)
        b.button.parent().layout().removeWidget(b.button)

        g.es('Moved to parent')
Example #2
0
    def select_screen(self):
        """select_screen - select which screen session to target
        """
        cmd = ['screen', '-ls']
        proc = subprocess.Popen(cmd,
                                stdout=subprocess.PIPE,
                                stderr=subprocess.PIPE)
        out, err = proc.communicate()

        screens = [[('CURRENT: ' if i == self.use_screen else '') + i, False,
                    i] for i in out.split('\n') if i.startswith('\t')]

        ld = ListDialog(None, 'Pick screen', 'Pick screen', screens)
        ld.exec_()

        screen = [i for i in screens if i[1]]
        if screen:
            self.use_screen = screen[0][2]
        else:
            self.use_screen = None