/b-gtk/fix-viz

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/b-gtk/fix-viz

« back to all changes in this revision

Viewing changes to push.py

  • Committer: Jelmer Vernooij
  • Date: 2007-07-15 15:13:34 UTC
  • Revision ID: jelmer@samba.org-20070715151334-2t0g8fmpgj6vnqa7
Add icon for Bazaar preferences.

Show diffs side-by-side

added added

removed removed

Lines of Context:
22
22
    
23
23
import gtk
24
24
 
25
 
from olive import delimiter
26
25
from errors import show_bzr_error
27
26
 
28
27
from bzrlib.config import LocationConfig
29
28
import bzrlib.errors as errors
30
29
 
31
 
from olive.dialog import error_dialog, info_dialog, question_dialog
 
30
from dialog import error_dialog, info_dialog, question_dialog
32
31
 
 
32
from history import UrlHistory
33
33
 
34
34
class PushDialog(gtk.Dialog):
35
35
    """ New implementation of the Push dialog. """
88
88
        self.vbox.show_all()
89
89
        
90
90
        # Build location history
 
91
        self._history = UrlHistory(self.branch.get_config(), 'push_history')
91
92
        self._build_history()
92
93
        
93
94
    def _build_history(self):
94
95
        """ Build up the location history. """
95
 
        config = LocationConfig(self.branch.base)
96
 
        history = config.get_user_option('gpush_history')
97
 
        if history is not None:
98
 
            self._combo_model = gtk.ListStore(str)
99
 
            for item in history.split(delimiter):
100
 
                self._combo_model.append([ item ])
101
 
            self._combo.set_model(self._combo_model)
102
 
            self._combo.set_text_column(0)
 
96
        self._combo_model = gtk.ListStore(str)
 
97
        for item in self._history.get_entries():
 
98
            self._combo_model.append([ item ])
 
99
        self._combo.set_model(self._combo_model)
 
100
        self._combo.set_text_column(0)
103
101
        
104
102
        location = self.branch.get_push_location()
105
103
        if location:
106
104
            self._combo.get_child().set_text(location)
107
105
    
108
 
    def _add_to_history(self, location):
109
 
        """ Add specified location to the history (if not yet added). """
110
 
        config = LocationConfig(self.branch.base)
111
 
        history = config.get_user_option('gpush_history')
112
 
        if history is None:
113
 
            config.set_user_option('gpush_history', location)
114
 
        else:
115
 
            h = history.split(delimiter)
116
 
            if location not in h:
117
 
                h.append(location)
118
 
            config.set_user_option('gpush_history', delimiter.join(h))
119
 
    
120
106
    def _on_test_clicked(self, widget):
121
107
        """ Test button clicked handler. """
122
108
        import re
127
113
        m = _urlRE.match(url)
128
114
        if m:
129
115
            proto = m.groupdict()['proto']
130
 
            if (proto == 'sftp') or (proto == 'file') or (proto == 'ftp'):
131
 
                # have write acces (most probably)
 
116
            # FIXME: This should ask the transport or branch rather than 
 
117
            # guessing using regular expressions. JRV 20070714
 
118
            if proto in ('sftp', 'file', 'ftp'):
 
119
                # have write access (most probably)
132
120
                self._image_test.set_from_stock(gtk.STOCK_YES, 4)
133
121
                self._label_test.set_markup(_('<b>Write access is probably available</b>'))
134
122
            else:
158
146
                revs = do_push(self.branch, overwrite=True)
159
147
            return
160
148
        
161
 
        self._add_to_history(location)
 
149
        self._history.add_entry(location)
162
150
        info_dialog(_('Push successful'),
163
151
                    _("%d revision(s) pushed.") % revs)
164
152