/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: 2008-06-29 16:24:24 UTC
  • mto: This revision was merged to the branch mainline in revision 519.
  • Revision ID: jelmer@samba.org-20080629162424-48a6rrjmmpejfcyr
Stop emitting no longer used revisions-loaded message.

Show diffs side-by-side

added added

removed removed

Lines of Context:
23
23
    pass
24
24
 
25
25
import gtk
 
26
import gtk.glade
26
27
 
27
28
from bzrlib.branch import Branch
28
29
import bzrlib.errors as errors
29
 
 
30
30
from bzrlib.plugins.gtk import _i18n
31
 
from bzrlib.plugins.gtk.dialog import error_dialog, info_dialog, warning_dialog
32
 
from bzrlib.plugins.gtk.errors import show_bzr_error
33
 
 
34
 
 
35
 
class MergeDialog(gtk.Dialog):
 
31
 
 
32
from dialog import error_dialog, info_dialog, warning_dialog
 
33
from errors import show_bzr_error
 
34
from olive.guifiles import GLADEFILENAME
 
35
 
 
36
 
 
37
class MergeDialog:
36
38
    """ Display the Merge dialog and perform the needed actions. """
37
 
    
38
 
    def __init__(self, wt, wtpath, default_branch_path=None, parent=None):
 
39
    def __init__(self, wt, wtpath,default_branch_path=None):
39
40
        """ Initialize the Merge dialog. """
40
 
        gtk.Dialog.__init__(self, title="Olive - Merge",
41
 
                                  parent=parent,
42
 
                                  flags=0,
43
 
                                  buttons=(gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL))
44
 
        
45
 
        # Get arguments
 
41
        self.glade = gtk.glade.XML(GLADEFILENAME, 'window_merge', 'olive-gtk')
 
42
        
 
43
        self.window = self.glade.get_widget('window_merge')
 
44
        
 
45
        # Dictionary for signal_autoconnect
 
46
        dic = { "on_button_merge_merge_clicked": self.merge,
 
47
                "on_button_merge_cancel_clicked": self.close,
 
48
                "on_button_merge_open_clicked": self.open }
 
49
        
 
50
        # Connect the signals to the handlers
 
51
        self.glade.signal_autoconnect(dic)
 
52
 
46
53
        self.wt = wt
47
54
        self.wtpath = wtpath
48
55
        
49
 
        directory = os.path.dirname(self.wt.abspath(self.wtpath))
50
 
        
51
 
        # Create widgets
52
 
        self._hbox = gtk.HBox()
53
 
        self._label_merge_from = gtk.Label(_i18n("Merge from"))
54
 
        self._filechooser_dialog = gtk.FileChooserDialog(title="Please select a folder",
55
 
                                    parent=self.window,
56
 
                                    action=gtk.FILE_CHOOSER_ACTION_SELECT_FOLDER,
57
 
                                    buttons=(gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL,
58
 
                                             gtk.STOCK_OPEN, gtk.RESPONSE_OK))
59
 
        self._filechooser_dialog.set_default_response(gtk.RESPONSE_OK)
60
 
        self._filechooser = gtk.FileChooserButton(self._filechooser_dialog)
61
 
        self._button_merge = gtk.Button(_i18n("_Merge"))
62
 
        self._button_merge_icon = gtk.Image()
63
 
        self._button_merge_icon.set_from_stock(gtk.STOCK_APPLY, gtk.ICON_SIZE_BUTTON)
64
 
        self._button_merge.set_image(self._button_merge_icon)
65
 
        
66
 
        self._button_merge.connect('clicked', self._on_merge_clicked)
67
 
        
68
 
        # Set location
69
 
        self._filechooser_dialog.set_current_folder(directory)
70
 
        
71
 
        # Add widgets to dialog
72
 
        self.vbox.add(self._hbox)
73
 
        self._hbox.add(self._label_merge_from)
74
 
        self._hbox.add(self._filechooser)
75
 
        self._hbox.set_spacing(5)
76
 
        self.action_area.pack_end(self._button_merge)
77
 
        
78
 
        self.vbox.show_all()
 
56
        # Get some widgets
 
57
        self.entry = self.glade.get_widget('entry_merge')
 
58
        if default_branch_path:
 
59
            self.entry.set_text(default_branch_path)
 
60
 
 
61
    def display(self):
 
62
        """ Display the Add file(s) dialog. """
 
63
        self.window.show_all()
79
64
 
80
65
    @show_bzr_error
81
 
    def _on_merge_clicked(self, widget):
82
 
        branch = self._filechooser.get_filename()
 
66
    def merge(self, widget):
 
67
        branch = self.entry.get_text()
83
68
        if branch == "":
84
69
            error_dialog(_i18n('Branch not given'),
85
70
                         _i18n('Please specify a branch to merge from.'))
93
78
            error_dialog(_i18n('Bazaar command error'), str(errmsg))
94
79
            return
95
80
        
 
81
        self.close()
96
82
        if conflicts == 0:
97
83
            # No conflicts found.
98
84
            info_dialog(_i18n('Merge successful'),
101
87
            # There are conflicts to be resolved.
102
88
            warning_dialog(_i18n('Conflicts encountered'),
103
89
                           _i18n('Please resolve the conflicts manually before committing.'))
104
 
        
105
 
        self.response(gtk.RESPONSE_OK)
 
90
    
 
91
    def open(self, widget):
 
92
        fcd = gtk.FileChooserDialog(title="Please select a folder",
 
93
                                    parent=self.window,
 
94
                                    action=gtk.FILE_CHOOSER_ACTION_SELECT_FOLDER,
 
95
                                    buttons=(gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL,
 
96
                                             gtk.STOCK_OPEN, gtk.RESPONSE_OK))
 
97
        fcd.set_default_response(gtk.RESPONSE_OK)
 
98
        
 
99
        if fcd.run() == gtk.RESPONSE_OK:
 
100
            self.entry.set_text(fcd.get_filename())
 
101
        
 
102
        fcd.destroy()
 
103
        
 
104
    def close(self, widget=None):
 
105
        self.window.destroy()