/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: Szilveszter Farkas (Phanatic)
  • Date: 2007-05-17 16:12:27 UTC
  • mto: This revision was merged to the branch mainline in revision 201.
  • Revision ID: szilveszter.farkas@gmail.com-20070517161227-9e37lj2rm2t0cwj6
Some small modifications to Branch, Checkout and Info to support remote branches.

Show diffs side-by-side

added added

removed removed

Lines of Context:
14
14
# along with this program; if not, write to the Free Software
15
15
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
16
16
 
17
 
import os
18
17
import os.path
19
 
import shutil
20
18
import sys
21
19
 
22
20
try:
30
28
import bzrlib.errors as errors
31
29
from bzrlib.workingtree import WorkingTree
32
30
 
33
 
from bzrlib.plugins.gtk.dialog import error_dialog, info_dialog, question_dialog, warning_dialog
 
31
from bzrlib.plugins.gtk.dialog import error_dialog, info_dialog, warning_dialog
34
32
from bzrlib.plugins.gtk.errors import show_bzr_error
35
33
from bzrlib.plugins.gtk.annotate.gannotate import GAnnotateWindow
36
34
from bzrlib.plugins.gtk.annotate.config import GAnnotateConfig
66
64
                                       _('Remove'), None,
67
65
                                       _('Remove the selected file'),
68
66
                                       self.remove_file),
69
 
                                      ('remove_and_delete', gtk.STOCK_REMOVE,
70
 
                                       _('Remove and delete'), None,
71
 
                                       _('Remove the selected file/dir and delete from disk'),
72
 
                                       self.remove_and_delete_file),
73
67
                                      ('rename', None,
74
68
                                       _('Rename'), None,
75
69
                                       _('Rename the selected file'),
117
111
                                      ('diff_all', None,
118
112
                                       _('All...'), None,
119
113
                                       _('Show the differences of all files'),
120
 
                                       self.diff_all),
121
 
                                      ('view_remote', None,
122
 
                                       _('View contents'), None,
123
 
                                       _('View the contents of the file in a builtin viewer'),
124
 
                                       self.view_remote),
125
 
                                      ('diff_remote', None,
126
 
                                       _('Show differences'), None,
127
 
                                       _('Show the differences between two revisions of the file'),
128
 
                                       self.diff_remote),
129
 
                                      ('revert_remote', None,
130
 
                                       _('Revert to this revision'), None,
131
 
                                       _('Revert the selected file to the selected revision'),
132
 
                                       self.revert_remote)
 
114
                                       self.diff_all)
133
115
                                     ])
134
116
        
135
117
        self.ui.insert_action_group(self.actiongroup, 0)
138
120
        self.cmenu_right = self.ui.get_widget('/context_right')
139
121
        self.cmenu_left = self.ui.get_widget('/context_left')
140
122
        self.toolbar_diff = self.ui.get_widget('/toolbar_diff')
141
 
        self.cmenu_remote = self.ui.get_widget('/context_remote')
142
123
        
143
124
        # Set icons
144
125
        # TODO: do it without using deprecated comm
161
142
    def left_context_menu(self):
162
143
        return self.cmenu_left
163
144
    
164
 
    def remote_context_menu(self):
165
 
        return self.cmenu_remote
166
 
    
167
145
    @show_bzr_error
168
146
    def add_file(self, action):
169
147
        """ Right context menu -> Add """
196
174
        branch = wt.branch
197
175
        file_id = wt.path2id(wt.relpath(os.path.join(directory, filename)))
198
176
        
199
 
        window = GAnnotateWindow(all=False, plain=False, parent=self.app)
 
177
        window = GAnnotateWindow(all=False, plain=False)
200
178
        window.set_title(os.path.join(directory, filename) + " - Annotate")
201
179
        config = GAnnotateConfig(window)
202
180
        window.show()
207
185
            branch.unlock()
208
186
    
209
187
    @show_bzr_error
210
 
    def remove_file(self, action,delete_on_disk=0):
 
188
    def remove_file(self, action):
211
189
        """ Right context menu -> Remove """
212
190
        # Remove only the selected file
213
191
        directory = self.path
220
198
        
221
199
        wt, path = WorkingTree.open_containing(os.path.join(directory, filename))
222
200
        wt.remove(path)
223
 
        
224
 
        if delete_on_disk:
225
 
            abs_filename = os.path.join(directory,filename)
226
 
            if os.path.isdir(abs_filename):
227
 
                response = question_dialog(_('Delete directory with all directories below ?'), abs_filename )
228
 
                if response == gtk.RESPONSE_YES:
229
 
                    shutil.rmtree(abs_filename)
230
 
            else:
231
 
                os.remove(abs_filename)
232
 
                
233
201
        self.app.set_path(self.path)
234
202
        self.app.refresh_right()
235
 
        
236
 
    def remove_and_delete_file(self, action):
237
 
        """ Right context menu -> Remove and delete"""
238
 
        self.remove_file(action,delete_on_disk=1)
239
203
 
240
204
    def rename_file(self, action):
241
205
        """ Right context menu -> Rename """
288
252
        except NotBranchError, e:
289
253
            path = e.path
290
254
        
291
 
        if self.selected:
292
 
            selected = os.path.join(path, self.selected)
293
 
        else:
294
 
            selected = None
295
 
        commit = CommitDialog(wt=wt, selected=selected, parent=None)
 
255
        commit = CommitDialog(wt, path, not branch, self.selected)
296
256
        response = commit.run()
297
257
        if response != gtk.RESPONSE_NONE:
298
258
            commit.hide()
306
266
    def diff(self, action):
307
267
        """ Right context menu -> Diff """
308
268
        wt = WorkingTree.open_containing(self.path)[0]
309
 
        window = DiffWindow(self.app)
 
269
        window = DiffWindow()
310
270
        parent_tree = wt.branch.repository.revision_tree(wt.branch.last_revision())
311
271
        window.set_diff(wt.branch.nick, wt, parent_tree)
312
272
        window.set_file(wt.relpath(self.path + os.sep + self.selected))
365
325
        from diff import OliveDiff
366
326
        diff = OliveDiff(self.comm)
367
327
        diff.display()
368
 
    
369
 
    def view_remote(self, action):
370
 
        """ Remote context menu -> View contents """
371
 
        print "DEBUG: view contents."
372
 
    
373
 
    def diff_remote(self, action):
374
 
        """ Remote context menu -> Show differences """
375
 
        print "DEBUG: show differences."
376
 
    
377
 
    def revert_remote(self, action):
378
 
        """ Remote context menu -> Revert to this revision """
379
 
        print "DEBUG: revert to this revision."