/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-02-03 15:04:56 UTC
  • Revision ID: jelmer@samba.org-20070203150456-t3ednkxql05rzg0m
Add trivial generic class for storing URL history.

Show diffs side-by-side

added added

removed removed

Lines of Context:
29
29
 
30
30
from dialog import error_dialog, info_dialog, question_dialog
31
31
 
32
 
from olive import delimiter
 
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
158
144
                revs = do_push(self.branch, overwrite=True)
159
145
            return
160
146
        
161
 
        self._add_to_history(location)
 
147
        self._history.add_entry(location)
162
148
        info_dialog(_('Push successful'),
163
149
                    _("%d revision(s) pushed.") % revs)
164
150