def __init__(self, revisions, revision=None, format_='%x %H:%M:%S.%f'): self.parent = get_toplevel_window() self.win = gtk.Dialog( _('Revision'), self.parent, gtk.DIALOG_MODAL | gtk.DIALOG_DESTROY_WITH_PARENT) Main().add_window(self.win) cancel_button = self.win.add_button(set_underline(_("Cancel")), gtk.RESPONSE_CANCEL) cancel_button.set_image( IconFactory.get_image('tryton-cancel', gtk.ICON_SIZE_BUTTON)) cancel_button.set_always_show_image(True) ok_button = self.win.add_button(set_underline(_("OK")), gtk.RESPONSE_OK) ok_button.set_image( IconFactory.get_image('tryton-ok', gtk.ICON_SIZE_BUTTON)) ok_button.set_always_show_image(True) self.win.set_default_response(gtk.RESPONSE_OK) self.win.set_icon(TRYTON_ICON) self.win.vbox.set_spacing(3) self.win.vbox.pack_start(gtk.Label(_('Select a revision')), expand=False, fill=True) self.win.vbox.pack_start(gtk.HSeparator()) hbox = gtk.HBox(spacing=3) label = gtk.Label(_('Revision:')) hbox.pack_start(label, expand=True, fill=True) list_store = gtk.ListStore(str, str) # Set model on instantiation to get the default cellrenderer as text combobox = gtk.ComboBoxEntry(model=list_store) # JCA : Force set text colmn for gtk2 combobox.set_text_column(0) self.entry = combobox.get_child() self.entry.connect('focus-out-event', self.focus_out) self.entry.connect('activate', self.activate) label.set_mnemonic_widget(self.entry) combobox.connect('changed', self.changed) self.entry.set_property('activates_default', True) self._format = format_ if revision: self.entry.set_text(datetime_strftime(revision, self._format)) self._value = revision active = -1 else: self._value = None active = 0 list_store.append(('', '')) for i, (rev, id_, name) in enumerate(revisions, 1): list_store.append((datetime_strftime(rev, self._format), name)) if rev == revision: active = i combobox.set_active(active) cell = gtk.CellRendererText() combobox.pack_start(cell, True) combobox.add_attribute(cell, 'text', 1) hbox.pack_start(combobox, expand=True, fill=True) combobox.set_entry_text_column(0) self.win.vbox.pack_start(hbox, expand=True, fill=True) self.win.show_all()
def __init__(self, revisions, revision=None, format_='%x %X.%f'): self.parent = get_toplevel_window() self.win = gtk.Dialog( _('Revision'), self.parent, gtk.DIALOG_MODAL | gtk.DIALOG_DESTROY_WITH_PARENT, (gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL, gtk.STOCK_OK, gtk.RESPONSE_OK)) self.win.set_default_response(gtk.RESPONSE_OK) self.win.set_icon(TRYTON_ICON) self.win.set_has_separator(True) self.win.vbox.set_spacing(3) self.win.vbox.pack_start(gtk.Label(_('Select a revision')), expand=False, fill=True) self.win.vbox.pack_start(gtk.HSeparator()) hbox = gtk.HBox(spacing=3) label = gtk.Label(_('Revision:')) hbox.pack_start(label, expand=True, fill=True) list_store = gtk.ListStore(str, str) combobox = gtk.ComboBoxEntry(list_store) self.entry = combobox.child self.entry.connect('focus-out-event', self.focus_out) self.entry.connect('activate', self.activate) label.set_mnemonic_widget(self.entry) combobox.connect('changed', self.changed) self.entry.set_property('activates_default', True) self._format = format_ if revision: self.entry.set_text(datetime_strftime(revision, self._format)) self._value = revision active = -1 else: self._value = None active = 0 list_store.append(('', '')) for i, (rev, id_, name) in enumerate(revisions, 1): list_store.append((datetime_strftime(rev, self._format), name)) if rev == revision: active = i combobox.set_active(active) cell = gtk.CellRendererText() combobox.pack_start(cell, True) combobox.add_attribute(cell, 'text', 1) hbox.pack_start(combobox, expand=True, fill=True) combobox.set_entry_text_column(0) self.win.vbox.pack_start(hbox, expand=True, fill=True) self.win.show_all()
def get_textual_value(self, record): if not record: return '' value = record[self.attrs['name']].get_client(record) if value: return datetime_strftime(value, self.renderer.props.format) else: return ''
def __init__(self, revisions, revision=None, format_="%x %X.%f"): self.parent = get_toplevel_window() self.win = gtk.Dialog( _("Revision"), self.parent, gtk.DIALOG_MODAL | gtk.DIALOG_DESTROY_WITH_PARENT, (gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL, gtk.STOCK_OK, gtk.RESPONSE_OK), ) self.win.set_default_response(gtk.RESPONSE_OK) self.win.set_icon(TRYTON_ICON) self.win.set_has_separator(True) self.win.vbox.set_spacing(3) self.win.vbox.pack_start(gtk.Label(_("Select a revision")), expand=False, fill=True) self.win.vbox.pack_start(gtk.HSeparator()) hbox = gtk.HBox(spacing=3) label = gtk.Label(_("Revision:")) hbox.pack_start(label, expand=True, fill=True) list_store = gtk.ListStore(str, str) combobox = gtk.ComboBoxEntry(list_store) self.entry = combobox.child self.entry.connect("focus-out-event", self.focus_out) self.entry.connect("activate", self.activate) label.set_mnemonic_widget(self.entry) combobox.connect("changed", self.changed) self.entry.set_property("activates_default", True) self._format = format_ if revision: self.entry.set_text(datetime_strftime(revision, self._format)) self._value = revision active = -1 else: self._value = None active = 0 list_store.append(("", "")) for i, (rev, id_, name) in enumerate(revisions, 1): list_store.append((datetime_strftime(rev, self._format), name)) if rev == revision: active = i combobox.set_active(active) cell = gtk.CellRendererText() combobox.pack_start(cell, True) combobox.add_attribute(cell, "text", 1) hbox.pack_start(combobox, expand=True, fill=True) combobox.set_entry_text_column(0) self.win.vbox.pack_start(hbox, expand=True, fill=True) self.win.show_all()
def update_revision(self): revision = self.screen.context.get('_datetime') if revision: format_ = self.screen.context.get('date_format', '%x') format_ += ' %H:%M:%S.%f' revision = datetime_strftime(revision, format_) self.title.set_label('%s @ %s' % (self.name, revision)) else: self.title.set_label(self.name) self.set_buttons_sensitive(revision)
def update_revision(self): revision = self.screen.context.get('_datetime') if revision: format_ = self.screen.context.get('date_format', '%x') format_ += ' %X.%f' revision = datetime_strftime(revision, format_) self.title.set_label('%s @ %s' % (self.name, revision)) else: self.title.set_label(self.name) self.set_buttons_sensitive(revision)
def update_revision(self): revision = self.screen.context.get('_datetime') if revision: format_ = self.screen.context.get('date_format', '%x') format_ += ' %X.%f' revision = datetime_strftime(revision, format_) self.title.set_label('%s @ %s' % (self.name, revision)) else: self.title.set_label(self.name) for button in ('new', 'save'): self.buttons[button].props.sensitive = not revision
def update_revision(self): tooltips = common.Tooltips() revision = self.screen.context.get('_datetime') if revision: format_ = self.screen.context.get('date_format', '%x') format_ += ' %H:%M:%S.%f' revision_label = ' @ %s' % datetime_strftime(revision, format_) label = common.ellipsize(self.name, 80 - len(revision_label)) + revision_label tooltip = self.name + revision_label else: label = common.ellipsize(self.name, 80) tooltip = self.name self.title.set_label(label) tooltips.set_tip(self.title, tooltip) self.set_buttons_sensitive(revision)
def update(self): if not self._value: self.entry.set_text('') else: self.entry.set_text(datetime_strftime(self._value, self._format))
def update(self): if not self._value: self.entry.set_text("") else: self.entry.set_text(datetime_strftime(self._value, self._format))