示例#1
0
    def __init__(self, parent, app, title, icon_name):
        self.app = app

        Popup.__init__(self, parent)
        self.part_text_set('title,text', title)
        self.part_content_set('title,icon', Icon(self, standard=icon_name))
        
        # TODO padding should be (4,4) but it seems buggy for the big entry
        tb = Table(self, padding=(0,4), size_hint_expand=EXPAND_BOTH)
        self.content = tb
        tb.show()
        self.table = tb

        # sep
        sep = Separator(self, horizontal=True, size_hint_expand=EXPAND_BOTH)
        tb.pack(sep, 0, 0, 2, 1)
        sep.show()

        # remote
        lb = Label(tb, text='Remote', size_hint_align=(0.0, 0.5))
        tb.pack(lb, 0, 1, 1, 1)
        lb.show()

        cb = ComboBox(self, icon=Icon(self, standard='git-remote'))
        cb.callback_selected_add(self.rbranch_populate)
        for remote in app.repo.remotes:
            cb.item_append(remote.name, 'git-remote')
        tb.pack(cb, 1, 1, 1, 1)
        cb.show()
        self.remote_combo = cb

        # remote branch
        lb = Label(tb, text='Remote branch', size_hint_align=(0.0, 0.5))
        tb.pack(lb, 0, 2, 1, 1)
        lb.show()

        cb = ComboBox(self, icon=Icon(cb, standard='git-branch'))
        tb.pack(cb, 1, 2, 1, 1)
        cb.show()
        self.rbranch_combo = cb

        # local branch
        lb = Label(tb, text='Local branch', size_hint_align=(0.0, 0.5))
        tb.pack(lb, 0, 3, 1, 1)
        lb.show()

        en = Entry(tb, disabled=True, single_line=True, scrollable=True,
                   text=app.repo.status.current_branch.name,
                   size_hint_expand=EXPAND_BOTH, size_hint_fill=FILL_BOTH)
        tb.pack(en, 1, 3, 1, 1)
        en.show()
        self.lbranch_entry = en

        # output entry
        en = CommandOutputEntry(self, min_size=(400, 150))
        tb.pack(en, 0, 4, 2, 1)
        en.show()
        self.output_entry = en

        # sep
        sep = Separator(self, horizontal=True, size_hint_expand=EXPAND_BOTH)
        tb.pack(sep, 0, 5, 2, 1)
        sep.show()

        # buttons
        bt = Button(self, text='Close')
        bt.callback_clicked_add(lambda b: self.delete())
        self.part_content_set('button1', bt)
        bt.show()
        self.close_btn = bt

        bt = Button(self, text='Action')
        bt.callback_clicked_add(self._action_btn_cb)
        self.part_content_set('button2', bt)
        bt.show()
        self.action_btn = bt

        self.autopopulate()
        self.show()
示例#2
0
文件: compare.py 项目: DaveMDS/egitu
    def __init__(self, parent, app, target=None):
        self.app = app
        self._selected_item = None

        DialogWindow.__init__(self, parent, 'Egitu-compare', 'Compare tool',
                              size=(500,500), autodel=True)

        # main vertical box (inside a padding frame)
        vbox = Box(self, padding=(0, 6), size_hint_expand=EXPAND_BOTH,
                   size_hint_fill=FILL_BOTH)
        fr = Frame(self, style='pad_medium', size_hint_expand=EXPAND_BOTH)
        self.resize_object_add(fr)
        fr.content = vbox
        fr.show()
        vbox.show()

        # two combos
        hbox = Box(self, horizontal=True, padding=(6,0),
                   size_hint_expand=EXPAND_HORIZ, size_hint_fill=FILL_HORIZ)
        vbox.pack_end(hbox)
        hbox.show()

        cb1 = ComboBox(self, text=app.repo.status.current_branch.name)
        cb1.icon = SafeIcon(cb1, 'git-branch')
        cb1.callback_selected_add(lambda c: self.compare())
        hbox.pack_end(cb1)
        cb1.show()
        self.base_combo = cb1

        lb = Label(self, text='<b>...</b>', size_hint_align=(0.5,1.0))
        hbox.pack_end(lb)
        lb.show()

        cb2 = ComboBox(self, text=target or app.repo.status.current_branch.name)
        cb2.icon = SafeIcon(cb1, 'git-branch')
        cb2.callback_selected_add(lambda c: self.compare())
        hbox.pack_end(cb2)
        cb2.show()
        self.compare_combo = cb2

        for branch in app.repo.branches:
            cb1.item_append(branch.name, 'git-branch')
            cb2.item_append(branch.name, 'git-branch')
        for branch in app.repo.remote_branches:
            cb1.item_append(branch, 'git-branch')
            cb2.item_append(branch, 'git-branch')
        for tag in app.repo.tags:
            cb1.item_append(tag.name, 'git-tag')
            cb2.item_append(tag.name, 'git-tag')

        # vertical panes
        panes = Panes(self, horizontal=True, content_left_size=0.25,
                      size_hint_expand=EXPAND_BOTH, size_hint_fill=FILL_BOTH)
        vbox.pack_end(panes)
        panes.show()

        # commit list (inside a frame)
        li = CommitsList(panes, select_mode=ELM_OBJECT_SELECT_MODE_ALWAYS)
        li.callback_selected_add(self._list_selected_cb)
        li.show()
        self.commits_list = li

        fr = Frame(panes, content=li)
        panes.part_content_set('left', fr)
        fr.show()
        self.commits_frame = fr

        # diff
        de = DiffedEntry(panes)
        panes.part_content_set('right', de)
        de.show()
        self.diff_entry = de

        # buttons
        hbox = Box(self, horizontal=True,
                   size_hint_expand=EXPAND_HORIZ, size_hint_fill=FILL_BOTH)
        vbox.pack_end(hbox)
        hbox.show()

        bt = Button(self, text='Merge', content=SafeIcon(self, 'git-merge'))
        bt.callback_clicked_add(lambda b: MergeBranchPopup(self, self.app,
                                                    self.compare_combo.text))
        hbox.pack_end(bt)
        bt.show()
        self.merge_btn = bt

        lb = Entry(self, single_line=True, editable=False)
        hbox.pack_end(lb)
        lb.show()
        self.merge_label = lb

        sep = Separator(self, size_hint_expand=EXPAND_HORIZ)
        hbox.pack_end(sep)

        bt = Button(self, text='Close')
        bt.callback_clicked_add(lambda b: self.delete())
        hbox.pack_end(bt)
        bt.show()

        #
        self.compare()
        self.show()