Almost allow copying a full line to clipboard

This commit is contained in:
René Stadler 2007-11-20 14:52:26 +02:00 committed by Stefan Sauer
parent 0736ed0257
commit 56e4a95450
2 changed files with 36 additions and 4 deletions

View file

@ -287,6 +287,19 @@ class LogLine (list):
return cls (groups)
def line_string (self, message = None):
# Replicates gstreamer/gst/gstinfo.c:gst_debug_log_default.
ts, pid, thread, level, category, filename, line, function, object_, message_offset = self
if isinstance (message_offset, str):
message = message_offset
return "%s %5d 0x%x %s %20s %s:%d:%s:%s %s" % (time_args (ts), pid, thread, level.name,
category, filename, line, function,
object_, message,)
class LogFile (Producer):
def __init__ (self, filename, dispatcher):
@ -299,6 +312,16 @@ class LogFile (Producer):
self.line_cache = LineCache (self.fileobj, dispatcher)
self.line_cache.consumers.append (self)
def get_full_line (self, line_index):
offset = self.line_cache.offsets[line_index]
self.fileobj.seek (offset)
line_string = self.fileobj.readline ()
line = LogLine.parse_full (line_string)
msg = line_string[line[-1]:]
line[-1] = msg
return line
def start_loading (self):
self.logger.debug ("starting load")

View file

@ -925,6 +925,15 @@ class Window (object):
self.window_state.detach ()
self.column_manager.detach ()
def get_active_line_index (self):
selection = self.log_view.get_selection ()
model, tree_iter = selection.get_selected ()
if tree_iter is None:
raise ValueError ("no line selected")
path = model.get_path (tree_iter)
return path[0]
def get_active_line (self):
selection = self.log_view.get_selection ()
@ -968,10 +977,10 @@ class Window (object):
def handle_edit_copy_line_action_activate (self, action):
self.logger.warning ("FIXME")
return
col_id = self.log_model.COL_
self.clipboard.set_text (self.get_active_line ()[col_id])
line_index = self.get_active_line_index ()
line = self.log_file.get_full_line (line_index)
self.logger.warning ("FIXME: This gets the wrong level; we still have the level in the model only (d'oh)")
self.clipboard.set_text (line.line_string ())
def handle_edit_copy_message_action_activate (self, action):