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

  • Committer: Curtis Hovey
  • Date: 2011-09-03 01:25:04 UTC
  • mto: This revision was merged to the branch mainline in revision 741.
  • Revision ID: sinzui.is@verizon.net-20110903012504-0jr4diz9033g5df2
Menu fixes.

Show diffs side-by-side

added added

removed removed

Lines of Context:
15
15
# along with this program; if not, write to the Free Software
16
16
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
17
17
 
18
 
try:
19
 
    import pygtk
20
 
    pygtk.require("2.0")
21
 
except:
22
 
    pass
23
 
 
24
 
import gtk
 
18
from gi.repository import GObject
 
19
from gi.repository import Gtk
25
20
 
26
21
from errors import show_bzr_error
27
22
 
36
31
from bzrlib.plugins.gtk.i18n import _i18n
37
32
 
38
33
 
39
 
class PushDialog(gtk.Dialog):
 
34
class PushDialog(Gtk.Dialog):
40
35
    """New implementation of the Push dialog."""
41
36
 
42
37
    def __init__(self, repository, revid, branch=None, parent=None):
43
38
        """Initialize the Push dialog. """
44
 
        gtk.Dialog.__init__(self, title="Push",
 
39
        Gtk.Dialog.__init__(self, title="Push",
45
40
                                  parent=parent,
46
41
                                  flags=0,
47
 
                                  buttons=(gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL))
 
42
                                  buttons=(Gtk.STOCK_CANCEL, Gtk.ResponseType.CANCEL))
 
43
 
48
44
 
49
45
        # Get arguments
50
46
        self.repository = repository
52
48
        self.branch = branch
53
49
 
54
50
        # Create the widgets
55
 
        self._label_location = gtk.Label(_i18n("Location:"))
56
 
        self._combo = gtk.ComboBoxEntry()
57
 
        self._button_push = gtk.Button(_i18n("_Push"), use_underline=True)
58
 
        self._hbox_location = gtk.HBox()
 
51
        self._label_location = Gtk.Label(label=_i18n("Location:"))
 
52
        self._combo = Gtk.ComboBox.new_with_entry()
 
53
        self._button_push = Gtk.Button(_i18n("_Push"), use_underline=True)
 
54
        self._hbox_location = Gtk.HBox()
59
55
 
60
56
        # Set callbacks
61
57
        self._button_push.connect('clicked', self._on_push_clicked)
63
59
        # Set properties
64
60
        self._label_location.set_alignment(0, 0.5)
65
61
        self._hbox_location.set_spacing(3)
66
 
        self.vbox.set_spacing(3)
 
62
        self.get_content_area().set_spacing(3)
67
63
 
68
64
        # Pack widgets
69
 
        self._hbox_location.pack_start(self._label_location, False, False)
70
 
        self._hbox_location.pack_start(self._combo, True, True)
71
 
        self.vbox.pack_start(self._hbox_location)
72
 
        self.action_area.pack_end(self._button_push)
 
65
        self._hbox_location.pack_start(
 
66
            self._label_location, False, False, 0)
 
67
        self._hbox_location.pack_start(self._combo, True, True, 0)
 
68
        self.get_content_area().pack_start(self._hbox_location, True, True, 0)
 
69
        # XXX sinzui 2011-08-12: maybe False, False, 0
 
70
        self.get_action_area().pack_end(self._button_push, True, True, 0)
73
71
 
74
72
        # Show the dialog
75
 
        self.vbox.show_all()
 
73
        self.get_content_area().show_all()
76
74
 
77
75
        # Build location history
78
76
        self._history = UrlHistory(self.branch.get_config(), 'push_history')
80
78
 
81
79
    def _build_history(self):
82
80
        """Build up the location history. """
83
 
        self._combo_model = gtk.ListStore(str)
 
81
        self._combo_model = Gtk.ListStore(str)
84
82
        for item in self._history.get_entries():
85
83
            self._combo_model.append([ item ])
86
84
        self._combo.set_model(self._combo_model)
87
 
        self._combo.set_text_column(0)
 
85
        self._combo.set_entry_text_column(0)
88
86
 
89
87
        if self.branch is not None:
90
88
            location = self.branch.get_push_location()
102
100
        except errors.DivergedBranches:
103
101
            response = question_dialog(_i18n('Branches have been diverged'),
104
102
                                       _i18n('You cannot push if branches have diverged.\nOverwrite?'))
105
 
            if response == gtk.RESPONSE_YES:
 
103
            if response == Gtk.ResponseType.YES:
106
104
                revs = do_push(self.branch, location=location, overwrite=True)
107
105
 
108
106
        if self.branch is not None and self.branch.get_push_location() is None:
112
110
        info_dialog(_i18n('Push successful'),
113
111
                    _i18n("%d revision(s) pushed.") % revs)
114
112
 
115
 
        self.response(gtk.RESPONSE_OK)
 
113
        self.response(Gtk.ResponseType.OK)
116
114
 
117
115
 
118
116
def do_push(br_from, location, overwrite):
143
141
        except errors.NoSuchFile:
144
142
            response = question_dialog(_i18n('Non existing parent directory'),
145
143
                         _i18n("The parent directory (%s)\ndoesn't exist. Create?") % location)
146
 
            if response == gtk.RESPONSE_OK:
 
144
            if response == Gtk.ResponseType.OK:
147
145
                transport.create_prefix()
148
146
            else:
149
147
                return