/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: 2008-05-04 18:16:01 UTC
  • Revision ID: jelmer@samba.org-20080504181601-u5gh89q8l2we201l
Fix display of children in branchview.

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
17
18
import os.path
 
19
import shutil
18
20
import sys
19
21
 
20
22
try:
28
30
import bzrlib.errors as errors
29
31
from bzrlib.workingtree import WorkingTree
30
32
 
31
 
from bzrlib.plugins.gtk.dialog import error_dialog, info_dialog, warning_dialog
 
33
from bzrlib.plugins.gtk.dialog import error_dialog, info_dialog, question_dialog, warning_dialog
32
34
from bzrlib.plugins.gtk.errors import show_bzr_error
33
35
from bzrlib.plugins.gtk.annotate.gannotate import GAnnotateWindow
34
36
from bzrlib.plugins.gtk.annotate.config import GAnnotateConfig
35
37
from bzrlib.plugins.gtk.diff import DiffWindow
36
38
from launch import launch
37
 
from olive import Preferences
 
39
from bzrlib.plugins.gtk.olive import Preferences
38
40
 
39
41
class OliveMenu:
40
42
    """ This class is responsible for building the context menus. """
64
66
                                       _('Remove'), None,
65
67
                                       _('Remove the selected file'),
66
68
                                       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),
67
73
                                      ('rename', None,
68
74
                                       _('Rename'), None,
69
75
                                       _('Rename the selected file'),
190
196
        branch = wt.branch
191
197
        file_id = wt.path2id(wt.relpath(os.path.join(directory, filename)))
192
198
        
193
 
        window = GAnnotateWindow(all=False, plain=False)
 
199
        window = GAnnotateWindow(all=False, plain=False, parent=self.app)
194
200
        window.set_title(os.path.join(directory, filename) + " - Annotate")
195
201
        config = GAnnotateConfig(window)
196
202
        window.show()
201
207
            branch.unlock()
202
208
    
203
209
    @show_bzr_error
204
 
    def remove_file(self, action):
 
210
    def remove_file(self, action,delete_on_disk=0):
205
211
        """ Right context menu -> Remove """
206
212
        # Remove only the selected file
207
213
        directory = self.path
214
220
        
215
221
        wt, path = WorkingTree.open_containing(os.path.join(directory, filename))
216
222
        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
                
217
233
        self.app.set_path(self.path)
218
234
        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)
219
239
 
220
240
    def rename_file(self, action):
221
241
        """ Right context menu -> Rename """
268
288
        except NotBranchError, e:
269
289
            path = e.path
270
290
        
271
 
        commit = CommitDialog(wt, path, not branch, self.selected)
 
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)
272
296
        response = commit.run()
273
297
        if response != gtk.RESPONSE_NONE:
274
298
            commit.hide()
282
306
    def diff(self, action):
283
307
        """ Right context menu -> Diff """
284
308
        wt = WorkingTree.open_containing(self.path)[0]
285
 
        window = DiffWindow()
 
309
        window = DiffWindow(self.app)
286
310
        parent_tree = wt.branch.repository.revision_tree(wt.branch.last_revision())
287
311
        window.set_diff(wt.branch.nick, wt, parent_tree)
288
312
        window.set_file(wt.relpath(self.path + os.sep + self.selected))