/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: 2008-06-29 18:31:29 UTC
  • mto: This revision was merged to the branch mainline in revision 518.
  • Revision ID: jelmer@samba.org-20080629183129-syqvz3xm5gqagzsx
Fix use of smart_add.

Show diffs side-by-side

added added

removed removed

Lines of Context:
30
30
import bzrlib.errors as errors
31
31
from bzrlib.workingtree import WorkingTree
32
32
 
 
33
from bzrlib.plugins.gtk import _i18n
33
34
from bzrlib.plugins.gtk.dialog import error_dialog, info_dialog, question_dialog, warning_dialog
34
35
from bzrlib.plugins.gtk.errors import show_bzr_error
35
36
from bzrlib.plugins.gtk.annotate.gannotate import GAnnotateWindow
36
37
from bzrlib.plugins.gtk.annotate.config import GAnnotateConfig
37
38
from bzrlib.plugins.gtk.diff import DiffWindow
38
39
from launch import launch
39
 
from olive import Preferences
 
40
from bzrlib.plugins.gtk.olive import Preferences
40
41
 
41
42
class OliveMenu:
42
43
    """ This class is responsible for building the context menus. """
59
60
        
60
61
        self.actiongroup = gtk.ActionGroup('context')
61
62
        self.actiongroup.add_actions([('add', gtk.STOCK_ADD,
62
 
                                       _('Add'), None,
63
 
                                       _('Add the selected file'),
 
63
                                       _i18n('Add'), None,
 
64
                                       _i18n('Add the selected file'),
64
65
                                       self.add_file),
65
66
                                      ('remove', gtk.STOCK_REMOVE,
66
 
                                       _('Remove'), None,
67
 
                                       _('Remove the selected file'),
 
67
                                       _i18n('Remove'), None,
 
68
                                       _i18n('Remove the selected file'),
68
69
                                       self.remove_file),
69
70
                                      ('remove_and_delete', gtk.STOCK_REMOVE,
70
 
                                       _('Remove and delete'), None,
71
 
                                       _('Remove the selected file/dir and delete from disk'),
 
71
                                       _i18n('Remove and delete'), None,
 
72
                                       _i18n('Remove the selected file/dir and delete from disk'),
72
73
                                       self.remove_and_delete_file),
73
74
                                      ('rename', None,
74
 
                                       _('Rename'), None,
75
 
                                       _('Rename the selected file'),
 
75
                                       _i18n('Rename'), None,
 
76
                                       _i18n('Rename the selected file'),
76
77
                                       self.rename_file),
77
78
                                      ('open', gtk.STOCK_OPEN,
78
 
                                       _('Open'), None,
79
 
                                       _('Open the selected file'),
 
79
                                       _i18n('Open'), None,
 
80
                                       _i18n('Open the selected file'),
80
81
                                       self.open_file),
81
82
                                      ('revert', None,
82
 
                                       _('Revert'), None,
83
 
                                       _('Revert the changes'),
 
83
                                       _i18n('Revert'), None,
 
84
                                       _i18n('Revert the changes'),
84
85
                                       self.revert),
85
86
                                      ('commit', None,
86
 
                                       _('Commit'), None,
87
 
                                       _('Commit the changes'),
 
87
                                       _i18n('Commit'), None,
 
88
                                       _i18n('Commit the changes'),
88
89
                                       self.commit),
89
90
                                      ('annotate', None,
90
 
                                       _('Annotate'), None,
91
 
                                       _('Annotate the selected file'),
 
91
                                       _i18n('Annotate'), None,
 
92
                                       _i18n('Annotate the selected file'),
92
93
                                       self.annotate),
93
94
                                      ('diff', None,
94
 
                                       _('Diff'), None,
95
 
                                       _('Show the diff of the file'),
 
95
                                       _i18n('Diff'), None,
 
96
                                       _i18n('Show the diff of the file'),
96
97
                                       self.diff),
97
98
                                      ('bookmark', None,
98
 
                                       _('Bookmark'), None,
99
 
                                       _('Bookmark current location'),
 
99
                                       _i18n('Bookmark'), None,
 
100
                                       _i18n('Bookmark current location'),
100
101
                                       self.bookmark),
101
102
                                      ('edit_bookmark', gtk.STOCK_EDIT,
102
 
                                       _('Edit'), None,
103
 
                                       _('Edit the selected bookmark'),
 
103
                                       _i18n('Edit'), None,
 
104
                                       _i18n('Edit the selected bookmark'),
104
105
                                       self.edit_bookmark),
105
106
                                      ('remove_bookmark', gtk.STOCK_REMOVE,
106
 
                                       _('Remove'), None,
107
 
                                       _('Remove the selected bookmark'),
 
107
                                       _i18n('Remove'), None,
 
108
                                       _i18n('Remove the selected bookmark'),
108
109
                                       self.remove_bookmark),
109
110
                                      ('open_folder', gtk.STOCK_OPEN,
110
 
                                       _('Open Folder'), None,
111
 
                                       _('Open bookmark folder in Nautilus'),
 
111
                                       _i18n('Open Folder'), None,
 
112
                                       _i18n('Open bookmark folder in Nautilus'),
112
113
                                       self.open_folder),
113
114
                                      ('diff_selected', None,
114
 
                                       _('Selected...'), None,
115
 
                                       _('Show the differences of the selected file'),
 
115
                                       _i18n('Selected...'), None,
 
116
                                       _i18n('Show the differences of the selected file'),
116
117
                                       self.diff_selected),
117
118
                                      ('diff_all', None,
118
 
                                       _('All...'), None,
119
 
                                       _('Show the differences of all files'),
 
119
                                       _i18n('All...'), None,
 
120
                                       _i18n('Show the differences of all files'),
120
121
                                       self.diff_all),
121
122
                                      ('view_remote', None,
122
 
                                       _('View contents'), None,
123
 
                                       _('View the contents of the file in a builtin viewer'),
 
123
                                       _i18n('View contents'), None,
 
124
                                       _i18n('View the contents of the file in a builtin viewer'),
124
125
                                       self.view_remote),
125
126
                                      ('diff_remote', None,
126
 
                                       _('Show differences'), None,
127
 
                                       _('Show the differences between two revisions of the file'),
 
127
                                       _i18n('Show differences'), None,
 
128
                                       _i18n('Show the differences between two revisions of the file'),
128
129
                                       self.diff_remote),
129
130
                                      ('revert_remote', None,
130
 
                                       _('Revert to this revision'), None,
131
 
                                       _('Revert the selected file to the selected revision'),
 
131
                                       _i18n('Revert to this revision'), None,
 
132
                                       _i18n('Revert the selected file to the selected revision'),
132
133
                                       self.revert_remote)
133
134
                                     ])
