/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: Curtis Hovey
  • Date: 2012-02-09 03:43:01 UTC
  • mto: This revision was merged to the branch mainline in revision 776.
  • Revision ID: sinzui.is@verizon.net-20120209034301-0uwkobbb0d64ugrw
Switched from Gtk.VPaned to Gtk.Paned.new(Gtk.Orientation.VERTICAL).

Show diffs side-by-side

added added

removed removed

Lines of Context:
16
16
 
17
17
import os
18
18
 
19
 
try:
20
 
    import pygtk
21
 
    pygtk.require("2.0")
22
 
except:
23
 
    pass
24
 
 
25
 
import gtk
 
19
from gi.repository import Gtk
26
20
 
27
21
from bzrlib.branch import Branch
28
22
import bzrlib.errors as errors
29
23
 
30
 
from bzrlib.plugins.gtk import _i18n, icon_path
 
24
from bzrlib.plugins.gtk import icon_path
31
25
from bzrlib.plugins.gtk.dialog import (
32
26
    error_dialog,
33
27
    info_dialog,
34
28
    warning_dialog,
35
29
    )
36
30
from bzrlib.plugins.gtk.errors import show_bzr_error
37
 
 
38
 
 
39
 
class MergeDialog(gtk.Dialog):
 
31
from bzrlib.plugins.gtk.i18n import _i18n
 
32
 
 
33
 
 
34
class MergeDialog(Gtk.Dialog):
40
35
    """ Display the Merge dialog and perform the needed actions. """
41
36
    
42
37
    def __init__(self, wt, wtpath, default_branch_path=None, parent=None):
43
38
        """ Initialize the Merge dialog. """
44
 
        gtk.Dialog.__init__(self, title="Merge changes",
45
 
                                  parent=parent,
46
 
                                  flags=0,
47
 
                                  buttons=(gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL))
 
39
        super(MergeDialog, self).__init__(
 
40
            title="Merge changes", parent=parent, flags=0,
 
41
            buttons=(Gtk.STOCK_CANCEL, Gtk.ResponseType.CANCEL))
48
42
        self.set_icon_from_file(icon_path("bzr-icon-64.png"))
49
43
        # Get arguments
50
44
        self.wt = wt
53
47
        self.parent_window = parent
54
48
        
55
49
        # Create widgets
56
 
        self._hbox = gtk.HBox()
57
 
        self._source = gtk.HBox()
58
 
        self._label_merge_from = gtk.Label(_i18n("Merge from"))
59
 
        self._combo_source = gtk.combo_box_new_text()
 
50
        self._hbox = Gtk.HBox()
 
51
        self._source = Gtk.HBox()
 
52
        self._label_merge_from = Gtk.Label(label=_i18n("Merge from"))
 
53
        self._combo_source = Gtk.ComboBoxText()
60
54
        for entry in [_i18n("Folder"),_i18n("Custom Location")]:
61
55
            self._combo_source.append_text(entry)
62
56
        self._combo_source.connect("changed", self._on_combo_changed)
63
 
        self._button_merge = gtk.Button(_i18n("_Merge"))
64
 
        self._button_merge_icon = gtk.Image()
65
 
        self._button_merge_icon.set_from_stock(gtk.STOCK_APPLY, gtk.ICON_SIZE_BUTTON)
 
57
        self._button_merge = Gtk.Button(_i18n("_Merge"))
 
58
        self._button_merge_icon = Gtk.Image()
 
59
        self._button_merge_icon.set_from_stock(Gtk.STOCK_APPLY, Gtk.IconSize.BUTTON)
66
60
        self._button_merge.set_image(self._button_merge_icon)
67
61
        self._button_merge.connect('clicked', self._on_merge_clicked)
68
62
        
69
63
        # Add widgets to dialog
70
 
        self.vbox.pack_start(self._hbox, False, False, 0)
 
64
        self.get_content_area().pack_start(self._hbox, False, False, 0)
71
65
        self._hbox.add(self._label_merge_from)
72
66
        self._hbox.add(self._combo_source)
73
67
        self._hbox.set_spacing(5)
74
 
        self.action_area.pack_end(self._button_merge)
 
68
        self.action_area.pack_end(self._button_merge, False, False, 0)
75
69
        
76
70
        if self.default_branch_path and os.path.isdir(
77
71
                            self.default_branch_path.partition('file://')[2]):
82
76
        else:
83
77
            # If no default_branch_path give, default to folder source with current folder
84
78
            self._combo_source.set_active(0)
85
 
        self.vbox.show_all()
 
79
        self.get_content_area().show_all()
86
80
    
87
81
    def _on_folder_source(self):
88
82
        """ Merge from folder, create a filechooser dialog and button """
89
 
        self._source = gtk.HBox()
90
 
        self._filechooser_dialog = gtk.FileChooserDialog(title="Please select a folder",
 
83
        self._source = Gtk.HBox()
 
84
        self._filechooser_dialog = Gtk.FileChooserDialog(title="Please select a folder",
91
85
                                    parent=self.parent_window,
92
 
                                    action=gtk.FILE_CHOOSER_ACTION_SELECT_FOLDER,
93
 
                                    buttons=(gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL,
94
 
                                             gtk.STOCK_OPEN, gtk.RESPONSE_OK))
95
 
        self._filechooser_dialog.set_default_response(gtk.RESPONSE_OK)
96
 
        self._filechooser = gtk.FileChooserButton(self._filechooser_dialog)
 
86
                                    action=Gtk.FileChooserAction.SELECT_FOLDER,
 
87
                                    buttons=(Gtk.STOCK_CANCEL, Gtk.ResponseType.CANCEL,
 
88
                                             Gtk.STOCK_OPEN, Gtk.ResponseType.OK))
 
89
        self._filechooser_dialog.set_default_response(Gtk.ResponseType.OK)
 
90
        self._filechooser = Gtk.FileChooserButton(self._filechooser_dialog)
97
91
        self._filechooser.show()
98
92
        directory = getattr(self, 'directory', None)
99
93
        if not directory:
100
94
            directory = os.path.dirname(self.wt.abspath(self.wtpath))
101
95
        self._filechooser_dialog.set_current_folder(directory)
102
96
        self._source.pack_start(self._filechooser, True, True, 0)
103
 
        self.vbox.pack_start(self._source, True, True, 5)
 
97
        self.get_content_area().pack_start(self._source, True, True, 5)
104
98
        self._source.show()
105
99
    
106
100
    def _on_custom_source(self):
107
101
        """ Merge from a custom source (can be folder, remote, etc), create entry """
108
 
        self._source = gtk.HBox()
109
 
        self._custom_entry = gtk.Entry()
 
102
        self._source = Gtk.HBox()
 
103
        self._custom_entry = Gtk.Entry()
110
104
        if self.default_branch_path:
111
105
            self._custom_entry.set_text(self.default_branch_path)
112
106
        self._custom_entry.connect("activate", self._on_merge_clicked)
113
107
        self._custom_entry.show()
114
108
        self._source.pack_start(self._custom_entry, True, True, 0)
115
 
        self.vbox.pack_start(self._source, True, True, 5)
 
109
        self.get_content_area().pack_start(self._source, True, True, 5)
116
110
        self._source.show()
117
111
    
118
112
    def _on_combo_changed(self, widget):
154
148
            warning_dialog(_i18n('Conflicts encountered'),
155
149
                           _i18n('Please resolve the conflicts manually before committing.'))
156
150
        
157
 
        self.response(gtk.RESPONSE_OK)
 
151
        self.response(Gtk.ResponseType.OK)