/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 merge.py

  • Committer: Jelmer Vernooij
  • Date: 2007-07-15 15:13:34 UTC
  • Revision ID: jelmer@samba.org-20070715151334-2t0g8fmpgj6vnqa7
Add icon for Bazaar preferences.

Show diffs side-by-side

added added

removed removed

Lines of Context:
25
25
import gtk
26
26
import gtk.glade
27
27
 
 
28
from bzrlib.branch import Branch
28
29
import bzrlib.errors as errors
29
30
 
30
 
from __init__ import gladefile
31
 
from dialog import error_dialog
 
31
from dialog import error_dialog, info_dialog, warning_dialog
 
32
from errors import show_bzr_error
 
33
from olive.guifiles import GLADEFILENAME
 
34
 
32
35
 
33
36
class MergeDialog:
34
37
    """ Display the Merge dialog and perform the needed actions. """
35
38
    def __init__(self, wt, wtpath):
36
39
        """ Initialize the Merge dialog. """
37
 
        self.glade = gtk.glade.XML(gladefile, 'window_merge', 'olive-gtk')
 
40
        self.glade = gtk.glade.XML(GLADEFILENAME, 'window_merge', 'olive-gtk')
38
41
        
39
42
        self.window = self.glade.get_widget('window_merge')
40
43
        
48
51
 
49
52
        self.wt = wt
50
53
        self.wtpath = wtpath
 
54
        
 
55
        # Get some widgets
 
56
        self.entry = self.glade.get_widget('entry_merge')
51
57
 
52
58
    def display(self):
53
59
        """ Display the Add file(s) dialog. """
54
60
        self.window.show_all()
55
61
 
 
62
    @show_bzr_error
56
63
    def merge(self, widget):
57
 
        print "DEBUG: Merge button pressed."
 
64
        branch = self.entry.get_text()
 
65
        if branch == "":
 
66
            error_dialog(_('Branch not given'),
 
67
                         _('Please specify a branch to merge from.'))
 
68
            return
 
69
 
 
70
        other_branch = Branch.open_containing(branch)[0]
 
71
 
 
72
        try:
 
73
            conflicts = self.wt.merge_from_branch(other_branch)
 
74
        except errors.BzrCommandError, errmsg:
 
75
            error_dialog(_('Bazaar command error'), str(errmsg))
 
76
            return
 
77
        
 
78
        self.close()
 
79
        if conflicts == 0:
 
80
            # No conflicts found.
 
81
            info_dialog(_('Merge successful'),
 
82
                        _('All changes applied successfully.'))
 
83
        else:
 
84
            # There are conflicts to be resolved.
 
85
            warning_dialog(_('Conflicts encountered'),
 
86
                           _('Please resolve the conflicts manually before committing.'))
58
87
    
59
88
    def open(self, widget):
60
 
        print "DEBUG: Open branch button pressed."
61
 
    
 
89
        fcd = gtk.FileChooserDialog(title="Please select a folder",
 
90
                                    parent=self.window,
 
91
                                    action=gtk.FILE_CHOOSER_ACTION_SELECT_FOLDER,
 
92
                                    buttons=(gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL,
 
93
                                             gtk.STOCK_OPEN, gtk.RESPONSE_OK))
 
94
        fcd.set_default_response(gtk.RESPONSE_OK)
 
95
        
 
96
        if fcd.run() == gtk.RESPONSE_OK:
 
97
            self.entry.set_text(fcd.get_filename())
 
98
        
 
99
        fcd.destroy()
 
100
        
62
101
    def close(self, widget=None):
63
102
        self.window.destroy()