/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: Jelmer Vernooij
  • Date: 2011-11-02 11:11:06 UTC
  • mfrom: (734.1.55 gtk3)
  • Revision ID: jelmer@samba.org-20111102111106-7l0vso8eg24dpf87
Merge gtk3 support from Curtis.

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",
45
 
                                  parent=parent,
46
 
                                  flags=0,
47
 
                                  buttons=(gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL))
 
39
        super(PushDialog, self).__init__(
 
40
            title="Push", parent=parent, flags=0,
 
41
            buttons=(Gtk.STOCK_CANCEL, Gtk.ResponseType.CANCEL))
 
42
 
48
43
 
49
44
        # Get arguments
50
45
        self.repository = repository
52
47
        self.branch = branch
53
48
 
54
49
        # 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()
 
50
        self._label_location = Gtk.Label(label=_i18n("Location:"))
 
51
        self._combo = Gtk.ComboBox.new_with_entry()
 
52
        self._button_push = Gtk.Button(_i18n("_Push"), use_underline=True)
 
53
        self._hbox_location = Gtk.HBox()
59
54
 
60
55
        # Set callbacks
61
56
        self._button_push.connect('clicked', self._on_push_clicked)
63
58
        # Set properties
64
59
        self._label_location.set_alignment(0, 0.5)
65
60
        self._hbox_location.set_spacing(3)
66
 
        self.vbox.set_spacing(3)
 
61
        self.get_content_area().set_spacing(3)
67
62
 
68
63
        # 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)
 
64
        self._hbox_location.pack_start(
 
65
            self._label_location, False, False, 0)
 
66
        self._hbox_location.pack_start(self._combo, True, True, 0)
 
67
        self.get_content_area().pack_start(self._hbox_location, True, True, 0)
 
68
        # XXX sinzui 2011-08-12: maybe False, False, 0
 
69
        self.get_action_area().pack_end(self._button_push, True, True, 0)
73
70
 
74
71
        # Show the dialog
75
 
        self.vbox.show_all()
 
72
        self.get_content_area().show_all()
76
73
 
77
74
        # Build location history
78
75
        self._history = UrlHistory(self.branch.get_config(), 'push_history')
80
77
 
81
78
    def _build_history(self):
82
79
        """Build up the location history. """
83
 
        self._combo_model = gtk.ListStore(str)
 
80
        self._combo_model = Gtk.ListStore(str)
84
81
        for item in self._history.get_entries():
85
82
            self._combo_model.append([ item ])
86
83
        self._combo.set_model(self._combo_model)
87
 
        self._combo.set_text_column(0)
 
84
        self._combo.set_entry_text_column(0)
88
85
 
89
86
        if self.branch is not None:
90
87
            location = self.branch.get_push_location()
102
99
        except errors.DivergedBranches:
103
100
            response = question_dialog(_i18n('Branches have been diverged'),
104
101
                                       _i18n('You cannot push if branches have diverged.\nOverwrite?'))
105
 
            if response == gtk.RESPONSE_YES:
 
102
            if response == Gtk.ResponseType.YES:
106
103
                revs = do_push(self.branch, location=location, overwrite=True)
107
104
 
108
105
        if self.branch is not None and self.branch.get_push_location() is None:
112
109
        info_dialog(_i18n('Push successful'),
113
110
                    _i18n("%d revision(s) pushed.") % revs)
114
111
 
115
 
        self.response(gtk.RESPONSE_OK)
 
112
        self.response(Gtk.ResponseType.OK)
116
113
 
117
114
 
118
115
def do_push(br_from, location, overwrite):
143
140
        except errors.NoSuchFile:
144
141
            response = question_dialog(_i18n('Non existing parent directory'),
145
142
                         _i18n("The parent directory (%s)\ndoesn't exist. Create?") % location)
146
 
            if response == gtk.RESPONSE_OK:
 
143
            if response == Gtk.ResponseType.OK:
147
144
                transport.create_prefix()
148
145
            else:
149
146
                return