/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: 2011-09-05 03:44:26 UTC
  • mto: This revision was merged to the branch mainline in revision 741.
  • Revision ID: sinzui.is@verizon.net-20110905034426-p98pxnay9rmzkr99
Fix the initializer for many classes.
Replace Gtk.Dialog.vbox with .get_content_area().

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