/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:
30
30
 
31
31
import bzrlib.errors as errors
32
32
 
 
33
from launch import launch
 
34
 
33
35
class OliveMenu:
34
36
    """ This class is responsible for building the context menus. """
35
37
    def __init__(self, gladefile, comm, dialog):
64
66
                                       _('Remove'), None,
65
67
                                       _('Remove the selected file'),
66
68
                                       self.remove_file),
 
69
                                      ('open', gtk.STOCK_OPEN,
 
70
                                       _('Open'), None,
 
71
                                       _('Open the selected file'),
 
72
                                       self.open_file),
67
73
                                      ('commit', None,
68
74
                                       _('Commit'), None,
69
75
                                       _('Commit the changes'),
84
90
                                       _('Remove'), None,
85
91
                                       _('Remove the selected bookmark'),
86
92
                                       self.remove_bookmark),
 
93
                                      ('open_folder', gtk.STOCK_OPEN,
 
94
                                       _('Open Folder'), None,
 
95
                                       _('Open bookmark folder in Nautilus'),
 
96
                                       self.open_folder),
87
97
                                      ('diff_selected', None,
88
98
                                       _('Selected...'), None,
89
99
                                       _('Show the differences of the selected file'),
169
179
        
170
180
        self.comm.refresh_right()
171
181
 
 
182
    def open_file(self, action):
 
183
        """ Right context menu -> Open """
 
184
        # Open only the selected file
 
185
        filename = self.comm.get_selected_right()
 
186
        
 
187
        if filename is None:
 
188
            self.dialog.error_dialog(_('No file was selected'),
 
189
                                     _('Please select a file from the list,\nor choose the other option.'))
 
190
            return
 
191
 
 
192
        if filename == '..':
 
193
            self.comm.set_path(os.path.split(self.comm.get_path())[0])
 
194
        else:
 
195
            fullpath = self.comm.get_path() + os.sep + filename
 
196
            if os.path.isdir(fullpath):
 
197
                # selected item is an existant directory
 
198
                self.comm.set_path(fullpath)
 
199
            else:
 
200
                launch(fullpath) 
 
201
        
 
202
        self.comm.refresh_right()
 
203
 
172
204
    def commit(self, action):
173
205
        """ Right context menu -> Commit """
174
206
        from commit import OliveCommit
195
227
    def edit_bookmark(self, action):
196
228
        """ Left context menu -> Edit """
197
229
        from bookmark import OliveBookmark
198
 
        bookmark = OliveBookmark(self.gladefile, self.comm, self.dialog)
199
 
        bookmark.display()
 
230
 
 
231
        if self.comm.get_selected_left() != None:
 
232
            bookmark = OliveBookmark(self.gladefile, self.comm, self.dialog)
 
233
            bookmark.display()
200
234
 
201
235
    def remove_bookmark(self, action):
202
236
        """ Left context menu -> Remove """
203
 
        self.comm.pref.remove_bookmark(self.comm.get_selected_left())
204
237
        
205
 
        self.comm.refresh_left()
 
238
        if self.comm.get_selected_left() != None:
 
239
            self.comm.pref.remove_bookmark(self.comm.get_selected_left())
 
240
            self.comm.refresh_left()
 
241
    
 
242
    def open_folder(self, action):
 
243
        """ Left context menu -> Open Folder """
 
244
        path = self.comm.get_selected_left()
 
245
 
 
246
        if path != None:
 
247
            launch(path)
206
248
    
207
249
    def diff_selected(self, action):
208
250
        """ Diff toolbutton -> Selected... """