Skip to content
14 changes: 9 additions & 5 deletions src/jarabe/journal/expandedentry.py
Original file line number Diff line number Diff line change
Expand Up @@ -438,21 +438,25 @@ def _format_date(self):
return _('No date')

def _create_buddy_list(self):

# No orphan heading: the label appears only when somebody
# actually worked on this together with the child.
vbox = Gtk.VBox()
vbox.props.spacing = style.DEFAULT_SPACING

buddies = []
if self._metadata.get('buddies'):
buddies = list(json.loads(self._metadata['buddies']).values())
if not buddies:
return vbox

text = Gtk.Label()
text.set_markup('<span foreground="%s">%s</span>' % (
style.COLOR_BUTTON_GREY.get_html(), _('Participants:')))
halign = Gtk.Alignment.new(0, 0, 0, 0)
halign.add(text)
vbox.pack_start(halign, False, False, 0)

if self._metadata.get('buddies'):
buddies = list(json.loads(self._metadata['buddies']).values())
vbox.pack_start(BuddyList(buddies), False, False, 0)
return vbox
vbox.pack_start(BuddyList(buddies), False, False, 0)
return vbox

def _create_scrollable(self, widget, label=None):
Expand Down
7 changes: 6 additions & 1 deletion src/jarabe/journal/journalactivity.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@
from jarabe.journal.journalwindow import JournalWindow
from jarabe.journal.bundlelauncher import launch_bundle, get_bundle
from jarabe.journal import journalwindow
from jarabe.journal.listmodel import ListModel

from jarabe.model import session, shell

Expand Down Expand Up @@ -410,6 +409,12 @@ def __key_press_event_cb(self, widget, event):
self._main_toolbox.search_entry.grab_focus()

elif self._active_view == JournalViews.DETAIL:
# Arrow keys and Return are writing when a text field has
# the keyboard; they only steer the Journal when none does.
focus = self.get_focus()
if isinstance(focus, (Gtk.Entry, Gtk.TextView)):
return False

if keyname == 'Left':
path, col = self._list_view.tree_view.get_cursor()
self._list_view.tree_view.grab_focus()
Expand Down
2 changes: 1 addition & 1 deletion src/jarabe/journal/journaltoolbox.py
Original file line number Diff line number Diff line change
Expand Up @@ -997,7 +997,7 @@ def do_draw(self, cr):
# draw a black background, has been done by the engine before
cr.set_source_rgb(0, 0, 0)
cr.rectangle(0, 0, allocation.width, allocation.height)
cr.paint()
cr.fill()

Gtk.ToolButton.do_draw(self, cr)

Expand Down
46 changes: 27 additions & 19 deletions src/jarabe/journal/listmodel.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,6 @@ class ListModel(GObject.GObject, Gtk.TreeModel, Gtk.TreeDragSource):
COLUMN_BUDDY_1 = 9
COLUMN_BUDDY_2 = 10
COLUMN_BUDDY_3 = 11
COLUMN_SELECT = 12

_COLUMN_TYPES = {
COLUMN_UID: str,
Expand All @@ -69,7 +68,6 @@ class ListModel(GObject.GObject, Gtk.TreeModel, Gtk.TreeDragSource):
COLUMN_BUDDY_1: object,
COLUMN_BUDDY_3: object,
COLUMN_BUDDY_2: object,
COLUMN_SELECT: bool,
}

_PAGE_SIZE = 10
Expand Down Expand Up @@ -141,6 +139,9 @@ def set_value(self, iterator, column, value):
if column == ListModel.COLUMN_TITLE:
metadata['title'] = value
self._updated_entries[metadata['uid']] = metadata
# The edit must survive a re-read of this same row: the row
# cache was primed by the read that preceded this write.
self._last_requested_index = None
if self._updated_callback is not None:
model.updated.disconnect(self._updated_callback)
model.write(metadata, update_mtime=False,
Expand All @@ -165,50 +166,55 @@ def do_get_value(self, iterator, column):
metadata = self._result_set.read()
metadata.update(self._updated_entries.get(metadata['uid'], {}))

self._last_requested_index = index
self._cached_row = []
self._cached_row.append(metadata['uid'])
self._cached_row.append(metadata.get('keep', '0') == '1')
self._cached_row.append(misc.get_icon_name(metadata))
row = []
row.append(metadata['uid'])
row.append(metadata.get('keep', '0') == '1')
row.append(misc.get_icon_name(metadata))

if misc.is_activity_bundle(metadata):
xo_color = XoColor('%s,%s' % (style.COLOR_BUTTON_GREY.get_svg(),
style.COLOR_TRANSPARENT.get_svg()))
else:
xo_color = misc.get_icon_color(metadata)
self._cached_row.append(xo_color)

title = GObject.markup_escape_text(metadata.get('title',
_('Untitled')))
self._cached_row.append('<b>%s</b>' % (title, ))
row.append(xo_color)

title_value = metadata.get('title', _('Untitled'))
if not isinstance(title_value, str):
# GObject.markup_escape_text raises TypeError on
# anything that isn't a string.
logging.warning('Content of title for %r is not a string: %r',
metadata['uid'], title_value)
title_value = _('Untitled')
title = GObject.markup_escape_text(title_value)
row.append('<b>%s</b>' % (title, ))

try:
timestamp = float(metadata.get('timestamp', 0))
except (TypeError, ValueError):
timestamp_content = _('Unknown')
else:
timestamp_content = util.timestamp_to_elapsed_string(timestamp)
self._cached_row.append(timestamp_content)
row.append(timestamp_content)

try:
creation_time = float(metadata.get('creation_time'))
except (TypeError, ValueError):
self._cached_row.append(_('Unknown'))
row.append(_('Unknown'))
else:
self._cached_row.append(
row.append(
util.timestamp_to_elapsed_string(float(creation_time)))

try:
size = int(metadata.get('filesize'))
except (TypeError, ValueError):
size = None
self._cached_row.append(util.format_size(size))
row.append(util.format_size(size))

try:
progress = int(float(metadata.get('progress', 100)))
except (TypeError, ValueError):
progress = 100
self._cached_row.append(progress)
row.append(progress)

buddies = []
if metadata.get('buddies'):
Expand All @@ -231,11 +237,13 @@ def do_get_value(self, iterator, column):
logging.warning('Malformed buddies for %r: %s',
metadata['uid'], exception)
else:
self._cached_row.append([nick, XoColor(color)])
row.append([nick, XoColor(color)])
continue

self._cached_row.append(None)
row.append(None)

self._cached_row = row
self._last_requested_index = index
return self._cached_row[column]

def do_iter_nth_child(self, parent_iter, n):
Expand Down
2 changes: 1 addition & 1 deletion src/jarabe/journal/listview.py
Original file line number Diff line number Diff line change
Expand Up @@ -773,7 +773,7 @@ def _key_press_event_cb(self, tree_view, event):
if self.cell_title.props.editable:
self.emit('title-edit-started')

column = self.tree_view.get_column(3)
column = self._title_column
tree_view.set_cursor_on_cell(path, column, self.cell_title,
start_editing=True)

Expand Down
2 changes: 1 addition & 1 deletion src/jarabe/journal/objectchooser.py
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ def __volume_changed_cb(self, volume_toolbar, mount_point):

def __visibility_notify_event_cb(self, window, event):
logging.debug('visibility_notify_event_cb %r', self)
visible = event.get_state() == Gdk.VisibilityState.FULLY_OBSCURED
visible = event.get_state() != Gdk.VisibilityState.FULLY_OBSCURED
if not self._show_preview:
self._list_view.set_is_visible(visible)
else:
Expand Down