134
135
        
174
175
        filename = self.selected
175
176
            
176
177
        if filename is None:
177
 
            error_dialog(_('No file was selected'),
178
 
                         _('Please select a file from the list,\nor choose the other option.'))
 
178
            error_dialog(_i18n('No file was selected'),
 
179
                         _i18n('Please select a file from the list,\nor choose the other option.'))
179
180
            return
180
181
        
181
 
        bzrlib.add.smart_add([os.path.join(directory, filename)])
 
182
        wt, path = WorkingTree.open_containing(os.path.join(directory, filename))
 
183
        wt.add([path])
182
184
    
183
185
    @show_bzr_error
184
186
    def annotate(self, action):
187
189
        filename = self.selected
188
190
        
189
191
        if filename is None:
190
 
            error_dialog(_('No file was selected'),
191
 
                         _('Please select a file from the list.'))
 
192
            error_dialog(_i18n('No file was selected'),
 
193
                         _i18n('Please select a file from the list.'))
192
194
            return
193
195
        
194
196
        wt, path = WorkingTree.open_containing(os.path.join(directory, filename))
214
216
        filename = self.selected
215
217
        
216
218
        if filename is None:
217
 
            error_dialog(_('No file was selected'),
218
 
                         _('Please select a file from the list,\nor choose the other option.'))
 
219
            error_dialog(_i18n('No file was selected'),
 
220
                         _i18n('Please select a file from the list,\nor choose the other option.'))
219
221
            return
220
222
        
221
223
        wt, path = WorkingTree.open_containing(os.path.join(directory, filename))
224
226
        if delete_on_disk:
225
227
            abs_filename = os.path.join(directory,filename)
226
228
            if os.path.isdir(abs_filename):
227
 
                response = question_dialog(_('Delete directory with all directories below ?'), abs_filename )
 
229
                response = question_dialog(_i18n('Delete directory with all directories below ?'), abs_filename )
228
230
                if response == gtk.RESPONSE_YES:
229
231
                    shutil.rmtree(abs_filename)
230
232
            else:
250
252
        filename = self.selected
251
253
        
252
254
        if filename is None:
253
 
            error_dialog(_('No file was selected'),
254
 
                         _('Please select a file from the list,\nor choose the other option.'))
 
255
            error_dialog(_i18n('No file was selected'),
 
256
                         _i18n('Please select a file from the list,\nor choose the other option.'))
255
257
            return
256
258
 
257
259
        if filename == '..':
271
273
        wt, path = WorkingTree.open_containing(self.path)
272
274
        ret = wt.revert([os.path.join(path, self.selected)])
273
275
        if ret:
274
 
            warning_dialog(_('Conflicts detected'),
275
 
                           _('Please have a look at the working tree before continuing.'))
 
276
            warning_dialog(_i18n('Conflicts detected'),
 
277
                           _i18n('Please have a look at the working tree before continuing.'))
276
278
        else:
277
 
            info_dialog(_('Revert successful'),
278
 
                        _('All files reverted to last revision.'))
 
279
            info_dialog(_i18n('Revert successful'),
 
280
                        _i18n('All files reverted to last revision.'))
279
281
        self.app.refresh_right()       
280
282
    
281
283
    def commit(self, action):
315
317
    def bookmark(self, action):
316
318
        """ Right context menu -> Bookmark """
317
319
        if self.pref.add_bookmark(self.path):
318
 
            info_dialog(_('Bookmark successfully added'),
319
 
                        _('The current directory was bookmarked. You can reach\nit by selecting it from the left panel.'))
 
320
            info_dialog(_i18n('Bookmark successfully added'),
 
321
                        _i18n('The current directory was bookmarked. You can reach\nit by selecting it from the left panel.'))
320
322
            self.pref.write()
321
323
        else:
322
 
            warning_dialog(_('Location already bookmarked'),
323
 
                           _('The current directory is already bookmarked.\nSee the left panel for reference.'))
 
324
            warning_dialog(_i18n('Location already bookmarked'),
 
325
                           _i18n('The current directory is already bookmarked.\nSee the left panel for reference.'))
324
326
        
325
327
        self.app.refresh_left()
326
328