/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-07-31 16:50:29 UTC
  • mto: This revision was merged to the branch mainline in revision 741.
  • Revision ID: sinzui.is@verizon.net-20110731165029-9gixuqypi3lwapzm
Removed import_pygtk because gi does not impicitly call Main(). Inlined checks for gtk availablility.

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