/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 olive/menu.py

  • Committer: Jelmer Vernooij
  • Date: 2007-01-29 23:27:09 UTC
  • Revision ID: jelmer@samba.org-20070129232709-0yygg83sh9is3xvw
Use decorator for catching and showing bzr-gtk errors graphically. Eventually, this should go away and should be handled by the ui factory.

Show diffs side-by-side

added added

removed removed

Lines of Context:
29
29
from bzrlib.workingtree import WorkingTree
30
30
 
31
31
from dialog import error_dialog, info_dialog, warning_dialog
 
32
from errors import show_bzr_error
32
33
from launch import launch
33
34
from olive import OlivePreferences, DiffWindow
34
35
 
130
131
    def left_context_menu(self):
131
132
        return self.cmenu_left
132
133
    
 
134
    @show_bzr_error
133
135
    def add_file(self, action):
134
136
        """ Right context menu -> Add """
135
137
        import bzrlib.add
143
145
                         _('Please select a file from the list,\nor choose the other option.'))
144
146
            return
145
147
        
146
 
        try:
147
 
            bzrlib.add.smart_add([os.path.join(directory, filename)])
148
 
        except errors.NotBranchError:
149
 
            error_dialog(_('Directory is not a branch'),
150
 
                         _('You can perform this action only in a branch.'))
151
 
            return
 
148
        bzrlib.add.smart_add([os.path.join(directory, filename)])
152
149
    
 
150
    @show_bzr_error
153
151
    def remove_file(self, action):
154
152
        """ Right context menu -> Remove """
155
153
        # Remove only the selected file
161
159
                         _('Please select a file from the list,\nor choose the other option.'))
162
160
            return
163
161
        
164
 
        try:
165
 
            wt, path = WorkingTree.open_containing(os.path.join(directory, filename))
166
 
            wt.remove(path)
167
 
 
168
 
        except errors.NotBranchError:
169
 
            error_dialog(_('Directory is not a branch'),
170
 
                         _('You can perform this action only in a branch.'))
171
 
            return
172
 
        except errors.NotVersionedError:
173
 
            error_dialog(_('File not versioned'),
174
 
                         _('The selected file is not versioned.'))
175
 
            return
176
 
 
 
162
        wt, path = WorkingTree.open_containing(os.path.join(directory, filename))
 
163
        wt.remove(path)
177
164
        self.app.set_path(self.path)
178
165
        self.app.refresh_right()
179
166
 
218
205
        commit = CommitDialog(wt, path, not branch)
219
206
        commit.display()
220
207
    
 
208
    @show_bzr_error
221
209
    def diff(self, action):
222
210
        """ Right context menu -> Diff """
223
 
        try:
224
 
            wt = WorkingTree.open_containing(self.path)[0]
225
 
        except errors.NotBranchError:
226
 
            error_dialog(_('File is not in a branch'),
227
 
                         _('The selected file is not in a branch.'))
228
 
            return
229
 
        
 
211
        wt = WorkingTree.open_containing(self.path)[0]
230
212
        window = DiffWindow()
231
213
        parent_tree = wt.branch.repository.revision_tree(wt.branch.last_revision())
232
214
        window.set_diff(wt.branch.nick, wt, parent_tree)
233
 
        try:
234
 
            window.set_file(wt.relpath(self.path + os.sep + self.selected))
235
 
        except errors.NoSuchFile:
236
 
            error_dialog(_("No diff output"),
237
 
                         _("The selected file hasn't changed."))
238
 
            return
 
215
        window.set_file(wt.relpath(self.path + os.sep + self.selected))
239
216
        window.show()
240
217
    
241
218
    def bookmark(self, action):