/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-04-10 18:44:39 UTC
  • mto: This revision was merged to the branch mainline in revision 730.
  • Revision ID: jelmer@samba.org-20110410184439-g7hqaacexqtviq13
Move i18n support to a separate file, so gettext files aren't loaded unless bzr-gtk is used.

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