Skip to content

Commit

Permalink
close #181 - reorganize text into 3 parts, in 2 columns.
Browse files Browse the repository at this point in the history
  • Loading branch information
mfrasca committed May 20, 2017
1 parent d0eead4 commit d578e1e
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 9 deletions.
46 changes: 40 additions & 6 deletions bauble/plugins/garden/plant.py
Original file line number Diff line number Diff line change
Expand Up @@ -1323,6 +1323,10 @@ def on_clicked(widget, event, parent):
self.vbox.show_all()


def label_size_allocate(widget, rect):
widget.set_size_request(rect.width, -1)


class PropagationExpander(InfoExpander):
"""
Propagation Expander
Expand All @@ -1332,24 +1336,54 @@ def __init__(self, widgets):
"""
"""
super(PropagationExpander, self).__init__(_('Propagations'), widgets)
self.vbox.set_spacing(3)
self.vbox.set_spacing(4)

def update(self, row):
sensitive = True
if not row.propagations:
sensitive = False
self.props.expanded = sensitive
self.props.sensitive = sensitive

self.vbox.foreach(self.vbox.remove)
format = prefs.prefs[prefs.date_format_pref]
for prop in row.propagations:
s = '<b>%s</b>: %s' % (prop.date.strftime(format),
prop.get_summary())
# (h1 (v1 (date_lbl)) (v2 (eventbox (accession_lbl)) (label)))
h1 = gtk.HBox()
h1.set_spacing(3)
self.vbox.pack_start(h1)

v1 = gtk.VBox()
v2 = gtk.VBox()
h1.pack_start(v1)
h1.pack_start(v2)

date_lbl = gtk.Label()
v1.pack_start(date_lbl)
date_lbl.set_markup("<b>%s</b>" % prop.date.strftime(format))
date_lbl.set_alignment(0.0, 0.0)

accession_code = prop.get_summary(partial=1)
if accession_code:
accession_lbl = gtk.Label()
eventbox = gtk.EventBox()
eventbox.add(accession_lbl)
v2.pack_start(eventbox)
accession_lbl.set_alignment(0.0, 0.0)
accession_lbl.set_text(accession_code)

def on_clicked(widget, event, obj):
select_in_search_results(obj)

utils.make_label_clickable(accession_lbl, on_clicked,
prop.used_source.accession)

label = gtk.Label()
label.set_markup(s)
v2.pack_start(label)

label.set_text(prop.get_summary(partial=2))
label.props.wrap = True
label.set_alignment(0.0, 0.5)
label.set_alignment(0.0, 0.0)
label.connect("size-allocate", label_size_allocate)
self.vbox.pack_start(label)
self.vbox.show_all()

Expand Down
12 changes: 9 additions & 3 deletions bauble/plugins/garden/propagation.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ def _get_details(self):

details = property(_get_details)

def get_summary(self):
def get_summary(self, partial=False):
"""
"""
date_format = prefs.prefs[prefs.date_format_pref]
Expand All @@ -121,10 +121,16 @@ def get_date(date):
return date

values = []
if self.used_source:
accession_code = ''

if self.used_source and partial != 2:
session = object_session(self.used_source.accession)
if self.used_source.accession not in session.new:
values.append(_('used in: %s') % self.used_source.accession)
accession_code = self.used_source.accession.code
values.append(_('used in: %s') % accession_code)

if partial == 1:
return accession_code

if self.prop_type == u'UnrootedCutting':
c = self._cutting
Expand Down

0 comments on commit d578e1e

Please sign in to comment.