/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 18:08:35 UTC
  • mto: (0.12.2 olive)
  • mto: This revision was merged to the branch mainline in revision 83.
  • Revision ID: jelmer@samba.org-20060927180835-4c295d9bb936623a
Turn some windows into dialogs.
Remove the diffwindow code from olive, 
switched to using the one from bzr-gtk instead.

Show diffs side-by-side

added added

removed removed

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