/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 checkout.py

Merged an approved request (single clicking bookmark).

Show diffs side-by-side

added added

removed removed

Lines of Context:
24
24
 
25
25
import gtk
26
26
 
27
 
from olive import delimiter
28
27
from errors import show_bzr_error
29
28
 
30
29
from bzrlib.branch import Branch
31
30
from bzrlib.config import GlobalConfig
32
31
 
33
 
from olive.dialog import error_dialog
 
32
from dialog import error_dialog
34
33
 
 
34
from history import UrlHistory
 
35
from olive import Preferences
35
36
 
36
37
class CheckoutDialog(gtk.Dialog):
37
38
    """ New implementation of the Checkout dialog. """
38
 
    def __init__(self, path=None, parent=None):
 
39
    def __init__(self, path=None, parent=None, remote_path=None):
39
40
        """ Initialize the Checkout dialog. """
40
41
        gtk.Dialog.__init__(self, title="Checkout - Olive",
41
42
                                  parent=parent,
64
65
        # Set callbacks
65
66
        self._button_checkout.connect('clicked', self._on_checkout_clicked)
66
67
        self._button_revision.connect('clicked', self._on_revision_clicked)
67
 
        self._combo.connect('changed', self._on_combo_changed)
 
68
        self._combo.child.connect('focus-out-event', self._on_combo_changed)
68
69
        
69
70
        # Create the table and pack the widgets into it
70
71
        self._table = gtk.Table(rows=3, columns=2)
92
93
        self.vbox.set_spacing(3)
93
94
        if self.path is not None:
94
95
            self._filechooser.set_filename(self.path)
 
96
        if remote_path is not None:
 
97
            self._combo.child.set_text(remote_path)
95
98
        
96
99
        # Pack some widgets
97
100
        self._hbox_revision.pack_start(self._entry_revision, True, True)
103
106
        self.vbox.show_all()
104
107
        
105
108
        # Build checkout history
 
109
        self._history = UrlHistory(GlobalConfig(), 'branch_history')
106
110
        self._build_history()
107
111
    
108
112
    def _build_history(self):
109
113
        """ Build up the checkout history. """
110
 
        config = GlobalConfig()
111
 
        history = config.get_user_option('gcheckout_history')
112
 
        if history is not None:
113
 
            self._combo_model = gtk.ListStore(str)
114
 
            for item in history.split(delimiter):
115
 
                self._combo_model.append([ item ])
116
 
            self._combo.set_model(self._combo_model)
117
 
            self._combo.set_text_column(0)
118
 
    
119
 
    def _add_to_history(self, location):
120
 
        """ Add specified location to the history (if not yet added). """
121
 
        config = GlobalConfig()
122
 
        history = config.get_user_option('gcheckout_history')
123
 
        if history is None:
124
 
            config.set_user_option('gcheckout_history', location)
125
 
        else:
126
 
            h = history.split(delimiter)
127
 
            if location not in h:
128
 
                h.append(location)
129
 
            config.set_user_option('gcheckout_history', delimiter.join(h))                
 
114
        self._combo_model = gtk.ListStore(str)
 
115
        
 
116
        for item in self._history.get_entries():
 
117
            self._combo_model.append([ item ])
 
118
        
 
119
        pref = Preferences()
 
120
        for item in pref.get_bookmarks():
 
121
            self._combo_model.append([ item ])
 
122
        
 
123
        self._combo.set_model(self._combo_model)
 
124
        self._combo.set_text_column(0)
130
125
    
131
126
    def _get_last_revno(self):
132
127
        """ Get the revno of the last revision (if any). """
189
184
        
190
185
        br_from.create_checkout(to_location, revision_id, lightweight)
191
186
        
192
 
        self._add_to_history(location)
 
187
        self._history.add_entry(location)
193
188
        
194
189
        self.response(gtk.RESPONSE_OK)
195
190
    
196
 
    def _on_combo_changed(self, widget):
 
191
    def _on_combo_changed(self, widget, event):
197
192
        """ We try to get the last revision if focus lost. """
198
193
        rev = self._get_last_revno()
199
194
        if rev is None: