/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-27 19:52:46 UTC
  • mto: (0.12.2 olive)
  • mto: This revision was merged to the branch mainline in revision 83.
  • Revision ID: jelmer@samba.org-20060927195246-9354d7ccf56127f5
Don't pass around gladefile all the time. 
Fix bug in status information when files have been removed.

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