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