/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: 2007-07-15 15:05:06 UTC
  • Revision ID: jelmer@samba.org-20070715150506-1uemecr5kt7d4kvg
Fix whitespace, add comment.

Show diffs side-by-side

added added

removed removed

Lines of Context:
29
29
from bzrlib.workingtree import WorkingTree
30
30
 
31
31
from bzrlib.plugins.gtk.dialog import error_dialog, info_dialog, warning_dialog
32
 
from errors import show_bzr_error
 
32
from bzrlib.plugins.gtk.errors import show_bzr_error
 
33
from bzrlib.plugins.gtk.annotate.gannotate import GAnnotateWindow
 
34
from bzrlib.plugins.gtk.annotate.config import GAnnotateConfig
 
35
from bzrlib.plugins.gtk.diff import DiffWindow
33
36
from launch import launch
34
 
from olive import Preferences, DiffWindow
 
37
from olive import Preferences
35
38
 
36
39
class OliveMenu:
37
40
    """ This class is responsible for building the context menus. """
77
80
                                       _('Commit'), None,
78
81
                                       _('Commit the changes'),
79
82
                                       self.commit),
 
83
                                      ('annotate', None,
 
84
                                       _('Annotate'), None,
 
85
                                       _('Annotate the selected file'),
 
86
                                       self.annotate),
80
87
                                      ('diff', None,
81
88
                                       _('Diff'), None,
82
89
                                       _('Show the diff of the file'),
104
111
                                      ('diff_all', None,
105
112
                                       _('All...'), None,
106
113
                                       _('Show the differences of all files'),
107
 
                                       self.diff_all)
 
114
                                       self.diff_all),
 
115
                                      ('view_remote', None,
 
116
                                       _('View contents'), None,
 
117
                                       _('View the contents of the file in a builtin viewer'),
 
118
                                       self.view_remote),
 
119
                                      ('diff_remote', None,
 
120
                                       _('Show differences'), None,
 
121
                                       _('Show the differences between two revisions of the file'),
 
122
                                       self.diff_remote),
 
123
                                      ('revert_remote', None,
 
124
                                       _('Revert to this revision'), None,
 
125
                                       _('Revert the selected file to the selected revision'),
 
126
                                       self.revert_remote)
108
127
                                     ])
109
128
        
110
129
        self.ui.insert_action_group(self.actiongroup, 0)
113
132
        self.cmenu_right = self.ui.get_widget('/context_right')
114
133
        self.cmenu_left = self.ui.get_widget('/context_left')
115
134
        self.toolbar_diff = self.ui.get_widget('/toolbar_diff')
 
135
        self.cmenu_remote = self.ui.get_widget('/context_remote')
116
136
        
117
137
        # Set icons
118
138
        # TODO: do it without using deprecated comm
135
155
    def left_context_menu(self):
136
156
        return self.cmenu_left
137
157
    
 
158
    def remote_context_menu(self):
 
159
        return self.cmenu_remote
 
160
    
138
161
    @show_bzr_error
139
162
    def add_file(self, action):
140
163
        """ Right context menu -> Add """
152
175
        bzrlib.add.smart_add([os.path.join(directory, filename)])
153
176
    
154
177
    @show_bzr_error
 
178
    def annotate(self, action):
 
179
        """ Right context menu -> Annotate """
 
180
        directory = self.path
 
181
        filename = self.selected
 
182
        
 
183
        if filename is None:
 
184
            error_dialog(_('No file was selected'),
 
185
                         _('Please select a file from the list.'))
 
186
            return
 
187
        
 
188
        wt, path = WorkingTree.open_containing(os.path.join(directory, filename))
 
189
        
 
190
        branch = wt.branch
 
191
        file_id = wt.path2id(wt.relpath(os.path.join(directory, filename)))
 
192
        
 
193
        window = GAnnotateWindow(all=False, plain=False)
 
194
        window.set_title(os.path.join(directory, filename) + " - Annotate")
 
195
        config = GAnnotateConfig(window)
 
196
        window.show()
 
197
        branch.lock_read()
 
198
        try:
 
199
            window.annotate(wt, branch, file_id)
 
200
        finally:
 
201
            branch.unlock()
 
202
    
 
203
    @show_bzr_error
155
204
    def remove_file(self, action):
156
205
        """ Right context menu -> Remove """
157
206
        # Remove only the selected file
292
341
        from diff import OliveDiff
293
342
        diff = OliveDiff(self.comm)
294
343
        diff.display()
 
344
    
 
345
    def view_remote(self, action):
 
346
        """ Remote context menu -> View contents """
 
347
        print "DEBUG: view contents."
 
348
    
 
349
    def diff_remote(self, action):
 
350
        """ Remote context menu -> Show differences """
 
351
        print "DEBUG: show differences."
 
352
    
 
353
    def revert_remote(self, action):
 
354
        """ Remote context menu -> Revert to this revision """
 
355
        print "DEBUG: revert to this revision."