/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: 2006-09-13 20:19:31 UTC
  • mfrom: (0.8.79 main)
  • mto: (0.8.83 merge)
  • mto: This revision was merged to the branch mainline in revision 83.
  • Revision ID: jelmer@samba.org-20060913201931-23adba246d4d6529
Merge main branch.

Show diffs side-by-side

added added

removed removed

Lines of Context:
22
22
    pygtk.require("2.0")
23
23
except:
24
24
    pass
25
 
 
26
 
import gtk
 
25
try:
 
26
    import gtk
 
27
    import gtk.glade
 
28
except:
 
29
    sys.exit(1)
27
30
 
28
31
import bzrlib.errors as errors
29
 
from dialog import error_dialog
30
32
 
31
33
from launch import launch
32
34
 
33
35
class OliveMenu:
34
36
    """ This class is responsible for building the context menus. """
35
 
    def __init__(self):
 
37
    def __init__(self, gladefile, comm, dialog):
36
38
        # Load the UI file
37
39
        if sys.platform == 'win32':
38
40
            self.uifile = os.path.dirname(sys.executable) + "/share/olive/cmenu.ui"
48
50
                print _('UI description file cannot be found.')
49
51
                sys.exit(1)
50
52
        
 
53
        self.gladefile = gladefile
 
54
        self.comm = comm
 
55
        self.dialog = dialog
 
56
        
51
57
        # Create the file list context menu
52
58
        self.ui = gtk.UIManager()
53
59
        
132
138
        filename = self.comm.get_selected_right()
133
139
            
134
140
        if filename is None:
135
 
            error_dialog(_('No file was selected'),
136
 
                         _('Please select a file from the list,\nor choose the other option.'))
 
141
            self.dialog.error_dialog(_('No file was selected'),
 
142
                                     _('Please select a file from the list,\nor choose the other option.'))
137
143
            return
138
144
        
139
145
        try:
140
146
            bzrlib.add.smart_add([directory + '/' + filename])
141
147
        except errors.NotBranchError:
142
 
            error_dialog(_('Directory is not a branch'),
143
 
                         _('You can perform this action only in a branch.'))
 
148
            self.dialog.error_dialog(_('Directory is not a branch'),
 
149
                                     _('You can perform this action only in a branch.'))
144
150
            return
145
151
        
146
152
        self.comm.refresh_right()
152
158
        filename = self.comm.get_selected_right()
153
159
        
154
160
        if filename is None:
155
 
            error_dialog(_('No file was selected'),
156
 
                         _('Please select a file from the list,\nor choose the other option.'))
 
161
            self.dialog.error_dialog(_('No file was selected'),
 
162
                                     _('Please select a file from the list,\nor choose the other option.'))
157
163
            return
158
164
        
159
165
        try:
161
167
            wt.remove(path)
162
168
 
163
169
        except errors.NotBranchError:
164
 
            error_dialog(_('Directory is not a branch'),
 
170
            self.dialog.error_dialog(_('Directory is not a branch'),
165
171
                                     _('You can perform this action only in a branch.'))
166
172
            return
167
173
        except errors.NotVersionedError:
168
 
            error_dialog(_('File not versioned'),
 
174
            self.dialog.error_dialog(_('File not versioned'),
169
175
                                     _('The selected file is not versioned.'))
170
176
            return
 
177
        except:
 
178
            raise
171
179
        
172
180
        self.comm.refresh_right()
173
181
 
177
185
        filename = self.comm.get_selected_right()
178
186
        
179
187
        if filename is None:
180
 
            error_dialog(_('No file was selected'),
 
188
            self.dialog.error_dialog(_('No file was selected'),
181
189
                                     _('Please select a file from the list,\nor choose the other option.'))
182
190
            return
183
191
 
196
204
    def commit(self, action):
197
205
        """ Right context menu -> Commit """
198
206
        from commit import OliveCommit
199
 
        wt, path = WorkingTree.open_containing(self.comm.get_path())
200
 
        commit = OliveCommit(wt, path)
 
207
        commit = OliveCommit(self.gladefile, self.comm, self.dialog)
201
208
        commit.display()
202
209
    
203
210
    def diff(self, action):
204
211
        """ Right context menu -> Diff """
205
212
        from diff import OliveDiff
206
 
        diff = OliveDiff(self.comm)
 
213
        diff = OliveDiff(self.gladefile, self.comm, self.dialog)
207
214
        diff.display()
208
215
    
209
216
    def bookmark(self, action):
210
217
        """ Right context menu -> Bookmark """
211
218
        if self.comm.pref.add_bookmark(self.comm.get_path()):
212
 
            info_dialog(_('Bookmark successfully added'),
 
219
            self.dialog.info_dialog(_('Bookmark successfully added'),
213
220
                                    _('The current directory was bookmarked. You can reach\nit by selecting it from the left panel.'))
214
221
        else:
215
 
            warning_dialog(_('Location already bookmarked'),
 
222
            self.dialog.warning_dialog(_('Location already bookmarked'),
216
223
                                       _('The current directory is already bookmarked.\nSee the left panel for reference.'))
217
224
        
218
225
        self.comm.refresh_left()
222
229
        from bookmark import OliveBookmark
223
230
 
224
231
        if self.comm.get_selected_left() != None:
225
 
            bookmark = OliveBookmark(self.comm)
 
232
            bookmark = OliveBookmark(self.gladefile, self.comm, self.dialog)
226
233
            bookmark.display()
227
234
 
228
235
    def remove_bookmark(self, action):
246
253
    def diff_all(self, action):
247
254
        """ Diff toolbutton -> All... """
248
255
        from diff import OliveDiff
249
 
        diff = OliveDiff(self.comm)
 
256
        diff = OliveDiff(self.gladefile, self.comm, self.dialog)
250
257
        diff.display()