def add_thing(self, thing): button = hildon.Button(gtk.HILDON_SIZE_FINGER_HEIGHT, hildon.BUTTON_ARRANGEMENT_VERTICAL) # align left button.set_alignment(0.0, 0.5, 1.0, 0.0) self._thing_buttons[thing] = button self._vbox.pack_start(button, False, False, 0) button.set_title(thing.title) value = [] if thing.projects: value.append('projects: %s' % ', '.join(thing.projects)) if thing.contexts: value.append('contexts: %s' % ', '.join(thing.contexts)) if thing.statuses: value.append('statuses: %s' % ', '.join(thing.statuses)) if thing.due: value.append(format.deadline(thing.due)) button.set_value(" - ".join(value)) button.show() button.connect('clicked', self._button_clicked_cb, thing) button.show()
def __init__(self, thing): hildon.StackableWindow.__init__(self) self._panarea = hildon.PannableArea() self._table = gtk.Table(rows=8, columns=4) self._panarea.add_with_viewport(self._table) self.add(self._panarea) label = gtk.Label(thing.title) label.single_line_mode = False label.wrap = True self._table.attach(label, 0, 4, 0, 1, xoptions=0, yoptions=0) self._table.props.border_width = 6 self._table.props.column_spacing = 6 self._table.props.row_spacing = 6 self._row = 1 self._col = 0 def add_label(name, value): if value: label = gtk.Label(name) label.set_justify(gtk.JUSTIFY_LEFT) label.props.xalign = 0.0 self._table.attach(label, self._col + 0, self._col + 1, self._row, self._row + 1, xoptions=0, yoptions=0) label = gtk.Label(value) self._table.attach(label, self._col + 1, self._col + 2, self._row, self._row + 1) self._col += 2 if self._col == 4: self._row += 1 self._col = 0 def add_list(name, value): add_label(name, ", ".join(value)) add_list("Projects:", thing.projects) add_list("Contexts:", thing.contexts) # flags add_list("Status:", thing.statuses) # covey covey = "%.2f" % thing.priority() how = { 1: 'not very', 2: 'a little', 3: '', 4: 'quite', 5: 'very', } if thing.urgency: covey += ', %s urgent' % how[thing.urgency] if thing.importance: covey += ', %s important' % how[thing.importance] add_label('Priority:', covey) # dates add_label('Due:', format.deadline(thing.due)) add_label('Started:', format.ago(thing.start)) self.show_all()
def _get_deadline_string(due): deadline = format.deadline(due) if not deadline: return deadline return "[%s]" % deadline