47
47
self.wtpath = wtpath
49
if default_branch_path and os.path.isdir(default_branch_path.partition('file://')[2]):
50
directory = default_branch_path.partition('file://')[2]
52
directory = os.path.dirname(self.wt.abspath(self.wtpath))
48
self.default_branch_path = default_branch_path
49
self.parent_window = parent
55
52
self._hbox = gtk.HBox()
53
self._source = gtk.HBox()
56
54
self._label_merge_from = gtk.Label(_i18n("Merge from"))
57
self._filechooser_dialog = gtk.FileChooserDialog(title="Please select a folder",
59
action=gtk.FILE_CHOOSER_ACTION_SELECT_FOLDER,
60
buttons=(gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL,
61
gtk.STOCK_OPEN, gtk.RESPONSE_OK))
62
self._filechooser_dialog.set_default_response(gtk.RESPONSE_OK)
63
self._filechooser = gtk.FileChooserButton(self._filechooser_dialog)
55
self._combo_source = gtk.combo_box_new_text()
56
for entry in [_i18n("Folder"),_i18n("Custom Location")]:
57
self._combo_source.append_text(entry)
58
self._combo_source.connect("changed", self._on_combo_changed)
64
59
self._button_merge = gtk.Button(_i18n("_Merge"))
65
60
self._button_merge_icon = gtk.Image()
66
61
self._button_merge_icon.set_from_stock(gtk.STOCK_APPLY, gtk.ICON_SIZE_BUTTON)
67
62
self._button_merge.set_image(self._button_merge_icon)
69
63
self._button_merge.connect('clicked', self._on_merge_clicked)
72
self._filechooser_dialog.set_current_folder(directory)
74
65
# Add widgets to dialog
75
self.vbox.add(self._hbox)
66
self.vbox.pack_start(self._hbox, False, False, 0)
76
67
self._hbox.add(self._label_merge_from)
77
self._hbox.add(self._filechooser)
68
self._hbox.add(self._combo_source)
78
69
self._hbox.set_spacing(5)
79
70
self.action_area.pack_end(self._button_merge)
72
if self.default_branch_path and os.path.isdir(self.default_branch_path.partition('file://')[2]):
73
self.directory = self.default_branch_path.partition('file://')[2]
74
self._combo_source.set_active(0)
76
self._on_custom_source()
81
77
self.vbox.show_all()
79
def _on_folder_source(self):
80
""" Merge from folder, create a filechooser dialog and button """
81
self._source = gtk.HBox()
82
self._filechooser_dialog = gtk.FileChooserDialog(title="Please select a folder",
83
parent=self.parent_window,
84
action=gtk.FILE_CHOOSER_ACTION_SELECT_FOLDER,
85
buttons=(gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL,
86
gtk.STOCK_OPEN, gtk.RESPONSE_OK))
87
self._filechooser_dialog.set_default_response(gtk.RESPONSE_OK)
88
self._filechooser = gtk.FileChooserButton(self._filechooser_dialog)
89
self._filechooser.show()
90
directory = getattr(self, 'directory', None)
92
directory = os.path.dirname(self.wt.abspath(self.wtpath))
93
self._filechooser_dialog.set_current_folder(directory)
94
self._source.pack_start(self._filechooser, True, True, 0)
95
self.vbox.pack_start(self._source, True, True, 5)
98
def _on_custom_source(self):
99
""" Merge from a custom source (can be folder, remote, etc), create entry """
100
self._source = gtk.HBox()
101
self._custom_entry = gtk.Entry()
102
self._custom_entry.set_text(self.default_branch_path)
103
self._custom_entry.show()
104
self._source.pack_start(self._custom_entry, True, True, 0)
105
self.vbox.pack_start(self._source, True, True, 5)
108
def _on_combo_changed(self, widget):
109
merge_source = self._combo_source.get_active()
110
self._source.destroy()
111
if merge_source == 0:
113
self._on_folder_source()
114
elif merge_source == 1:
116
self._on_custom_source()
84
119
def _on_merge_clicked(self, widget):
85
branch = self._filechooser.get_filename()
120
merge_source = self._combo_source.get_active()
121
if merge_source == 0:
122
branch = self._filechooser.get_filename()
123
elif merge_source == 1:
124
branch = self._custom_entry.get_text()
87
126
error_dialog(_i18n('Branch not given'),
88
127
_i18n('Please specify a branch to merge from.'))