/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-28 06:35:56 UTC
  • mto: (0.12.2 olive)
  • mto: This revision was merged to the branch mainline in revision 83.
  • Revision ID: jelmer@samba.org-20060928063556-62ec354cb06ba38c
Update TODO
integrate the handle and communicator functions into a main class.

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):
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
 
        self.comm = comm
56
 
        self.dialog = dialog
57
 
        
58
51
        # Create the file list context menu
59
52
        self.ui = gtk.UIManager()
60
53
        
139
132
        filename = self.comm.get_selected_right()
140
133
            
141
134
        if filename is None:
142
 
            self.dialog.error_dialog(_('No file was selected'),
143
 
                                     _('Please select a file from the list,\nor choose the other option.'))
 
135
            error_dialog(_('No file was selected'),
 
136
                         _('Please select a file from the list,\nor choose the other option.'))
144
137
            return
145
138
        
146
139
        try:
147
 
            fileops.add([directory + '/' + filename])
 
140
            bzrlib.add.smart_add([directory + '/' + filename])
148
141
        except errors.NotBranchError:
149
 
            self.dialog.error_dialog(_('Directory is not a branch'),
150
 
                                     _('You can perform this action only in a branch.'))
 
142
            error_dialog(_('Directory is not a branch'),
 
143
                         _('You can perform this action only in a branch.'))
151
144
            return
152
 
        except:
153
 
            raise
154
145
        
155
146
        self.comm.refresh_right()
156
147
    
161
152
        filename = self.comm.get_selected_right()
162
153
        
163
154
        if filename is None:
164
 
            self.dialog.error_dialog(_('No file was selected'),
165
 
                                     _('Please select a file from the list,\nor choose the other option.'))
 
155
            error_dialog(_('No file was selected'),
 
156
                         _('Please select a file from the list,\nor choose the other option.'))
166
157
            return
167
158
        
168
159
        try:
169
 
            fileops.remove([directory + '/' + filename])
 
160
            wt, path = WorkingTree.open_containing(directory+'/'+filename)
 
161
            wt.remove(path)
 
162
 
170
163
        except errors.NotBranchError:
171
 
            self.dialog.error_dialog(_('Directory is not a branch'),
 
164
            error_dialog(_('Directory is not a branch'),
172
165
                                     _('You can perform this action only in a branch.'))
173
166
            return
174
167
        except errors.NotVersionedError:
175
 
            self.dialog.error_dialog(_('File not versioned'),
 
168
            error_dialog(_('File not versioned'),
176
169
                                     _('The selected file is not versioned.'))
177
170
            return
178
 
        except:
179
 
            raise
180
171
        
181
172
        self.comm.refresh_right()
182
173
 
186
177
        filename = self.comm.get_selected_right()
187
178
        
188
179
        if filename is None:
189
 
            self.dialog.error_dialog(_('No file was selected'),
 
180
            error_dialog(_('No file was selected'),
190
181
                                     _('Please select a file from the list,\nor choose the other option.'))
191
182
            return
192
183
 
205
196
    def commit(self, action):
206
197
        """ Right context menu -> Commit """
207
198
        from commit import OliveCommit
208
 
        commit = OliveCommit(self.gladefile, self.comm, self.dialog)
 
199
        wt, path = WorkingTree.open_containing(self.comm.get_path())
 
200
        commit = OliveCommit(wt, path)
209
201
        commit.display()
210
202
    
211
203
    def diff(self, action):
212
204
        """ Right context menu -> Diff """
213
205
        from diff import OliveDiff
214
 
        diff = OliveDiff(self.gladefile, self.comm, self.dialog)
 
206
        diff = OliveDiff(self.comm)
215
207
        diff.display()
216
208
    
217
209
    def bookmark(self, action):
218
210
        """ Right context menu -> Bookmark """
219
211
        if self.comm.pref.add_bookmark(self.comm.get_path()):
220
 
            self.dialog.info_dialog(_('Bookmark successfully added'),
 
212
            info_dialog(_('Bookmark successfully added'),
221
213
                                    _('The current directory was bookmarked. You can reach\nit by selecting it from the left panel.'))
222
214
        else:
223
 
            self.dialog.warning_dialog(_('Location already bookmarked'),
 
215
            warning_dialog(_('Location already bookmarked'),
224
216
                                       _('The current directory is already bookmarked.\nSee the left panel for reference.'))
225
217
        
226
218
        self.comm.refresh_left()
230
222
        from bookmark import OliveBookmark
231
223
 
232
224
        if self.comm.get_selected_left() != None:
233
 
            bookmark = OliveBookmark(self.gladefile, self.comm, self.dialog)
 
225
            bookmark = OliveBookmark(self.comm)
234
226
            bookmark.display()
235
227
 
236
228
    def remove_bookmark(self, action):
254
246
    def diff_all(self, action):
255
247
        """ Diff toolbutton -> All... """
256
248
        from diff import OliveDiff
257
 
        diff = OliveDiff(self.gladefile, self.comm, self.dialog)
 
249
        diff = OliveDiff(self.comm)
258
250
        diff.display()