def __init__(self): """ Initialize the Dialog. """ gtk.Window.__init__(self, gtk.WINDOW_TOPLEVEL) gtklib.set_tortoise_icon(self, 'general.ico') gtklib.set_tortoise_keys(self) self.set_default_size(600, 400) self.connect('delete-event', self._delete) self.hgthread = None self.inprogress = False self.last_pbar_update = 0 try: repo = hg.repository(ui.ui(), path=paths.find_root()) except error.RepoError: gtklib.idle_add_single_call(self.destroy) return self.repo = repo self.reponame = hglib.get_reponame(repo) self.set_title(_('%s - recovery') % self.reponame) # toolbar self.tbar = gtk.Toolbar() self.tips = gtklib.Tooltips() self._stop_button = self._toolbutton(gtk.STOCK_STOP, _('Stop'), self._stop_clicked, tip=_('Stop the hg operation')) self._stop_button.set_sensitive(False) tbuttons = [ self._toolbutton(gtk.STOCK_CLEAR, _('Clean'), self._clean_clicked, tip=_('Clean checkout, undo all changes')), gtk.SeparatorToolItem(), self._toolbutton(gtk.STOCK_UNDO, _('Rollback'), self._rollback_clicked, tip=_('Rollback (undo) last transaction to ' 'repository (pull, commit, etc)')), gtk.SeparatorToolItem(), self._toolbutton(gtk.STOCK_CLEAR, _('Recover'), self._recover_clicked, tip=_('Recover from interrupted operation')), gtk.SeparatorToolItem(), self._toolbutton(gtk.STOCK_APPLY, _('Verify'), self._verify_clicked, tip=_('Validate repository consistency')), gtk.SeparatorToolItem(), self._stop_button, gtk.SeparatorToolItem(), ] for btn in tbuttons: self.tbar.insert(btn, -1) vbox = gtk.VBox() self.add(vbox) vbox.pack_start(self.tbar, False, False, 2) # hg output window scrolledwindow = gtk.ScrolledWindow() scrolledwindow.set_shadow_type(gtk.SHADOW_ETCHED_IN) scrolledwindow.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC) self.textview = gtk.TextView(buffer=None) self.textview.set_editable(False) fontlog = hglib.getfontconfig()['fontlog'] self.textview.modify_font(pango.FontDescription(fontlog)) scrolledwindow.add(self.textview) self.textbuffer = self.textview.get_buffer() gtklib.configstyles(repo.ui) for tag, argdict in gtklib.TextBufferTags.iteritems(): self.textbuffer.create_tag(tag, **argdict) vbox.pack_start(scrolledwindow, True, True) self.progstat = gtk.Label() vbox.pack_start(self.progstat, False, False, 0) self.progstat.set_alignment(0, 0.5) self.progstat.set_ellipsize(pango.ELLIPSIZE_END) self.pbar = gtk.ProgressBar() vbox.pack_start(self.pbar, False, False, 2)
def __init__(self, cmdline, progressbar=True, text=None): if type(cmdline) is tuple: self.cmdlist = list(cmdline)[1:] cmdline = cmdline[0] else: self.cmdlist = [] title = text or ' '.join(cmdline) if len(title) > 80: title = hglib.tounicode(title)[:80] + '...' title = hglib.toutf(title.replace('\n', ' ')) gtk.Dialog.__init__(self, title=title, flags=gtk.DIALOG_MODAL) self.set_has_separator(False) gtklib.set_tortoise_icon(self, 'hg.ico') gtklib.set_tortoise_keys(self) self.cmdline = cmdline self.returncode = None self.hgthread = None self.set_default_size(520, 400) self._button_stop = gtk.Button(_('Stop')) self._button_stop.connect('clicked', self._on_stop_clicked) self.action_area.pack_start(self._button_stop) self._button_ok = gtk.Button(_('Close')) self._button_ok.connect('clicked', self._on_ok_clicked) self.action_area.pack_start(self._button_ok) self.connect('thg-accept', self._on_ok_clicked) self.connect('delete-event', self._delete) self.connect('response', self._response) self.pbar = None if progressbar: self.last_pbar_update = 0 hbox = gtk.HBox() self.status_text = gtk.Label() self.status_text.set_text(title) self.status_text.set_alignment(0, 0.5) self.status_text.set_ellipsize(pango.ELLIPSIZE_END) hbox.pack_start(self.status_text, True, True, 3) # Create a centering alignment object align = gtk.Alignment(0.0, 0.0, 1, 0) hbox.pack_end(align, False, False, 3) align.show() # create the progress bar self.pbar = gtk.ProgressBar() align.add(self.pbar) self.pbar.pulse() self.pbar.show() self.vbox.pack_start(hbox, False, False, 3) scrolledwindow = gtk.ScrolledWindow() scrolledwindow.set_shadow_type(gtk.SHADOW_ETCHED_IN) scrolledwindow.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC) self.textview = gtk.TextView(buffer=None) self.textview.set_editable(False) fontlog = hglib.getfontconfig()['fontlog'] self.textview.modify_font(pango.FontDescription(fontlog)) scrolledwindow.add(self.textview) self.textbuffer = self.textview.get_buffer() gtklib.configstyles(ui.ui()) for tag, argdict in gtklib.TextBufferTags.iteritems(): self.textbuffer.create_tag(tag, **argdict) self.vbox.pack_start(scrolledwindow, True, True) self.connect('map_event', self._on_window_map_event) self.show_all()
def __init__(self, repos=[], pushmode=False): """ Initialize the Dialog. """ gtk.Window.__init__(self, gtk.WINDOW_TOPLEVEL) gtklib.set_tortoise_icon(self, 'menusynch.ico') gtklib.set_tortoise_keys(self) self.root = paths.find_root() self.selected_path = None self.hgthread = None self.notify_func = None self.last_drop_time = None self.lastcmd = [] # persistent app data self._settings = settings.Settings('synch') self.set_default_size(655, 552) self.paths = self.get_paths() self.set_title(_('%s - synchronize') % hglib.get_reponame(self.repo)) self.connect('delete-event', self.delete) # toolbar self.tbar = gtk.Toolbar() self.tips = gtklib.Tooltips() self.stop_button = self.toolbutton(gtk.STOCK_STOP, _('Stop'), self.stop_clicked, tip=_('Stop the hg operation')) self.stop_button.set_sensitive(False) tbuttons = [ self.toolbutton(gtk.STOCK_GO_DOWN, _('Incoming'), self.incoming_clicked, tip=_('Display changes that can be pulled ' 'from selected repository')), self.toolbutton(gtk.STOCK_GOTO_BOTTOM, _(' Pull '), self.pull_clicked, tip=_('Pull changes from selected ' 'repository')), gtk.SeparatorToolItem(), self.toolbutton(gtk.STOCK_GO_UP, _('Outgoing'), self.outgoing_clicked, tip=_('Display local changes that will be ' 'pushed to selected repository')), self.toolbutton(gtk.STOCK_GOTO_TOP, _('Push'), self.push_clicked, tip=_('Push local changes to selected ' 'repository')), self.toolbutton(gtk.STOCK_GOTO_LAST, _('Email'), self.email_clicked, tip=_('Email local outgoing changes to ' 'one or more recipients')), self.toolbutton(gtk.STOCK_UNDO, _('Shelve'), self.shelve_clicked, tip=_('Shelve uncommited changes')), gtk.SeparatorToolItem(), self.stop_button, gtk.SeparatorToolItem(), self.toolbutton(gtk.STOCK_PREFERENCES, _('Configure'), self.conf_clicked, tip=_('Configure peer repository paths')), gtk.SeparatorToolItem(), ] for btn in tbuttons: self.tbar.insert(btn, -1) # Base box self.basevbox = basevbox = gtk.VBox() self.add(basevbox) basevbox.pack_start(self.tbar, False, False, 2) # Sync Target Path targethbox = gtk.HBox() ## target selection buttons lbl = gtk.Button(_('Repo:')) lbl.unset_flags(gtk.CAN_FOCUS) lbl.connect('clicked', self.btn_remotepath_clicked) targethbox.pack_start(lbl, False, False) lbl = gtk.Button(_('Bundle:')) lbl.unset_flags(gtk.CAN_FOCUS) lbl.connect('clicked', self.btn_bundlepath_clicked) targethbox.pack_start(lbl, False, False) ## target path combobox self.pathlist = gtk.ListStore(str, str) self.pathbox = gtk.ComboBoxEntry(self.pathlist, 0) self.pathtext = self.pathbox.get_child() cell = gtk.CellRendererText() self.pathbox.pack_end(cell, False) self.pathbox.add_attribute(cell, 'text', 1) targethbox.pack_start(self.pathbox, True, True) self.fill_path_combo() defrow = None defpushrow = None for i, (path, alias) in enumerate(self.pathlist): if alias == 'default': defrow = i if defpushrow is None: defpushrow = i elif alias == 'default-push': defpushrow = i if repos: self.pathtext.set_text(hglib.toutf(repos[0])) elif defpushrow is not None and pushmode: self.pathbox.set_active(defpushrow) elif defrow is not None: self.pathbox.set_active(defrow) exs = [ name for name, module in extensions.extensions() ] # Post Pull Operation ppullhbox = gtk.HBox() self.ppulldata = [('none', _('Nothing')), ('update', _('Update'))] cfg = self.repo.ui.config('tortoisehg.postpull', 'none') if 'fetch' in exs or 'fetch' == cfg: self.ppulldata.append(('fetch', _('Fetch'))) if 'rebase' in exs or 'rebase' == cfg: self.ppulldata.append(('rebase', _('Rebase'))) self.ppullcombo = combo = gtk.combo_box_new_text() for (index, (name, label)) in enumerate(self.ppulldata): combo.insert_text(index, label) ppullhbox.pack_start(gtk.Label(_('Post Pull: ')), False, False, 2) ppullhbox.pack_start(self.ppullcombo, True, True) # Fixed options box (non-foldable) fixedhbox = gtk.HBox() fixedhbox.pack_start(targethbox, True, True, 2) fixedhbox.pack_start(ppullhbox, False, False, 2) # Advanced options (foldable) opthbox = gtk.HBox() self.expander = expander = gtk.Expander(_('Advanced Options')) expander.set_expanded(False) expander.connect_after('activate', self.expanded) expander.add(opthbox) ## checkbox options chkopthbox = gtk.HBox() self.force = gtk.CheckButton(_('Force pull or push')) self.tips.set_tip(self.force, _('Run even when remote repository is unrelated.')) self.newbranch = gtk.CheckButton(_('Push new branch')) self.tips.set_tip(self.newbranch, _('Allow pushing a new branch')) self.use_proxy = gtk.CheckButton(_('Use proxy server')) if ui.ui().config('http_proxy', 'host', ''): self.use_proxy.set_active(True) else: self.use_proxy.set_sensitive(False) chkopthbox.pack_start(self.force, False, False, 4) chkopthbox.pack_start(self.newbranch, False, False, 4) chkopthbox.pack_start(self.use_proxy, False, False, 4) ## target revision option revhbox = gtk.HBox() self.reventry = gtk.Entry() revhbox.pack_start(gtk.Label(_('Target revision:')), False, False, 2) revhbox.pack_start(self.reventry, True, True, 2) reveventbox = gtk.EventBox() reveventbox.add(revhbox) self.tips.set_tip(reveventbox, _('A specific revision up to which you ' 'would like to push or pull.')) ## remote command option cmdhbox = gtk.HBox() self.cmdentry = gtk.Entry() cmdhbox.pack_start(gtk.Label(_('Remote command:')), False, False, 2) cmdhbox.pack_start(self.cmdentry, True, True, 2) cmdeventbox = gtk.EventBox() cmdeventbox.add(cmdhbox) self.tips.set_tip(cmdeventbox, _('Name of hg executable on remote machine.')) revvbox = gtk.VBox() revvbox.pack_start(chkopthbox, False, False, 8) revvbox.pack_start(reveventbox, False, False, 4) revvbox.pack_start(cmdeventbox, False, False, 4) opthbox.pack_start(revvbox, True, True, 4) ## incoming/outgoing options frame = gtk.Frame(_('Incoming/Outgoing')) opthbox.pack_start(frame, False, False, 2) self.showpatch = gtk.CheckButton(_('Show patches')) self.newestfirst = gtk.CheckButton(_('Show newest first')) self.nomerge = gtk.CheckButton(_('Show no merges')) iovbox = gtk.VBox() iovbox.pack_start(self.showpatch, False, False, 2) iovbox.pack_start(self.newestfirst, False, False, 2) iovbox.pack_start(self.nomerge, False, False, 2) frame.add(iovbox) # Main option box topvbox = gtk.VBox() topvbox.pack_start(fixedhbox, True, True, 2) topvbox.pack_start(expander, False, False, 2) basevbox.pack_start(topvbox, False, False, 2) # hg output window scrolledwindow = gtk.ScrolledWindow() scrolledwindow.set_shadow_type(gtk.SHADOW_ETCHED_IN) scrolledwindow.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC) self.textview = gtk.TextView(buffer=None) self.textview.set_editable(False) fontlog = hglib.getfontconfig()['fontlog'] self.textview.modify_font(pango.FontDescription(fontlog)) scrolledwindow.add(self.textview) self.textview.connect('populate-popup', self.add_to_popup) self.textbuffer = self.textview.get_buffer() gtklib.configstyles(self.repo.ui) for tag, argdict in gtklib.TextBufferTags.iteritems(): self.textbuffer.create_tag(tag, **argdict) basevbox.pack_start(scrolledwindow, True, True) # statusbar self.stbar = statusbar.StatusBar() basevbox.pack_end(self.stbar, False, False, 2) # support dropping of repos or bundle files self.drag_dest_set(gtk.DEST_DEFAULT_ALL, [("text/uri-list", 0, 1)], gtk.gdk.ACTION_COPY) self.connect('drag_data_received', self._drag_receive) # prepare to show self.load_settings() self.update_pull_setting() gtklib.idle_add_single_call(self.finalize_startup)