def __init__(self, repository, revid=None, branch=None, parent=None): """ Initialize Add tag dialog. """ gtk.Dialog.__init__(self, title="Add tag", parent=parent, flags=0, buttons=(gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL)) # Get arguments self._repository = repository self._revid = revid self._branch = branch # Create the widgets self._button_add = gtk.Button(_i18n("_Add tag"), use_underline=True) self._table = gtk.Table(2, 2) self._label_name = gtk.Label(_i18n("Tag Name:")) self._label_revid = gtk.Label(_i18n("Revision ID:")) self._entry_name = gtk.Entry() if self._revid is not None: self._hbox_revid = gtk.Label(self._revid) else: self._hbox_revid = RevisionSelectionBox(self._branch) # Set callbacks self._button_add.connect('clicked', self._on_add_clicked) # Set properties self._label_name.set_alignment(0, 0.5) self._label_revid.set_alignment(0, 0.5) self._button_add.set_image(gtk.image_new_from_stock(gtk.STOCK_ADD, gtk.ICON_SIZE_BUTTON)) self._button_add.set_flags(gtk.CAN_DEFAULT) # Construct the dialog self._table.attach(self._label_name, 0, 1, 0, 1) self._table.attach(self._label_revid, 0, 1, 1, 2) self._table.attach(self._entry_name, 1, 2, 0, 1) self._table.attach(self._hbox_revid, 1, 2, 1, 2) self.vbox.add(self._table) self.action_area.pack_end(self._button_add) # Show the dialog self.vbox.show_all()
class AddTagDialog(gtk.Dialog): """ Add tag dialog. """ def __init__(self, repository, revid=None, branch=None, parent=None): """ Initialize Add tag dialog. """ gtk.Dialog.__init__(self, title="Add tag", parent=parent, flags=0, buttons=(gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL)) # Get arguments self._repository = repository self._revid = revid self._branch = branch # Create the widgets self._button_add = gtk.Button(_i18n("_Add tag"), use_underline=True) self._table = gtk.Table(2, 2) self._label_name = gtk.Label(_i18n("Tag Name:")) self._label_revid = gtk.Label(_i18n("Revision ID:")) self._entry_name = gtk.Entry() if self._revid is not None: self._hbox_revid = gtk.Label(self._revid) else: self._hbox_revid = RevisionSelectionBox(self._branch) # Set callbacks self._button_add.connect('clicked', self._on_add_clicked) # Set properties self._label_name.set_alignment(0, 0.5) self._label_revid.set_alignment(0, 0.5) self._button_add.set_image(gtk.image_new_from_stock(gtk.STOCK_ADD, gtk.ICON_SIZE_BUTTON)) self._button_add.set_flags(gtk.CAN_DEFAULT) # Construct the dialog self._table.attach(self._label_name, 0, 1, 0, 1) self._table.attach(self._label_revid, 0, 1, 1, 2) self._table.attach(self._entry_name, 1, 2, 0, 1) self._table.attach(self._hbox_revid, 1, 2, 1, 2) self.vbox.add(self._table) self.action_area.pack_end(self._button_add) # Show the dialog self.vbox.show_all() def _on_add_clicked(self, widget): """ Add button clicked handler. """ if len(self._entry_name.get_text()) == 0: error_dialog(_i18n("No tag name specified"), _i18n("You have to specify the tag's desired name.")) return if self._revid is None: if self._hbox_revid.get_revision_id() is None: self._revid = self._branch.last_revision() else: self._revid = self._hbox_revid.get_revision_id() self.tagname = self._entry_name.get_text() self.response(gtk.RESPONSE_OK)