/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 branch.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:
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
import bzrlib.errors as errors
33
32
 
34
 
from olive.dialog import error_dialog, info_dialog
 
33
from dialog import error_dialog, info_dialog
35
34
 
 
35
from history import UrlHistory
 
36
from olive import Preferences
36
37
 
37
38
class BranchDialog(gtk.Dialog):
38
39
    """ New implementation of the Branch dialog. """
39
 
    def __init__(self, path=None, parent=None):
 
40
 
 
41
    def __init__(self, path=None, parent=None, remote_path=None):
40
42
        """ Initialize the Branch dialog. """
41
43
        gtk.Dialog.__init__(self, title="Branch - Olive",
42
44
                                  parent=parent,
63
65
        # Set callbacks
64
66
        self._button_branch.connect('clicked', self._on_branch_clicked)
65
67
        self._button_revision.connect('clicked', self._on_revision_clicked)
66
 
        self._combo.connect('changed', self._on_combo_changed)
 
68
        self._combo.child.connect('focus-out-event', self._on_combo_changed)
67
69
        
68
70
        # Create the table and pack the widgets into it
69
71
        self._table = gtk.Table(rows=3, columns=2)
90
92
        self.vbox.set_spacing(3)
91
93
        if self.path is not None:
92
94
            self._filechooser.set_filename(self.path)
 
95
        if remote_path is not None:
 
96
            self._combo.child.set_text(remote_path)
93
97
        
94
98
        # Pack some widgets
95
99
        self._hbox_revision.pack_start(self._entry_revision, True, True)
101
105
        self.vbox.show_all()
102
106
        
103
107
        # Build branch history
 
108
        self._history = UrlHistory(GlobalConfig(), 'branch_history')
104
109
        self._build_history()
105
110
    
106
111
    def _build_history(self):
107
112
        """ Build up the branch history. """
108
 
        config = GlobalConfig()
109
 
        history = config.get_user_option('gbranch_history')
110
 
        if history is not None:
111
 
            self._combo_model = gtk.ListStore(str)
112
 
            for item in history.split(delimiter):
113
 
                self._combo_model.append([ item ])
114
 
            self._combo.set_model(self._combo_model)
115
 
            self._combo.set_text_column(0)
116
 
    
117
 
    def _add_to_history(self, location):
118
 
        """ Add specified location to the history (if not yet added). """
119
 
        config = GlobalConfig()
120
 
        history = config.get_user_option('gbranch_history')
121
 
        if history is None:
122
 
            config.set_user_option('gbranch_history', location)
123
 
        else:
124
 
            h = history.split(delimiter)
125
 
            if location not in h:
126
 
                h.append(location)
127
 
            config.set_user_option('gbranch_history', delimiter.join(h))                
 
113
        self._combo_model = gtk.ListStore(str)
 
114
        
 
115
        for item in self._history.get_entries():
 
116
            self._combo_model.append([ item ])
 
117
        
 
118
        pref = Preferences()
 
119
        for item in pref.get_bookmarks():
 
120
            self._combo_model.append([ item ])
 
121
        
 
122
        self._combo.set_model(self._combo_model)
 
123
        self._combo.set_text_column(0)
128
124
    
129
125
    def _get_last_revno(self):
130
126
        """ Get the revno of the last revision (if any). """
205
201
        finally:
206
202
            br_from.unlock()
207
203
                
208
 
        self._add_to_history(location)
 
204
        self._history.add_entry(location)
209
205
        info_dialog(_('Branching successful'),
210
206
                    _('%d revision(s) branched.') % revs)
211
207
        
212
208
        self.response(gtk.RESPONSE_OK)
213
209
    
214
 
    def _on_combo_changed(self, widget):
 
210
    def _on_combo_changed(self, widget, event):
215
211
        """ We try to get the last revision if focus lost. """
216
212
        rev = self._get_last_revno()
217
213
        if rev is None: